feat: rudimentary config

This commit is contained in:
2025-02-24 00:01:25 +00:00
parent 70b8b3ae55
commit b7fe76b6ff
11 changed files with 64 additions and 20 deletions

BIN
rust/icons/slow.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

View File

@ -5,7 +5,7 @@ use crate::pkg_store::PackageStore;
pub struct AppData {
pub profile: Option<Profile>,
pub pkgs: PackageStore,
pub pkgs: PackageStore
}
impl AppData {

View File

@ -134,3 +134,19 @@ pub async fn init_profile(
Ok(new_profile)
}
#[tauri::command]
pub async fn set_cfg(
state: State<'_, Mutex<AppData>>,
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(())
}

View File

@ -116,7 +116,8 @@ pub async fn run(_args: Vec<String>) {
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");

View File

@ -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<PkgKey>,
pub wine_runtime: Option<PathBuf>,
pub wine_prefix: Option<PathBuf>,
pub cfg: HashMap<String, String>
}
impl Profile {
@ -39,6 +39,7 @@ impl Profile {
),
#[cfg(target_os = "windows")]
wine_prefix: None,
cfg: HashMap::new()
}
}

View File

@ -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(())

View File

@ -42,6 +42,6 @@
"bundle": {
"active": true,
"targets": "all",
"icon": ["icons/slow.png"]
"icon": ["icons/slow.png", "icons/slow.ico"]
}
}