|
1 | 1 | import { |
2 | 2 | AlignStartVertical, |
| 3 | + Fullscreen, |
| 4 | + GitCompareArrows, |
3 | 5 | Keyboard, |
4 | 6 | ListCheck, |
5 | 7 | ListEnd, |
| 8 | + Mouse, |
6 | 9 | MousePointerClick, |
7 | 10 | Move, |
8 | 11 | RotateCw, |
9 | 12 | ScanEye, |
10 | 13 | Skull, |
| 14 | + TextSelect, |
11 | 15 | } from "lucide-react"; |
12 | | -import React from "react"; |
13 | | -import { useTranslation } from "react-i18next"; |
14 | | -import KeyBind from "../../components/KeyBind"; |
15 | | -import { KeyBinds } from "../../core/service/controlService/KeyBinds"; |
16 | | -import { Field, SettingField } from "./_field"; |
| 16 | +import { FieldGroup, SettingField } from "./_field"; |
17 | 17 |
|
18 | 18 | export default function Control() { |
19 | | - const [keyBinds, setKeyBinds] = React.useState<[id: string, { key: string; modifiers: KeyBinds.KeyModifiers }][]>([]); |
| 19 | + return ( |
| 20 | + <> |
| 21 | + <FieldGroup title="Mouse 鼠标设定" icon={<Mouse />}> |
| 22 | + <SettingField icon={<MousePointerClick />} settingKey="mouseRightDragBackground" type="select" /> |
| 23 | + </FieldGroup> |
20 | 24 |
|
21 | | - React.useEffect(() => { |
22 | | - KeyBinds.entries().then((entries) => { |
23 | | - setKeyBinds(entries); |
24 | | - }); |
25 | | - }, []); |
| 25 | + <FieldGroup title="TextNode 文本节点" icon={<TextSelect />}> |
| 26 | + <SettingField icon={<ListEnd />} settingKey="textNodeContentLineBreak" type="select" /> |
| 27 | + <SettingField icon={<ListCheck />} settingKey="textNodeExitEditMode" type="select" /> |
| 28 | + <SettingField icon={<AlignStartVertical />} settingKey="enableDragAutoAlign" type="switch" /> |
| 29 | + </FieldGroup> |
26 | 30 |
|
27 | | - const { t } = useTranslation("keyBinds"); |
| 31 | + <FieldGroup title="Edge 连线" icon={<GitCompareArrows />}> |
| 32 | + <SettingField icon={<RotateCw />} settingKey="allowAddCycleEdge" type="switch" /> |
| 33 | + </FieldGroup> |
28 | 34 |
|
29 | | - return ( |
30 | | - <> |
31 | | - <SettingField icon={<MousePointerClick />} settingKey="mouseRightDragBackground" type="select" /> |
32 | | - <SettingField icon={<ListEnd />} settingKey="textNodeContentLineBreak" type="select" /> |
33 | | - <SettingField icon={<ListCheck />} settingKey="textNodeExitEditMode" type="select" /> |
34 | | - <SettingField icon={<AlignStartVertical />} settingKey="enableDragAutoAlign" type="switch" /> |
35 | | - <SettingField icon={<ScanEye />} settingKey="scaleExponent" type="slider" min={0} max={1} step={0.01} /> |
36 | | - <SettingField icon={<ScanEye />} settingKey="scaleCameraByMouseLocation" type="switch" /> |
37 | | - <SettingField icon={<Keyboard />} settingKey="allowMoveCameraByWSAD" type="switch" /> |
38 | | - <SettingField icon={<Keyboard />} settingKey="cameraKeyboardMoveReverse" type="switch" /> |
39 | | - <SettingField icon={<RotateCw />} settingKey="allowAddCycleEdge" type="switch" /> |
40 | | - <SettingField icon={<Move />} settingKey="moveAmplitude" type="slider" min={0} max={10} step={0.1} /> |
41 | | - <SettingField icon={<Move />} settingKey="moveFriction" type="slider" min={0} max={1} step={0.01} /> |
42 | | - <SettingField icon={<Skull />} settingKey="gamepadDeadzone" type="slider" min={0} max={1} step={0.01} /> |
43 | | - <Field icon={<Keyboard />} title={t("title")} color="blue" /> |
44 | | - {keyBinds |
45 | | - .map(([id, bind]) => ( |
46 | | - <Field |
47 | | - key={id} |
48 | | - icon={<Keyboard />} |
49 | | - title={t(`${id}.title`, { defaultValue: id })} |
50 | | - description={t(`${id}.description`, { defaultValue: "" })} |
51 | | - > |
52 | | - <KeyBind |
53 | | - value={bind} |
54 | | - onChange={(value) => { |
55 | | - KeyBinds.set(id, value.key, value.modifiers); |
56 | | - setKeyBinds((prev) => prev.map((item) => (item[0] === id ? [item[0], value] : item))); |
57 | | - }} |
58 | | - /> |
59 | | - </Field> |
60 | | - )) |
61 | | - .sort((a, b) => { |
62 | | - if (a.key === null && b.key === null) return 0; // 两者均为 null,相等 |
63 | | - if (a.key === null) return 1; // a.key 为 null,把它排到后面 |
64 | | - if (b.key === null) return -1; // b.key 为 null,把它排到后面 |
65 | | - return a.key.localeCompare(b.key); // 正常比较 |
66 | | - })} |
| 35 | + <FieldGroup title="Camera 摄像机/视野/相关" icon={<Fullscreen />}> |
| 36 | + <SettingField icon={<ScanEye />} settingKey="scaleExponent" type="slider" min={0} max={1} step={0.01} /> |
| 37 | + <SettingField icon={<ScanEye />} settingKey="scaleCameraByMouseLocation" type="switch" /> |
| 38 | + <SettingField icon={<Keyboard />} settingKey="allowMoveCameraByWSAD" type="switch" /> |
| 39 | + <SettingField icon={<Keyboard />} settingKey="cameraKeyboardMoveReverse" type="switch" /> |
| 40 | + <SettingField icon={<Move />} settingKey="moveAmplitude" type="slider" min={0} max={10} step={0.1} /> |
| 41 | + <SettingField icon={<Move />} settingKey="moveFriction" type="slider" min={0} max={1} step={0.01} /> |
| 42 | + <SettingField icon={<Skull />} settingKey="gamepadDeadzone" type="slider" min={0} max={1} step={0.01} /> |
| 43 | + </FieldGroup> |
| 44 | + {/* 已经有快捷键专栏了,这里不再显示快捷键相关 */} |
67 | 45 | </> |
68 | 46 | ); |
69 | 47 | } |
0 commit comments