Fix team selection, maintain team after map change

This commit is contained in:
Sofia 2026-07-22 00:03:03 +03:00
parent 17b5272a9e
commit 609a803104
3 changed files with 7 additions and 1 deletions

View File

@ -1,7 +1,10 @@
[gd_resource type="MapResource" format=3 uid="uid://bsjoandgu476y"] [gd_resource type="MapResource" format=3 uid="uid://bsjoandgu476y"]
[ext_resource type="PackedScene" uid="uid://ylj40hkjsgjc" path="res://maps/diner/diner.tscn" id="1_yteo6"] [ext_resource type="PackedScene" uid="uid://ylj40hkjsgjc" path="res://maps/diner/diner.tscn" id="1_yteo6"]
[ext_resource type="TeamResource" uid="uid://p2fqqnaejjn7" path="res://maps/teams/blue_team.tres" id="2_47vax"]
[ext_resource type="TeamResource" uid="uid://db4b3sjsftg15" path="res://maps/teams/red_ream.tres" id="3_i3gdq"]
[resource] [resource]
name = "Diner" name = "Diner"
scene = ExtResource("1_yteo6") scene = ExtResource("1_yteo6")
teams = Array[TeamResource]([ExtResource("2_47vax"), ExtResource("3_i3gdq")])

View File

@ -1,9 +1,10 @@
[gd_scene format=3 uid="uid://ccd0wj2usx5os"] [gd_scene format=3 uid="uid://ccd0wj2usx5os"]
[node name="player_listing" type="PlayerListing" unique_id=772938280 node_paths=PackedStringArray("name_label", "ping_label", "ready_label")] [node name="player_listing" type="PlayerListing" unique_id=772938280 node_paths=PackedStringArray("name_label", "ping_label", "ready_label", "team_dropdown")]
name_label = NodePath("name") name_label = NodePath("name")
ping_label = NodePath("ping") ping_label = NodePath("ping")
ready_label = NodePath("ready") ready_label = NodePath("ready")
team_dropdown = NodePath("option_button")
offset_right = 319.0 offset_right = 319.0
offset_bottom = 23.0 offset_bottom = 23.0
columns = 4 columns = 4

View File

@ -48,10 +48,12 @@ impl PlayerListing {
pub fn update_teams(&mut self, teams: Array<Gd<TeamResource>>) { pub fn update_teams(&mut self, teams: Array<Gd<TeamResource>>) {
if let Some(dropdown) = &mut self.team_dropdown { if let Some(dropdown) = &mut self.team_dropdown {
let prev_selection = dropdown.get_selected();
dropdown.clear(); dropdown.clear();
for team in teams.iter_shared() { for team in teams.iter_shared() {
dropdown.add_item(&team.bind().name); dropdown.add_item(&team.bind().name);
} }
dropdown.select(prev_selection);
} }
} }
} }