From e09efc6ed3b17512873f9dc3ee8fde1b13bea090 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Thu, 3 Aug 2023 18:58:36 +0200 Subject: [PATCH] refactor: rewrote game edition selector --- src/ui/preferences/general/mod.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/ui/preferences/general/mod.rs b/src/ui/preferences/general/mod.rs index 00dac0f..63617a5 100644 --- a/src/ui/preferences/general/mod.rs +++ b/src/ui/preferences/general/mod.rs @@ -291,21 +291,15 @@ impl SimpleAsyncComponent for GeneralApp { &tr!("china") ])), - set_selected: match CONFIG.launcher.edition { - GameEdition::Global => 0, - GameEdition::China => 1 - }, + set_selected: GameEdition::list().iter() + .position(|edition| edition == &CONFIG.launcher.edition) + .unwrap() as u32, 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!() - }; + config.launcher.edition = GameEdition::list()[row.selected() as usize]; Config::update(config);