Self-highlight player listing
This commit is contained in:
parent
604b97925b
commit
00776a4c52
@ -19,6 +19,7 @@ ping_high = ExtResource("3_kx1on")
|
|||||||
ping_high_color = Color(0.99999994, 0.22953579, 0.17418489, 1)
|
ping_high_color = Color(0.99999994, 0.22953579, 0.17418489, 1)
|
||||||
ping_icon = NodePath("ping_icon")
|
ping_icon = NodePath("ping_icon")
|
||||||
stats_button = NodePath("stats_button")
|
stats_button = NodePath("stats_button")
|
||||||
|
self_color = Color(1, 1, 0.41000003, 1)
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
theme = ExtResource("4_kx1on")
|
theme = ExtResource("4_kx1on")
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,9 @@ pub struct PlayerListing {
|
|||||||
#[export]
|
#[export]
|
||||||
stats_button: Option<Gd<Button>>,
|
stats_button: Option<Gd<Button>>,
|
||||||
|
|
||||||
|
#[export]
|
||||||
|
self_color: Color,
|
||||||
|
|
||||||
pub player_id: Option<u16>,
|
pub player_id: Option<u16>,
|
||||||
|
|
||||||
#[export]
|
#[export]
|
||||||
@ -86,25 +89,38 @@ impl PlayerListing {
|
|||||||
pub fn update(&mut self) {
|
pub fn update(&mut self) {
|
||||||
if let Some(player_id) = self.player_id {
|
if let Some(player_id) = self.player_id {
|
||||||
if let Some(game) = Game::singleton() {
|
if let Some(game) = Game::singleton() {
|
||||||
|
let is_self = player_id == game.bind().self_id.unwrap_or(0);
|
||||||
if let Some(player) = game.bind().find_player(player_id) {
|
if let Some(player) = game.bind().find_player(player_id) {
|
||||||
if let Some(name_label) = &mut self.name_label {
|
if let Some(name_label) = &mut self.name_label {
|
||||||
name_label.set_text(&player.data.name);
|
name_label.set_text(&player.data.name);
|
||||||
|
if is_self {
|
||||||
|
name_label.set_modulate(self.self_color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let Some(kills_label) = &mut self.kills_label {
|
if let Some(kills_label) = &mut self.kills_label {
|
||||||
kills_label.set_text(&player.stats.kills.to_string());
|
kills_label.set_text(&player.stats.kills.to_string());
|
||||||
|
if is_self {
|
||||||
|
kills_label.set_modulate(self.self_color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let Some(deaths_label) = &mut self.deaths_label {
|
if let Some(deaths_label) = &mut self.deaths_label {
|
||||||
deaths_label.set_text(&player.stats.deaths.to_string());
|
deaths_label.set_text(&player.stats.deaths.to_string());
|
||||||
|
if is_self {
|
||||||
|
deaths_label.set_modulate(self.self_color);
|
||||||
}
|
}
|
||||||
if let Some(ping_label) = &mut self.ping_label {
|
|
||||||
ping_label.set_text(&player.data.ping.to_string());
|
|
||||||
}
|
}
|
||||||
if let Some(ping_icon) = &mut self.ping_icon {
|
|
||||||
let (icon, color) = match player.data.ping {
|
let (icon, color) = match player.data.ping {
|
||||||
..100 => (self.ping_low.clone(), self.ping_low_color),
|
..100 => (self.ping_low.clone(), self.ping_low_color),
|
||||||
100..200 => (self.ping_medium.clone(), self.ping_medium_color),
|
100..200 => (self.ping_medium.clone(), self.ping_medium_color),
|
||||||
200.. => (self.ping_high.clone(), self.ping_high_color),
|
200.. => (self.ping_high.clone(), self.ping_high_color),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(ping_label) = &mut self.ping_label {
|
||||||
|
ping_label.set_text(&player.data.ping.to_string());
|
||||||
|
ping_label.set_modulate(color);
|
||||||
|
}
|
||||||
|
if let Some(ping_icon) = &mut self.ping_icon {
|
||||||
if let Some(icon) = icon {
|
if let Some(icon) = icon {
|
||||||
ping_icon.set_texture(&icon);
|
ping_icon.set_texture(&icon);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user