feat: added wine tools to settings

This commit is contained in:
Observer KRypt0n_ 2023-04-09 17:58:23 +02:00
parent 567df16610
commit f777963548
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
4 changed files with 83 additions and 7 deletions

8
Cargo.lock generated
View file

@ -86,8 +86,8 @@ dependencies = [
[[package]]
name = "anime-launcher-sdk"
version = "0.5.13"
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.13#66a80e5f5906b1cfc1b9716a4448dd03cf854ae8"
version = "0.5.14"
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.14#98de4c7d707ed7428257953526625e8f168f7d84"
dependencies = [
"anime-game-core",
"anyhow",
@ -1718,9 +1718,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "open"
version = "4.0.0"
version = "4.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd61e3bf9d78956c72ee864bba52431f7f43994b21a17e9e72596a81bd61075b"
checksum = "075c5203b3a2b698bc72c6c10b1f6263182135751d5013ea66e8a4b3d0562a43"
dependencies = [
"pathdiff",
]

View file

@ -17,7 +17,7 @@ glib-build-tools = "0.17"
[dependencies.anime-launcher-sdk]
git = "https://github.com/an-anime-team/anime-launcher-sdk"
tag = "0.5.13"
tag = "0.5.14"
# path = "../anime-launcher-sdk" # ! for dev purposes only
@ -25,8 +25,9 @@ tag = "0.5.13"
relm4 = { version = "0.6.0-alpha.2", features = ["macros", "libadwaita"] }
gtk = { package = "gtk4", version = "0.6", features = ["v4_8"] }
adw = { package = "libadwaita", version = "0.3", features = ["v1_2"] }
rfd = { version = "0.11", features = ["xdg-portal"], default-features = false }
open = "4.0.0"
open = "4.0"
tracing = "0.1"
tracing-subscriber = "0.3"

View file

@ -6,6 +6,8 @@ debug-file-opening-error = Failed to open debug file
wish-url-search-failed = No wishes url found
wish-url-opening-error = Could not open wishes url
wine-run-error = Failed to run {$executable} executable using wine
game-launching-failed = Failed to launch game
failed-get-selected-wine = Failed to get selected wine version
downloading-failed = Downloading failed

View file

@ -152,6 +152,7 @@ pub enum GeneralAppMsg {
OpenMigrateInstallation,
RepairGame,
WineOpen(&'static [&'static str]),
UpdateLauncherStyle(LauncherStyle),
@ -696,6 +697,57 @@ impl SimpleAsyncComponent for GeneralApp {
add = model.wine_components.widget(),
},
add = &adw::PreferencesGroup {
adw::ExpanderRow {
set_title: "Wine tools",
add_row = &adw::ActionRow {
set_title: "Command line",
set_subtitle: "start cmd",
set_activatable: true,
connect_activated => GeneralAppMsg::WineOpen(&["start", "cmd"])
},
add_row = &adw::ActionRow {
set_title: "Registry editor",
set_subtitle: "regedit",
set_activatable: true,
connect_activated => GeneralAppMsg::WineOpen(&["regedit"])
},
add_row = &adw::ActionRow {
set_title: "Explorer",
set_subtitle: "explorer",
set_activatable: true,
connect_activated => GeneralAppMsg::WineOpen(&["explorer"])
},
add_row = &adw::ActionRow {
set_title: "Task manager",
set_subtitle: "taskmgr",
set_activatable: true,
connect_activated => GeneralAppMsg::WineOpen(&["taskmgr"])
},
add_row = &adw::ActionRow {
set_title: "Configuration",
set_subtitle: "winecfg",
set_activatable: true,
connect_activated => GeneralAppMsg::WineOpen(&["winecfg"])
}
}
},
add = &adw::PreferencesGroup {
set_title: &tr("dxvk-version"),
@ -968,6 +1020,27 @@ impl SimpleAsyncComponent for GeneralApp {
sender.output(Self::Output::RepairGame);
}
GeneralAppMsg::WineOpen(executable) => {
let config = config::get().unwrap_or_else(|_| CONFIG.clone());
if let Ok(Some(wine)) = config.get_selected_wine() {
let result = wine.to_wine(config.components.path, Some(config.game.wine.builds.join(&wine.name)))
.with_prefix(config.game.wine.prefix)
.run_args(executable);
if let Err(err) = result {
sender.input(GeneralAppMsg::Toast {
title: tr_args("wine-run-error", [
("executable", executable.join(" ").into())
]),
description: Some(err.to_string())
});
tracing::error!("Failed to run {:?} using wine: {err}", executable);
}
}
}
#[allow(unused_must_use)]
GeneralAppMsg::UpdateLauncherStyle(style) => {
if style == LauncherStyle::Classic && !KEEP_BACKGROUND_FILE.exists() {