mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Unitframes now display the actual health values. Also smaller improvements to them.
This commit is contained in:
parent
157c5db604
commit
4ee06625ce
@ -8,55 +8,58 @@ export (PackedScene) var aura_entry_scene : PackedScene
|
|||||||
|
|
||||||
export (NodePath) var name_text_path : NodePath
|
export (NodePath) var name_text_path : NodePath
|
||||||
export (NodePath) var health_range_path : NodePath
|
export (NodePath) var health_range_path : NodePath
|
||||||
|
export (NodePath) var health_text_path : NodePath
|
||||||
export (NodePath) var aura_grid_path : NodePath
|
export (NodePath) var aura_grid_path : NodePath
|
||||||
|
|
||||||
var name_text : Label
|
var _name_text : Label
|
||||||
var health_range : Range
|
var _health_range : Range
|
||||||
var aura_grid : GridContainer
|
var _health_text : Label
|
||||||
|
var _aura_grid : GridContainer
|
||||||
|
|
||||||
var player : Entity
|
var _player : Entity
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
name_text = get_node(name_text_path) as Label
|
_name_text = get_node(name_text_path) as Label
|
||||||
health_range = get_node(health_range_path) as Range
|
_health_range = get_node(health_range_path) as Range
|
||||||
aura_grid = get_node(aura_grid_path) as GridContainer
|
_health_text = get_node(health_text_path) as Label
|
||||||
|
_aura_grid = get_node(aura_grid_path) as GridContainer
|
||||||
|
|
||||||
func set_player(p_player : Entity) -> void:
|
func set_player(p_player : Entity) -> void:
|
||||||
if not player == null and is_instance_valid(player):
|
if not _player == null and is_instance_valid(_player):
|
||||||
player.get_health().disconnect("c_changed", self, "_on_player_health_changed")
|
_player.get_health().disconnect("c_changed", self, "_on_player_health_changed")
|
||||||
player.disconnect("caura_added", self, "on_caura_added")
|
_player.disconnect("caura_added", self, "on_caura_added")
|
||||||
player.disconnect("caura_removed", self, "on_caura_removed")
|
_player.disconnect("caura_removed", self, "on_caura_removed")
|
||||||
player.disconnect("cdied", self, "cdied")
|
_player.disconnect("cdied", self, "cdied")
|
||||||
|
|
||||||
for a in aura_grid.get_children():
|
for a in _aura_grid.get_children():
|
||||||
aura_grid.remove_child(a)
|
_aura_grid.remove_child(a)
|
||||||
a.queue_free();
|
a.queue_free();
|
||||||
|
|
||||||
player = null
|
_player = null
|
||||||
set_process(false)
|
set_process(false)
|
||||||
|
|
||||||
if p_player == null:
|
if p_player == null:
|
||||||
hide()
|
hide()
|
||||||
return
|
return
|
||||||
|
|
||||||
player = p_player
|
_player = p_player
|
||||||
|
|
||||||
for index in range(player.cget_aura_count()):
|
for index in range(_player.cget_aura_count()):
|
||||||
var aura : AuraData = player.cget_aura(index)
|
var aura : AuraData = _player.cget_aura(index)
|
||||||
|
|
||||||
on_caura_added(aura)
|
on_caura_added(aura)
|
||||||
|
|
||||||
|
|
||||||
player.connect("caura_added", self, "on_caura_added")
|
_player.connect("caura_added", self, "on_caura_added")
|
||||||
player.connect("caura_removed", self, "on_caura_removed")
|
_player.connect("caura_removed", self, "on_caura_removed")
|
||||||
player.connect("cdied", self, "cdied")
|
_player.connect("cdied", self, "cdied")
|
||||||
|
|
||||||
var health = player.get_health()
|
var health = _player.get_health()
|
||||||
_on_player_health_changed(health)
|
_on_player_health_changed(health)
|
||||||
health.connect("c_changed", self, "_on_player_health_changed")
|
health.connect("c_changed", self, "_on_player_health_changed")
|
||||||
|
|
||||||
name_text.text = player.centity_name
|
_name_text.text = _player.centity_name
|
||||||
|
|
||||||
set_process(true)
|
set_process(true)
|
||||||
show()
|
show()
|
||||||
@ -64,28 +67,33 @@ func set_player(p_player : Entity) -> void:
|
|||||||
func on_caura_added(aura_data : AuraData) -> void:
|
func on_caura_added(aura_data : AuraData) -> void:
|
||||||
var created_node : Node = aura_entry_scene.instance()
|
var created_node : Node = aura_entry_scene.instance()
|
||||||
|
|
||||||
aura_grid.add_child(created_node)
|
_aura_grid.add_child(created_node)
|
||||||
created_node.owner = aura_grid
|
created_node.owner = _aura_grid
|
||||||
|
|
||||||
created_node.set_aura_data(aura_data)
|
created_node.set_aura_data(aura_data)
|
||||||
|
|
||||||
func on_caura_removed(aura_data : AuraData) -> void:
|
func on_caura_removed(aura_data : AuraData) -> void:
|
||||||
for bn in aura_grid.get_children():
|
for bn in _aura_grid.get_children():
|
||||||
if bn.get_aura_data() == aura_data:
|
if bn.get_aura_data() == aura_data:
|
||||||
aura_grid.remove_child(bn)
|
_aura_grid.remove_child(bn)
|
||||||
bn.queue_free()
|
bn.queue_free()
|
||||||
return
|
return
|
||||||
|
|
||||||
func _on_player_health_changed(health : Stat) -> void:
|
func _on_player_health_changed(health : Stat) -> void:
|
||||||
if health.cmax == 0:
|
if health.cmax == 0:
|
||||||
health_range.min_value = 0
|
_health_range.min_value = 0
|
||||||
health_range.max_value = 1
|
_health_range.max_value = 1
|
||||||
health_range.value = 0
|
_health_range.value = 0
|
||||||
|
|
||||||
|
_health_text.text = ""
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
health_range.min_value = 0
|
_health_range.min_value = 0
|
||||||
health_range.max_value = health.cmax
|
_health_range.max_value = health.cmax
|
||||||
health_range.value = health.ccurrent
|
_health_range.value = health.ccurrent
|
||||||
|
|
||||||
|
_health_text.text = str(health.ccurrent) + "/" + str(health.cmax)
|
||||||
|
|
||||||
func cdied(entity : Entity) -> void:
|
func cdied(entity : Entity) -> void:
|
||||||
set_player(null)
|
set_player(null)
|
||||||
|
@ -6,19 +6,21 @@
|
|||||||
[node name="TargetUnitframe" type="UnitFrame"]
|
[node name="TargetUnitframe" type="UnitFrame"]
|
||||||
margin_left = 151.0
|
margin_left = 151.0
|
||||||
margin_right = 300.0
|
margin_right = 300.0
|
||||||
margin_bottom = 60.0
|
margin_bottom = 57.0
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
aura_entry_scene = ExtResource( 2 )
|
aura_entry_scene = ExtResource( 2 )
|
||||||
name_text_path = NodePath("MarginContainer/HBoxContainer/VBoxContainer/Label")
|
name_text_path = NodePath("MarginContainer/HBoxContainer/VBoxContainer/Label")
|
||||||
health_range_path = NodePath("MarginContainer/HBoxContainer/VBoxContainer/ProgressBar")
|
health_range_path = NodePath("MarginContainer/HBoxContainer/VBoxContainer/MarginContainer/ProgressBar")
|
||||||
|
health_text_path = NodePath("MarginContainer/HBoxContainer/VBoxContainer/MarginContainer/Label")
|
||||||
aura_grid_path = NodePath("auras")
|
aura_grid_path = NodePath("auras")
|
||||||
|
|
||||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
margin_bottom = -1.0
|
||||||
custom_constants/margin_right = 2
|
custom_constants/margin_right = 2
|
||||||
custom_constants/margin_top = 2
|
custom_constants/margin_top = 2
|
||||||
custom_constants/margin_left = 2
|
custom_constants/margin_left = 2
|
||||||
@ -31,24 +33,37 @@ __meta__ = {
|
|||||||
margin_left = 2.0
|
margin_left = 2.0
|
||||||
margin_top = 2.0
|
margin_top = 2.0
|
||||||
margin_right = 147.0
|
margin_right = 147.0
|
||||||
margin_bottom = 60.0
|
margin_bottom = 54.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"]
|
||||||
margin_right = 145.0
|
margin_right = 145.0
|
||||||
margin_bottom = 58.0
|
margin_bottom = 52.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="MarginContainer/HBoxContainer/VBoxContainer"]
|
[node name="Label" type="Label" parent="MarginContainer/HBoxContainer/VBoxContainer"]
|
||||||
margin_right = 145.0
|
margin_right = 145.0
|
||||||
margin_bottom = 25.0
|
margin_bottom = 14.0
|
||||||
|
|
||||||
[node name="ProgressBar" type="ProgressBar" parent="MarginContainer/HBoxContainer/VBoxContainer"]
|
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer/VBoxContainer"]
|
||||||
margin_top = 33.0
|
margin_top = 18.0
|
||||||
margin_right = 145.0
|
margin_right = 145.0
|
||||||
margin_bottom = 58.0
|
margin_bottom = 32.0
|
||||||
|
|
||||||
|
[node name="ProgressBar" type="ProgressBar" parent="MarginContainer/HBoxContainer/VBoxContainer/MarginContainer"]
|
||||||
|
margin_right = 145.0
|
||||||
|
margin_bottom = 14.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
percent_visible = false
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="MarginContainer/HBoxContainer/VBoxContainer/MarginContainer"]
|
||||||
|
margin_right = 145.0
|
||||||
|
margin_bottom = 14.0
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
[node name="auras" type="GridContainer" parent="."]
|
[node name="auras" type="GridContainer" parent="."]
|
||||||
margin_left = 1.0
|
margin_left = 1.0
|
||||||
|
@ -7,11 +7,13 @@ extends Container
|
|||||||
export (NodePath) var name_text_path : NodePath
|
export (NodePath) var name_text_path : NodePath
|
||||||
export (NodePath) var level_text_path : NodePath
|
export (NodePath) var level_text_path : NodePath
|
||||||
export (NodePath) var health_range_path : NodePath
|
export (NodePath) var health_range_path : NodePath
|
||||||
|
export (NodePath) var health_text_path : NodePath
|
||||||
export (NodePath) var xp_range_path : NodePath
|
export (NodePath) var xp_range_path : NodePath
|
||||||
|
|
||||||
var _name_text : Label
|
var _name_text : Label
|
||||||
var _level_text : Label
|
var _level_text : Label
|
||||||
var _health_range : Range
|
var _health_range : Range
|
||||||
|
var _health_text : Label
|
||||||
var _xp_range : Range
|
var _xp_range : Range
|
||||||
|
|
||||||
var _player : Entity
|
var _player : Entity
|
||||||
@ -20,6 +22,7 @@ func _ready() -> void:
|
|||||||
_name_text = get_node(name_text_path)
|
_name_text = get_node(name_text_path)
|
||||||
_level_text = get_node(level_text_path)
|
_level_text = get_node(level_text_path)
|
||||||
_health_range = get_node(health_range_path)
|
_health_range = get_node(health_range_path)
|
||||||
|
_health_text = get_node(health_text_path)
|
||||||
_xp_range = get_node(xp_range_path)
|
_xp_range = get_node(xp_range_path)
|
||||||
|
|
||||||
func set_player(p_player: Entity) -> void:
|
func set_player(p_player: Entity) -> void:
|
||||||
@ -59,12 +62,17 @@ func _on_player_health_changed(health: Stat) -> void:
|
|||||||
_health_range.min_value = 0
|
_health_range.min_value = 0
|
||||||
_health_range.max_value = 1
|
_health_range.max_value = 1
|
||||||
_health_range.value = 0
|
_health_range.value = 0
|
||||||
|
|
||||||
|
_health_text.text = ""
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
_health_range.min_value = 0
|
_health_range.min_value = 0
|
||||||
_health_range.max_value = health.cmax
|
_health_range.max_value = health.cmax
|
||||||
_health_range.value = health.ccurrent
|
_health_range.value = health.ccurrent
|
||||||
|
|
||||||
|
_health_text.text = str(health.ccurrent) + "/" + str(health.cmax)
|
||||||
|
|
||||||
func cname_changed(entity: Entity) -> void:
|
func cname_changed(entity: Entity) -> void:
|
||||||
_name_text.text = _player.centity_name
|
_name_text.text = _player.centity_name
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
[node name="UnitFrame" type="PanelContainer"]
|
[node name="UnitFrame" type="PanelContainer"]
|
||||||
margin_right = 150.0
|
margin_right = 150.0
|
||||||
margin_bottom = 69.0
|
margin_bottom = 61.0
|
||||||
theme = ExtResource( 2 )
|
theme = ExtResource( 2 )
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
@ -13,14 +13,15 @@ __meta__ = {
|
|||||||
}
|
}
|
||||||
name_text_path = NodePath("VBoxContainer/HBoxContainer/Label")
|
name_text_path = NodePath("VBoxContainer/HBoxContainer/Label")
|
||||||
level_text_path = NodePath("VBoxContainer/HBoxContainer/Label2")
|
level_text_path = NodePath("VBoxContainer/HBoxContainer/Label2")
|
||||||
health_range_path = NodePath("VBoxContainer/ProgressBar")
|
health_range_path = NodePath("VBoxContainer/MarginContainer/ProgressBar")
|
||||||
|
health_text_path = NodePath("VBoxContainer/MarginContainer/Label")
|
||||||
xp_range_path = NodePath("VBoxContainer/XPBar")
|
xp_range_path = NodePath("VBoxContainer/XPBar")
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
margin_left = 4.0
|
margin_left = 4.0
|
||||||
margin_top = 4.0
|
margin_top = 4.0
|
||||||
margin_right = 146.0
|
margin_right = 146.0
|
||||||
margin_bottom = 65.0
|
margin_bottom = 57.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
custom_constants/separation = 1
|
custom_constants/separation = 1
|
||||||
@ -30,7 +31,7 @@ margin_right = 142.0
|
|||||||
margin_bottom = 15.0
|
margin_bottom = 15.0
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
|
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
|
||||||
margin_right = 134.0
|
margin_right = 138.0
|
||||||
margin_bottom = 15.0
|
margin_bottom = 15.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
@ -39,22 +40,48 @@ margin_left = 142.0
|
|||||||
margin_right = 142.0
|
margin_right = 142.0
|
||||||
margin_bottom = 15.0
|
margin_bottom = 15.0
|
||||||
|
|
||||||
[node name="ProgressBar" type="ProgressBar" parent="VBoxContainer"]
|
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"]
|
||||||
margin_top = 16.0
|
margin_top = 16.0
|
||||||
margin_right = 142.0
|
margin_right = 142.0
|
||||||
margin_bottom = 35.0
|
margin_bottom = 31.0
|
||||||
size_flags_horizontal = 3
|
|
||||||
|
|
||||||
[node name="ResourceBar" type="ProgressBar" parent="VBoxContainer"]
|
[node name="ProgressBar" type="ProgressBar" parent="VBoxContainer/MarginContainer"]
|
||||||
margin_top = 36.0
|
|
||||||
margin_right = 142.0
|
margin_right = 142.0
|
||||||
margin_bottom = 55.0
|
margin_bottom = 15.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
percent_visible = false
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer/MarginContainer"]
|
||||||
|
margin_right = 142.0
|
||||||
|
margin_bottom = 15.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="MarginContainer2" type="MarginContainer" parent="VBoxContainer"]
|
||||||
|
margin_top = 32.0
|
||||||
|
margin_right = 142.0
|
||||||
|
margin_bottom = 47.0
|
||||||
|
|
||||||
|
[node name="ResourceBar" type="ProgressBar" parent="VBoxContainer/MarginContainer2"]
|
||||||
|
margin_right = 142.0
|
||||||
|
margin_bottom = 15.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
percent_visible = false
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer/MarginContainer2"]
|
||||||
|
margin_right = 142.0
|
||||||
|
margin_bottom = 15.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="XPBar" type="ProgressBar" parent="VBoxContainer"]
|
[node name="XPBar" type="ProgressBar" parent="VBoxContainer"]
|
||||||
margin_top = 56.0
|
margin_top = 48.0
|
||||||
margin_right = 142.0
|
margin_right = 142.0
|
||||||
margin_bottom = 61.6018
|
margin_bottom = 53.6018
|
||||||
rect_min_size = Vector2( 20, 5 )
|
rect_min_size = Vector2( 20, 5 )
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
percent_visible = false
|
percent_visible = false
|
||||||
|
Loading…
Reference in New Issue
Block a user