Initial commit

This commit is contained in:
2024-01-14 12:22:14 +01:00
commit 9b47e374c7
24 changed files with 529 additions and 0 deletions

8
ui/FPS.gd Normal file
View File

@ -0,0 +1,8 @@
extends Label
func _ready():
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
func _process(_delta):
var fps = Engine.get_frames_per_second()
text = str(fps)

38
ui/Ping.gd Normal file
View File

@ -0,0 +1,38 @@
extends Label
const HISTORY_SIZE = 8
var pingCount := 0
var pingSent: Array[float] = []
func _ready():
var timer := Timer.new()
add_child(timer)
timer.autostart = true
timer.wait_time = 1
timer.connect("timeout", self._ping)
timer.start()
pingSent.resize(HISTORY_SIZE)
func _process(_delta):
if Client.udp.get_available_packet_count() > 0:
#print("Received: %s" % udp.get_packet().get_string_from_utf8())
var bytes := Client.udp.get_packet()
var count := bytes.decode_u8(1)
var timeSent := pingSent[count]
var duration := Time.get_unix_time_from_system() - timeSent
var ping := duration * 1000
text = str(snapped(ping, 0.01))
func _ping():
var buffer := StreamPeerBuffer.new()
buffer.put_8(0)
buffer.put_8(pingCount)
Client.udp.put_packet(buffer.data_array)
pingSent[pingCount] = Time.get_unix_time_from_system()
pingCount += 1
if pingCount >= HISTORY_SIZE:
pingCount = 0

41
ui/UI.tscn Normal file
View File

@ -0,0 +1,41 @@
[gd_scene load_steps=3 format=3 uid="uid://bxotvk73tbgw0"]
[ext_resource type="Script" path="res://ui/FPS.gd" id="1_128dk"]
[ext_resource type="Script" path="res://ui/Ping.gd" id="2_m7fhx"]
[node name="UI" type="Control"]
layout_mode = 3
anchors_preset = 0
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer"]
offset_right = 40.0
offset_bottom = 50.0
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/MarginContainer"]
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="FPSLabel" type="Label" parent="CanvasLayer/MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "FPS:"
[node name="FPS" type="Label" parent="CanvasLayer/MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "0"
script = ExtResource("1_128dk")
[node name="HBoxContainer2" type="HBoxContainer" parent="CanvasLayer/MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="PingLabel" type="Label" parent="CanvasLayer/MarginContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "Ping:"
[node name="Ping" type="Label" parent="CanvasLayer/MarginContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "0"
script = ExtResource("2_m7fhx")

1
ui/icon.svg Normal file
View File

@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>

After

Width:  |  Height:  |  Size: 950 B

37
ui/icon.svg.import Normal file
View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://biplb56hj51h7"
path="res://.godot/imported/icon.svg-57a480398ce0db3d1582eb3ec78dffaa.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://ui/icon.svg"
dest_files=["res://.godot/imported/icon.svg-57a480398ce0db3d1582eb3ec78dffaa.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

10
ui/theme.tres Normal file
View File

@ -0,0 +1,10 @@
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://caqphxkvcu3tb"]
[ext_resource type="FontFile" uid="uid://b7mov13kwi8u8" path="res://ui/ubuntu_nf_regular.ttf" id="1_1unma"]
[resource]
default_font = ExtResource("1_1unma")
MarginContainer/constants/margin_bottom = 5
MarginContainer/constants/margin_left = 5
MarginContainer/constants/margin_right = 5
MarginContainer/constants/margin_top = 5

View File

@ -0,0 +1,38 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://b7mov13kwi8u8"
path="res://.godot/imported/ubuntu_nf_regular.ttf-feed7a5a59b6d10a4a32843efe52a9da.fontdata"
[deps]
source_file="res://ui/ubuntu_nf_regular.ttf"
dest_files=["res://.godot/imported/ubuntu_nf_regular.ttf-feed7a5a59b6d10a4a32843efe52a9da.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[{
"chars": [],
"glyphs": [],
"name": "New Configuration",
"size": Vector2i(16, 0)
}]
language_support={}
script_support={}
opentype_features={}