Files
STARTLINER/src/components/options/Segatools.vue
2025-04-10 13:53:20 +00:00

146 lines
4.8 KiB
Vue

<script setup lang="ts">
import { computed } from 'vue';
import Select from 'primevue/select';
import { useConfirm } from 'primevue/useconfirm';
import { emit } from '@tauri-apps/api/event';
import * as path from '@tauri-apps/api/path';
import FilePicker from '../FilePicker.vue';
import OptionCategory from '../OptionCategory.vue';
import OptionRow from '../OptionRow.vue';
import { invoke } from '../../invoke';
import { usePkgStore, usePrfStore } from '../../stores';
import { Feature } from '../../types';
import { pkgKey } from '../../util';
const prf = usePrfStore();
const pkgs = usePkgStore();
const confirmDialog = useConfirm();
const names = computed(() => {
switch (prf.current?.meta.game) {
case 'ongeki': {
return {
exe: 'mu3.exe',
hook: 'mu3hook',
io: 'mu3io',
};
}
case 'chunithm': {
return {
exe: 'chusanApp.exe',
hook: 'chusanhook',
io: 'chuniio',
};
}
case undefined:
throw new Error('Option tab without a profile');
}
});
const checkSegatoolsIni = async (target: string) => {
const iniPath = await path.join(target, '../segatools.ini');
if (await invoke('file_exists', { path: iniPath })) {
confirmDialog.require({
message: 'Would you like to load the existing configuration data?',
header: 'segatools.ini found',
accept: async () => {
await invoke('load_segatools_ini', { path: iniPath });
await prf.reload();
await emit('reload-aime-code');
},
});
}
};
</script>
<template>
<OptionCategory title="General">
<OptionRow
:title="names.exe"
tooltip="STARTLINER expects unpacked executables put into otherwise clean data."
>
<FilePicker
:directory="false"
:promptname="names.exe"
extension="exe"
:value="prf.current!.data.sgt.target"
:callback="
(value: string) => (
(prf.current!.data.sgt.target = value),
checkSegatoolsIni(value)
)
"
></FilePicker>
</OptionRow>
<OptionRow title="amfs">
<FilePicker
:directory="true"
placeholder="amfs"
:value="prf.current!.data.sgt.amfs"
:callback="
(value: string) => (prf.current!.data.sgt.amfs = value)
"
></FilePicker>
</OptionRow>
<OptionRow title="option">
<FilePicker
:directory="true"
placeholder="option"
:value="prf.current!.data.sgt.option"
:callback="
(value: string) => (prf.current!.data.sgt.option = value)
"
></FilePicker>
</OptionRow>
<OptionRow title="appdata">
<FilePicker
:directory="true"
:value="prf.current!.data.sgt.appdata"
:callback="
(value: string) => (prf.current!.data.sgt.appdata = value)
"
></FilePicker>
</OptionRow>
<OptionRow
:title="names.hook"
tooltip="Hooks can be downloaded from the package store."
>
<Select
v-model="prf.current!.data.sgt.hook"
:options="
pkgs
.byFeature(
prf.current?.meta.game === 'ongeki'
? Feature.Mu3Hook
: Feature.ChusanHook
)
.map((p) => {
return { title: pkgKey(p), value: pkgKey(p) };
})
"
option-label="title"
option-value="value"
></Select>
</OptionRow>
<OptionRow
:title="names.io"
v-if="prf.current?.meta.game === 'ongeki'"
tooltip="IO plugins can be downloaded from the package store."
>
<Select
v-model="prf.current!.data.sgt.io"
placeholder="segatools built-in"
:options="[
{ title: 'segatools built-in', value: null },
...pkgs.byFeature(Feature.Mu3IO).map((p) => {
return { title: pkgKey(p), value: pkgKey(p) };
}),
]"
option-label="title"
option-value="value"
></Select>
</OptionRow>
</OptionCategory>
</template>