Skip to content

Commit 9e485bd

Browse files
committed
feat: 从 AquaMai 中读取 ConfigSort 和 ADX 键位映射编辑
1 parent 084dd52 commit 9e485bd

File tree

7 files changed

+76
-13
lines changed

7 files changed

+76
-13
lines changed

AquaMai

MaiChartManager/Controllers/ModController.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using MaiChartManager.Models;
88
using Microsoft.AspNetCore.Mvc;
99
using Microsoft.VisualBasic.FileIO;
10+
using Mono.Cecil;
11+
using YamlDotNet.Serialization;
1012

1113
namespace MaiChartManager.Controllers;
1214

@@ -157,6 +159,19 @@ public static IConfig GetCurrentAquaMaiConfig()
157159
[HttpGet]
158160
public AquaMaiConfigDto.ConfigDto GetAquaMaiConfig()
159161
{
162+
Dictionary<string, string[]>? configSort = null;
163+
using (var stream = new FileStream(AquaMaiDllInstalledPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
164+
{
165+
var asm = ModuleDefinition.ReadModule(stream);
166+
var configSortRes = asm.Resources.FirstOrDefault(it => it is EmbeddedResource { Name: "configSort.yaml.compressed" } or EmbeddedResource { Name: "configSort.yaml" });
167+
if (configSortRes != null)
168+
{
169+
var (name, res) = ResourceLoader.LoadResource(configSortRes);
170+
var deserializer = new DeserializerBuilder().Build();
171+
var yaml = new StreamReader(res).ReadToEnd();
172+
configSort = deserializer.Deserialize<Dictionary<string, string[]>>(yaml);
173+
}
174+
}
160175
var config = GetCurrentAquaMaiConfig();
161176
// 未解之谜
162177
// logger.LogInformation("{}", lockCredits.GetType());
@@ -177,7 +192,8 @@ public AquaMaiConfigDto.ConfigDto GetAquaMaiConfig()
177192
return new AquaMaiConfigDto.Section(section.Path, entries, section.Attribute);
178193
}),
179194
config.ReflectionManager.Sections.ToDictionary(section => section.Path, section => config.GetSectionState(section)),
180-
config.ReflectionManager.Entries.ToDictionary(entry => entry.Path, entry => config.GetEntryState(entry))
195+
config.ReflectionManager.Entries.ToDictionary(entry => entry.Path, entry => config.GetEntryState(entry)),
196+
configSort
181197
);
182198
}
183199

MaiChartManager/Front/src/client/apiGen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export interface ConfigDto {
7070
sections?: Section[] | null;
7171
sectionStates?: Record<string, ISectionState>;
7272
entryStates?: Record<string, IEntryState>;
73+
configSort?: Record<string, string[]>;
7374
}
7475

