feat(ui): added game edition switcher

This commit is contained in:
Observer KRypt0n_ 2023-04-23 10:15:33 +02:00
parent 6c442bd947
commit d14a31aa0c
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2

View file

@ -5,6 +5,7 @@ use gtk::prelude::*;
use adw::prelude::*;
use anime_launcher_sdk::anime_game_core::prelude::*;
use anime_launcher_sdk::anime_game_core::star_rail::consts::GameEdition;
use anime_launcher_sdk::wincompatlib::prelude::*;
@ -207,6 +208,41 @@ impl SimpleAsyncComponent for GeneralApp {
}
},
adw::ComboRow {
set_title: &tr("game-edition"),
set_model: Some(&gtk::StringList::new(&[
&tr("global"),
&tr("china")
])),
set_selected: match CONFIG.launcher.edition {
GameEdition::Global => 0,
GameEdition::China => 1
},
connect_selected_notify[sender] => move |row| {
if is_ready() {
#[allow(unused_must_use)]
if let Ok(mut config) = Config::get() {
config.launcher.edition = match row.selected() {
0 => GameEdition::Global,
1 => GameEdition::China,
_ => unreachable!()
};
// Select new game edition
config.launcher.edition.select();
Config::update(config);
sender.output(PreferencesAppMsg::UpdateLauncherState);
}
}
}
},
gtk::Box {
set_orientation: gtk::Orientation::Horizontal,
set_spacing: 8,