Skip to content

Commit 8d7f796

Browse files
committed
feat: HID 冲突检测
1 parent d4e3cb9 commit 8d7f796

File tree

7 files changed

+93
-11
lines changed

7 files changed

+93
-11
lines changed

AquaMai

MaiChartManager/Controllers/ModController.cs

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using AquaMai.Config.Interfaces;
77
using MaiChartManager.Models;
88
using Microsoft.AspNetCore.Mvc;
9+
using Microsoft.VisualBasic.FileIO;
910

1011
namespace MaiChartManager.Controllers;
1112

@@ -29,12 +30,19 @@ public bool IsAquaMaiInstalled()
2930
return System.IO.File.Exists(AquaMaiDllInstalledPath);
3031
}
3132

32-
public record GameModInfo(bool MelonLoaderInstalled, bool AquaMaiInstalled, string AquaMaiVersion, string BundledAquaMaiVersion, bool IsJudgeDisplay4BInstalled);
33+
public record GameModInfo(
34+
bool MelonLoaderInstalled,
35+
bool AquaMaiInstalled,
36+
string AquaMaiVersion,
37+
string BundledAquaMaiVersion,
38+
bool IsJudgeDisplay4BInstalled,
39+
bool IsHidConflictExist);
3340

3441
private static string AquaMaiConfigPath => Path.Combine(StaticSettings.GamePath, "AquaMai.toml");
3542
private static string AquaMaiConfigBackupDirPath => Path.Combine(StaticSettings.GamePath, "AquaMai.toml.bak");
3643
private static string AquaMaiDllInstalledPath => Path.Combine(StaticSettings.GamePath, @"Mods\AquaMai.dll");
3744
private static string AquaMaiDllBuiltinPath => Path.Combine(StaticSettings.exeDir, "AquaMai.dll");
45+
private static readonly string[] HidModPaths = [@"Mods\Mai2InputMod.dll", @"Mods\hid_input_lib.dll", "hid_input_lib.dll", "mai2io.dll"];
3846

3947
[HttpGet]
4048
public GameModInfo GetGameModInfo()
@@ -43,12 +51,12 @@ public GameModInfo GetGameModInfo()
4351
var aquaMaiVersion = "N/A";
4452
if (aquaMaiInstalled)
4553
{
46-
aquaMaiVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(AquaMaiDllInstalledPath).ProductVersion ?? "N/A";
54+
aquaMaiVersion = FileVersionInfo.GetVersionInfo(AquaMaiDllInstalledPath).ProductVersion ?? "N/A";
4755
}
4856

49-
var aquaMaiBuiltinVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(AquaMaiDllBuiltinPath).ProductVersion;
57+
var aquaMaiBuiltinVersion = FileVersionInfo.GetVersionInfo(AquaMaiDllBuiltinPath).ProductVersion;
5058

51-
return new GameModInfo(IsMelonInstalled(), aquaMaiInstalled, aquaMaiVersion, aquaMaiBuiltinVersion!, GetIsJudgeDisplay4BInstalled());
59+
return new GameModInfo(IsMelonInstalled(), aquaMaiInstalled, aquaMaiVersion, aquaMaiBuiltinVersion!, GetIsJudgeDisplay4BInstalled(), GetIsHidConflictExist());
5260
}
5361

5462
[NonAction]
@@ -60,6 +68,32 @@ private static bool GetIsJudgeDisplay4BInstalled()
6068
return filesShouldBeInstalled.Select(file => Path.Combine(StaticSettings.SkinAssetsDir, Path.GetFileName(file))).All(System.IO.File.Exists);
6169
}
6270

