Skip to content

Commit 523e4a7

Browse files
committed
feat(mod-ui): add MuMod version display, conflict warning, and channel switcher
1 parent c8c7178 commit 523e4a7

1 file changed

Lines changed: 62 additions & 10 deletions

File tree

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

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { defineComponent, ref, watch } from "vue";
33
import api from "@/client/api";
44
import { globalCapture, modInfo, updateModInfo, updateMusicList } from "@/store/refs";
55
import AquaMaiConfigurator from "./AquaMaiConfigurator";
6-
import { latestVersion, shouldShowUpdate } from "./shouldShowUpdateController";
6+
import { latestVersion, shouldShowUpdate, isMuModMode } from "./shouldShowUpdateController";
77
import ModInstallDropdown from "@/views/ModManager/ModInstallDropdown";
88
import { useI18n } from 'vue-i18n';
9-
import { Button, addToast } from '@munet/ui';
9+
import { Button, addToast, Radio } from '@munet/ui';
1010
import { debounce } from 'perfect-debounce';
1111
import AquaMaiSignatureStatusDisplay from "./AquaMaiSignatureStatusDisplay";
1212
import { useAsyncState } from '@vueuse/core';
13-
import { aquaMaiConfig as config, configReadErr, configReadErrTitle, updateAquaMaiConfig, configJustLoaded } from "./refs";
13+
import { aquaMaiConfig as config, configReadErr, configReadErrTitle, updateAquaMaiConfig, configJustLoaded, muModChannel, isBothModsPresent, updateMuModChannel } from "./refs";
1414

1515
export default defineComponent({
1616
setup() {
@@ -60,6 +60,33 @@ export default defineComponent({
6060
await updateAquaMaiConfig(false, true);
6161
}
6262

63+
const localMuModChannel = ref(muModChannel.value);
64+
watch(muModChannel, (v) => { localMuModChannel.value = v; });
65+
66+
const { execute: deleteAquaMai } = useAsyncState(async () => {
67+
await api.DeleteAquaMai();
68+
await updateModInfo();
69+
await updateAquaMaiConfig();
70+
}, undefined, {
71+
immediate: false,
72+
onError: (e: any) => globalCapture(e, t('mod.conflict.deleteAquaMai')),
73+
});
74+
75+
const { execute: deleteMuMod } = useAsyncState(async () => {
76+
await api.DeleteMuMod();
77+
await updateModInfo();
78+
await updateAquaMaiConfig();
79+
}, undefined, {
80+
immediate: false,
81+
onError: (e: any) => globalCapture(e, t('mod.conflict.deleteMuMod')),
82+
});
83+
84+
watch(localMuModChannel, (v) => {
85+
if (v !== muModChannel.value) {
86+
updateMuModChannel(v);
87+
}
88+
});
89+
6390
return () => {
6491

6592
let editorPart = <></>;
@@ -105,21 +132,46 @@ export default defineComponent({
105132
{modInfo.value.melonLoaderInstalled ? <span class="c-green-6 max-[1060px]:hidden">{t('mod.installed')}</span> : <span class="c-red-6">{t('mod.notInstalled')}</span>}
106133
{!modInfo.value.melonLoaderInstalled && <Button ing={installingMelonLoader.value} onClick={() => installMelonLoader()}>{t('mod.install')}</Button>}
107134
<div class={["w-8", "max-[1060px]:hidden"]}/>
108-
<span class="max-[1060px]:hidden">AquaMai:</span>
109-
{modInfo.value.aquaMaiInstalled ?
110-
!shouldShowUpdate.value ? <span class="c-green-6 max-[1060px]:hidden">{t('mod.installed')}</span> : <span class="c-orange">{t('mod.updateAvailable')}</span> :
111-
<span class="c-red-6">{t('mod.notInstalled')}</span>}
135+
<span class="max-[1060px]:hidden">{isMuModMode.value ? 'MuMod:' : 'AquaMai:'}</span>
136+
{isMuModMode.value ? (
137+
<span class="c-green-6 max-[1060px]:hidden">{t('mod.mumodInstalled')}</span>
138+
) : (
139+
modInfo.value.aquaMaiInstalled ?
140+
!shouldShowUpdate.value ? <span class="c-green-6 max-[1060px]:hidden">{t('mod.installed')}</span> : <span class="c-orange">{t('mod.updateAvailable')}</span> :
141+
<span class="c-red-6">{t('mod.notInstalled')}</span>
142+
)}
112143
<ModInstallDropdown/>
113144
<span class="max-[1060px]:hidden">{t('mod.installedVersion')}:</span>
114-
<span class="max-[450px]:hidden">{modInfo.value.aquaMaiVersion !=='N/A' && 'v'}{modInfo.value.aquaMaiVersion}</span>
115-
<AquaMaiSignatureStatusDisplay/>
145+
{isMuModMode.value ? (
146+
<span class="max-[450px]:hidden">v{modInfo.value.muModVersion ?? 'N/A'}</span>
147+
) : (
148+
<span class="max-[450px]:hidden">{modInfo.value.aquaMaiVersion !== 'N/A' && 'v'}{modInfo.value.aquaMaiVersion}</span>
149+
)}
150+
{!isMuModMode.value && <AquaMaiSignatureStatusDisplay/>}
116151
<span class="max-[1060px]:hidden">{t('mod.availableVersion')}:</span>
117152
<span class={[shouldShowUpdate.value && "c-orange", "max-[1060px]:hidden"]}>{latestVersion.value.version}</span>
118153
<Button onClick={() => api.KillGameProcess()}>
119154
{t('mod.killGameProcess')}
120155
</Button>
121156
</div>
122-
{editorPart}
157+
{isBothModsPresent.value && (
158+
<div class="flex flex-col gap-2 p-4 bg-orange-50 border border-orange-200 border-solid rounded-xl">
159+
<div class="font-semibold c-orange-7">{t('mod.conflict.title')}</div>
160+
<div class="c-orange-6">{t('mod.conflict.message')}</div>
161+
<div class="flex gap-2">
162+
<Button onClick={() => deleteAquaMai()}>{t('mod.conflict.deleteAquaMai')}</Button>
163+
<Button onClick={() => deleteMuMod()}>{t('mod.conflict.deleteMuMod')}</Button>
164+
</div>
165+
</div>
166+
)}
167+
{isMuModMode.value && (
168+
<div class="flex items-center gap-3 px-2 py-1">
169+
<span class="shrink-0">{t('mod.mumodChannel')}:</span>
170+
<Radio k={'slow'} v-model:value={localMuModChannel.value}>{t('mod.mumodChannelSlow')}</Radio>
171+
<Radio k={'fast'} v-model:value={localMuModChannel.value}>{t('mod.mumodChannelFast')}</Radio>
172+
</div>
173+
)}
174+
{!isBothModsPresent.value && editorPart}
123175
</div>}
124176
</div>
125177
};

0 commit comments

Comments
 (0)