forked from akanyan/STARTLINER
fix: misc cleanup
This commit is contained in:
@ -190,12 +190,16 @@ pub async fn get_all_packages(state: State<'_, Mutex<AppData>>) -> Result<HashMa
|
||||
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_game_packages(state: State<'_, Mutex<AppData>>, game: Game) -> Result<Vec<PkgKey>, ()> {
|
||||
log::debug!("invoke: get_game_packages {game}");
|
||||
pub async fn get_game_packages(state: State<'_, Mutex<AppData>>, game: Option<Game>) -> Result<Vec<PkgKey>, ()> {
|
||||
log::debug!("invoke: get_game_packages {game:?}");
|
||||
|
||||
let appd = state.lock().await;
|
||||
|
||||
Ok(appd.pkgs.get_game_list(game))
|
||||
if let Some(game) = game {
|
||||
Ok(appd.pkgs.get_game_list(game))
|
||||
} else {
|
||||
Ok(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@ -437,6 +441,26 @@ pub async fn import_profile(path: PathBuf) -> Result<(), String> {
|
||||
Profile::import(path).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn clear_cache(state: State<'_, Mutex<AppData>>) -> Result<(), String> {
|
||||
log::debug!("invoke: clear_cache");
|
||||
|
||||
let appd = state.lock().await;
|
||||
if let Some(p) = &appd.profile {
|
||||
let dir = p.data_dir().join("mu3-mods-cache");
|
||||
let path = dir.join("data_cache.bin");
|
||||
if path.exists() {
|
||||
std::fs::remove_file(path).map_err(|e| e.to_string())?;
|
||||
}
|
||||
let path = dir.join("data_fumen_analysis_cache.bin");
|
||||
if path.exists() {
|
||||
std::fs::remove_file(path).map_err(|e| e.to_string())?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn list_platform_capabilities() -> Result<Vec<String>, ()> {
|
||||
log::debug!("invoke: list_platform_capabilities");
|
||||
|
@ -207,6 +207,7 @@ pub async fn run(_args: Vec<String>) {
|
||||
cmd::create_shortcut,
|
||||
cmd::export_profile,
|
||||
cmd::import_profile,
|
||||
cmd::clear_cache,
|
||||
|
||||
cmd::get_global_config,
|
||||
cmd::set_global_config,
|
||||
|
@ -56,11 +56,6 @@ listen<undefined>('update-end', (_) => {
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
invoke('list_directories').then((d) => {
|
||||
general.dirs = d as Dirs;
|
||||
client.load();
|
||||
});
|
||||
|
||||
const fetch_promise = pkg.fetch(true);
|
||||
|
||||
await Promise.all([prf.reloadList(), prf.reload()]);
|
||||
@ -231,8 +226,9 @@ listen<DownloadingStatus>('download-progress', (event) => {
|
||||
><div class="pi pi-ticket"></div
|
||||
></Tab>
|
||||
<Tab
|
||||
v-if="pkg.networkStatus === 'online'"
|
||||
:disabled="isProfileDisabled"
|
||||
:disabled="
|
||||
isProfileDisabled || pkg.networkStatus !== 'online'
|
||||
"
|
||||
value="rmt"
|
||||
><div class="pi pi-download"></div
|
||||
></Tab>
|
||||
@ -304,19 +300,19 @@ listen<DownloadingStatus>('download-progress', (event) => {
|
||||
</TabList>
|
||||
</div>
|
||||
<TabPanels class="w-full grow mt-[3rem]">
|
||||
<TabPanel value="loc">
|
||||
<TabPanel value="loc" v-if="!isProfileDisabled">
|
||||
<ModList :search="pkgSearchTerm" />
|
||||
</TabPanel>
|
||||
<TabPanel value="rmt">
|
||||
<TabPanel value="rmt" v-if="!isProfileDisabled">
|
||||
<ModStore :search="pkgSearchTerm" />
|
||||
</TabPanel>
|
||||
<TabPanel value="cfg">
|
||||
<TabPanel value="cfg" v-if="!isProfileDisabled">
|
||||
<OptionList />
|
||||
</TabPanel>
|
||||
<TabPanel value="users">
|
||||
<ProfileList />
|
||||
</TabPanel>
|
||||
<TabPanel value="patches">
|
||||
<TabPanel value="patches" v-if="!isProfileDisabled">
|
||||
<PatchList
|
||||
v-if="
|
||||
pkg.hasLocal('mempatcher-mempatcher') &&
|
||||
|
@ -22,7 +22,7 @@ const empty = ref(false);
|
||||
const gameSublist: Ref<string[]> = ref([]);
|
||||
|
||||
invoke('get_game_packages', {
|
||||
game: prf.current?.meta.game,
|
||||
game: prf.current?.meta.game ?? null,
|
||||
}).then((list) => {
|
||||
gameSublist.value = list as string[];
|
||||
});
|
||||
@ -55,6 +55,9 @@ const group = computed(() => {
|
||||
const missing = computed(() => {
|
||||
return prf.current?.data.mods.filter((m) => !pkgs.hasLocal(m)) ?? [];
|
||||
});
|
||||
|
||||
const emptyVisible = ref(false);
|
||||
setTimeout(() => (emptyVisible.value = true), 500);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -84,5 +87,7 @@ const missing = computed(() => {
|
||||
<Fieldset v-for="(namespace, key) in group" :legend="key.toString()">
|
||||
<ModListEntry v-for="p in namespace" :pkg="p" />
|
||||
</Fieldset>
|
||||
<div v-if="empty === true" class="text-3xl fadein">∅</div>
|
||||
<div v-if="empty === true && emptyVisible === true" class="text-3xl fadein">
|
||||
∅
|
||||
</div>
|
||||
</template>
|
||||
|
@ -23,7 +23,7 @@ const props = defineProps({
|
||||
const gameSublist: Ref<string[]> = ref([]);
|
||||
|
||||
invoke('get_game_packages', {
|
||||
game: prf.current?.meta.game,
|
||||
game: prf.current?.meta.game ?? null,
|
||||
}).then((list) => {
|
||||
gameSublist.value = list as string[];
|
||||
});
|
||||
@ -46,10 +46,10 @@ const list = () => {
|
||||
};
|
||||
|
||||
const shouldShowRecommended = computed(() => {
|
||||
if (prf.current!.meta.game === 'ongeki') {
|
||||
if (prf.current?.meta.game === 'ongeki') {
|
||||
return !pkgs.allLocal.some((p) => pkgKey(p) === 'segatools-mu3hook');
|
||||
}
|
||||
if (prf.current!.meta.game === 'chunithm') {
|
||||
if (prf.current?.meta.game === 'chunithm') {
|
||||
return (
|
||||
!pkgs.allLocal.some((p) => pkgKey(p) === 'segatools-chusanhook') ||
|
||||
!pkgs.allLocal.some((p) => pkgKey(p) === 'mempatcher-mempatcher')
|
||||
@ -58,21 +58,21 @@ const shouldShowRecommended = computed(() => {
|
||||
return false;
|
||||
});
|
||||
|
||||
const getRecommendedTooltip = () => {
|
||||
if (prf.current!.meta.game === 'ongeki') {
|
||||
const recommendedTooltip = computed(() => {
|
||||
if (prf.current?.meta.game === 'ongeki') {
|
||||
return 'segatools-mu3hook';
|
||||
}
|
||||
if (prf.current!.meta.game === 'chunithm') {
|
||||
if (prf.current?.meta.game === 'chunithm') {
|
||||
return 'segatools-chusanhook + mempatcher';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
});
|
||||
|
||||
const installRecommended = () => {
|
||||
if (prf.current!.meta.game === 'ongeki') {
|
||||
if (prf.current?.meta.game === 'ongeki') {
|
||||
pkgs.installFromKey('segatools-mu3hook');
|
||||
}
|
||||
if (prf.current!.meta.game === 'chunithm') {
|
||||
if (prf.current?.meta.game === 'chunithm') {
|
||||
pkgs.installFromKey('segatools-chusanhook');
|
||||
pkgs.installFromKey('mempatcher-mempatcher');
|
||||
}
|
||||
@ -120,7 +120,7 @@ const installRecommended = () => {
|
||||
<Button
|
||||
v-if="shouldShowRecommended"
|
||||
:label="t('store.installRecommended')"
|
||||
v-tooltip="getRecommendedTooltip"
|
||||
v-tooltip="recommendedTooltip"
|
||||
icon="pi pi-plus"
|
||||
class="mb-3"
|
||||
@click="installRecommended"
|
||||
|
@ -61,7 +61,7 @@ prf.reload();
|
||||
<MiscOptions />
|
||||
<OptionCategory
|
||||
title="Extensions"
|
||||
v-if="prf.current!.meta.game === 'chunithm'"
|
||||
v-if="prf.current?.meta.game === 'chunithm'"
|
||||
>
|
||||
<OptionRow :title="t('cfg.extensions.saekawa')">
|
||||
<FileEditor
|
||||
@ -72,7 +72,7 @@ prf.reload();
|
||||
></OptionCategory>
|
||||
<OptionCategory
|
||||
:title="t('cfg.extensions.title')"
|
||||
v-if="prf.current!.meta.game === 'ongeki'"
|
||||
v-if="prf.current?.meta.game === 'ongeki'"
|
||||
>
|
||||
<OptionRow :title="t('cfg.extensions.inohara')">
|
||||
<FileEditor
|
||||
|
@ -30,7 +30,7 @@ const exportTemplate = async () => {
|
||||
files: fl,
|
||||
});
|
||||
await invoke('open_file', {
|
||||
path: await path.join(general.configDir, 'exports'),
|
||||
path: await path.join(await general.configDir, 'exports'),
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -137,7 +137,7 @@ const menuItems = computed(() => {
|
||||
{
|
||||
label: t('start.button.cache'),
|
||||
icon: 'pi pi-trash',
|
||||
command: async () => {},
|
||||
command: async () => await invoke('clear_cache'),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { Ref, computed, ref } from 'vue';
|
||||
import { Ref, computed, onMounted, ref } from 'vue';
|
||||
import InputNumber from 'primevue/inputnumber';
|
||||
import Select from 'primevue/select';
|
||||
import SelectButton from 'primevue/selectbutton';
|
||||
@ -67,10 +67,12 @@ const loadDisplays = () => {
|
||||
|
||||
loadDisplays();
|
||||
|
||||
const game = prf.current!.meta.game;
|
||||
const isVertical = game === 'ongeki';
|
||||
const adjustableRez = game === 'ongeki';
|
||||
const canSkipPrimarySwitch = game === 'ongeki';
|
||||
const game = computed(() => prf.current!.meta.game);
|
||||
const isVertical = computed(() => prf.current!.meta.game === 'ongeki');
|
||||
const adjustableRez = computed(() => prf.current!.meta.game === 'ongeki');
|
||||
const canSkipPrimarySwitch = computed(
|
||||
() => prf.current!.meta.game === 'ongeki'
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -35,8 +35,6 @@ const names = computed(() => {
|
||||
io: 'chuniio',
|
||||
};
|
||||
}
|
||||
case undefined:
|
||||
throw new Error('Option tab without a profile');
|
||||
}
|
||||
});
|
||||
|
||||
@ -59,14 +57,14 @@ const checkSegatoolsIni = async (target: string) => {
|
||||
<template>
|
||||
<OptionCategory :title="t('cfg.segatools.general')">
|
||||
<OptionRow
|
||||
:title="names.exe"
|
||||
:title="names?.exe"
|
||||
:tooltip="t('cfg.segatools.targetTooltip')"
|
||||
>
|
||||
<FilePicker
|
||||
:directory="false"
|
||||
:promptname="names.exe"
|
||||
:promptname="names?.exe"
|
||||
extension="exe"
|
||||
:value="prf.current!.data.sgt.target"
|
||||
:value="prf.current?.data.sgt.target"
|
||||
:callback="
|
||||
(value: string) => (
|
||||
(prf.current!.data.sgt.target = value),
|
||||
@ -80,7 +78,7 @@ const checkSegatoolsIni = async (target: string) => {
|
||||
<FilePicker
|
||||
:directory="true"
|
||||
placeholder="amfs"
|
||||
:value="prf.current!.data.sgt.amfs"
|
||||
:value="prf.current?.data.sgt.amfs"
|
||||
:callback="
|
||||
(value: string) => (prf.current!.data.sgt.amfs = value)
|
||||
"
|
||||
@ -106,7 +104,7 @@ const checkSegatoolsIni = async (target: string) => {
|
||||
></FilePicker>
|
||||
</OptionRow>
|
||||
<OptionRow
|
||||
:title="names.hook"
|
||||
:title="names?.hook"
|
||||
:tooltip="
|
||||
t('cfg.segatools.installTooltip', {
|
||||
thing: t('cfg.segatools.hooks'),
|
||||
@ -132,7 +130,7 @@ const checkSegatoolsIni = async (target: string) => {
|
||||
></Select>
|
||||
</OptionRow>
|
||||
<OptionRow
|
||||
:title="names.io"
|
||||
:title="names?.io"
|
||||
:tooltip="
|
||||
t('cfg.segatools.installTooltip', {
|
||||
thing: t('cfg.segatools.ioModules'),
|
||||
|
@ -32,23 +32,24 @@ export const useGeneralStore = defineStore('general', () => {
|
||||
},
|
||||
});
|
||||
|
||||
const configDir = computed(() => {
|
||||
const loadDirs = async () => {
|
||||
if (dirs.value === null) {
|
||||
throw new Error('Invalid directory access');
|
||||
const d = (await invoke('list_directories')) as Dirs;
|
||||
dirs.value = d;
|
||||
}
|
||||
return dirs.value.config_dir;
|
||||
};
|
||||
|
||||
const configDir = computed(async () => {
|
||||
await loadDirs();
|
||||
return dirs.value!.config_dir;
|
||||
});
|
||||
const dataDir = computed(() => {
|
||||
if (dirs.value === null) {
|
||||
throw new Error('Invalid directory access');
|
||||
}
|
||||
return dirs.value.data_dir;
|
||||
const dataDir = computed(async () => {
|
||||
await loadDirs();
|
||||
return dirs.value!.data_dir;
|
||||
});
|
||||
const cacheDir = computed(() => {
|
||||
if (dirs.value === null) {
|
||||
throw new Error('Invalid directory access');
|
||||
}
|
||||
return dirs.value.cache_dir;
|
||||
const cacheDir = computed(async () => {
|
||||
await loadDirs();
|
||||
return dirs.value!.cache_dir;
|
||||
});
|
||||
|
||||
return {
|
||||
@ -322,7 +323,7 @@ export const usePrfStore = defineStore('prf', () => {
|
||||
|
||||
const configDir = computed(async () => {
|
||||
return await path.join(
|
||||
generalStore.configDir,
|
||||
await generalStore.configDir,
|
||||
`profile-${current.value?.meta.game}-${current.value?.meta.name}`
|
||||
);
|
||||
});
|
||||
@ -412,7 +413,7 @@ export const useClientStore = defineStore('client', () => {
|
||||
const input = JSON.parse(
|
||||
await readTextFile(
|
||||
await path.join(
|
||||
generalStore.configDir,
|
||||
await generalStore.configDir,
|
||||
'client-options.json'
|
||||
)
|
||||
)
|
||||
@ -464,7 +465,10 @@ export const useClientStore = defineStore('client', () => {
|
||||
const size = await w.innerSize();
|
||||
|
||||
await writeTextFile(
|
||||
await path.join(generalStore.configDir, 'client-options.json'),
|
||||
await path.join(
|
||||
await generalStore.configDir,
|
||||
'client-options.json'
|
||||
),
|
||||
JSON.stringify({
|
||||
scaleFactor: scaleFactor.value,
|
||||
windowSize: {
|
||||
|
Reference in New Issue
Block a user