ajout d'une animation de recharge et réparation du crash au chargement de chunk
This commit is contained in:
58
gui/game/energy_info/energy_info.tscn
Normal file
58
gui/game/energy_info/energy_info.tscn
Normal file
@@ -0,0 +1,58 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://brfsapvj2quxm"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://0dhj8sdpil7q" path="res://gui/tools/control_animation_player.gd" id="1_g7kwx"]
|
||||
[ext_resource type="Script" uid="uid://b77b1yr81r462" path="res://gui/game/energy_info/scripts/energy_info.gd" id="1_h7p5h"]
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/hud.tres" id="2_h7p5h"]
|
||||
[ext_resource type="FontFile" uid="uid://qt80w6o01q5s" path="res://gui/ressources/fonts/TitanOne-Regular.ttf" id="3_c14dn"]
|
||||
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="4_rqwov"]
|
||||
|
||||
[node name="EnergyInfo" type="HBoxContainer"]
|
||||
modulate = Color(1, 0, 0, 1)
|
||||
offset_right = 167.0
|
||||
offset_bottom = 75.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
theme_override_constants/separation = 0
|
||||
alignment = 1
|
||||
script = ExtResource("1_h7p5h")
|
||||
wanted_max_energy = 3
|
||||
|
||||
[node name="EnergyAnimationPlayer" type="Node" parent="."]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("1_g7kwx")
|
||||
metadata/_custom_type_script = "uid://0dhj8sdpil7q"
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
theme_override_constants/margin_left = 0
|
||||
theme_override_constants/margin_top = -25
|
||||
theme_override_constants/margin_right = 0
|
||||
theme_override_constants/margin_bottom = -15
|
||||
|
||||
[node name="EnergyCount" type="RichTextLabel" parent="MarginContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme = ExtResource("2_h7p5h")
|
||||
theme_override_fonts/normal_font = ExtResource("3_c14dn")
|
||||
theme_override_fonts/bold_font = ExtResource("3_c14dn")
|
||||
theme_override_fonts/bold_italics_font = ExtResource("3_c14dn")
|
||||
theme_override_fonts/italics_font = ExtResource("3_c14dn")
|
||||
theme_override_font_sizes/normal_font_size = 30
|
||||
theme_override_font_sizes/bold_font_size = 100
|
||||
bbcode_enabled = true
|
||||
text = "[b]0[/b] / 3"
|
||||
fit_content = true
|
||||
autowrap_mode = 0
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="."]
|
||||
custom_minimum_size = Vector2(50, 50)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
texture = ExtResource("4_rqwov")
|
||||
expand_mode = 4
|
||||
stretch_mode = 5
|
||||
37
gui/game/energy_info/scripts/energy_info.gd
Normal file
37
gui/game/energy_info/scripts/energy_info.gd
Normal file
@@ -0,0 +1,37 @@
|
||||
@tool
|
||||
extends HBoxContainer
|
||||
class_name EnergyInfo
|
||||
|
||||
@export var wanted_energy = 0
|
||||
@export var wanted_max_energy = 0
|
||||
|
||||
var energy := 0
|
||||
var max_energy := 0
|
||||
|
||||
@export_tool_button("Update", "Callable") var update_action = func(): update(wanted_energy, wanted_max_energy)
|
||||
|
||||
func _ready():
|
||||
%EnergyAnimationPlayer.disappear()
|
||||
|
||||
func update(
|
||||
_energy : int,
|
||||
_max_energy : int,
|
||||
with_animation := true,
|
||||
):
|
||||
var changed = (energy != _energy or max_energy != _max_energy)
|
||||
if changed:
|
||||
print("Energy change with %d/%d" % [_energy, _max_energy])
|
||||
energy = _energy
|
||||
max_energy = _max_energy
|
||||
var energy_count_text = "[b]%d[/b] / %d" % [energy, max_energy]
|
||||
|
||||
if with_animation:
|
||||
%EnergyAnimationPlayer.bounce()
|
||||
%EnergyCount.text = energy_count_text
|
||||
modulate = Color.WHITE if energy > 0 else Color.RED
|
||||
|
||||
func appear():
|
||||
await %EnergyAnimationPlayer.appear()
|
||||
|
||||
func disappear():
|
||||
await %EnergyAnimationPlayer.disappear()
|
||||
1
gui/game/energy_info/scripts/energy_info.gd.uid
Normal file
1
gui/game/energy_info/scripts/energy_info.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b77b1yr81r462
|
||||
Reference in New Issue
Block a user