From 1c112630d15355c22094492e740f55119a3fb58c Mon Sep 17 00:00:00 2001 From: Dustin Date: Fri, 11 Apr 2025 22:24:12 -0700 Subject: [PATCH] Preparing HUD for more players. --- Main.tscn | 4 -- project.godot | 4 ++ src/ui/HUD.gd | 4 +- src/ui/HUD.tscn | 78 ++------------------------------ src/ui/PlayerHUD.tscn | 66 +++++++++++++++++++++++++++ src/ui/SelectedInventoryItems.gd | 4 ++ 6 files changed, 79 insertions(+), 81 deletions(-) create mode 100644 src/ui/PlayerHUD.tscn diff --git a/Main.tscn b/Main.tscn index c510508..cc48cc4 100644 --- a/Main.tscn +++ b/Main.tscn @@ -52,10 +52,6 @@ __meta__ = { [node name="PlayerE" parent="ViewportContainer/Viewport" instance=ExtResource( 1 )] position = Vector2( 112, 56 ) -[node name="PlayerE2" parent="ViewportContainer/Viewport" instance=ExtResource( 1 )] -position = Vector2( 112, 56 ) -player_number = 2 - [node name="UI_Layer" parent="ViewportContainer/Viewport" instance=ExtResource( 3 )] [node name="CameraGuide" type="KinematicBody2D" parent="ViewportContainer/Viewport"] diff --git a/project.godot b/project.godot index c718d34..d6640ac 100644 --- a/project.godot +++ b/project.godot @@ -370,6 +370,10 @@ switch_secondary_item_2={ , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":66,"physical_scancode":0,"unicode":0,"echo":false,"script":null) ] } +dash_2={ +"deadzone": 0.5, +"events": [ ] +} [layer_names] diff --git a/src/ui/HUD.gd b/src/ui/HUD.gd index a4bce21..3bf3719 100644 --- a/src/ui/HUD.gd +++ b/src/ui/HUD.gd @@ -14,9 +14,9 @@ onready var DialogContainerText = $PanelContainer/HSplitContainer/Label onready var DialogIndicator = $PanelContainer/Polygon2D -onready var health_bar = $HealthBar +onready var health_bar = $PlayerHUD/HealthBar -onready var stamina_bar = $StaminaBar +onready var stamina_bar = $PlayerHUD/StaminaBar ## Cool I can bring this in with a ctrl drag onready var selected_inventory_items = $"%SelectedInventoryItems" diff --git a/src/ui/HUD.tscn b/src/ui/HUD.tscn index d30ffe9..0a3d752 100644 --- a/src/ui/HUD.tscn +++ b/src/ui/HUD.tscn @@ -1,14 +1,9 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://icon.png" type="Texture" id=1] [ext_resource path="res://assets/Fonts/QuinqueFive.tres" type="DynamicFont" id=2] [ext_resource path="res://src/ui/HUD.gd" type="Script" id=3] -[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] -[ext_resource path="res://src/ui/SelectedInventoryItems.gd" type="Script" id=8] -[ext_resource path="res://src/ui/StaminaBar.gd" type="Script" id=9] +[ext_resource path="res://src/ui/PlayerHUD.tscn" type="PackedScene" id=4] [node name="HUD" type="CanvasLayer"] pause_mode = 2 @@ -52,28 +47,6 @@ scale = Vector2( 0.769547, 0.833333 ) color = Color( 0.533333, 0.533333, 0.533333, 1 ) polygon = PoolVector2Array( 294, 63, 300.177, 63, 307, 63, 300.503, 69 ) -[node name="HealthBar" type="TextureProgress" parent="."] -margin_left = 2.0 -margin_top = 2.0 -margin_right = 104.0 -margin_bottom = 14.0 -value = 50.0 -texture_under = ExtResource( 4 ) -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( 9 ) - [node name="Debug" type="Label" parent="."] anchor_left = 1.0 anchor_right = 1.0 @@ -85,49 +58,4 @@ 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 - -[node name="SelectedInventoryItems" type="HBoxContainer" parent="."] -unique_name_in_owner = true -anchor_top = 1.0 -anchor_bottom = 1.0 -margin_left = 2.0 -margin_top = -18.0 -margin_right = 48.0 -margin_bottom = -2.0 -rect_clip_content = true -script = ExtResource( 8 ) - -[node name="PrimaryItem" type="TextureRect" parent="SelectedInventoryItems"] -margin_bottom = 16.0 - -[node name="Label" type="Label" parent="SelectedInventoryItems/PrimaryItem"] -margin_right = 20.0 -margin_bottom = 10.0 -custom_fonts/font = ExtResource( 2 ) -align = 2 -valign = 2 - -[node name="SecondaryItem" type="TextureRect" parent="SelectedInventoryItems"] -margin_left = 4.0 -margin_right = 4.0 -margin_bottom = 16.0 - -[node name="Label" type="Label" parent="SelectedInventoryItems/SecondaryItem"] -margin_right = 20.0 -margin_bottom = 10.0 -custom_fonts/font = ExtResource( 2 ) -align = 2 -valign = 2 +[node name="PlayerHUD" parent="." instance=ExtResource( 4 )] diff --git a/src/ui/PlayerHUD.tscn b/src/ui/PlayerHUD.tscn new file mode 100644 index 0000000..42a97b6 --- /dev/null +++ b/src/ui/PlayerHUD.tscn @@ -0,0 +1,66 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://assets/Fonts/QuinqueFive.tres" type="DynamicFont" id=1] +[ext_resource path="res://assets/UI/Staminabar-Indicator.png" type="Texture" id=2] +[ext_resource path="res://assets/UI/Healthbar.png" type="Texture" id=3] +[ext_resource path="res://assets/UI/Healthbar-Indicator.png" type="Texture" id=4] +[ext_resource path="res://src/ui/HealthBar.gd" type="Script" id=5] +[ext_resource path="res://src/ui/SelectedInventoryItems.gd" type="Script" id=6] +[ext_resource path="res://src/ui/StaminaBar.gd" type="Script" id=7] + +[node name="PlayerHUD" type="Control"] +margin_right = 320.0 +margin_bottom = 180.0 + +[node name="HealthBar" type="TextureProgress" parent="."] +margin_left = 2.0 +margin_top = 2.0 +margin_right = 104.0 +margin_bottom = 14.0 +value = 50.0 +texture_under = ExtResource( 3 ) +texture_progress = ExtResource( 4 ) +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 = 26.0 +value = 50.0 +texture_under = ExtResource( 3 ) +texture_progress = ExtResource( 2 ) +texture_progress_offset = Vector2( 1, 1 ) +script = ExtResource( 7 ) + +[node name="SelectedInventoryItems" type="HBoxContainer" parent="."] +unique_name_in_owner = true +anchor_top = 1.0 +anchor_bottom = 1.0 +margin_top = -16.0 +margin_right = 46.0 +rect_clip_content = true +script = ExtResource( 6 ) + +[node name="PrimaryItem" type="TextureRect" parent="SelectedInventoryItems"] +margin_bottom = 16.0 + +[node name="Label" type="Label" parent="SelectedInventoryItems/PrimaryItem"] +margin_right = 20.0 +margin_bottom = 10.0 +custom_fonts/font = ExtResource( 1 ) +align = 2 +valign = 2 + +[node name="SecondaryItem" type="TextureRect" parent="SelectedInventoryItems"] +margin_left = 4.0 +margin_right = 4.0 +margin_bottom = 16.0 + +[node name="Label" type="Label" parent="SelectedInventoryItems/SecondaryItem"] +margin_right = 20.0 +margin_bottom = 10.0 +custom_fonts/font = ExtResource( 1 ) +align = 2 +valign = 2 diff --git a/src/ui/SelectedInventoryItems.gd b/src/ui/SelectedInventoryItems.gd index 38dd364..6d261af 100644 --- a/src/ui/SelectedInventoryItems.gd +++ b/src/ui/SelectedInventoryItems.gd @@ -12,6 +12,10 @@ onready var _secondary_item_count = $SecondaryItem/Label # Called when the node enters the scene tree for the first time. func _ready(): + if primary_item == null: + print("--------WTF is going oN") + else: + print("----------thats find. ") pass #secondary_item.texture = PlayerInfo.player_inventory.secondary_selection.inventory_icon