Unit panel rewire
This commit is contained in:
19
prefabs/chip_bar.tscn
Normal file
19
prefabs/chip_bar.tscn
Normal file
@@ -0,0 +1,19 @@
|
||||
[gd_scene format=3 uid="uid://8edgswcwdiwu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cvmmsm13nyr62" path="res://scripts/ui/chip_bar.gd" id="1_3whrn"]
|
||||
|
||||
[node name="ChipBar" type="Control" unique_id=379110810]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_3whrn")
|
||||
|
||||
[node name="HFlowContainer" type="HFlowContainer" parent="." unique_id=185867767]
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
theme_override_constants/h_separation = 0
|
||||
theme_override_constants/v_separation = 0
|
||||
@@ -4,7 +4,8 @@
|
||||
[ext_resource type="Script" uid="uid://w2wh6gtv3u2l" path="res://scripts/battle/combat_ui.gd" id="2_ui_script"]
|
||||
[ext_resource type="Texture2D" uid="uid://cavpqnd0qqoou" path="res://assets/ui/SO008B.BMP" id="3_hadma"]
|
||||
[ext_resource type="Texture2D" uid="uid://cau61m1755dkn" path="res://assets/ui/SO008A.BMP" id="3_tfn3h"]
|
||||
[ext_resource type="PackedScene" uid="uid://bc5a7tb0my6n5" path="res://prefabs/StylizedNumberDisplay.tscn" id="5_55shj"]
|
||||
[ext_resource type="PackedScene" uid="uid://bc5a7tb0my6n5" path="res://prefabs/stylized_number_display.tscn" id="5_55shj"]
|
||||
[ext_resource type="PackedScene" uid="uid://8edgswcwdiwu" path="res://prefabs/chip_bar.tscn" id="6_gqe5k"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_hadma"]
|
||||
atlas = ExtResource("3_tfn3h")
|
||||
@@ -18,6 +19,10 @@ region = Rect2(393, 280, 168, 77)
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(141, 0, 513, 169)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_hr2yf"]
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(393, 169, 263, 111)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3wejr"]
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(614, 711, 137, 26)
|
||||
@@ -28,7 +33,23 @@ region = Rect2(614, 737, 55, 20)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_yayqj"]
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(546, 839, 272, 39)
|
||||
region = Rect2(547, 839, 270, 36)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_eskga"]
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(249, 272, 3, 14)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_14b7f"]
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(246, 272, 3, 14)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_manhy"]
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(1055, 151, 28, 19)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ox7qj"]
|
||||
atlas = ExtResource("3_hadma")
|
||||
region = Rect2(547, 824, 130, 15)
|
||||
|
||||
[node name="BattleViewUI" type="CanvasLayer" unique_id=1093388037]
|
||||
script = ExtResource("2_ui_script")
|
||||
@@ -76,6 +97,14 @@ offset_bottom = 169.0
|
||||
grow_horizontal = 0
|
||||
texture = SubResource("AtlasTexture_gqe5k")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="UIBase/Overlay" unique_id=1469571203]
|
||||
layout_mode = 0
|
||||
offset_left = 536.0
|
||||
offset_top = 432.0
|
||||
offset_right = 799.0
|
||||
offset_bottom = 543.0
|
||||
texture = SubResource("AtlasTexture_hr2yf")
|
||||
|
||||
[node name="UnitPanel" type="PanelContainer" parent="UIBase" unique_id=2000000001]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
@@ -254,59 +283,69 @@ anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -241.0
|
||||
offset_left = -265.0
|
||||
offset_top = -194.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="UIBase/UnitPanel2" unique_id=1655913738]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Level" type="Control" parent="UIBase/UnitPanel2/VBoxContainer" unique_id=1040926780]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="UIBase/UnitPanel2/VBoxContainer/Level" unique_id=691752297]
|
||||
[node name="TextureRect" type="TextureRect" parent="UIBase/UnitPanel2" unique_id=691752297]
|
||||
layout_mode = 0
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -137.0
|
||||
offset_top = -13.0
|
||||
offset_bottom = 13.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
offset_left = 128.0
|
||||
offset_right = 265.0
|
||||
offset_bottom = 26.0
|
||||
size_flags_horizontal = 8
|
||||
texture = SubResource("AtlasTexture_3wejr")
|
||||
|
||||
[node name="Items" type="HBoxContainer" parent="UIBase/UnitPanel2/VBoxContainer/Level" unique_id=828992814]
|
||||
layout_mode = 0
|
||||
[node name="Items" type="HBoxContainer" parent="UIBase/UnitPanel2/TextureRect" unique_id=828992814]
|
||||
layout_mode = 1
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -241.0
|
||||
offset_top = -10.0
|
||||
offset_bottom = 10.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -63.0
|
||||
offset_top = -20.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="Spacer" type="Control" parent="UIBase/UnitPanel2/VBoxContainer/Level/Items" unique_id=1068603879]
|
||||
[node name="Spacer" type="Control" parent="UIBase/UnitPanel2/TextureRect/Items" unique_id=1068603879]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="TextureRect" parent="UIBase/UnitPanel2/VBoxContainer/Level/Items" unique_id=1299333906]
|
||||
[node name="Label" type="TextureRect" parent="UIBase/UnitPanel2/TextureRect/Items" unique_id=1299333906]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
texture = SubResource("AtlasTexture_uh1k2")
|
||||
|
||||
[node name="StylizedNumberDisplay" parent="UIBase/UnitPanel2/VBoxContainer/Level/Items" unique_id=702997768 instance=ExtResource("5_55shj")]
|
||||
[node name="StylizedNumberDisplay" parent="UIBase/UnitPanel2/TextureRect/Items" unique_id=702997768 instance=ExtResource("5_55shj")]
|
||||
layout_mode = 2
|
||||
sprite_sheet = SubResource("AtlasTexture_yayqj")
|
||||
number_sprite_width = 28
|
||||
number_sprite_height = 36
|
||||
number_sprite_width = 27
|
||||
number_sprite_height = 39
|
||||
value = 12
|
||||
|
||||
[node name="UnitHealth" type="HBoxContainer" parent="UIBase/UnitPanel2" unique_id=53239936]
|
||||
layout_mode = 0
|
||||
offset_left = 185.0
|
||||
offset_top = 103.0
|
||||
offset_right = 225.0
|
||||
offset_bottom = 143.0
|
||||
|
||||
[node name="ChipBar" parent="UIBase/UnitPanel2/UnitHealth" unique_id=379110810 instance=ExtResource("6_gqe5k")]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
max_chips_per_row = 100
|
||||
empty_chip_texture = SubResource("AtlasTexture_eskga")
|
||||
filled_chip_texture = SubResource("AtlasTexture_14b7f")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="UIBase/UnitPanel2/UnitHealth" unique_id=668812970]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
texture = SubResource("AtlasTexture_manhy")
|
||||
|
||||
[node name="StylizedNumberDisplay" parent="UIBase/UnitPanel2/UnitHealth" unique_id=1442983008 instance=ExtResource("5_55shj")]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
sprite_sheet = SubResource("AtlasTexture_ox7qj")
|
||||
number_sprite_width = 13
|
||||
number_sprite_height = 15
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
[ext_resource type="Texture2D" uid="uid://b8td6sv5re6r8" path="res://assets/sprites/grey_castle_spritesheet_mask.bmp" id="2_7ddre"]
|
||||
[ext_resource type="Texture2D" uid="uid://b20mhn7ca5xyo" path="res://assets/sprites/aux_terrain.BMP" id="5_qjeyg"]
|
||||
[ext_resource type="Script" uid="uid://csdcbi2gtwrly" path="res://scripts/battle/camera_controller.gd" id="6_wtsjf"]
|
||||
[ext_resource type="PackedScene" uid="uid://bc5a7tb0my6n5" path="res://prefabs/StylizedNumberDisplay.tscn" id="7_rnaij"]
|
||||
[ext_resource type="PackedScene" uid="uid://bc5a7tb0my6n5" path="res://prefabs/stylized_number_display.tscn" id="7_rnaij"]
|
||||
[ext_resource type="PackedScene" uid="uid://8edgswcwdiwu" path="res://prefabs/chip_bar.tscn" id="8_h3xc6"]
|
||||
[ext_resource type="Texture2D" uid="uid://cavpqnd0qqoou" path="res://assets/ui/SO008B.BMP" id="9_s36qc"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_qjeyg"]
|
||||
texture = ExtResource("1_7ddre")
|
||||
@@ -55,6 +57,14 @@ region = Rect2(0, 100, 100, 100)
|
||||
atlas = ExtResource("5_qjeyg")
|
||||
region = Rect2(210, 0, 41, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6qxox"]
|
||||
atlas = ExtResource("9_s36qc")
|
||||
region = Rect2(249, 272, 3, 14)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gthg3"]
|
||||
atlas = ExtResource("9_s36qc")
|
||||
region = Rect2(246, 272, 3, 14)
|
||||
|
||||
[node name="TestScene" type="Node2D" unique_id=1687841395]
|
||||
|
||||
[node name="TileMapLayer" type="TileMapLayer" parent="." unique_id=265586128]
|
||||
@@ -73,7 +83,16 @@ texture = SubResource("AtlasTexture_3qnke")
|
||||
script = ExtResource("6_wtsjf")
|
||||
metadata/_custom_type_script = "uid://csdcbi2gtwrly"
|
||||
|
||||
[node name="StylizedNumberDisplay" parent="." unique_id=702997768 instance=ExtResource("7_rnaij")]
|
||||
[node name="Control" type="Control" parent="." unique_id=794632273]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="StylizedNumberDisplay" parent="Control" unique_id=702997768 instance=ExtResource("7_rnaij")]
|
||||
layout_mode = 0
|
||||
anchors_preset = 0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
@@ -84,3 +103,15 @@ grow_vertical = 1
|
||||
number_sprite_width = 27
|
||||
number_sprite_height = 36
|
||||
value = 1234567890
|
||||
|
||||
[node name="ChipBar" parent="Control" unique_id=379110810 instance=ExtResource("8_h3xc6")]
|
||||
layout_mode = 1
|
||||
offset_left = -87.0
|
||||
offset_top = -101.0
|
||||
offset_right = -37.0
|
||||
offset_bottom = -1.0
|
||||
value = 5
|
||||
max_value = 5
|
||||
max_chips_per_row = 10
|
||||
empty_chip_texture = SubResource("AtlasTexture_6qxox")
|
||||
filled_chip_texture = SubResource("AtlasTexture_gthg3")
|
||||
|
||||
47
scripts/ui/chip_bar.gd
Normal file
47
scripts/ui/chip_bar.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
class_name ChipBar extends Control
|
||||
|
||||
# The value to represent in filled chips. In the future chips may be colored differently above certain thresholds to stop drawing too many
|
||||
@export var value: int:
|
||||
set(v):
|
||||
value = v
|
||||
if is_node_ready():
|
||||
_refresh()
|
||||
|
||||
# The total number of chips. If value is less than this, those chips should be empty.
|
||||
@export var max_value: int:
|
||||
set(v):
|
||||
max_value = v
|
||||
if is_node_ready():
|
||||
_refresh()
|
||||
|
||||
# Configures the size of the hflow based on the chip texture size.
|
||||
@export var max_chips_per_row: int
|
||||
|
||||
# The texture for an empty chip
|
||||
@export var empty_chip_texture: Texture2D
|
||||
|
||||
# The texture for a filled chip
|
||||
@export var filled_chip_texture: Texture2D
|
||||
|
||||
@onready var _container: HFlowContainer = $HFlowContainer
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_refresh()
|
||||
|
||||
|
||||
func _refresh() -> void:
|
||||
for child in _container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
if filled_chip_texture and max_chips_per_row > 0:
|
||||
var chip_width := filled_chip_texture.get_width()
|
||||
_container.custom_minimum_size.x = chip_width * max_chips_per_row
|
||||
|
||||
for i in max_value:
|
||||
var tex_rect := TextureRect.new()
|
||||
if i < value:
|
||||
tex_rect.texture = filled_chip_texture
|
||||
else:
|
||||
tex_rect.texture = empty_chip_texture
|
||||
_container.add_child(tex_rect)
|
||||
1
scripts/ui/chip_bar.gd.uid
Normal file
1
scripts/ui/chip_bar.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cvmmsm13nyr62
|
||||
Reference in New Issue
Block a user