diff --git a/godot/maps/diner/diner.lmbake b/godot/maps/diner/diner.lmbake index d554928..e76c996 100644 Binary files a/godot/maps/diner/diner.lmbake and b/godot/maps/diner/diner.lmbake differ diff --git a/godot/scenes/lobby.tscn b/godot/scenes/lobby.tscn index e8e2156..3401d64 100644 --- a/godot/scenes/lobby.tscn +++ b/godot/scenes/lobby.tscn @@ -37,6 +37,8 @@ offset_bottom = 200.0 [node name="h_box_container" type="HBoxContainer" parent="v_box_container" unique_id=1789302658] layout_mode = 2 +offset_transform_enabled = true +offset_transform_position = Vector2(100, 0) metadata/_edit_lock_ = true [node name="label" type="Label" parent="v_box_container/h_box_container" unique_id=626633696] diff --git a/godot/scenes/ui/player_listing.tscn b/godot/scenes/ui/player_listing.tscn index 5180c98..d3f9b7a 100644 --- a/godot/scenes/ui/player_listing.tscn +++ b/godot/scenes/ui/player_listing.tscn @@ -10,11 +10,14 @@ offset_bottom = 23.0 columns = 4 [node name="option_button" type="OptionButton" parent="." unique_id=199328927] +custom_minimum_size = Vector2(150, 0) +custom_maximum_size = Vector2(150, -1) +clip_contents = true layout_mode = 2 [node name="name" type="Label" parent="." unique_id=635700663] -custom_minimum_size = Vector2(400, 0) -custom_maximum_size = Vector2(400, -1) +custom_minimum_size = Vector2(350, 0) +custom_maximum_size = Vector2(350, -1) layout_mode = 2 text = "Name" clip_text = true diff --git a/rust/src/game_manager.rs b/rust/src/game_manager.rs index 845e070..d9d9852 100644 --- a/rust/src/game_manager.rs +++ b/rust/src/game_manager.rs @@ -254,6 +254,10 @@ impl Game { } } + pub fn get_team(&self, team: u8) -> Option> { + self.get_teams().get(team as usize) + } + pub fn try_set_player_team(&mut self, player_id: u16, team: u8, emit: bool) { if let Some(player) = self.find_player_mut(player_id) { player.data.team = team; diff --git a/rust/src/ui/player_listing.rs b/rust/src/ui/player_listing.rs index 86321b2..09f1331 100644 --- a/rust/src/ui/player_listing.rs +++ b/rust/src/ui/player_listing.rs @@ -1,5 +1,5 @@ use godot::{ - classes::{GridContainer, IGridContainer, Label, OptionButton}, + classes::{GridContainer, IGridContainer, Label, OptionButton, TextEdit}, prelude::*, }; @@ -47,13 +47,7 @@ impl IGridContainer for PlayerListing { .signals() .item_selected() .connect_other(self, |s, selection| { - if let Some(mut game) = Game::singleton() { - game.bind_mut().try_set_player_team( - s.player_id.unwrap_or(0), - selection as u8, - false, - ); - } + s.on_team_selection_changed(selection as u8); }); } @@ -82,6 +76,10 @@ impl PlayerListing { "{} ({})", player.data.name, player.connection_addr )); + + if let Some(team) = game.bind().get_team(player.data.team) { + player_label.add_theme_color_override("font_color", team.bind().color); + } } if let Some(ready_label) = &mut self.ready_label { @@ -113,9 +111,33 @@ impl PlayerListing { } } + pub fn on_team_selection_changed(&mut self, team: u8) { + if let Some(mut game) = Game::singleton() { + game.bind_mut() + .try_set_player_team(self.player_id.unwrap_or(0), team, false); + + if let Some(player) = game.bind().find_player(self.player_id.unwrap_or(0)) + && let Some(player_label) = &mut self.name_label + && let Some(team) = game.bind().get_team(player.data.team) + { + godot_print!("Setting color"); + player_label.add_theme_color_override("font_color", team.bind().color); + } + } + } + fn on_team_update(&mut self, team: u8) { if let Some(dropdown) = &mut self.team_dropdown { dropdown.select(team as i32); } + + if let Some(game) = Game::singleton() + && let Some(player) = game.bind().find_player(self.player_id.unwrap_or(0)) + && let Some(player_label) = &mut self.name_label + && let Some(team) = game.bind().get_team(player.data.team) + { + godot_print!("Setting color"); + player_label.add_theme_color_override("font_color", team.bind().color); + } } }