diff --git a/rust/icons/slow.ico b/rust/icons/slow.ico new file mode 100644 index 0000000..90a5442 Binary files /dev/null and b/rust/icons/slow.ico differ diff --git a/rust/src/appdata.rs b/rust/src/appdata.rs index a66ac05..6ac902d 100644 --- a/rust/src/appdata.rs +++ b/rust/src/appdata.rs @@ -5,7 +5,7 @@ use crate::pkg_store::PackageStore; pub struct AppData { pub profile: Option, - pub pkgs: PackageStore, + pub pkgs: PackageStore } impl AppData { diff --git a/rust/src/cmd.rs b/rust/src/cmd.rs index a2ee43c..377ef2f 100644 --- a/rust/src/cmd.rs +++ b/rust/src/cmd.rs @@ -134,3 +134,19 @@ pub async fn init_profile( Ok(new_profile) } + +#[tauri::command] +pub async fn set_cfg( + state: State<'_, Mutex>, + key: String, + value: String +) -> Result<(), ()> { + log::debug!("invoke: sync_cfg({}, {})", key, value); + + let mut appd = state.lock().await; + if let Some(p) = &mut appd.profile { + p.cfg.insert(key, value); + } + + Ok(()) +} diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 933e205..9e0f370 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -116,7 +116,8 @@ pub async fn run(_args: Vec) { cmd::get_current_profile, cmd::init_profile, cmd::save_profile, - cmd::startline + cmd::startline, + cmd::set_cfg ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/rust/src/profile.rs b/rust/src/profile.rs index 6cc7eea..e93408d 100644 --- a/rust/src/profile.rs +++ b/rust/src/profile.rs @@ -1,5 +1,4 @@ -use std::{collections::HashSet, path::PathBuf}; - +use std::{collections::{HashMap, HashSet}, path::PathBuf}; use crate::{model::misc, pkg::PkgKey, util}; use serde::{Deserialize, Serialize}; use tokio::fs; @@ -15,6 +14,7 @@ pub struct Profile { pub mods: HashSet, pub wine_runtime: Option, pub wine_prefix: Option, + pub cfg: HashMap } impl Profile { @@ -39,6 +39,7 @@ impl Profile { ), #[cfg(target_os = "windows")] wine_prefix: None, + cfg: HashMap::new() } } diff --git a/rust/src/start.rs b/rust/src/start.rs index 5a1bfa8..9e29496 100644 --- a/rust/src/start.rs +++ b/rust/src/start.rs @@ -32,27 +32,37 @@ pub fn start(p: &Profile, app: AppHandle) -> Result<()> { } #[cfg(target_os = "windows")] -pub fn start(p: &Profile) -> Result<()> { +pub fn start(p: &Profile, app: AppHandle) -> Result<()> { use std::process::Stdio; use tokio::task::JoinSet; + let create_no_window = 0x08000000; + let ini_path = util::profile_dir(&p).join("segatools.ini"); log::debug!("With path {}", ini_path.to_string_lossy()); log::info!("Launching amdaemon"); - let mut amd = Command::new("cmd.exe") - .env( + + let mut amd_builder = Command::new("cmd.exe"); + amd_builder.env( "SEGATOOLS_CONFIG_PATH", &ini_path, ) - .env("OPENSSL_ia32cap", ":~0x20000000") + .creation_flags(create_no_window) .current_dir(&p.exe_dir) .args(["/C", &util::path_to_str(p.exe_dir.join( "inject.exe"))?, "-d", "-k", "mu3hook.dll", "amdaemon.exe", "-f", "-c", "config_common.json", "config_server.json", "config_client.json"]) // Obviously this is a meme // Output will be handled properly at a later time .stdout(Stdio::null()) - .stderr(Stdio::null()) - .spawn()?; + .stderr(Stdio::null()); + + if let Some(v) = p.cfg.get("intel") { + if v == "true" { + amd_builder.env("OPENSSL_ia32cap", ":~0x20000000"); + } + } + + let mut amd = amd_builder.spawn()?; log::info!("Launching mu3"); let mut game = Command::new(p.exe_dir.join( "inject.exe")) @@ -60,6 +70,7 @@ pub fn start(p: &Profile) -> Result<()> { "SEGATOOLS_CONFIG_PATH", ini_path, ) + .creation_flags(create_no_window) .current_dir(&p.exe_dir) .args(["-d", "-k", "mu3hook.dll", "mu3.exe", "-monitor 1", "-screen-fullscreen", "0", "-popupwindow", "-screen-width", "1080", "-screen-height", "1920"]) .stdout(Stdio::null()) @@ -87,7 +98,7 @@ pub fn start(p: &Profile) -> Result<()> { log::debug!("Fin"); - app.emit("launch-end", ""); + _ = app.emit("launch-end", ""); }); Ok(()) diff --git a/rust/tauri.conf.json b/rust/tauri.conf.json index 88fe22d..be47d01 100644 --- a/rust/tauri.conf.json +++ b/rust/tauri.conf.json @@ -42,6 +42,6 @@ "bundle": { "active": true, "targets": "all", - "icon": ["icons/slow.png"] + "icon": ["icons/slow.png", "icons/slow.ico"] } } diff --git a/src/components/App.vue b/src/components/App.vue index 5db382c..6a41253 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -20,7 +20,7 @@ const store = usePkgStore(); store.setupListeners(); const currentTab = ref('3'); -const startEnabled = ref(true); +const startEnabled = ref(false); const loadProfile = async () => { await store.reloadProfile(); @@ -42,6 +42,7 @@ const loadProfile = async () => { } if (store.profile !== null) { changePrimaryColor(store.profile.game); + startEnabled.value = true; currentTab.value = '0'; } diff --git a/src/components/Options.vue b/src/components/Options.vue index e2d3477..eec837d 100644 --- a/src/components/Options.vue +++ b/src/components/Options.vue @@ -1,19 +1,25 @@ diff --git a/src/stores.ts b/src/stores.ts index 4d81c89..b6f5168 100644 --- a/src/stores.ts +++ b/src/stores.ts @@ -25,6 +25,7 @@ export const usePkgStore = defineStore('pkg', { profile: (state) => state.prf, isEnabled: (state) => (pkg: Package | undefined) => pkg !== undefined && state.prf?.mods.includes(pkgKey(pkg)), + cfg: (state) => (key: string) => state.prf?.cfg[key] }, actions: { setupListeners() { @@ -99,5 +100,11 @@ export const usePkgStore = defineStore('pkg', { await this.reloadProfile(); await this.saveProfile(); }, + + async set_cfg(key: string, value: string | boolean | number) { + await invoke('set_cfg', { key, value: `${value}` }); + await this.reloadProfile(); + await this.saveProfile(); + } }, -}); +}); \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 7f8fb09..2edbd0c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -23,6 +23,7 @@ export interface Profile { name: string; game: 'Ongeki' | 'Chunithm'; mods: string[]; + cfg: {[key: string]: string | boolean} } export type PackageC = Map;