Preparing HUD for more players.

This commit is contained in:
Dustin 2025-04-11 22:24:12 -07:00
parent 911db44bc2
commit 1c112630d1
6 changed files with 79 additions and 81 deletions

View File

@ -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"]

View File

@ -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]

View File

@ -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"

View File

@ -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 )]

66
src/ui/PlayerHUD.tscn Normal file
View File

@ -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

View File

@ -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