From 2e17e0ae75232bb301d0b1a8c381e5f816f41085 Mon Sep 17 00:00:00 2001 From: akanyan Date: Wed, 30 Apr 2025 21:19:15 +0000 Subject: [PATCH] feat: diagnostic exports --- rust/src/cmd.rs | 9 +++++-- rust/src/patcher.rs | 4 +++ rust/src/profiles/template.rs | 29 ++++++++++++++++++--- rust/tauri.conf.json | 2 +- src/components/ProfileList.vue | 47 ++++++++++++++++++++++++++++------ src/i18n/en.ts | 4 ++- src/i18n/pl.ts | 4 ++- 7 files changed, 83 insertions(+), 16 deletions(-) diff --git a/rust/src/cmd.rs b/rust/src/cmd.rs index c8ccec6..7f034a1 100644 --- a/rust/src/cmd.rs +++ b/rust/src/cmd.rs @@ -480,13 +480,18 @@ pub async fn create_shortcut(_app: AppHandle, profile_meta: ProfileMeta) -> Resu } #[tauri::command] -pub async fn export_profile(state: State<'_, Mutex>, export_keychip: bool, files: Vec) -> Result<(), String> { +pub async fn export_profile( + state: State<'_, Mutex>, + is_diagnostic: bool, + export_keychip: bool, + files: Vec +) -> Result<(), String> { log::debug!("invoke: export_profile({:?}, {:?} files)", export_keychip, files.len()); let appd = state.lock().await; match &appd.profile { Some(p) => { - p.export(export_keychip, files) + p.export(export_keychip, files, is_diagnostic) .map_err(|e| e.to_string())?; } None => { diff --git a/rust/src/patcher.rs b/rust/src/patcher.rs index 450c94d..3cc7050 100644 --- a/rust/src/patcher.rs +++ b/rust/src/patcher.rs @@ -29,6 +29,10 @@ impl PatchFileVec { } pub fn find_patches(&self, target: impl AsRef) -> Result> { + if !target.as_ref().exists() { + log::warn!("invalid target path: {:?}", target.as_ref()); + anyhow::bail!("Unable to open {:?}. Make sure the game path is correct.", target.as_ref()); + } let checksum = try_digest(target.as_ref())?; let mut res_patches = Vec::new(); diff --git a/rust/src/profiles/template.rs b/rust/src/profiles/template.rs index 6b0cf88..ce87c8e 100644 --- a/rust/src/profiles/template.rs +++ b/rust/src/profiles/template.rs @@ -36,7 +36,7 @@ impl Profile { Ok(()) } - pub fn export(&self, export_keychip: bool, extra_files: Vec) -> anyhow::Result<()> { + pub fn export(&self, export_keychip: bool, extra_files: Vec, is_diagnostic: bool) -> anyhow::Result<()> { let mut prf = self.clone(); let dir = util::config_dir().join("exports"); @@ -45,7 +45,7 @@ impl Profile { std::fs::create_dir(&dir)?; } - let path = dir.join(format!("{}-{}-template.zip", &self.meta.game, &self.meta.name)); + let path = dir.join(format!("{}-{}-{}.zip", &self.meta.game, &self.meta.name, if is_diagnostic { "diagnostic" } else { "template" } )); { let sgt = &mut prf.data.sgt; @@ -66,7 +66,7 @@ impl Profile { if network.local_path.is_absolute() { network.local_path = PathBuf::new(); } - if !export_keychip { + if !export_keychip || is_diagnostic { network.keychip = String::new(); } } @@ -83,6 +83,29 @@ impl Profile { zip.write_all(&std::fs::read(self.config_dir().join(file))?)?; } + if is_diagnostic { + let name = "mu3.exe.log"; + let path = self.data_dir().join(name); + if path.exists() { + zip.start_file(name, options)?; + zip.write_all(&std::fs::read(path)?)?; + } + + let name = "chusanApp.exe.log"; + let path = self.data_dir().join(name); + if path.exists() { + zip.start_file(name, options)?; + zip.write_all(&std::fs::read(path)?)?; + } + + let name = "amdaemon.exe.log"; + let path = self.data_dir().join(name); + if path.exists() { + zip.start_file(name, options)?; + zip.write_all(&std::fs::read(path)?)?; + } + } + zip.finish()?; Ok(()) diff --git a/rust/tauri.conf.json b/rust/tauri.conf.json index 8cda16a..7a182da 100644 --- a/rust/tauri.conf.json +++ b/rust/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "STARTLINER", - "version": "0.18.3", + "version": "0.19.0", "identifier": "zip.patafour.startliner", "build": { "beforeDevCommand": "bun run dev", diff --git a/src/components/ProfileList.vue b/src/components/ProfileList.vue index c21322c..d2f046a 100644 --- a/src/components/ProfileList.vue +++ b/src/components/ProfileList.vue @@ -29,23 +29,34 @@ const files = new Set(); ).includes('chunithm'); })(); +const fileList = { + ongeki: ['aime.txt', 'inohara.cfg', 'mu3.ini', 'segatools-base.ini'], + chunithm: ['aime.txt', 'saekawa.toml', 'segatools-base.ini'], +}; + +const diagnosticList = { + ongeki: ['mu3.ini', 'segatools-base.ini'], + chunithm: ['segatools-base.ini'], +}; + +const diagnostic = ref(false); + const exportTemplate = async () => { const fl = [...files.values()]; exportVisible.value = false; await invoke('export_profile', { exportKeychip: exportKeychip.value, - files: fl, + isDiagnostic: diagnostic.value, + files: + diagnostic.value === true + ? diagnosticList[prf.current!.meta.game] + : fl, }); await invoke('open_file', { path: await path.join(await general.configDir, 'exports'), }); }; -const fileList = { - ongeki: ['aime.txt', 'inohara.cfg', 'mu3.ini', 'segatools-base.ini'], - chunithm: ['aime.txt', 'saekawa.toml', 'segatools-base.ini'], -}; - const fileListCurrent: Ref = ref([]); const recalcFileList = async () => { @@ -91,16 +102,36 @@ const importPick = async () => { :visible="exportVisible" :closable="false /*this shit doesn't work */" :header="`${t('profile.export')} ${prf.current?.meta.name}`" - :style="{ width: '300px', scale: client.scaleValue }" + :style="{ width: '330px', scale: client.scaleValue }" >
+
+ + +
{{ t('profile.export') }} keychip
- +
{{ t('profile.export') }} {{ f }}