From 04448b393bf0bd72148b42ecc7bb70d20419ed42 Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Sun, 5 Jan 2025 23:44:41 +0100 Subject: [PATCH] Fix map vote index in lists --- game/client-ui/src/ingame_menu/call_vote/map.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/game/client-ui/src/ingame_menu/call_vote/map.rs b/game/client-ui/src/ingame_menu/call_vote/map.rs index b4d9f02..e664dd3 100644 --- a/game/client-ui/src/ingame_menu/call_vote/map.rs +++ b/game/client-ui/src/ingame_menu/call_vote/map.rs @@ -68,7 +68,7 @@ const MAP_VOTE_DIR_STORAGE_NAME: &str = "map-vote-sort-dir"; fn render_table( ui: &mut egui::Ui, - map_infos: &[&(MapVoteKey, MapVote)], + map_infos: &[(usize, &(MapVoteKey, MapVote))], index: usize, config: &mut Config, has_ddrace: bool, @@ -106,8 +106,8 @@ fn render_table( }) .body(|body| { body.rows(25.0, map_infos.len(), |mut row| { - row.set_selected(index == row.index()); - let (map, info) = &map_infos[row.index()]; + let (original_index, (map, info)) = &map_infos[row.index()]; + row.set_selected(index == *original_index); row.col(|ui| { ui.label(map.name.as_str()); }); @@ -168,7 +168,7 @@ fn render_table( .ui .path .query - .insert("vote-map-index".to_string(), row.index().to_string()); + .insert("vote-map-index".to_string(), original_index.to_string()); } }) }); @@ -588,7 +588,8 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe, ui_state: &m add_margins(ui, |ui| { let map_infos: Vec<_> = map_infos .iter() - .filter(|(key, _)| { + .enumerate() + .filter(|(_, (key, _))| { key.name .as_str() .to_lowercase()