Skip to content

Commit a239df1

Browse files
committed
feat: Mod 更新角标提示
1 parent c04418e commit a239df1

6 files changed

Lines changed: 44 additions & 8 deletions

File tree

1 KB
Binary file not shown.
1.5 KB
Binary file not shown.

MaiChartManager/Controllers/ModController.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.IO.Compression;
2-
using System.Windows.Forms;
32
using Microsoft.AspNetCore.Mvc;
43
using Tomlet;
54

@@ -23,6 +22,24 @@ public bool IsAquaMaiInstalled()
2322
return System.IO.File.Exists(Path.Combine(StaticSettings.GamePath, @"Mods\AquaMai.dll"));
2423
}
2524

25+
public record GameModInfo(bool MelonLoaderInstalled, bool AquaMaiInstalled, string AquaMaiVersion, string BundledAquaMaiVersion);
26+
27+
[HttpGet]
28+
public GameModInfo GetGameModInfo()
29+
{
30+
var aquaMaiInstalled = IsAquaMaiInstalled();
31+
var aquaMaiVersion = "N/A";
32+
if (aquaMaiInstalled)
33+
{
34+
aquaMaiVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(Path.Combine(StaticSettings.GamePath, @"Mods\AquaMai.dll")).ProductVersion;
35+
}
36+
37+
var bundledAquaMaiVersion = AppDomain.CurrentDomain.GetAssemblies()
38+
.FirstOrDefault(a => a.GetName().Name == "AquaMai")?.GetName().Version?.ToString(3) ?? "N/A";
39+
40+
return new GameModInfo(IsMelonInstalled(), aquaMaiInstalled, aquaMaiVersion, bundledAquaMaiVersion);
41+
}
42+
2643
[HttpGet]
2744
public AquaMai.Config GetAquaMaiConfig()
2845
{

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { computed, defineComponent, onMounted, PropType, ref, watch } from "vue";
2-
import { NButton, NDivider, NFlex, NFormItem, NInput, NModal, NScrollbar, NSwitch, useDialog } from "naive-ui";
2+
import { NButton, NCheckbox, NDivider, NFlex, NFormItem, NInput, NModal, NScrollbar, NSwitch, useDialog } from "naive-ui";
33
import { Config, GameModInfo } from "@/client/apiGen";
44
import comments from './modComments.yaml';
55
import api from "@/client/api";
@@ -9,14 +9,20 @@ import ProblemsDisplay from "@/components/ProblemsDisplay";
99
export default defineComponent({
1010
props: {
1111
show: Boolean,
12+
disableBadge: Boolean,
1213
info: {type: Object as PropType<GameModInfo>, required: true},
1314
refresh: {type: Function, required: true},
15+
badgeType: String,
1416
},
1517
setup(props, {emit}) {
1618
const show = computed({
1719
get: () => props.show,
1820
set: (val) => emit('update:show', val)
1921
})
22+
const disableBadge = computed({
23+
get: () => props.disableBadge,
24+
set: (val) => emit('update:disableBadge', val)
25+
})
2026

2127
const config = ref<Config>()
2228
const dialog = useDialog()
@@ -87,6 +93,7 @@ export default defineComponent({
8793
可安装:
8894
<span class={props.info.aquaMaiVersion === props.info.bundledAquaMaiVersion ? "" : "c-orange"}>{props.info.bundledAquaMaiVersion}</span>
8995
</NFlex>
96+
{props.badgeType && <NCheckbox v-model:checked={disableBadge.value}>隐藏按钮上的角标</NCheckbox>}
9097
{config.value && <NScrollbar class="max-h-60vh p-2">
9198
{Object.entries(config.value).map(([key, section]) => !!section && <>
9299
<NDivider titlePlacement="left">{comments.sections[key]}</NDivider>

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { defineComponent, onMounted, ref } from "vue";
2-
import { NButton } from "naive-ui";
1+
import { computed, defineComponent, onMounted, ref } from "vue";
2+
import { NBadge, NButton } from "naive-ui";
33
import { useStorage } from "@vueuse/core";
44
import ModNotInstalledWarning from "@/components/ModManager/ModNotInstalledWarning";
55
import api from "@/client/api";
@@ -20,13 +20,24 @@ export default defineComponent({
2020
showWarning.value = !info.value.aquaMaiInstalled || !info.value.melonLoaderInstalled;
2121
})
2222

23-
return () => <NButton secondary onClick={() => showConfigurator.value = true}>
24-
Mod 管理
23+
const badgeType = computed(() => {
24+
if (!info.value) return
25+
if (!info.value.aquaMaiInstalled || !info.value.melonLoaderInstalled) return 'error'
26+
if (info.value.aquaMaiVersion !== info.value.bundledAquaMaiVersion) return 'warning'
27+
})
28+
29+
return () => <>
30+
<NBadge dot show={!!badgeType.value && !disableBadge.value} type={badgeType.value as any}>
31+
<NButton secondary onClick={() => showConfigurator.value = true}>
32+
Mod 管理
33+
</NButton>
34+
</NBadge>
2535
<ModNotInstalledWarning show={showWarning.value} closeModal={(dismiss: boolean) => {
2636
showWarning.value = false
2737
isWarningConfirmed.value = dismiss
2838
}}/>
29-
{info.value && <ConfigEditor v-model:show={showConfigurator.value} info={info.value} refresh={async () => info.value = (await api.GetGameModInfo()).data}/>}
30-
</NButton>;
39+
{info.value && <ConfigEditor v-model:show={showConfigurator.value} v-model:disableBadge={disableBadge.value} info={info.value} badgeType={badgeType.value}
40+
refresh={async () => info.value = (await api.GetGameModInfo()).data}/>}
41+
</>;
3142
}
3243
})

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ cheat:
88
ticketUnlock: 解锁游戏里所有可能的跑图券
99
mapUnlock: 解锁游戏里所有的区域,包括非当前版本的(并不会帮你跑完)
1010
unlockUtage: 不需要万分也可以进宴会场
11+
debugFeature: 恢复 SDGA 的自动播放(Home)和暂停(Enter)按键
1112

1213
ux:
1314
skipWarningScreen: 跳过日服启动时候的 WARNING 界面

0 commit comments

Comments
 (0)