diff --git a/src/components/keyboard/KeyBoard.vue b/src/components/keyboard/KeyBoard.vue index 221f428..4ce9f25 100644 --- a/src/components/keyboard/KeyBoard.vue +++ b/src/components/keyboard/KeyBoard.vue @@ -8,6 +8,7 @@ import KeySkill from "./KeySkill.vue"; import KeyObservation from "./KeyObservation.vue"; import KeySight from "./KeySight.vue"; import KeyFire from "./KeyFire.vue"; + import { KeyDirectionalSkill, KeySteeringWheel as KeyMappingSteeringWheel, @@ -15,6 +16,8 @@ import { KeyTap, KeyMacro, KeyMapping, + KeySight as KeyMappingKeySight, + KeyFire as KeyMappingKeyFire, } from "../../keyMappingConfig"; import { useGlobalStore } from "../../store/global"; import { DropdownOption, NDropdown, useDialog, useMessage } from "naive-ui"; @@ -54,6 +57,14 @@ const addButtonOptions: DropdownOption[] = [ label: () => t("pages.KeyBoard.addButton.Macro"), key: "Macro", }, + { + label: () => t("pages.KeyBoard.addButton.Sight"), + key: "Sight", + }, + { + label: () => t("pages.KeyBoard.addButton.Fire"), + key: "Fire", + }, ]; function onAddButtonSelect( @@ -64,6 +75,8 @@ function onAddButtonSelect( | "CancelSkill" | "Observation" | "Macro" + | "Sight" + | "Fire" ) { keyboardStore.showButtonAddFlag = false; const keyMapping = { @@ -72,11 +85,13 @@ function onAddButtonSelect( note: "", posX: addButtonPos.value.x - 70, posY: addButtonPos.value.y - 30, - pointerId: 2, // default skill pointerId + pointerId: 2, // default skill and fire pointerId }; if (type === "Tap") { + keyMapping.pointerId = 3; (keyMapping as KeyTap).time = 80; } else if (type === "SteeringWheel") { + keyMapping.pointerId = 1; (keyMapping as unknown as KeyMappingSteeringWheel).key = { left: "NONE1", right: "NONE2", @@ -89,14 +104,36 @@ function onAddButtonSelect( } else if (type === "CancelSkill") { keyMapping.note = t("pages.KeyBoard.addButton.CancelSkill"); } else if (type === "Observation") { + keyMapping.pointerId = 4; (keyMapping as unknown as KeyMappingObservation).scale = 0.6; } else if (type === "Macro") { + delete (keyMapping as any).pointerId; (keyMapping as unknown as KeyMacro).macro = { down: null, loop: null, up: null, }; - delete (keyMapping as any).pointerId; + } else if (type === "Sight") { + for (const mapping of store.editKeyMappingList) { + if (mapping.type === "Sight") { + message.error(t("pages.KeyBoard.addButton.existSight")); + return; + } + } + keyMapping.pointerId = 0; + (keyMapping as unknown as KeyMappingKeySight).scaleX = 0.5; + (keyMapping as unknown as KeyMappingKeySight).scaleY = 0.5; + } else if (type === "Fire") { + for (const mapping of store.editKeyMappingList) { + if (mapping.type === "Fire") { + message.error(t("pages.KeyBoard.addButton.existFire")); + return; + } + } + delete (keyMapping as any).key; + (keyMapping as unknown as KeyMappingKeyFire).scaleX = 0.5; + (keyMapping as unknown as KeyMappingKeyFire).scaleY = 0.5; + (keyMapping as unknown as KeyMappingKeyFire).drag = false; } else return; keyboardStore.edited = true; store.editKeyMappingList.push(keyMapping as KeyMapping); diff --git a/src/hotkey.ts b/src/hotkey.ts index c02f331..f71bcba 100644 --- a/src/hotkey.ts +++ b/src/hotkey.ts @@ -650,7 +650,7 @@ function addSightShortcuts( sightKeyMapping: KeySight, fireKeyMapping?: KeyFire ) { - // TODO 3. 可视化组件 4. 组件配置中唯一 + // TODO 5. 调整所有按键设置宽度,英文的存在换行问题 const appWindow = getCurrent(); let mouseLock = false; diff --git a/src/i18n/en-US.json b/src/i18n/en-US.json index 7023b7d..2858c69 100644 --- a/src/i18n/en-US.json +++ b/src/i18n/en-US.json @@ -133,7 +133,11 @@ "Skill": "Skill", "CancelSkill": "CancelSkill", "Observation": "Observation", - "Macro": "Macro" + "Macro": "Macro", + "Sight": "Front sight", + "Fire": "Fire", + "existFire": "Fire button already exists", + "existSight": "Front sight button already exists" }, "buttonKeyRepeat": "Key repeat: {0}", "KeyCommon": { diff --git a/src/i18n/zh-CN.json b/src/i18n/zh-CN.json index d05b3b1..cb127aa 100644 --- a/src/i18n/zh-CN.json +++ b/src/i18n/zh-CN.json @@ -126,7 +126,11 @@ "Skill": "技能", "CancelSkill": "技能取消", "Observation": "观察视角", - "Macro": "宏" + "Macro": "宏", + "Sight": "准星", + "Fire": "开火", + "existSight": "已存在准星按钮", + "existFire": "已存在开火按钮" }, "buttonKeyRepeat": "按键重复: {0}", "noSaveDialog": {