Order game options by key

This commit is contained in:
Sofia 2026-08-03 21:45:39 +03:00
parent d0b3586f6b
commit 1a2376931b
2 changed files with 8 additions and 4 deletions

View File

@ -97,7 +97,7 @@ impl GameOptions {
}
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Hash, Copy, Clone, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, PartialOrd, Hash, Copy, Clone, Serialize, Deserialize, Ord)]
pub enum GameOption {
/// Allow anyone to select a map, not just the host
AllowAnyMap,
@ -107,12 +107,12 @@ pub enum GameOption {
FriendlyFire,
/// The number of goals needed to win a match
GoalsNeededToWin,
/// Whether telegrenades are allowed or not.
TelegrenadesAllowed,
/// How long in seconds does it take for a player to respawn
RespawnTimer,
/// How long in seconds is spawn protected
SpawnProtection,
/// Whether telegrenades are allowed or not.
TelegrenadesAllowed,
/// Whether pickups are allowed
PickupsAllowed,
}

View File

@ -464,7 +464,11 @@ impl LobbyPanel {
team: Option<u8>,
) -> Vec<Gd<Control>> {
let mut nodes = Vec::new();
for (option, value) in opts {
let mut keys = opts.keys().collect::<Vec<_>>();
keys.sort();
for option in keys {
let value = opts.get(option).unwrap();
let mut label = Label::new_alloc();
label.set_text(&format!("{}:", option.to_string()));
nodes.push(label.upcast());