From bdb610b1e445debe8c9343bb7755079dae607dd0 Mon Sep 17 00:00:00 2001 From: Raxki Date: Mon, 14 Oct 2024 10:17:22 -0400 Subject: [PATCH] Add textured HP bars --- Scripts/ui.gd | 4 +-- UI/battle_ui.tscn | 49 +++++++++++++++++++++------------- UI/hp_bar_border.png | 3 +++ UI/hp_bar_border.png.import | 34 +++++++++++++++++++++++ UI/hp_bar_border_bg.png | 3 +++ UI/hp_bar_border_bg.png.import | 34 +++++++++++++++++++++++ UI/hp_bar_green.png | 3 +++ UI/hp_bar_green.png.import | 34 +++++++++++++++++++++++ UI/hp_bar_redpng.png | 3 +++ UI/hp_bar_redpng.png.import | 34 +++++++++++++++++++++++ 10 files changed, 181 insertions(+), 20 deletions(-) create mode 100644 UI/hp_bar_border.png create mode 100644 UI/hp_bar_border.png.import create mode 100644 UI/hp_bar_border_bg.png create mode 100644 UI/hp_bar_border_bg.png.import create mode 100644 UI/hp_bar_green.png create mode 100644 UI/hp_bar_green.png.import create mode 100644 UI/hp_bar_redpng.png create mode 100644 UI/hp_bar_redpng.png.import diff --git a/Scripts/ui.gd b/Scripts/ui.gd index d1e6096..e50f4f8 100644 --- a/Scripts/ui.gd +++ b/Scripts/ui.gd @@ -1,7 +1,7 @@ extends Control -@onready var player_health_bar: ProgressBar = $MarginContainer/HBoxContainer/HealthBar -@onready var enemy_health_bar: ProgressBar = $MarginContainer/HBoxContainer/EnemyBar +@onready var player_health_bar: TextureProgressBar = $MarginContainer/HBoxContainer/HealthBar +@onready var enemy_health_bar: TextureProgressBar = $MarginContainer/HBoxContainer/EnemyBar func initialize(player: PlayableCharacter, enemy: AICharacter): player_health_bar.max_value = player.max_health diff --git a/UI/battle_ui.tscn b/UI/battle_ui.tscn index 021c0c6..b206ab8 100644 --- a/UI/battle_ui.tscn +++ b/UI/battle_ui.tscn @@ -1,12 +1,10 @@ -[gd_scene load_steps=4 format=3 uid="uid://ce2tjyxwaar01"] +[gd_scene load_steps=6 format=3 uid="uid://ce2tjyxwaar01"] [ext_resource type="Script" path="res://Scripts/ui.gd" id="1_pbo7d"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3rm2j"] -bg_color = Color(0.12549, 0.72549, 0, 1) - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_688ss"] -bg_color = Color(1, 0.25098, 0.262745, 1) +[ext_resource type="Texture2D" uid="uid://bavf70a0as4yp" path="res://UI/hp_bar_border_bg.png" id="2_puub5"] +[ext_resource type="Texture2D" uid="uid://bastebwa8n686" path="res://UI/hp_bar_border.png" id="3_y0hpc"] +[ext_resource type="Texture2D" uid="uid://btu7bkrjnk3ph" path="res://UI/hp_bar_green.png" id="4_vjleo"] +[ext_resource type="Texture2D" uid="uid://dp8pfpterhtai" path="res://UI/hp_bar_redpng.png" id="5_uk45e"] [node name="UI" type="Control"] layout_mode = 3 @@ -31,26 +29,41 @@ theme_override_constants/margin_right = 16 custom_minimum_size = Vector2(0, 16) layout_mode = 2 -[node name="HealthBar" type="ProgressBar" parent="MarginContainer/HBoxContainer"] +[node name="HealthBar" type="TextureProgressBar" parent="MarginContainer/HBoxContainer"] +texture_filter = 1 +custom_minimum_size = Vector2(0, 12) layout_mode = 2 size_flags_horizontal = 3 -size_flags_vertical = 1 +size_flags_vertical = 0 size_flags_stretch_ratio = 2.0 -theme_override_styles/fill = SubResource("StyleBoxFlat_3rm2j") -step = 1.0 value = 50.0 -show_percentage = false +nine_patch_stretch = true +stretch_margin_left = 4 +stretch_margin_top = 4 +stretch_margin_right = 4 +stretch_margin_bottom = 4 +texture_under = ExtResource("2_puub5") +texture_over = ExtResource("3_y0hpc") +texture_progress = ExtResource("4_vjleo") [node name="Spacer" type="Control" parent="MarginContainer/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 +size_flags_stretch_ratio = 2.0 -[node name="EnemyBar" type="ProgressBar" parent="MarginContainer/HBoxContainer"] +[node name="EnemyBar" type="TextureProgressBar" parent="MarginContainer/HBoxContainer"] +texture_filter = 1 +custom_minimum_size = Vector2(0, 12) layout_mode = 2 size_flags_horizontal = 3 -size_flags_vertical = 1 +size_flags_vertical = 0 size_flags_stretch_ratio = 2.0 -theme_override_styles/fill = SubResource("StyleBoxFlat_688ss") -step = 1.0 -value = 13.0 -show_percentage = false +value = 50.0 +nine_patch_stretch = true +stretch_margin_left = 4 +stretch_margin_top = 4 +stretch_margin_right = 4 +stretch_margin_bottom = 4 +texture_under = ExtResource("2_puub5") +texture_over = ExtResource("3_y0hpc") +texture_progress = ExtResource("5_uk45e") diff --git a/UI/hp_bar_border.png b/UI/hp_bar_border.png new file mode 100644 index 0000000..c44ea36 --- /dev/null +++ b/UI/hp_bar_border.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6e6b7c0a3f6ceab073e21f3a5d56d54380f7cd374f2a3adf549f379475d8470 +size 237 diff --git a/UI/hp_bar_border.png.import b/UI/hp_bar_border.png.import new file mode 100644 index 0000000..9f7a855 --- /dev/null +++ b/UI/hp_bar_border.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bastebwa8n686" +path="res://.godot/imported/hp_bar_border.png-a32c80a7fdc781b0bf2d9852e6618966.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/hp_bar_border.png" +dest_files=["res://.godot/imported/hp_bar_border.png-a32c80a7fdc781b0bf2d9852e6618966.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/UI/hp_bar_border_bg.png b/UI/hp_bar_border_bg.png new file mode 100644 index 0000000..f60e606 --- /dev/null +++ b/UI/hp_bar_border_bg.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53ee5727b61304eb2cd7d77a23b7927b13f4eda665ca409ae2e6a1fb8220bd71 +size 204 diff --git a/UI/hp_bar_border_bg.png.import b/UI/hp_bar_border_bg.png.import new file mode 100644 index 0000000..ab4fd4a --- /dev/null +++ b/UI/hp_bar_border_bg.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bavf70a0as4yp" +path="res://.godot/imported/hp_bar_border_bg.png-362420a8e13a5d9dff335822c6f738a0.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/hp_bar_border_bg.png" +dest_files=["res://.godot/imported/hp_bar_border_bg.png-362420a8e13a5d9dff335822c6f738a0.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/UI/hp_bar_green.png b/UI/hp_bar_green.png new file mode 100644 index 0000000..53dc90e --- /dev/null +++ b/UI/hp_bar_green.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04416fd6f478712e968b3a9f5e024d5e8137f9a4f9d7063a2683bebf79037de5 +size 332 diff --git a/UI/hp_bar_green.png.import b/UI/hp_bar_green.png.import new file mode 100644 index 0000000..5cf83c6 --- /dev/null +++ b/UI/hp_bar_green.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://btu7bkrjnk3ph" +path="res://.godot/imported/hp_bar_green.png-f41c6b471c3c4ba32159cc3ea9f6a619.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/hp_bar_green.png" +dest_files=["res://.godot/imported/hp_bar_green.png-f41c6b471c3c4ba32159cc3ea9f6a619.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/UI/hp_bar_redpng.png b/UI/hp_bar_redpng.png new file mode 100644 index 0000000..119d928 --- /dev/null +++ b/UI/hp_bar_redpng.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f94a80dbe16fa99cf70bf87c8bbac2f7fd1229fb551f73546cd9e334b93e8dc2 +size 339 diff --git a/UI/hp_bar_redpng.png.import b/UI/hp_bar_redpng.png.import new file mode 100644 index 0000000..deda17f --- /dev/null +++ b/UI/hp_bar_redpng.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dp8pfpterhtai" +path="res://.godot/imported/hp_bar_redpng.png-9f79fa0bbd5c79f53e2343b6eccd345a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/hp_bar_redpng.png" +dest_files=["res://.godot/imported/hp_bar_redpng.png-9f79fa0bbd5c79f53e2343b6eccd345a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1