From 6d9d08d78ca6f6da5865871fbb0524ec13213ecf Mon Sep 17 00:00:00 2001 From: gamer147 Date: Fri, 10 Apr 2026 12:23:45 -0400 Subject: [PATCH] Testing chip bar --- prefabs/combat_ui.tscn | 25 +++++++++++++++---- prefabs/deployed_unit.tscn | 1 + .../appearance_sets/lily_child_deployed.tres | 10 ++++---- resources/units/lily_child.tres | 2 +- scenes/views/main_menu_view.tscn | 1 + scripts/battle/combat_ui.gd | 4 +++ .../deployed_units/deployed_unit_stats.gd | 2 ++ scripts/ui/chip_bar.gd | 7 +++--- scripts/units/unit_stats.gd | 3 +++ 9 files changed, 41 insertions(+), 14 deletions(-) diff --git a/prefabs/combat_ui.tscn b/prefabs/combat_ui.tscn index ac12cc1..55471d1 100644 --- a/prefabs/combat_ui.tscn +++ b/prefabs/combat_ui.tscn @@ -303,7 +303,7 @@ offset_bottom = 26.0 size_flags_horizontal = 8 texture = SubResource("AtlasTexture_3wejr") -[node name="Items" type="HBoxContainer" parent="UIBase/UnitPanel/TextureRect" unique_id=828992814] +[node name="UnitLevel" type="HBoxContainer" parent="UIBase/UnitPanel/TextureRect" unique_id=828992814] layout_mode = 1 anchors_preset = 3 anchor_left = 1.0 @@ -315,16 +315,17 @@ offset_top = -20.0 grow_horizontal = 0 grow_vertical = 0 -[node name="Spacer" type="Control" parent="UIBase/UnitPanel/TextureRect/Items" unique_id=1068603879] +[node name="Spacer" type="Control" parent="UIBase/UnitPanel/TextureRect/UnitLevel" unique_id=1068603879] layout_mode = 2 size_flags_horizontal = 3 -[node name="Label" type="TextureRect" parent="UIBase/UnitPanel/TextureRect/Items" unique_id=1299333906] +[node name="Label" type="TextureRect" parent="UIBase/UnitPanel/TextureRect/UnitLevel" unique_id=1299333906] layout_mode = 2 size_flags_vertical = 8 texture = SubResource("AtlasTexture_uh1k2") -[node name="StylizedNumberDisplay" parent="UIBase/UnitPanel/TextureRect/Items" unique_id=702997768 instance=ExtResource("5_55shj")] +[node name="LevelNumber" parent="UIBase/UnitPanel/TextureRect/UnitLevel" unique_id=702997768 instance=ExtResource("5_55shj")] +unique_name_in_owner = true layout_mode = 2 sprite_sheet = SubResource("AtlasTexture_yayqj") number_sprite_width = 27 @@ -333,7 +334,7 @@ value = 12 [node name="UnitHealth" type="HBoxContainer" parent="UIBase/UnitPanel" unique_id=53239936] layout_mode = 0 -offset_left = 1.0 +offset_left = -102.0 offset_top = 103.0 offset_right = 225.0 offset_bottom = 131.0 @@ -415,3 +416,17 @@ size_flags_vertical = 0 sprite_sheet = SubResource("AtlasTexture_ox7qj") number_sprite_width = 13 number_sprite_height = 15 + +[node name="UnitName" type="RichTextLabel" parent="UIBase/UnitPanel" unique_id=1945794101] +unique_name_in_owner = true +layout_mode = 0 +offset_left = 69.0 +offset_top = 51.0 +offset_right = 258.0 +offset_bottom = 66.0 +theme = ExtResource("1_2ro41") +theme_override_font_sizes/normal_font_size = 16 +theme_override_font_sizes/bold_font_size = 16 +bbcode_enabled = true +scroll_active = false +text_direction = 2 diff --git a/prefabs/deployed_unit.tscn b/prefabs/deployed_unit.tscn index 1677f5d..2aa7cce 100644 --- a/prefabs/deployed_unit.tscn +++ b/prefabs/deployed_unit.tscn @@ -3,6 +3,7 @@ [ext_resource type="Script" uid="uid://cmh4lphvboggy" path="res://scripts/battle/deployed_units/deployed_unit.gd" id="1_cq4v0"] [ext_resource type="Texture2D" uid="uid://cw5su6lignryo" path="res://assets/sprites/flag.png" id="2_fhs1y"] [ext_resource type="Shader" uid="uid://bd8ki8xwym5nc" path="res://shaders/chroma_key.gdshader" id="3_fhs1y"] + [sub_resource type="GDScript" id="GDScript_on614"] resource_name = "UnitSelectorHandler" script/source = "extends ColorRect diff --git a/resources/units/appearance_sets/lily_child_deployed.tres b/resources/units/appearance_sets/lily_child_deployed.tres index a6068a9..88ad11b 100644 --- a/resources/units/appearance_sets/lily_child_deployed.tres +++ b/resources/units/appearance_sets/lily_child_deployed.tres @@ -101,7 +101,7 @@ animations = [{ }], "loop": true, "name": &"down", -"speed": 8.0 +"speed": 5.0 }, { "frames": [{ "duration": 1.0, @@ -118,7 +118,7 @@ animations = [{ }], "loop": true, "name": &"idle", -"speed": 8.0 +"speed": 5.0 }, { "frames": [{ "duration": 1.0, @@ -135,7 +135,7 @@ animations = [{ }], "loop": true, "name": &"left", -"speed": 8.0 +"speed": 5.0 }, { "frames": [{ "duration": 1.0, @@ -152,7 +152,7 @@ animations = [{ }], "loop": true, "name": &"right", -"speed": 8.0 +"speed": 5.0 }, { "frames": [{ "duration": 1.0, @@ -169,7 +169,7 @@ animations = [{ }], "loop": true, "name": &"up", -"speed": 8.0 +"speed": 5.0 }] [resource] diff --git a/resources/units/lily_child.tres b/resources/units/lily_child.tres index 899882c..eba1926 100644 --- a/resources/units/lily_child.tres +++ b/resources/units/lily_child.tres @@ -22,7 +22,7 @@ metadata/_custom_type_script = "uid://d37ulss2k0bq5" [sub_resource type="Resource" id="Resource_nc6h6"] script = ExtResource("5_rqhbp") -max_hp = 20 +max_hp = 156 metadata/_custom_type_script = "uid://cydoey8a8nmb8" [resource] diff --git a/scenes/views/main_menu_view.tscn b/scenes/views/main_menu_view.tscn index a3a1765..2913ce2 100644 --- a/scenes/views/main_menu_view.tscn +++ b/scenes/views/main_menu_view.tscn @@ -87,6 +87,7 @@ func _pressed() -> void: var player_unit: Unit = LILY_CHILD.duplicate(true) player_unit.allegiance = PLAYER_ALLEGIANCE + player_unit.stats.level = 68 combat_map.deploy_unit(player_unit, Vector2i(3, 3)) var enemy_unit: Unit = LILY_CHILD.duplicate(true) diff --git a/scripts/battle/combat_ui.gd b/scripts/battle/combat_ui.gd index d7cd607..616c1ba 100644 --- a/scripts/battle/combat_ui.gd +++ b/scripts/battle/combat_ui.gd @@ -4,6 +4,8 @@ signal fight_confirmed(proposal: CombatProposal) signal fight_cancelled @onready var unit_panel: Control = %UnitPanel +@onready var unit_name_label: RichTextLabel = %UnitName +@onready var level_number: StylizedNumberDisplay = %LevelNumber @onready var health_chip_bar: ChipBar = %HealthChipBar @onready var health_number: StylizedNumberDisplay = %HealthNumber @onready var sp_chip_bar: ChipBar = %SPChipBar @@ -82,6 +84,8 @@ func _on_unit_selected_changed(deployed: DeployedUnit, selected: bool) -> void: func _refresh_unit_panel() -> void: var stats := _selected_unit.current_stats + unit_name_label.text = "[b]%s[/b]" % _selected_unit.unit.info.name + level_number.value = stats.level health_chip_bar.max_value = stats.max_hp health_chip_bar.value = stats.current_hp health_number.value = stats.current_hp diff --git a/scripts/battle/deployed_units/deployed_unit_stats.gd b/scripts/battle/deployed_units/deployed_unit_stats.gd index 5f55fb2..4f6b87d 100644 --- a/scripts/battle/deployed_units/deployed_unit_stats.gd +++ b/scripts/battle/deployed_units/deployed_unit_stats.gd @@ -33,6 +33,8 @@ var lck: int: get: return unit_stats.lck var mov: int: get: return unit_stats.mov +var level: int: + get: return unit_stats.level static func from_unit_stats(source: UnitStats) -> DeployedUnitStats: var stats := DeployedUnitStats.new() diff --git a/scripts/ui/chip_bar.gd b/scripts/ui/chip_bar.gd index 05838f1..6ec05a6 100644 --- a/scripts/ui/chip_bar.gd +++ b/scripts/ui/chip_bar.gd @@ -38,10 +38,11 @@ func _refresh() -> void: var chip_width := filled_chip_texture.get_width() _container.custom_minimum_size.x = chip_width * max_chips_per_row + var empty_count := max_value - value for i in max_value: var tex_rect := TextureRect.new() - if i < value: - tex_rect.texture = filled_chip_texture - else: + if i < empty_count: tex_rect.texture = empty_chip_texture + else: + tex_rect.texture = filled_chip_texture _container.add_child(tex_rect) diff --git a/scripts/units/unit_stats.gd b/scripts/units/unit_stats.gd index 206cc6c..1fc2fc3 100644 --- a/scripts/units/unit_stats.gd +++ b/scripts/units/unit_stats.gd @@ -13,3 +13,6 @@ class_name UnitStats extends Resource @export var eva: int = 1 @export var lck: int = 1 @export var mov: int = 3 + +@export var level: int = 1 +@export var experience: int = 0