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"]
}
}

View File

@ -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';
}

View File

@ -1,19 +1,25 @@
<script setup lang="ts">
import { usePkgStore } from '../stores';
import Fieldset from 'primevue/fieldset';
import Toggle from 'primevue/toggleswitch';
const store = usePkgStore();
const setValue = async (value: boolean) => {
await store.set_cfg('intel', value);
}
</script>
<template>
<Fieldset>
<div class="flex w-full flex-col">
<label for="switch" class="flex flex-row w-full p-2">
<div class="grow">Aime emulation</div>
<Toggle disabled inputId="switch" />
<div class="grow">OpenSSL crash workaround for Intel 10th gen</div>
<Toggle
inputId="switch"
:modelValue="store.cfg('intel') === 'true'"
v-on:value-change="setValue" />
</label>
<div class="flex flex-row w-full p-2">
<div class="grow">Enable console</div>
<Toggle disabled />
</div>
</div>
</Fieldset>
</template>

View File

@ -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();
}
},
});
});

View File

@ -23,6 +23,7 @@ export interface Profile {
name: string;
game: 'Ongeki' | 'Chunithm';
mods: string[];
cfg: {[key: string]: string | boolean}
}
export type PackageC = Map<string, Package>;