From 1a82c2bdf0e77af44df1a60dd320838199b53619 Mon Sep 17 00:00:00 2001 From: Dustin Date: Sat, 5 Apr 2025 09:22:52 -0700 Subject: [PATCH] UI improvements. Add stamina indicator for future --- assets/UI/Staminabar-Indicator.png | Bin 0 -> 133 bytes assets/UI/Staminabar-Indicator.png.import | 35 ++++++++++++++++++++++ lib/singleton_autoloads/PlayerInfo.gd | 1 + src/ui/HUD.tscn | 29 ++++++++++++++++-- src/ui/StaminaBar.gd | 16 ++++++++++ 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 assets/UI/Staminabar-Indicator.png create mode 100644 assets/UI/Staminabar-Indicator.png.import create mode 100644 src/ui/StaminaBar.gd diff --git a/assets/UI/Staminabar-Indicator.png b/assets/UI/Staminabar-Indicator.png new file mode 100644 index 0000000000000000000000000000000000000000..18238318c562f94859b7f4a4585da658a0224c89 GIT binary patch literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^DL~A{!3-oz4{`edDaPU;cPEB*=VV?2Ih+ALA+A8$ z!NEc2Kf~Mg3-y2;=8_=4V21zyT>`Et0=d$jE{-7@6O$8?7TBgFBrUO(*_v`?l43rm atOCRN9M(!kzQVgeWelFKelF{r5}E+j%_6h_ literal 0 HcmV?d00001 diff --git a/assets/UI/Staminabar-Indicator.png.import b/assets/UI/Staminabar-Indicator.png.import new file mode 100644 index 0000000..a6350da --- /dev/null +++ b/assets/UI/Staminabar-Indicator.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Staminabar-Indicator.png-788a1183a5b10acd59c2a4cfb5ea2038.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/UI/Staminabar-Indicator.png" +dest_files=[ "res://.import/Staminabar-Indicator.png-788a1183a5b10acd59c2a4cfb5ea2038.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/lib/singleton_autoloads/PlayerInfo.gd b/lib/singleton_autoloads/PlayerInfo.gd index c65333b..83765a2 100644 --- a/lib/singleton_autoloads/PlayerInfo.gd +++ b/lib/singleton_autoloads/PlayerInfo.gd @@ -6,6 +6,7 @@ extends Node # var b = "text" var player_position: Vector2 var player_health: int +var player_stamina: int # Called when the node enters the scene tree for the first time. func _ready(): diff --git a/src/ui/HUD.tscn b/src/ui/HUD.tscn index 718ec6e..e261e20 100644 --- a/src/ui/HUD.tscn +++ b/src/ui/HUD.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://icon.png" type="Texture" id=1] [ext_resource path="res://assets/Fonts/QuinqueFive.tres" type="DynamicFont" id=2] @@ -6,6 +6,7 @@ [ext_resource path="res://assets/UI/Healthbar.png" type="Texture" id=4] [ext_resource path="res://src/ui/HealthBar.gd" type="Script" id=5] [ext_resource path="res://assets/UI/Healthbar-Indicator.png" type="Texture" id=6] +[ext_resource path="res://assets/UI/Staminabar-Indicator.png" type="Texture" id=7] [node name="HUD" type="CanvasLayer"] pause_mode = 2 @@ -13,7 +14,6 @@ layer = 2 script = ExtResource( 3 ) [node name="PanelContainer" type="PanelContainer" parent="."] -visible = false margin_left = 2.0 margin_top = 2.0 margin_right = 318.0 @@ -61,6 +61,17 @@ texture_progress = ExtResource( 6 ) texture_progress_offset = Vector2( 1, 1 ) script = ExtResource( 5 ) +[node name="StaminaBar" type="TextureProgress" parent="."] +margin_left = 2.0 +margin_top = 14.0 +margin_right = 104.0 +margin_bottom = 14.0 +value = 50.0 +texture_under = ExtResource( 4 ) +texture_progress = ExtResource( 7 ) +texture_progress_offset = Vector2( 1, 1 ) +script = ExtResource( 5 ) + [node name="Debug" type="Label" parent="."] anchor_left = 1.0 anchor_right = 1.0 @@ -71,3 +82,17 @@ margin_bottom = 17.0 custom_fonts/font = ExtResource( 2 ) text = "Foo" align = 2 + +[node name="InventoryContainer" type="HSplitContainer" parent="."] +margin_right = 40.0 +margin_bottom = 40.0 +split_offset = 1 + +[node name="Primary" type="TextureRect" parent="InventoryContainer"] +margin_right = 1.0 +margin_bottom = 40.0 + +[node name="Secondary" type="TextureRect" parent="InventoryContainer"] +margin_left = 13.0 +margin_right = 40.0 +margin_bottom = 40.0 diff --git a/src/ui/StaminaBar.gd b/src/ui/StaminaBar.gd new file mode 100644 index 0000000..117aad2 --- /dev/null +++ b/src/ui/StaminaBar.gd @@ -0,0 +1,16 @@ +extends TextureProgress + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + value = PlayerInfo.player_stamina