diff --git a/.gitignore b/.gitignore index 212a339..902df57 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,8 @@ dist-ssr *.sln *.sw? +*.png +*.bat +*.exe + tsconfig.tsbuildinfo \ No newline at end of file diff --git a/rust/icons/ongeki.ico b/rust/icons/ongeki.ico new file mode 100644 index 0000000..282cbe0 Binary files /dev/null and b/rust/icons/ongeki.ico differ diff --git a/rust/src/cmd.rs b/rust/src/cmd.rs index d9285b9..4dd5398 100644 --- a/rust/src/cmd.rs +++ b/rust/src/cmd.rs @@ -24,7 +24,7 @@ pub async fn startline(app: AppHandle) -> Result<(), String> { } if let Some(p) = &mut appd.profile { log::debug!("{}", hash); - p.line_up(app.clone(), hash).await + p.line_up(hash, app.clone()).await .map_err(|e| format!("Lineup failed:\n{}", e))?; p.start(app.clone()).await .map_err(|e| format!("Startup failed:\n{}", e))?; diff --git a/rust/src/modules/display_windows.rs b/rust/src/modules/display_windows.rs index 82c6c79..ec0af80 100644 --- a/rust/src/modules/display_windows.rs +++ b/rust/src/modules/display_windows.rs @@ -20,23 +20,18 @@ impl Default for DisplayInfo { } impl Display { - pub fn activate(&self, app: AppHandle) { - let display = self.clone(); + pub fn wait_for_exit(app: AppHandle, info: DisplayInfo) { + log::debug!("display: waiting"); tauri::async_runtime::spawn(async move { - let info = display.line_up()?; - if let Some(info) = info { - app.listen("launch-end", move |_| { - if let Err(e) = Self::clean_up(&info) { - log::error!("Error cleaning up display: {:?}", e); - } - }); - } - - Ok::<(), anyhow::Error>(()) + app.listen("launch-end", move |_| { + if let Err(e) = Self::clean_up(&info) { + log::error!("error cleaning up display: {:?}", e); + } + }); }); } - fn line_up(&self) -> Result> { + pub fn line_up(&self) -> Result> { use anyhow::anyhow; use displayz::{query_displays, Orientation, Resolution, Frequency}; @@ -101,7 +96,7 @@ impl Display { Ok(Some(res)) } - fn clean_up(info: &DisplayInfo) -> Result<()> { + pub fn clean_up(info: &DisplayInfo) -> Result<()> { use anyhow::anyhow; let display_set = info.set.as_ref() diff --git a/rust/src/profiles/mod.rs b/rust/src/profiles/mod.rs index ac8b9c7..3528982 100644 --- a/rust/src/profiles/mod.rs +++ b/rust/src/profiles/mod.rs @@ -3,7 +3,7 @@ use ongeki::OngekiProfile; use serde::{Deserialize, Serialize}; use tauri::AppHandle; use std::{collections::BTreeSet, path::{Path, PathBuf}}; -use crate::{model::misc::Game, modules::package::prepare_packages, pkg::PkgKey, util}; +use crate::{model::{config::Display, misc::Game}, modules::package::prepare_packages, pkg::PkgKey, util}; pub mod ongeki; @@ -70,7 +70,28 @@ impl AnyProfile { Self::OngekiProfile(p) => &mut p.mods } } - pub async fn line_up(&self, _app: AppHandle, pkg_hash: String) -> Result<()> { + pub async fn line_up(&self, pkg_hash: String, _app: AppHandle) -> Result<()> { + match self { + Self::OngekiProfile(p) => { + #[cfg(target_os = "windows")] + let info = p.display.line_up()?; + + let res = self.line_up_the_rest(pkg_hash).await; + + #[cfg(target_os = "windows")] + if let Some(info) = info { + if res.is_ok() { + Display::wait_for_exit(_app, info); + } else { + Display::clean_up(&info)?; + } + } + + res + } + } + } + async fn line_up_the_rest(&self, pkg_hash: String) -> Result<()> { match self { Self::OngekiProfile(p) => { if !p.data_dir().exists() { @@ -80,9 +101,6 @@ impl AnyProfile { let hash_path = p.data_dir().join(".sl-state"); let meta = self.meta(); - #[cfg(target_os = "windows")] - p.display.activate(_app.clone()); - util::clean_up_opts(p.data_dir().join("option"))?; if Self::hash_check(&hash_path, &pkg_hash).await? == true { diff --git a/src/components/OptionList.vue b/src/components/OptionList.vue index a362d30..718b841 100644 --- a/src/components/OptionList.vue +++ b/src/components/OptionList.vue @@ -26,12 +26,12 @@ const displayList: Ref<{ title: string; value: string }[]> = ref([ }, ]); -const hookList: Ref<{ title: string; value: string }[]> = ref([ - { - title: 'segatools-mu3hook', - value: 'segatools-mu3hook', - }, -]); +// const hookList: Ref<{ title: string; value: string }[]> = ref([ +// { +// title: 'segatools-mu3hook', +// value: 'segatools-mu3hook', +// }, +// ]); invoke('list_platform_capabilities') .then(async (v: unknown) => { @@ -86,14 +86,14 @@ const extraDisplayOptionsDisabled = computed(() => { :callback="(value: string) => (prf.current!.sgt.target = value)" > - +