mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
fix: disable crew on non-tech trees
This commit is contained in:
1 parent
b89925e86b
commit
7a123b68db
2 files changed
+46
-42
No files matched your search
+45
-41
@@ -3,6 +3,7 @@ import { clamp, debounce } from 'lodash';
|
|||||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { GenericTankComponentButton } from '../../../../../../../components/ModuleButtons/GenericTankComponentButton';
|
import { GenericTankComponentButton } from '../../../../../../../components/ModuleButtons/GenericTankComponentButton';
|
||||||
import { asset } from '../../../../../../../core/blitzkrieg/asset';
|
import { asset } from '../../../../../../../core/blitzkrieg/asset';
|
||||||
|
import { useDuel } from '../../../../../../../stores/duel';
|
||||||
import {
|
import {
|
||||||
mutateTankopediaTemporary,
|
mutateTankopediaTemporary,
|
||||||
useTankopediaTemporary,
|
useTankopediaTemporary,
|
||||||
@@ -17,6 +18,7 @@ export function Miscellaneous() {
|
|||||||
const crewMastery = useTankopediaTemporary((state) => state.crewMastery);
|
const crewMastery = useTankopediaTemporary((state) => state.crewMastery);
|
||||||
const crewInput = useRef<HTMLInputElement>(null);
|
const crewInput = useRef<HTMLInputElement>(null);
|
||||||
const [crewMasteryDraft, setCrewMasteryDraft] = useState(crewMastery);
|
const [crewMasteryDraft, setCrewMasteryDraft] = useState(crewMastery);
|
||||||
|
const { tank } = useDuel((state) => state.protagonist!);
|
||||||
|
|
||||||
const debouncedApplyDraft = useMemo(
|
const debouncedApplyDraft = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@@ -80,51 +82,53 @@ export function Miscellaneous() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Flex
|
{tank.treeType === 'researchable' && (
|
||||||
align="center"
|
<Flex
|
||||||
direction="column"
|
align="center"
|
||||||
gap="1"
|
direction="column"
|
||||||
justify="end"
|
gap="1"
|
||||||
style={{ width: 180 }}
|
justify="end"
|
||||||
>
|
style={{ width: 180 }}
|
||||||
<TextField.Root>
|
>
|
||||||
<TextField.Slot>Crew</TextField.Slot>
|
<TextField.Root>
|
||||||
<TextField.Input
|
<TextField.Slot>Crew</TextField.Slot>
|
||||||
ref={crewInput}
|
<TextField.Input
|
||||||
defaultValue={Math.round(crewMastery * 100)}
|
ref={crewInput}
|
||||||
style={{ textAlign: 'right' }}
|
defaultValue={Math.round(crewMastery * 100)}
|
||||||
onBlur={() => {
|
style={{ textAlign: 'right' }}
|
||||||
const newValue = Number(crewInput.current!.value) / 100;
|
onBlur={() => {
|
||||||
|
const newValue = Number(crewInput.current!.value) / 100;
|
||||||
|
|
||||||
if (isNaN(newValue)) {
|
if (isNaN(newValue)) {
|
||||||
crewInput.current!.value = `${Math.round(crewMastery * 100)}`;
|
crewInput.current!.value = `${Math.round(crewMastery * 100)}`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutateTankopediaTemporary((draft) => {
|
mutateTankopediaTemporary((draft) => {
|
||||||
draft.crewMastery = clamp(newValue / 100, 0.5, 1);
|
draft.crewMastery = clamp(newValue / 100, 0.5, 1);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onKeyUp={(event) => {
|
onKeyUp={(event) => {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
crewInput.current?.blur();
|
crewInput.current?.blur();
|
||||||
}
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextField.Slot>%</TextField.Slot>
|
||||||
|
</TextField.Root>
|
||||||
|
|
||||||
|
<Slider
|
||||||
|
min={50}
|
||||||
|
max={100}
|
||||||
|
value={[crewMasteryDraft * 100]}
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
onValueChange={([value]) => {
|
||||||
|
setCrewMasteryDraft(value / 100);
|
||||||
|
debouncedApplyDraft(value / 100);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<TextField.Slot>%</TextField.Slot>
|
</Flex>
|
||||||
</TextField.Root>
|
)}
|
||||||
|
|
||||||
<Slider
|
|
||||||
min={50}
|
|
||||||
max={100}
|
|
||||||
value={[crewMasteryDraft * 100]}
|
|
||||||
style={{ width: '100%' }}
|
|
||||||
onValueChange={([value]) => {
|
|
||||||
setCrewMasteryDraft(value / 100);
|
|
||||||
debouncedApplyDraft(value / 100);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
</ConfigurationChildWrapper>
|
</ConfigurationChildWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ export function Characteristics() {
|
|||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Flex direction="column" gap="2">
|
<Flex direction="column" gap="2">
|
||||||
<Heading size="5">Crew</Heading>
|
<Heading size="5">Crew training</Heading>
|
||||||
|
|
||||||
{tank.crew.map((member) => {
|
{tank.crew.map((member) => {
|
||||||
const count = member.count ?? 1;
|
const count = member.count ?? 1;
|
||||||
|
|||||||
Reference in new issue
Block a user