diff --git a/assets/locales/en/errors.ftl b/assets/locales/en/errors.ftl index 68634ab..3b1da58 100644 --- a/assets/locales/en/errors.ftl +++ b/assets/locales/en/errors.ftl @@ -1,6 +1,7 @@ launcher-folder-opening-error = Failed to open launcher folder game-folder-opening-error = Failed to open game folder config-file-opening-error = Failed to open config file +debug-file-opening-error = Failed to open debug file game-launching-failed = Failed to launch game diff --git a/assets/locales/en/main.ftl b/assets/locales/en/main.ftl index e72a898..dfa714e 100644 --- a/assets/locales/en/main.ftl +++ b/assets/locales/en/main.ftl @@ -20,6 +20,11 @@ unpacking = Unpacking launch = Launch +apply-patch = Apply patch +download-wine = Download wine +create-prefix = Create prefix +update = Update +download = Download preferences = Preferences diff --git a/assets/locales/ru/errors.ftl b/assets/locales/ru/errors.ftl index 92a5d79..25ad6ea 100644 --- a/assets/locales/ru/errors.ftl +++ b/assets/locales/ru/errors.ftl @@ -1,6 +1,7 @@ launcher-folder-opening-error = Не удалось открыть папку лаунчера game-folder-opening-error = Не удалось открыть папку игры config-file-opening-error = Не удалось открыть файл настроек +debug-file-opening-error = Не удалось открыть файл отладки game-launching-failed = Не удалось запустить игру diff --git a/src/ui/main.rs b/src/ui/main.rs index ea686f5..518b5a8 100644 --- a/src/ui/main.rs +++ b/src/ui/main.rs @@ -24,6 +24,7 @@ relm4::new_action_group!(WindowActionGroup, "win"); relm4::new_stateless_action!(LauncherFolder, WindowActionGroup, "launcher_folder"); relm4::new_stateless_action!(GameFolder, WindowActionGroup, "game_folder"); relm4::new_stateless_action!(ConfigFile, WindowActionGroup, "config_file"); +relm4::new_stateless_action!(DebugFile, WindowActionGroup, "debug_file"); relm4::new_stateless_action!(About, WindowActionGroup, "about"); @@ -76,6 +77,7 @@ impl SimpleComponent for App { "Launcher folder" => LauncherFolder, "Game folder" => GameFolder, "Config file" => ConfigFile, + "Debug file" => DebugFile, }, section! { @@ -209,8 +211,36 @@ impl SimpleComponent for App { set_margin_top: 64, set_spacing: 8, + // TODO: add tooltips + gtk::Button { - set_label: &tr("launch"), + #[watch] + set_label: &match model.state { + Some(LauncherState::Launch) => tr("launch"), + Some(LauncherState::PredownloadAvailable { .. }) => tr("launch"), + Some(LauncherState::PatchAvailable(_)) => tr("apply-patch"), + Some(LauncherState::WineNotInstalled) => tr("download-wine"), + Some(LauncherState::PrefixNotExists) => tr("create-prefix"), + Some(LauncherState::VoiceUpdateAvailable(_)) => tr("update"), + Some(LauncherState::VoiceOutdated(_)) => tr("update"), + Some(LauncherState::VoiceNotInstalled(_)) => tr("download"), + Some(LauncherState::GameUpdateAvailable(_)) => tr("update"), + Some(LauncherState::GameOutdated(_)) => tr("update"), + Some(LauncherState::GameNotInstalled(_)) => tr("download"), + + None => String::from("...") + }, + + #[watch] + set_sensitive: match model.state { + Some(LauncherState::GameOutdated { .. }) => false, + Some(LauncherState::VoiceOutdated(_)) => false, + + Some(_) => true, + + None => false + }, + set_hexpand: false, set_width_request: 200, add_css_class: "suggested-action", @@ -316,6 +346,17 @@ impl SimpleComponent for App { } }))); + group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { + if let Err(err) = std::process::Command::new("xdg-open").arg(DEBUG_FILE.as_os_str()).spawn() { + sender.input(AppMsg::Toast { + title: tr("debug-file-opening-error"), + description: Some(err.to_string()) + }); + + tracing::error!("Failed to open debug file: {err}"); + } + }))); + group.add_action::(&RelmAction::new_stateless(move |_| { about_dialog_broker.send(AboutDialogMsg::Show); }));