71+
[NonAction]
72+
private static bool GetIsHidConflictExist()
73+
{
74+
foreach (var mod in HidModPaths)
75+
{
76+
if (System.IO.File.Exists(Path.Combine(StaticSettings.GamePath, mod)))
77+
{
78+
return true;
79+
}
80+
}
81+
82+
return false;
83+
}
84+
85+
[HttpPost]
86+
public void DeleteHidConflict()
87+
{
88+
foreach (var mod in HidModPaths)
89+
{
90+
if (System.IO.File.Exists(Path.Combine(StaticSettings.GamePath, mod)))
91+
{
92+
FileSystem.DeleteFile(Path.Combine(StaticSettings.GamePath, mod), UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
93+
}
94+
}
95+
}
96+
6397
[HttpPost]
6498
public void InstallJudgeDisplay4B()
6599
{

MaiChartManager/Front/src/client/apiGen.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export interface GameModInfo {
102102
aquaMaiVersion?: string | null;
103103
bundledAquaMaiVersion?: string | null;
104104
isJudgeDisplay4BInstalled?: boolean;
105+
isHidConflictExist?: boolean;
105106
}
106107

107108
export interface GenreAddRequest {
@@ -1236,6 +1237,20 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
12361237
...params,
12371238
}),
12381239

1240+
/**
1241+
* No description
1242+
*
1243+
* @tags Mod
1244+
* @name DeleteHidConflict
1245+
* @request POST:/MaiChartManagerServlet/DeleteHidConflictApi
1246+
*/
1247+
DeleteHidConflict: (params: RequestParams = {}) =>
1248+
this.request<void, any>({
1249+
path: `/MaiChartManagerServlet/DeleteHidConflictApi`,
1250+
method: "POST",
1251+
...params,
1252+
}),
1253+
12391254
/**
12401255
* No description
12411256
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export default defineComponent({
119119
{bigSections.value.map((key) => <NAnchorLink key={key} title={key} href={`#${key}`}/>)}
120120
{otherSection.value.length > 0 && <NAnchorLink key="其他" title="其他" href="#其他"/>}
121121
</NAnchor>
122-
<NScrollbar class="max-h-60vh p-2"
122+
<NScrollbar class="max-h-75vh p-2"
123123
// @ts-ignore
124124
id="scroll"
125125
>

MaiChartManager/Front/src/components/ModManager/configSort.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
- Fancy.GamePlay.JudgeDisplay4B
5050
- Fancy.Triggers
5151

52+
键位和灵敏度:
53+
- GameSystem.HidInput
54+
- GameSystem.AdxHidInput
55+
- GameSystem.KeyMap
56+
- GameSettings.TouchSensitivity
57+
5258
调试:
5359
- GameSystem.Window
5460
- GameSettings.JudgeAdjust
@@ -72,10 +78,6 @@
7278
- GameSystem.CustomCameraId
7379
- UX.ServerAnnouncement
7480

75-
键位和灵敏度:
76-
- GameSystem.KeyMap
77-
- GameSettings.TouchSensitivity
78-
7981
过新过热:
8082
- Fancy.CustomTrackStartDiff
8183
- Fancy.GamePlay.BreakSlideJudgeBlink
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { defineComponent, PropType, ref, computed } from 'vue';
2+
import { IEntryState, ISectionState } from "@/client/apiGen";
3+
import { NButton, NFlex } from "naive-ui";
4+
import api from "@/client/api";
5+
import { modInfo, updateModInfo } from "@/store/refs";
6+
7+
export default defineComponent({
8+
props: {
9+
entryStates: { type: Object as PropType<Record<string, IEntryState>>, required: true },
10+
sectionState: { type: Object as PropType<ISectionState>, required: true },
11+
},
12+
setup(props, { emit }) {
13+
const load = ref(false)
14+
15+
const del = async () => {
16+
load.value = true
17+
await api.DeleteHidConflict();
18+
await updateModInfo();
19+
load.value = false
20+
}
21+
22+
return () =>
23+
modInfo.value?.isHidConflictExist ? <NFlex align="center" class="m-l-35 translate-y--3">
24+
<span class="c-orange">检测到冲突的 Mod</span>
25+
<NButton secondary onClick={del} loading={load.value}>一键删除</NButton>
26+
</NFlex>
27+
: <NFlex align="center" class="m-l-35 translate-y--3">
28+
<span class="c-green-6">没有检测到冲突</span>
29+
</NFlex>
30+
},
31+
});

MaiChartManager/Front/src/components/ModManager/sectionPanelOverride/UX.JudgeAccuracyInfo/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default defineComponent({
1111
setup(props, { emit }) {
1212
return () => <NFlex align="center" class="m-l-35 translate-y--3">
1313
作者:Minepig
14-
<NButton onClick={() => api.OpenJudgeAccuracyInfoPdf()}>查看说明文件</NButton>
14+
<NButton secondary onClick={() => api.OpenJudgeAccuracyInfoPdf()}>查看说明文件</NButton>
1515
</NFlex>;
1616
},
1717
});

0 commit comments

Comments
 (0)