7576
export interface ConfigSaveDto {

MaiChartManager/Front/src/components/ModManager/AquaMaiConfigurator.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import comments from "./modComments.yaml";
66
import _ from "lodash";
77
import { KeyCodeName } from "@/components/ModManager/types/KeyCodeName";
88
import ProblemsDisplay from "@/components/ProblemsDisplay";
9-
import configSort from './configSort.yaml'
9+
import configSortStub from './configSort.yaml'
1010
import { useMagicKeys, whenever } from "@vueuse/core";
1111

1212
const sectionPanelOverrides = import.meta.glob('./sectionPanelOverride/*/index.tsx', { eager: true })
@@ -105,6 +105,7 @@ export default defineComponent({
105105
setup(props, { emit }) {
106106
const search = ref('');
107107
const searchRef = ref();
108+
const configSort = computed(() => props.config?.configSort || configSortStub)
108109

109110
const { ctrl_f } = useMagicKeys({
110111
passive: false,
@@ -129,14 +130,14 @@ export default defineComponent({
129130

130131
const bigSections = computed(() => {
131132
if (props.useNewSort) {
132-
return Object.keys(configSort).filter(it => filteredSections.value!.some(s => configSort[it].includes(s.path!)));
133+
return Object.keys(configSort.value).filter(it => filteredSections.value!.some(s => configSort.value[it].includes(s.path!)));
133134
}
134135
return _.uniq(filteredSections.value!.filter(it => !it.attribute?.exampleHidden).map(s => s.path?.split('.')[0]));
135136
});
136137

137138
const otherSection = computed(() => {
138139
if (!props.useNewSort) return [];
139-
const knownSections = _.flatten(Object.values(configSort) as string[][]);
140+
const knownSections = _.flatten(Object.values(configSort.value) as string[][]);
140141
return filteredSections.value?.filter(it => !knownSections.includes(it.path!) && !it.attribute!.exampleHidden) || [];
141142
});
142143

@@ -156,12 +157,12 @@ export default defineComponent({
156157
<NDivider titlePlacement="left" class="mt-2!">{big}</NDivider>
157158
{filteredSections.value?.filter(it => {
158159
if (props.useNewSort) {
159-
return configSort[big!].includes(it.path!);
160+
return configSort.value[big!].includes(it.path!);
160161
}
161162
return it.path!.split('.')[0] === big && !it.attribute!.exampleHidden;
162163
}).sort((a, b) => {
163164
if (!props.useNewSort) return 0;
164-
return configSort[big!].indexOf(a.path!) - configSort[big!].indexOf(b.path!);
165+
return configSort.value[big!].indexOf(a.path!) - configSort.value[big!].indexOf(b.path!);
165166
}).map((section) => {
166167
return <ConfigSection key={section.path!} section={section}
167168
entryStates={props.config.entryStates!}

MaiChartManager/Front/src/components/ModManager/sectionPanelOverride/GameSystem.AdxHidInput/index.tsx

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
import { defineComponent, PropType, ref, computed } from 'vue';
1+
import { defineComponent, PropType, ref, computed, h } from 'vue';
22
import { IEntryState, ISectionState } from "@/client/apiGen";
3-
import { NButton, NFlex } from "naive-ui";
3+
import { NButton, NFlex, NFormItem, NGrid, NGridItem, NSelect } from "naive-ui";
44
import api from "@/client/api";
55
import { modInfo, updateModInfo } from "@/store/refs";
66

7+
const options = [
8+
{ label: '禁用', value: 'None' },
9+
{ label: '1P 选择', value: 'Select1P' },
10+
{ label: '2P 选择', value: 'Select2P' },
11+
{ label: '服务', value: 'Service' },
12+
{ label: '测试', value: 'Test' },
13+
]
14+
715
export default defineComponent({
816
props: {
917
entryStates: { type: Object as PropType<Record<string, IEntryState>>, required: true },
@@ -19,13 +27,44 @@ export default defineComponent({
1927
load.value = false
2028
}
2129

22-
return () =>
23-
modInfo.value?.isHidConflictExist ? <NFlex align="center" class="m-l-35 translate-y--3">
30+
return () => <NFlex vertical>
31+
{modInfo.value?.isHidConflictExist ? <NFlex align="center" class="m-l-35 translate-y--3">
2432
<span class="c-orange">检测到冲突的 Mod</span>
2533
<NButton secondary onClick={del} loading={load.value}>一键删除</NButton>
2634
</NFlex>
2735
: <NFlex align="center" class="m-l-35 translate-y--3">
2836
<span class="c-green-6">没有检测到冲突</span>
29-
</NFlex>
37+
</NFlex>}
38+
<NGrid cols={2}>
39+
<NGridItem>
40+
<NFormItem label="按键 1" labelPlacement="left" labelWidth="10em">
41+
<NFlex vertical class="w-full ws-pre-line">
42+
<NSelect v-model:value={props.entryStates['GameSystem.AdxHidInput.Button1'].value} options={options}/>
43+
向上的三角键
44+
</NFlex>
45+
</NFormItem>
46+
<NFormItem label="按键 2" labelPlacement="left" labelWidth="10em">
47+
<NFlex vertical class="w-full ws-pre-line">
48+
<NSelect v-model:value={props.entryStates['GameSystem.AdxHidInput.Button2'].value} options={options}/>
49+
三角键中间的圆形按键
50+
</NFlex>
51+
</NFormItem>
52+
</NGridItem>
53+
<NGridItem>
54+
<NFormItem label="按键 3" labelPlacement="left" labelWidth="10em">
55+
<NFlex vertical class="w-full ws-pre-line">
56+
<NSelect v-model:value={props.entryStates['GameSystem.AdxHidInput.Button3'].value} options={options}/>
57+
向下的三角键
58+
</NFlex>
59+
</NFormItem>
60+
<NFormItem label="按键 4" labelPlacement="left" labelWidth="10em">
61+
<NFlex vertical class="w-full ws-pre-line">
62+
<NSelect v-model:value={props.entryStates['GameSystem.AdxHidInput.Button4'].value} options={options}/>
63+
最下方的圆形按键
64+
</NFlex>
65+
</NFormItem>
66+
</NGridItem>
67+
</NGrid>
68+
</NFlex>
3069
},
3170
});

MaiChartManager/MaiChartManager.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<PackageReference Include="Vanara.Windows.Forms" Version="4.1.3"/>
6969
<PackageReference Include="WinBlur" Version="1.0.0"/>
7070
<PackageReference Include="Xabe.FFmpeg" Version="6.0.1"/>
71+
<PackageReference Include="YamlDotNet" Version="16.3.0"/>
7172
</ItemGroup>
7273
<ItemGroup>
7374
<Compile Update="Launcher.cs">

MaiChartManager/Models/AquaMaiConfigDto.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ public record Entry(string Path, string Name, IConfigEntryAttribute Attribute, s
99

1010
public record Section(string Path, IEnumerable<Entry> Entries, IConfigSectionAttribute Attribute);
1111

12-
public record ConfigDto(IEnumerable<Section> Sections, Dictionary<string, IConfig.ISectionState> SectionStates, Dictionary<string, IConfig.IEntryState> EntryStates);
12+
public record ConfigDto(
13+
IEnumerable<Section> Sections,
14+
Dictionary<string, IConfig.ISectionState> SectionStates,
15+
Dictionary<string, IConfig.IEntryState> EntryStates,
16+
Dictionary<string, string[]>? ConfigSort
17+
);
1318

1419
public record SectionSaveDto : IConfig.ISectionState
1520
{

0 commit comments

Comments
 (0)