diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index df79542..d1251e8 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -26,6 +26,17 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom 0.2.7", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.18" @@ -725,6 +736,7 @@ dependencies = [ "regex", "registry", "reqwest", + "rust-ini", "rustls-pemfile", "serde", "serde_json", @@ -888,6 +900,12 @@ dependencies = [ "syn", ] +[[package]] +name = "dlv-list" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" + [[package]] name = "dtoa" version = "0.4.8" @@ -1481,6 +1499,9 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] [[package]] name = "heck" @@ -2451,6 +2472,16 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "ordered-multimap" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" +dependencies = [ + "dlv-list", + "hashbrown", +] + [[package]] name = "os_info" version = "3.4.0" @@ -3223,6 +3254,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "rust-ini" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" +dependencies = [ + "cfg-if 1.0.0", + "ordered-multimap", +] + [[package]] name = "rustc-serialize" version = "0.3.24" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index c26dd33..f6fb564 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -61,6 +61,7 @@ regex = "1" # other file_diff = "1.0.0" +rust-ini = "0.18.0" [features] # by default Tauri runs in production mode diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index cf9dd1d..f591428 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -45,6 +45,7 @@ fn main() { system_helpers::open_in_browser, system_helpers::install_location, system_helpers::is_elevated, + system_helpers::set_migoto_target, proxy::set_proxy_addr, proxy::generate_ca_files, unzip::unzip, diff --git a/src-tauri/src/system_helpers.rs b/src-tauri/src/system_helpers.rs index ab070d2..b72ddaa 100644 --- a/src-tauri/src/system_helpers.rs +++ b/src-tauri/src/system_helpers.rs @@ -1,4 +1,6 @@ use duct::cmd; +use ini::Ini; +use std::path::PathBuf; #[tauri::command] pub fn run_program(path: String, args: Option) { @@ -88,6 +90,43 @@ pub fn install_location() -> String { return exe_path.to_str().unwrap().to_string(); } +#[tauri::command] +pub fn set_migoto_target(path: String, migoto_path: String) -> bool { + let pathbuf = PathBuf::from(path); + let mut migoto_pathbuf = PathBuf::from(migoto_path); + + migoto_pathbuf.pop(); + migoto_pathbuf.push("d3dx.ini"); + + let mut conf = match Ini::load_from_file(&migoto_pathbuf) { + Ok(c) => { + println!("Loaded migoto ini"); + c + } + Err(e) => { + println!("Error loading migoto config: {}", e); + return false; + } + }; + + // Set options + conf + .with_section(Some("Loader")) + .set("target", pathbuf.to_str().unwrap()); + + // Write file + match conf.write_to_file(&migoto_pathbuf) { + Ok(_) => { + println!("Wrote config!"); + true + } + Err(e) => { + println!("Error writing config: {}", e); + false + } + } +} + #[cfg(windows)] #[tauri::command] pub fn is_elevated() -> bool { diff --git a/src/ui/components/menu/Options.tsx b/src/ui/components/menu/Options.tsx index b06dbf1..df69bf8 100644 --- a/src/ui/components/menu/Options.tsx +++ b/src/ui/components/menu/Options.tsx @@ -151,6 +151,12 @@ export default class Options extends React.Component { this.setState({ migoto_path: value, }) + + // Set game exe in Migoto ini + invoke('set_migoto_target', { + path: this.state.game_install_path, + migotoPath: value, + }) } setReshade(value: string) {