feat: replaced "auto-close" option by "launcher behavior"

New option will allow to keep launcher window open as well
This commit is contained in:
Observer KRypt0n_ 2023-07-31 19:41:36 +02:00
parent efc7229717
commit d04bb3e5e0
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
26 changed files with 106 additions and 42 deletions

4
Cargo.lock generated
View file

@ -87,8 +87,8 @@ dependencies = [
[[package]]
name = "anime-launcher-sdk"
version = "1.8.11"
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.8.11#4b2e02c10e7d3bc7f240b8fb7cd881d6b489b49f"
version = "1.8.12"
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.8.12#e9814f33dd1e1bd3648b6d6fc761e62b39b8736c"
dependencies = [
"anime-game-core",
"anyhow",

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 = "1.8.11"
tag = "1.8.12"
features = ["all", "genshin", "genshin-patch"]
# path = "../anime-launcher-sdk" # ! for dev purposes only

View file

@ -58,8 +58,8 @@ disable-mhypbase-description = Experimentell. Wenn sie diese option aktivieren,
ask-superuser-permissions = Superuser-Berechtigungen anfordern
ask-superuser-permissions-description = Launcher benötigt Superuser-Zugriff, um Ihre Hosts-Datei automatisch zu aktualisieren. Dies ist in der Flatpak-Edition nicht erforderlich
auto-close-launcher = Auto-close launcher
auto-close-launcher-description = Close the launcher after the game is closed
launcher-behavior = Launcher behavior
launcher-behavior-description = What should launcher window do when it starts the game
wine-tools = Wine-Tools
command-line = Befehlszeile

View file

@ -18,6 +18,8 @@ about = Über
close = Schließen
hide = Hide
nothing = Nothing
save = Speichern
continue = Weiter
resume = Fortsetzen

View file

@ -58,8 +58,8 @@ disable-mhypbase-description = Experimental. If enabled, launcher will disable m
ask-superuser-permissions = Ask superuser permissions
ask-superuser-permissions-description = Launcher will use them to automatically update your hosts file. This is not needed in flatpak edition
auto-close-launcher = Auto-close launcher
auto-close-launcher-description = Close the launcher after the game is closed
launcher-behavior = Launcher behavior
launcher-behavior-description = What should launcher window do when it starts the game
wine-tools = Wine tools
command-line = Command line

View file

@ -18,6 +18,8 @@ about = About
close = Close
hide = Hide
nothing = Nothing
save = Save
continue = Continue
resume = Resume

View file

@ -58,8 +58,8 @@ disable-mhypbase-description = Experimental. Si se activa, el launcher desactiva
ask-superuser-permissions = Pedir permisos de superusuario
ask-superuser-permissions-description = El launcher usará los permisos para actualizar automáticamente tu archivo hosts. Esto no es necesario en la versión de Flatpak
auto-close-launcher = Auto-close launcher
auto-close-launcher-description = Close the launcher after the game is closed
launcher-behavior = Launcher behavior
launcher-behavior-description = What should launcher window do when it starts the game
wine-tools = Herramientas de Wine
command-line = Línea de Comandos

View file

@ -18,6 +18,8 @@ about = Acerca de
close = Cerrar
hide = Hide
nothing = Nothing
save = Guardar
continue = Continuar
resume = Reanudar

View file

@ -58,8 +58,8 @@ disable-mhypbase-description = Experimental. If enabled, launcher will disable m
ask-superuser-permissions = Ask superuser permissions
ask-superuser-permissions-description = Launcher will use them to automatically update your hosts file. This is not needed in flatpak edition
auto-close-launcher = Auto-close launcher
auto-close-launcher-description = Close the launcher after the game is closed
launcher-behavior = Launcher behavior
launcher-behavior-description = What should launcher window do when it starts the game
wine-tools = Wine tools
command-line = Command line

View file

@ -18,6 +18,8 @@ about = À propos
close = Fermer
hide = Hide
nothing = Nothing
save = Sauvegarder
continue = Continuer
resume = Reprendre

View file

@ -58,8 +58,8 @@ disable-mhypbase-description = Tesztelés alatt. Ha bekapcsolod, kikapcsolja a m
ask-superuser-permissions = Superuser engedély kérése
ask-superuser-permissions-description = A Launcher autómatikusan használni fogja hogy frissítse a hosts fájlodat. A Flatpak verzióhoz nem kell
auto-close-launcher = Auto-close launcher
auto-close-launcher-description = Close the launcher after the game is closed
launcher-behavior = Launcher behavior
launcher-behavior-description = What should launcher window do when it starts the game
wine-tools = Wine eszközök
command-line = Parancssor

View file

@ -18,6 +18,8 @@ about = Részletek
close = Bezárás
hide = Hide
nothing = Nothing
save = Mentés
continue = Folytatás
resume = Resume

View file

@ -58,8 +58,8 @@ disable-mhypbase-description = Masih dalam pengujicobaan. Jika diaktifkan, launc
ask-superuser-permissions = Minta izin dari admin
ask-superuser-permissions-description = Launcher akan otomatis memperbarui file hosts Anda. Opsi ini tidak diperlukan jika Anda memakai edisi flatpak
auto-close-launcher = Auto-close launcher
auto-close-launcher-description = Close the launcher after the game is closed
launcher-behavior = Launcher behavior
launcher-behavior-description = What should launcher window do when it starts the game
wine-tools = Peralatan wine
command-line = Command line

View file

@ -18,6 +18,8 @@ about = Tentang
close = Tutup
hide = Hide
nothing = Nothing
save = Simpan
continue = Lanjutkan
resume = Lanjutkan

View file

@ -58,8 +58,8 @@ disable-mhypbase-description = Sperimentale. Se abiliata, il launcher disabilite
ask-superuser-permissions = Chiedi permessi di amministratore
ask-superuser-permissions-description = Il launcher li userà per aggiornare automaticamente il tuo file hosts. Questo non è necessario nell'edizione flatpak
auto-close-launcher = Chiusura automatica del launcher
auto-close-launcher-description = Chiudi il launcher dopo che il gioco è stato chiuso
launcher-behavior = Launcher behavior
launcher-behavior-description = What should launcher window do when it starts the game
wine-tools = Strumenti di Wine
command-line = Linea di comando

View file

@ -18,6 +18,8 @@ about = Informazioni
close = Chiudi
hide = Hide
nothing = Nothing
save = Salva
continue = Continua
resume = Riprendi

View file

@ -58,8 +58,8 @@ disable-mhypbase-description = 試験的です。有効にすると、ランチ
ask-superuser-permissions = スーパーユーザーを尋ねる。
ask-superuser-permissions-description = あなたのホストのファイルを自動更新するために、 これらを利用します。flatpak版では必要ありません。
auto-close-launcher = ランチャーを自動で閉じる
auto-close-launcher-description = ゲーム終了後にランチャーも閉じるようにする
launcher-behavior = Launcher behavior
launcher-behavior-description = What should launcher window do when it starts the game
wine-tools = ワインツール
command-line = コマンドライン

View file

@ -18,6 +18,8 @@ about = "An anime Game launcher"について
close = 閉じる
hide = Hide
nothing = Nothing
save = 保存
continue = 続行
resume = 一時停止

View file

@ -58,8 +58,8 @@ disable-mhypbase-description = Экспериментально. Когда вк
ask-superuser-permissions = Запрашивать права суперпользователя
ask-superuser-permissions-description = Лаунчер будет использовать их чтобы автоматически обновлять ваш hosts файл для отключения телеметрии игры. Не требуется при использовании flatpak
auto-close-launcher = Автоматически закрывать лаунчер
auto-close-launcher-description = Закрывать лаунчер после выхода из игры
launcher-behavior = Поведение лаунчера
launcher-behavior-description = Что должно делать окно лаунчера когда оно запускает игру
wine-tools = Инструменты Wine
command-line = Коммандная строка

View file

@ -17,7 +17,17 @@ wish-url = История молитв
about = О программе
close = Закрыть
close = { $form ->
[verb] Закрываться
*[noun] Закрыть
}
hide = { $form ->
[verb] Скрываться
*[noun] Скрыть
}
nothing = Ничего
save = Сохранить
continue = Продолжить
resume = Возобновить

View file

@ -58,8 +58,8 @@ disable-mhypbase-description = Deneysel. Etkinleştirilirse, istemci ana yamayı
ask-superuser-permissions = Yönetici izinlerini sor
ask-superuser-permissions-description = İstemci yönetici iznini hostunuzun dosyalarını güncellemek için otomatik olarak kullanacaktır. Buna flatpak versiyonunda gerek yoktur
auto-close-launcher = Auto-close launcher
auto-close-launcher-description = Close the launcher after the game is closed
launcher-behavior = Launcher behavior
launcher-behavior-description = What should launcher window do when it starts the game
wine-tools = Wine araçları
command-line = Komut istemi

View file

@ -18,6 +18,8 @@ about = Hakkında
close = Kapat
hide = Hide
nothing = Nothing
save = Kaydet
continue = Devam et
resume = Sürdürmek

View file

@ -58,8 +58,8 @@ disable-mhypbase-description = 实验性功能。启用此选项后,启动器
ask-superuser-permissions = 请求超级用户权限
ask-superuser-permissions-description = 启动器需要超级用户权限来修改 hosts 文件。Flatpak 版无需此权限
auto-close-launcher = Auto-close launcher
auto-close-launcher-description = Close the launcher after the game is closed
launcher-behavior = Launcher behavior
launcher-behavior-description = What should launcher window do when it starts the game
wine-tools = Wine 工具
command-line = 命令行

View file

@ -18,6 +18,8 @@ about = 关于
close = 关闭
hide = Hide
nothing = Nothing
save = 保存
continue = 继续
resume = 恢复

View file

@ -1,11 +1,23 @@
use relm4::prelude::*;
use gtk::prelude::*;
use anime_launcher_sdk::genshin::config::schema::prelude::LauncherBehavior;
use crate::*;
use crate::i18n::*;
use super::{App, AppMsg};
pub fn launch(sender: ComponentSender<App>) {
sender.input(AppMsg::HideWindow);
let config = Config::get().unwrap();
match config.launcher.behavior {
// Disable launch button if behavior set to "Nothing" to prevent sussy actions
LauncherBehavior::Nothing => sender.input(AppMsg::DisableButtons(true)),
// Hide launcher window if behavior set to "Hide" or "Close"
LauncherBehavior::Hide | LauncherBehavior::Close => sender.input(AppMsg::HideWindow)
}
std::thread::spawn(move || {
if let Err(err) = anime_launcher_sdk::genshin::game::run() {
@ -17,6 +29,18 @@ pub fn launch(sender: ComponentSender<App>) {
});
}
sender.input(AppMsg::ShowWindow);
match config.launcher.behavior {
// Enable launch button if behavior set to "Nothing" after the game has closed
LauncherBehavior::Nothing => sender.input(AppMsg::DisableButtons(false)),
// Show back launcher window if behavior set to "Hide" and the game has closed
LauncherBehavior::Hide => sender.input(AppMsg::ShowWindow),
// Otherwise close the launcher if behavior set to "Close" and the game has closed
// We're calling quit method from the main context here because otherwise app won't be closed properly
LauncherBehavior::Close => gtk::glib::MainContext::default().invoke(|| {
relm4::main_application().quit();
})
}
});
}

View file

@ -13,7 +13,7 @@ use anime_launcher_sdk::wincompatlib::prelude::*;
use anime_launcher_sdk::config::ConfigExt;
use anime_launcher_sdk::genshin::config::Config;
use anime_launcher_sdk::genshin::config::schema::launcher::LauncherStyle;
use anime_launcher_sdk::genshin::config::schema::prelude::*;
use anime_launcher_sdk::anime_game_core::genshin::consts::GameEdition;
use anime_launcher_sdk::genshin::env_emulation::Environment;
@ -576,26 +576,36 @@ impl SimpleAsyncComponent for GeneralApp {
add = &adw::PreferencesGroup {
set_title: &tr("options"),
adw::ActionRow {
set_title: &tr("auto-close-launcher"),
set_subtitle: &tr("auto-close-launcher-description"),
adw::ComboRow {
set_title: &tr("launcher-behavior"),
set_subtitle: &tr("launcher-behavior-description"),
add_suffix = &gtk::Switch {
set_valign: gtk::Align::Center,
set_model: Some(&gtk::StringList::new(&[
&tr("nothing"),
&tr_args("hide", [("form", "verb".into())]),
&tr_args("close", [("form", "verb".into())]),
])),
set_state: CONFIG.launcher.auto_close,
set_selected: match CONFIG.launcher.behavior {
LauncherBehavior::Nothing => 0,
LauncherBehavior::Hide => 1,
LauncherBehavior::Close => 2
},
connect_state_notify => |switch| {
connect_selected_notify => |row| {
if is_ready() {
if let Ok(mut config) = Config::get() {
config.launcher.auto_close = switch.state();
config.launcher.behavior = [
LauncherBehavior::Nothing,
LauncherBehavior::Hide,
LauncherBehavior::Close
][row.selected() as usize];
Config::update(config);
}
}
}
}
}
},
add = &adw::PreferencesGroup {