Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NotThorny committed Jan 17, 2025
2 parents 3669bb3 + 03fed7a commit 14173e5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ fn main() -> Result<(), ArgsError> {
get_theme_list,
system_helpers::run_command,
system_helpers::run_program,
system_helpers::run_program_args,
system_helpers::run_program_relative,
system_helpers::start_service,
system_helpers::service_status,
Expand Down
12 changes: 12 additions & 0 deletions src-tauri/src/system_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ impl SpawnItsFineReally for Command {
}
}

#[tauri::command]
pub fn run_program_args(path: String, args: Option<String>) {
match open::with(
format!("{}", args.unwrap_or_else(|| "".into())),
path.clone(),
) {
Ok(_) => (),
Err(e) => println!("Failed to open program ({}): {}", &path, e),
};
return;
}

#[tauri::command]
pub fn run_program(path: String, args: Option<String>) {
// Without unwrap_or, this can crash when UAC prompt is denied
Expand Down
7 changes: 7 additions & 0 deletions src/ui/components/ServerLaunchSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
if (config.launch_args.length < 1) {
// Run relative when there are no args
await invoke('run_program_relative', { path: exe || config.game_install_path })
}
// Handle XXMI
else if (proc_name?.toLowerCase().includes('xxmi')) {
await invoke('run_program_args', {
path: exe,
args: config.launch_args,
})
} else {
// Run directly when there are args
await invoke('run_program', {
Expand Down
15 changes: 14 additions & 1 deletion src/ui/components/menu/ExtrasMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ export class ExtrasMenu extends React.Component<IProps, IState> {

// This injects independent of the game
if (this.state.launch_migoto) {
await this.launchMigoto()
if (await this.launchMigoto()) {
// Already launched the game (ie. via XXMI)
return
}
}

// This injects independent of the game
Expand Down Expand Up @@ -104,7 +107,17 @@ export class ExtrasMenu extends React.Component<IProps, IState> {

if (!config.migoto_path) return alert('Migoto not installed or set!')

if (config.migoto_path?.toLowerCase().includes('xxmi')) {
// Get game exe from game path, so we can watch it
const pathArr = config.migoto_path.replace(/\\/g, '/').split('/')
const gameExec = pathArr[pathArr.length - 1]

this.props.playGame(config.migoto_path, gameExec)
return true
}

await invoke('run_program_relative', { path: config.migoto_path })
return false
}

async launchReshade() {
Expand Down

0 comments on commit 14173e5

Please sign in to comment.