Add HP/VT bars

This commit is contained in:
2025-08-08 23:16:51 -07:00
parent 7c694149c2
commit bd6794dafd
6 changed files with 75 additions and 16 deletions

View File

@@ -24,6 +24,13 @@ public partial class PlayerInfoUI : Control, IPlayerInfoUI
[Node] public Label HPNumber { get; set; } = default!;
[Node] public Label VTNumber { get; set; } = default!;
[Node] public Label EXPNumber { get; set; } = default!;
[Node] public ProgressBar HPProgressBar { get; set; } = default!;
[Node] public ProgressBar VTProgressBar { get; set; } = default!;
#endregion
[Dependency] public IPlayer Player => this.DependOn<IPlayer>();
@@ -37,30 +44,45 @@ public partial class PlayerInfoUI : Control, IPlayerInfoUI
Player.Stats.MaximumVT.Sync += MaximumVT_Sync;
Player.Stats.CurrentLevel.Sync += CurrentLevel_Sync;
Player.Stats.CurrentExp.Sync += CurrentExp_Sync;
Player.Stats.ExpToNextLevel.Sync += ExpToNextLevel_Sync;
}
private void CurrentLevel_Sync(int obj)
{
LevelNumber.Text = $"{obj}";
LevelNumber.Text = $"LVL. {obj}";
}
private void MaximumVT_Sync(int obj)
{
VTNumber.Text = $"{Player.Stats.CurrentVT.Value}/{obj}";
VTProgressBar.MaxValue = obj;
}
private void CurrentVT_Sync(int obj)
{
VTNumber.Text = $"{obj}/{Player.Stats.MaximumVT.Value}";
VTProgressBar.Value = obj;
}
private void MaximumHP_Sync(int obj)
{
HPNumber.Text = $"{Player.Stats.CurrentHP.Value}/{obj}";
HPProgressBar.MaxValue = obj;
}
private void CurrentHP_Sync(int obj)
{
HPNumber.Text = $"{obj}/{Player.Stats.MaximumHP.Value}";
HPProgressBar.Value = obj;
}
private void CurrentExp_Sync(double obj)
{
EXPNumber.Text = $"XP {(int)obj}/{Player.Stats.ExpToNextLevel.Value}";
}
private void ExpToNextLevel_Sync(int obj)
{
EXPNumber.Text = $"XP {Player.Stats.CurrentExp.Value}/{obj}";
}
}

View File

@@ -1,9 +1,31 @@
[gd_scene load_steps=4 format=3 uid="uid://dxl8il8f13c2x"]
[gd_scene load_steps=8 format=3 uid="uid://dxl8il8f13c2x"]
[ext_resource type="Script" uid="uid://b65cbirtijlii" path="res://src/ui/player_ui/PlayerInfoUI.cs" id="1_d8yyu"]
[ext_resource type="LabelSettings" uid="uid://ca1q6yu8blwxf" path="res://src/ui/label_settings/InventoryMainTextBold.tres" id="2_aa7fx"]
[ext_resource type="LabelSettings" uid="uid://dupifadnagodp" path="res://src/ui/label_settings/MainTextRegular.tres" id="3_xdjh1"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_bqtin"]
bg_color = Color(0.00392157, 0.341176, 0.141176, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hkw8m"]
bg_color = Color(0.207843, 1, 0.52549, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0.00392157, 0.341176, 0.141176, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nv5jb"]
bg_color = Color(0.0980392, 0.129412, 0.270588, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gio7f"]
bg_color = Color(0.223529, 0.368627, 0.996078, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0.0980392, 0.129412, 0.270588, 1)
[node name="PlayerInfoUI" type="Control"]
layout_mode = 3
anchors_preset = 15
@@ -51,9 +73,21 @@ border_width = 0.0
[node name="HPNumber" type="Label" parent="AspectRatio/PlayerInfo/HBoxContainer/VBox/HP Box"]
unique_name_in_owner = true
custom_minimum_size = Vector2(160, 0)
layout_mode = 2
text = "222/222"
label_settings = ExtResource("3_xdjh1")
horizontal_alignment = 2
[node name="HPProgressBar" type="ProgressBar" parent="AspectRatio/PlayerInfo/HBoxContainer/VBox/HP Box"]
unique_name_in_owner = true
custom_minimum_size = Vector2(150, 12)
layout_mode = 2
size_flags_vertical = 4
theme_override_styles/background = SubResource("StyleBoxFlat_bqtin")
theme_override_styles/fill = SubResource("StyleBoxFlat_hkw8m")
value = 50.0
show_percentage = false
[node name="VT Box" type="HBoxContainer" parent="AspectRatio/PlayerInfo/HBoxContainer/VBox"]
layout_mode = 2
@@ -70,9 +104,21 @@ border_width = 0.0
[node name="VTNumber" type="Label" parent="AspectRatio/PlayerInfo/HBoxContainer/VBox/VT Box"]
unique_name_in_owner = true
custom_minimum_size = Vector2(160, 0)
layout_mode = 2
text = "444/444"
label_settings = ExtResource("3_xdjh1")
horizontal_alignment = 2
[node name="VTProgressBar" type="ProgressBar" parent="AspectRatio/PlayerInfo/HBoxContainer/VBox/VT Box"]
unique_name_in_owner = true
custom_minimum_size = Vector2(150, 12)
layout_mode = 2
size_flags_vertical = 4
theme_override_styles/background = SubResource("StyleBoxFlat_nv5jb")
theme_override_styles/fill = SubResource("StyleBoxFlat_gio7f")
value = 50.0
show_percentage = false
[node name="Level Box" type="HBoxContainer" parent="AspectRatio/PlayerInfo/HBoxContainer/VBox"]
layout_mode = 2
@@ -82,8 +128,7 @@ unique_name_in_owner = true
layout_mode = 2
text = "LVL. 08"
label_settings = ExtResource("2_aa7fx")
horizontal_alignment = 1
vertical_alignment = 1
horizontal_alignment = 2
[node name="EXP Box" type="HBoxContainer" parent="AspectRatio/PlayerInfo/HBoxContainer/VBox"]
layout_mode = 2
@@ -93,5 +138,4 @@ unique_name_in_owner = true
layout_mode = 2
text = "XP 901/2002"
label_settings = ExtResource("2_aa7fx")
horizontal_alignment = 1
vertical_alignment = 1
horizontal_alignment = 2