Add small host icon

This commit is contained in:
Sofia 2026-08-15 00:24:09 +03:00
parent c4ffd2fcdd
commit c6a4c44b9c
4 changed files with 27 additions and 8 deletions

View File

@ -2,9 +2,11 @@
[ext_resource type="Theme" uid="uid://drydbnrcdv4pk" path="res://default_theme.tres" id="1_f2dvx"]
[ext_resource type="Texture2D" uid="uid://crhexmmf6si2k" path="res://raw_assets/icons/PNG/White/1x/door.png" id="2_iceu0"]
[ext_resource type="Texture2D" uid="uid://deeejct7aeim2" path="res://raw_assets/icons/PNG/White/2x/medal2.png" id="2_n2fnk"]
[node name="lobby_player_listing" type="LobbyPlayerListing" unique_id=887620055 node_paths=PackedStringArray("name_label", "ping_label", "ready_label", "team_dropdown", "kick_button")]
[node name="lobby_player_listing" type="LobbyPlayerListing" unique_id=887620055 node_paths=PackedStringArray("name_label", "host_icon", "ping_label", "ready_label", "team_dropdown", "kick_button")]
name_label = NodePath("name")
host_icon = NodePath("host_icon")
ping_label = NodePath("ping")
ready_label = NodePath("ready")
team_dropdown = NodePath("option_button")
@ -12,7 +14,7 @@ kick_button = NodePath("kick_button")
offset_right = 673.0
offset_bottom = 23.0
theme = ExtResource("1_f2dvx")
columns = 5
columns = 6
[node name="option_button" type="OptionButton" parent="." unique_id=199328927]
custom_minimum_size = Vector2(150, 0)
@ -20,6 +22,12 @@ custom_maximum_size = Vector2(150, -1)
clip_contents = true
layout_mode = 2
[node name="host_icon" type="TextureRect" parent="." unique_id=1732020549]
layout_mode = 2
tooltip_text = "Host"
texture = ExtResource("2_n2fnk")
expand_mode = 2
[node name="name" type="Label" parent="." unique_id=635700663]
custom_minimum_size = Vector2(300, 0)
custom_maximum_size = Vector2(300, -1)

View File

@ -8,7 +8,6 @@ use godot::{
use crate::{
game::Game,
net::network_manager::NetworkManager,
ui::{chatbox::ChatBox, cli::CommandLinePanel, settings::SettingsPanel},
};

View File

@ -75,6 +75,11 @@ impl IPanel for LobbyPanel {
.signals()
.on_map_changed()
.connect_other(self, |s, id| s.update_map_selection(id));
if let Some(game) = Game::singleton() {
game.signals()
.on_host_privileges_changed()
.connect_other(self, |s| s.update_players(false));
}
if let Some(ready_button) = &self.ready_button {
ready_button

View File

@ -1,5 +1,5 @@
use godot::{
classes::{Button, GridContainer, IGridContainer, Label, OptionButton},
classes::{Button, GridContainer, IGridContainer, Label, OptionButton, TextureRect},
prelude::*,
};
@ -18,6 +18,8 @@ pub struct LobbyPlayerListing {
#[export]
pub name_label: Option<Gd<Label>>,
#[export]
pub host_icon: Option<Gd<TextureRect>>,
#[export]
pub ping_label: Option<Gd<Label>>,
#[export]
pub ready_label: Option<Gd<Label>>,
@ -108,11 +110,13 @@ impl LobbyPlayerListing {
}
pub fn update_game_options(&mut self, opts: &GameOptions, self_id: Option<u16>) {
let is_host = NetworkManager::singleton().bind().is_host();
if let Some(dropdown) = &mut self.team_dropdown {
if let Some(game) = &Game::singleton()
&& let Some(dropdown) = &mut self.team_dropdown
{
dropdown.set_disabled(
!is_host && !opts.is_true(GameOption::AllowAnyTeam) && self.player_id != self_id,
!game.bind().has_host_privileges()
&& !opts.is_true(GameOption::AllowAnyTeam)
&& self.player_id != self_id,
);
}
}
@ -122,6 +126,9 @@ impl LobbyPlayerListing {
&& let Some(game) = Game::singleton()
&& let Some(player) = game.bind().find_player(*player_id)
{
if let Some(host_icon) = &mut self.host_icon {
host_icon.set_visible(player.data.has_host_privileges);
}
if let Some(player_label) = &mut self.name_label {
player_label.set_text(&format!(
"{} ({})",