Skip to content

Commit 61e8cd8

Browse files
committed
feat: 实现对AquaMai的CustomFn和UX.CustomFnToKeyboard的配置支持。
详见 MuNET-OSS/AquaMai#118 因为AquaMai的上述功能中,新增了VKCode枚举类型和修改了一些现有枚举类型的定义,因此MCM这边也需要做出相应的适配,才能实现编辑与之相关的配置。
1 parent 01b41ad commit 61e8cd8

7 files changed

Lines changed: 85 additions & 3 deletions

File tree

AquaMai

MaiChartManager/Front/src/locales/en.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ mod:
318318
select2P: 2P Select
319319
service: Service
320320
test: Test
321+
customFn: 'Custom FnKey '
321322
adxHid:
322323
disabled: Disabled
323324
select1P: 1P Select

MaiChartManager/Front/src/locales/zh-TW.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ mod:
296296
select2P: 2P 選擇
297297
service: 服務
298298
test: 測試
299+
customFn: 自訂功能鍵
299300
adxHid:
300301
disabled: 停用
301302
select1P: 1P 選擇

MaiChartManager/Front/src/locales/zh.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ mod:
296296
select2P: 2P 选择
297297
service: 服务
298298
test: 测试
299+
customFn: 自定义功能键
299300
adxHid:
300301
conflictDetected: 检测到冲突的 Mod
301302
oneClickDelete: 一键删除

MaiChartManager/Front/src/views/ModManager/ConfigEntry.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { KeyCodeName } from "./types/KeyCodeName";
66
import { getNameForPath } from "./utils";
77
import comments from "./modComments.yaml";
88
import { KeyCodeID } from "./types/KeyCodeID";
9+
import { VKCode } from "./types/VKCode";
910
import { useI18n } from 'vue-i18n';
1011
import { locale } from "@/locales";
1112
import { ENTRY_LABEL_CLASS } from "./constants";
@@ -19,9 +20,31 @@ export function optionsIoKeyMap(t: (key: string) => string): { label: string, va
1920
{ label: t('mod.ioKeyMap.select2P'), value: 'Select2P' },
2021
{ label: t('mod.ioKeyMap.service'), value: 'Service' },
2122
{ label: t('mod.ioKeyMap.test'), value: 'Test' },
23+
{ label: t('mod.ioKeyMap.customFn') + "1", value: 'CustomFn1' },
24+
{ label: t('mod.ioKeyMap.customFn') + "2", value: 'CustomFn2' },
25+
{ label: t('mod.ioKeyMap.customFn') + "3", value: 'CustomFn3' },
26+
{ label: t('mod.ioKeyMap.customFn') + "4", value: 'CustomFn4' },
2227
];
2328
}
2429

30+
export function optionsKeyCodeOrName(t: (key: string) => string): { label: string, value: string }[] {
31+
return Object.entries(KeyCodeName).map(([label, value]) => {
32+
if (label.startsWith("CustomFn")) { // "自定义功能键"需要单独i18n
33+
return { label: t('mod.ioKeyMap.customFn') + label[8], value };
34+
}
35+
return { label, value }; // 其他的则沿用枚举中的值
36+
});
37+
}
38+
39+
export function optionsVKCode(t: (key: string) => string): { label: string, value: string }[] {
40+
return Object.entries(VKCode).map(([label, value]) => {
41+
if (label == "None") { // 单独翻译为“禁用”
42+
return { label: t('mod.disable'), value };
43+
}
44+
return { label, value }; // 其他的则沿用枚举中的值
45+
});
46+
}
47+
2548
export default defineComponent({
2649
props: {
2750
entry: { type: Object as PropType<Entry>, required: true },
@@ -77,13 +100,14 @@ export default defineComponent({
77100
case 'System.Single':
78101
return <NumberInput innerClass="h-42px!" v-model:value={props.entryState.value} step={.1} decimal={4}/>;
79102
case 'AquaMai.Config.Types.KeyCodeOrName':
80-
return <Select v-model:value={props.entryState.value} options={Object.entries(KeyCodeName).map(([label, value]) => ({ label, value }))}/>;
103+
return <Select v-model:value={props.entryState.value} options={optionsKeyCodeOrName(t)}/>;
81104
case 'AquaMai.Config.Types.KeyCodeID':
82105
return <Select v-model:value={props.entryState.value} options={Object.entries(KeyCodeID).map(([label, value]) => ({label, value}))}/>;
83106
case 'AquaMai.Config.Types.IOKeyMap':
84-
return <Select v-model:value={props.entryState.value} options={optionsIoKeyMap(t)}/>;
85107
case 'AquaMai.Config.Types.AdxKeyMap':
86108
return <Select v-model:value={props.entryState.value} options={optionsIoKeyMap(t)}/>;
109+
case 'AquaMai.Config.Types.VKCode':
110+
return <Select v-model:value={props.entryState.value} options={optionsVKCode(t)}/>;
87111
case 'AquaMai.Config.Types.SoundChannel':
88112
return <Select v-model:value={props.entryState.value} options={optionsSoundChannel}/>;
89113
}

MaiChartManager/Front/src/views/ModManager/types/KeyCodeName.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@ export enum KeyCodeName {
4646
Select2P = "Select2P",
4747
Service = "Service",
4848
Test = "Test",
49+
CustomFn1 = "CustomFn1",
50+
CustomFn2 = "CustomFn2",
51+
CustomFn3 = "CustomFn3",
52+
CustomFn4 = "CustomFn4",
4953
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
export enum VKCode {
2+
None = "None",
3+
Alpha0 = "Alpha0", // 0 键
4+
Alpha1 = "Alpha1",
5+
Alpha2 = "Alpha2",
6+
Alpha3 = "Alpha3",
7+
Alpha4 = "Alpha4",
8+
Alpha5 = "Alpha5",
9+
Alpha6 = "Alpha6",
10+
Alpha7 = "Alpha7",
11+
Alpha8 = "Alpha8",
12+
Alpha9 = "Alpha9",
13+
Keypad0 = "Keypad0", // 数字键盘 0 键
14+
Keypad1 = "Keypad1",
15+
Keypad2 = "Keypad2",
16+
Keypad3 = "Keypad3",
17+
Keypad4 = "Keypad4",
18+
Keypad5 = "Keypad5",
19+
Keypad6 = "Keypad6",
20+
Keypad7 = "Keypad7",
21+
Keypad8 = "Keypad8",
22+
Keypad9 = "Keypad9",
23+
F1 = "F1",
24+
F2 = "F2",
25+
F3 = "F3",
26+
F4 = "F4",
27+
F5 = "F5",
28+
F6 = "F6",
29+
F7 = "F7",
30+
F8 = "F8",
31+
F9 = "F9",
32+
F10 = "F10",
33+
F11 = "F11",
34+
F12 = "F12",
35+
Enter = "Enter", // VK_RETURN 输入键
36+
Space = "Space", // 空格键
37+
Backspace = "Backspace", // VK_BACK
38+
Tab = "Tab",
39+
Esc = "Esc", // VK_ESCAPE
40+
Insert = "Insert",
41+
Delete = "Delete",
42+
Home = "Home",
43+
End = "End",
44+
Pause = "Pause",
45+
PageUp = "PageUp", // VK_PRIOR
46+
PageDown = "PageDown", // VK_NEXT
47+
UpArrow = "UpArrow", // VK_UP
48+
DownArrow = "DownArrow", // VK_DOWN
49+
LeftArrow = "LeftArrow", // VK_LEFT
50+
RightArrow = "RightArrow", // VK_RIGHT
51+
}

0 commit comments

Comments
 (0)