) -> Option<(Game, String)> {
+ let regex = regex::Regex::new(
+ r"profile-([^\-]+)-([^\-]+)\.json"
+ ).expect("Invalid regex");
+
+ let fname = path.as_ref().file_name().unwrap_or_default().to_string_lossy();
+
+ if let Some(caps) = regex.captures(&fname) {
+ let game = caps.get(1).unwrap().as_str();
+ let name = caps.get(2).unwrap().as_str().to_owned();
+ if let Some(game) = Game::from_str(game) {
+ return Some((game, name));
+ }
+ }
+
+ None
+ }
}
diff --git a/rust/src/start.rs b/rust/src/start.rs
index b5afb27..7160cde 100644
--- a/rust/src/start.rs
+++ b/rust/src/start.rs
@@ -1,5 +1,6 @@
use anyhow::Result;
use std::fs::File;
+use std::path::PathBuf;
use tokio::process::Command;
use tauri::{AppHandle, Emitter};
use std::process::Stdio;
@@ -26,13 +27,13 @@ pub fn start(p: &Profile, app: AppHandle) -> Result<()> {
}
#[cfg(target_os = "linux")]
{
- let wine = p.wine_runtime.as_ref()
- .expect("No wine path specified");
+ let wine = p.data.wine_runtime.clone()
+ .unwrap_or_else(|| PathBuf::from("/usr/bin/wine"));
- game_builder = Command::new(wine);
- amd_builder = Command::new(wine);
+ game_builder = Command::new(&wine);
+ amd_builder = Command::new(&wine);
- game_builder.arg(p.exe_dir.join("inject.exe"));
+ game_builder.arg(p.data.exe_dir.join("inject.exe"));
amd_builder.arg("cmd.exe");
}
@@ -42,10 +43,10 @@ pub fn start(p: &Profile, app: AppHandle) -> Result<()> {
"SEGATOOLS_CONFIG_PATH",
&ini_path,
)
- .current_dir(&p.exe_dir)
+ .current_dir(&p.data.exe_dir)
.args([
"/C",
- &util::path_to_str(p.exe_dir.join("inject.exe"))?, "-d", "-k", "mu3hook.dll",
+ &util::path_to_str(p.data.exe_dir.join("inject.exe"))?, "-d", "-k", "mu3hook.dll",
"amdaemon.exe", "-f", "-c", "config_common.json", "config_server.json", "config_client.json"
]);
game_builder
@@ -53,7 +54,7 @@ pub fn start(p: &Profile, app: AppHandle) -> Result<()> {
"SEGATOOLS_CONFIG_PATH",
ini_path,
)
- .current_dir(&p.exe_dir)
+ .current_dir(&p.data.exe_dir)
.args([
"-d", "-k", "mu3hook.dll",
"mu3.exe", "-monitor 1",
@@ -68,10 +69,14 @@ pub fn start(p: &Profile, app: AppHandle) -> Result<()> {
#[cfg(target_os = "linux")]
{
- let wineprefix = p.wine_prefix.as_ref()
- .expect("No wineprefix specified");
- amd_builder.env("WINEPREFIX", wineprefix);
- game_builder.env("WINEPREFIX", wineprefix);
+ let wineprefix = p.data.wine_prefix.clone().unwrap_or_else(||
+ directories::UserDirs::new()
+ .expect("No home directory")
+ .home_dir()
+ .join(".wine")
+ );
+ amd_builder.env("WINEPREFIX", &wineprefix);
+ game_builder.env("WINEPREFIX", &wineprefix);
}
diff --git a/src/components/App.vue b/src/components/App.vue
index f1e0143..10fe93c 100644
--- a/src/components/App.vue
+++ b/src/components/App.vue
@@ -7,53 +7,31 @@ import TabPanel from 'primevue/tabpanel';
import TabPanels from 'primevue/tabpanels';
import Tabs from 'primevue/tabs';
import { onOpenUrl } from '@tauri-apps/plugin-deep-link';
-import { open } from '@tauri-apps/plugin-dialog';
import ModList from './ModList.vue';
import ModStore from './ModStore.vue';
import Options from './Options.vue';
+import ProfileList from './ProfileList.vue';
import StartButton from './StartButton.vue';
-import { usePkgStore } from '../stores';
-import { changePrimaryColor } from '../util';
+import { usePkgStore, usePrfStore } from '../stores';
-const store = usePkgStore();
-store.setupListeners();
+const pkg = usePkgStore();
+const prf = usePrfStore();
+
+pkg.setupListeners();
+prf.setupListeners();
const currentTab = ref('3');
-const loadProfile = async (openWindow: boolean) => {
- await store.reloadProfile();
-
- if (store.profile === null && openWindow) {
- const exePath = await open({
- multiple: false,
- directory: false,
- filters: [
- {
- name: 'mu3.exe' /* or chusanApp.exe'*/,
- extensions: ['exe'],
- },
- ],
- });
- if (exePath !== null) {
- await store.initProfile(exePath);
- }
- }
- if (store.profile !== null) {
- changePrimaryColor(store.profile.game);
- currentTab.value = '0';
- }
-
- await store.reloadAll();
-};
-
-const isProfileDisabled = computed(() => store.profile === null);
-
-onOpenUrl((urls) => {
- console.log('deep link:', urls);
-});
+const isProfileDisabled = computed(() => prf.current === null);
onMounted(async () => {
- await loadProfile(false);
+ await prf.reloadList();
+ await prf.reload();
+
+ if (prf.current !== null) {
+ await pkg.reloadAll();
+ currentTab.value = '0';
+ }
});
@@ -93,14 +71,10 @@ onMounted(async () => {
missing.
Existing features are expected to break any
time.
-
Select mu3.exe
to create a
- profile:
-
+
Select mu3.exe
to create a profile:
+
+
+
+