Add ping icon
This commit is contained in:
parent
4f16588d69
commit
7e2751393c
BIN
godot/RawAssets/Ping.xcf
Normal file
BIN
godot/RawAssets/Ping.xcf
Normal file
Binary file not shown.
BIN
godot/assets/Ping_high.png
Normal file
BIN
godot/assets/Ping_high.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 260 B |
40
godot/assets/Ping_high.png.import
Normal file
40
godot/assets/Ping_high.png.import
Normal file
@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c0n5ugd867e2k"
|
||||
path="res://.godot/imported/Ping_high.png-78b5667ceb93c91e9ec1243749341ac5.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Ping_high.png"
|
||||
dest_files=["res://.godot/imported/Ping_high.png-78b5667ceb93c91e9ec1243749341ac5.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
godot/assets/Ping_low.png
Normal file
BIN
godot/assets/Ping_low.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 239 B |
40
godot/assets/Ping_low.png.import
Normal file
40
godot/assets/Ping_low.png.import
Normal file
@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bhrbrc725q0yd"
|
||||
path="res://.godot/imported/Ping_low.png-607d26045b7085e3f2b980d8e4623f1d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Ping_low.png"
|
||||
dest_files=["res://.godot/imported/Ping_low.png-607d26045b7085e3f2b980d8e4623f1d.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
godot/assets/Ping_medium.png
Normal file
BIN
godot/assets/Ping_medium.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 251 B |
40
godot/assets/Ping_medium.png.import
Normal file
40
godot/assets/Ping_medium.png.import
Normal file
@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://7u2jx45bwejo"
|
||||
path="res://.godot/imported/Ping_medium.png-ef65cc30e3ffdd76332aa788d0be7a4a.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Ping_medium.png"
|
||||
dest_files=["res://.godot/imported/Ping_medium.png-ef65cc30e3ffdd76332aa788d0be7a4a.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
@ -1,10 +1,21 @@
|
||||
[gd_scene format=3 uid="uid://2sfy0vq0fqt3"]
|
||||
|
||||
[node name="player_listing" type="PlayerListing" unique_id=965142972 node_paths=PackedStringArray("name_label", "kills_label", "deaths_label", "ping_label")]
|
||||
[ext_resource type="Texture2D" uid="uid://bhrbrc725q0yd" path="res://assets/Ping_low.png" id="1_3pnyb"]
|
||||
[ext_resource type="Texture2D" uid="uid://7u2jx45bwejo" path="res://assets/Ping_medium.png" id="2_h6por"]
|
||||
[ext_resource type="Texture2D" uid="uid://c0n5ugd867e2k" path="res://assets/Ping_high.png" id="3_kx1on"]
|
||||
|
||||
[node name="player_listing" type="PlayerListing" unique_id=965142972 node_paths=PackedStringArray("name_label", "kills_label", "deaths_label", "ping_label", "ping_icon")]
|
||||
name_label = NodePath("name")
|
||||
kills_label = NodePath("kills")
|
||||
deaths_label = NodePath("deaths")
|
||||
ping_label = NodePath("ping")
|
||||
ping_low = ExtResource("1_3pnyb")
|
||||
ping_low_color = Color(0, 0.7983432, 0, 1)
|
||||
ping_medium = ExtResource("2_h6por")
|
||||
ping_medium_color = Color(0.7963379, 0.79633814, 0, 1)
|
||||
ping_high = ExtResource("3_kx1on")
|
||||
ping_high_color = Color(0.99999994, 0.22953579, 0.17418489, 1)
|
||||
ping_icon = NodePath("ping_icon")
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="name" type="Label" parent="." unique_id=1361759955]
|
||||
@ -28,8 +39,15 @@ text = "0"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ping" type="Label" parent="." unique_id=1700548535]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
custom_maximum_size = Vector2(100, -1)
|
||||
custom_minimum_size = Vector2(50, 0)
|
||||
custom_maximum_size = Vector2(50, -1)
|
||||
layout_mode = 2
|
||||
text = "0ms"
|
||||
horizontal_alignment = 1
|
||||
horizontal_alignment = 2
|
||||
clip_text = true
|
||||
|
||||
[node name="ping_icon" type="TextureRect" parent="." unique_id=1921112362]
|
||||
layout_mode = 2
|
||||
texture = ExtResource("3_kx1on")
|
||||
expand_mode = 2
|
||||
stretch_mode = 4
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use godot::{
|
||||
classes::{HBoxContainer, IHBoxContainer, Label},
|
||||
classes::{CompressedTexture2D, HBoxContainer, IHBoxContainer, Label, Texture2D, TextureRect},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
@ -16,6 +16,20 @@ pub struct PlayerListing {
|
||||
deaths_label: Option<Gd<Label>>,
|
||||
#[export]
|
||||
ping_label: Option<Gd<Label>>,
|
||||
#[export]
|
||||
ping_low: Option<Gd<Texture2D>>,
|
||||
#[export]
|
||||
ping_low_color: Color,
|
||||
#[export]
|
||||
ping_medium: Option<Gd<Texture2D>>,
|
||||
#[export]
|
||||
ping_medium_color: Color,
|
||||
#[export]
|
||||
ping_high: Option<Gd<Texture2D>>,
|
||||
#[export]
|
||||
ping_high_color: Color,
|
||||
#[export]
|
||||
ping_icon: Option<Gd<TextureRect>>,
|
||||
|
||||
pub player_id: Option<u16>,
|
||||
|
||||
@ -55,6 +69,17 @@ impl PlayerListing {
|
||||
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 {
|
||||
..100 => (self.ping_low.clone(), self.ping_low_color),
|
||||
100..200 => (self.ping_medium.clone(), self.ping_medium_color),
|
||||
200.. => (self.ping_high.clone(), self.ping_high_color),
|
||||
};
|
||||
if let Some(icon) = icon {
|
||||
ping_icon.set_texture(&icon);
|
||||
}
|
||||
ping_icon.set_modulate(color);
|
||||
}
|
||||
} else {
|
||||
if let Some(name_label) = &mut self.name_label {
|
||||
name_label.set_text("Name");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user