diff --git a/godot/RawAssets/Ping.xcf b/godot/RawAssets/Ping.xcf new file mode 100644 index 0000000..db6fff6 Binary files /dev/null and b/godot/RawAssets/Ping.xcf differ diff --git a/godot/assets/Ping_high.png b/godot/assets/Ping_high.png new file mode 100644 index 0000000..abaf4e6 Binary files /dev/null and b/godot/assets/Ping_high.png differ diff --git a/godot/assets/Ping_high.png.import b/godot/assets/Ping_high.png.import new file mode 100644 index 0000000..3803863 --- /dev/null +++ b/godot/assets/Ping_high.png.import @@ -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 diff --git a/godot/assets/Ping_low.png b/godot/assets/Ping_low.png new file mode 100644 index 0000000..f142d72 Binary files /dev/null and b/godot/assets/Ping_low.png differ diff --git a/godot/assets/Ping_low.png.import b/godot/assets/Ping_low.png.import new file mode 100644 index 0000000..490d896 --- /dev/null +++ b/godot/assets/Ping_low.png.import @@ -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 diff --git a/godot/assets/Ping_medium.png b/godot/assets/Ping_medium.png new file mode 100644 index 0000000..f197322 Binary files /dev/null and b/godot/assets/Ping_medium.png differ diff --git a/godot/assets/Ping_medium.png.import b/godot/assets/Ping_medium.png.import new file mode 100644 index 0000000..c1de186 --- /dev/null +++ b/godot/assets/Ping_medium.png.import @@ -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 diff --git a/godot/scenes/ui/player_listing.tscn b/godot/scenes/ui/player_listing.tscn index 5a903fe..eff2921 100644 --- a/godot/scenes/ui/player_listing.tscn +++ b/godot/scenes/ui/player_listing.tscn @@ -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 diff --git a/rust/src/ui/player_listing.rs b/rust/src/ui/player_listing.rs index 3492574..4c28e67 100644 --- a/rust/src/ui/player_listing.rs +++ b/rust/src/ui/player_listing.rs @@ -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>, #[export] ping_label: Option>, + #[export] + ping_low: Option>, + #[export] + ping_low_color: Color, + #[export] + ping_medium: Option>, + #[export] + ping_medium_color: Color, + #[export] + ping_high: Option>, + #[export] + ping_high_color: Color, + #[export] + ping_icon: Option>, pub player_id: Option, @@ -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");