added save mechanic
This commit is contained in:
parent
b24117740b
commit
04873e3880
226 changed files with 4577 additions and 38 deletions
|
|
@ -2,6 +2,48 @@ extends MarginContainer
|
|||
class_name IngameControls
|
||||
|
||||
signal menu_button_clicked
|
||||
signal settings_button_clicked
|
||||
signal save_button_clicked
|
||||
signal save_button_released
|
||||
signal save_timer_incremented(value: int)
|
||||
signal save_timer_reached
|
||||
|
||||
var save_button_held_down: bool = false
|
||||
var save_timer: float = 0.0
|
||||
var time_to_save: float = 0.8 # second
|
||||
|
||||
func _process(delta) -> void:
|
||||
if save_button_held_down:
|
||||
if save_timer >= time_to_save:
|
||||
save_timer_reached.emit()
|
||||
save_timer = 0.0
|
||||
save_button_held_down = false
|
||||
else:
|
||||
save_timer_incremented.emit(ceili((save_timer / time_to_save) * 100))
|
||||
save_timer += delta
|
||||
|
||||
func _on_menu_button_pressed() -> void:
|
||||
menu_button_clicked.emit()
|
||||
|
||||
func _on_settings_button_pressed() -> void:
|
||||
settings_button_clicked.emit()
|
||||
|
||||
# the save function should work as follows:
|
||||
# a percentage sign with 0% should be shown
|
||||
# the player has to hold down the save button
|
||||
# during holding down, the percentage increases until 100%
|
||||
# a finishing animation plays, the game is saved and the countdown disappears again
|
||||
func _on_save_button_button_down() -> void:
|
||||
save_button_held_down = true
|
||||
save_button_clicked.emit()
|
||||
|
||||
func _on_save_button_button_up() -> void:
|
||||
save_button_held_down = false
|
||||
save_button_released.emit()
|
||||
save_timer = 0.0
|
||||
|
||||
func disable_save_button() -> void:
|
||||
%SaveButton.disabled = true
|
||||
|
||||
func enable_save_button() -> void:
|
||||
%SaveButton.disabled = false
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://1anjhvi173g3"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://1anjhvi173g3"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/ui/ingame_controls.gd" id="1_iw1sp"]
|
||||
[ext_resource type="Texture2D" uid="uid://2vxx2waofxpw" path="res://assets/textures/Xbox Series/Vector/xbox_button_menu_outline.svg" id="1_wr5sh"]
|
||||
[ext_resource type="Script" path="res://scripts/joystick.gd" id="2_pyri2"]
|
||||
[ext_resource type="Texture2D" uid="uid://8anyvhkcy4ng" path="res://assets/textures/Xbox Series/Vector/xbox_button_a.svg" id="3_lgi8v"]
|
||||
[ext_resource type="Texture2D" uid="uid://cbep021ykpb23" path="res://assets/textures/Game Icons/Vector/2x/save.png" id="5_2pil1"]
|
||||
[ext_resource type="Texture2D" uid="uid://bwyoxxotdisyp" path="res://assets/textures/Game Icons/Vector/2x/gear.png" id="5_nwwsc"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_uoef2"]
|
||||
|
||||
|
|
@ -14,60 +16,101 @@ corner_radius_top_right = 999
|
|||
corner_radius_bottom_right = 999
|
||||
corner_radius_bottom_left = 999
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_hfsbq"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_x4icw"]
|
||||
|
||||
[node name="IngameControls" type="MarginContainer"]
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -484.0
|
||||
offset_top = -338.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
size_flags_vertical = 8
|
||||
theme_override_constants/margin_left = 30
|
||||
theme_override_constants/margin_right = 30
|
||||
theme_override_constants/margin_bottom = 30
|
||||
script = ExtResource("1_iw1sp")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
alignment = 2
|
||||
|
||||
[node name="Left" type="VBoxContainer" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 32
|
||||
theme_override_constants/separation = 8
|
||||
alignment = 2
|
||||
|
||||
[node name="MenuButton" type="Button" parent="VBoxContainer"]
|
||||
[node name="MenuButton" type="Button" parent="HBoxContainer/Left"]
|
||||
self_modulate = Color(0, 0, 0, 0.392157)
|
||||
custom_minimum_size = Vector2(200, 200)
|
||||
custom_minimum_size = Vector2(120, 120)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
theme_override_styles/focus = SubResource("StyleBoxEmpty_uoef2")
|
||||
icon = ExtResource("1_wr5sh")
|
||||
flat = true
|
||||
icon_alignment = 1
|
||||
expand_icon = true
|
||||
|
||||
[node name="JoystickPanel" type="Panel" parent="VBoxContainer"]
|
||||
custom_minimum_size = Vector2(400, 400)
|
||||
[node name="JoystickPanel" type="Panel" parent="HBoxContainer/Left"]
|
||||
custom_minimum_size = Vector2(180, 180)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_nfkty")
|
||||
script = ExtResource("2_pyri2")
|
||||
|
||||
[node name="Thumbstick" type="TextureRect" parent="VBoxContainer/JoystickPanel"]
|
||||
[node name="Thumbstick" type="TextureRect" parent="HBoxContainer/Left/JoystickPanel"]
|
||||
self_modulate = Color(0, 0, 0, 0.392157)
|
||||
custom_minimum_size = Vector2(200, 200)
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -32.0
|
||||
offset_top = -32.0
|
||||
offset_right = 32.0
|
||||
offset_bottom = 32.0
|
||||
offset_left = -65.0
|
||||
offset_top = -65.0
|
||||
offset_right = 65.0
|
||||
offset_bottom = 65.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("3_lgi8v")
|
||||
expand_mode = 3
|
||||
stretch_mode = 5
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/MenuButton" to="." method="_on_menu_button_pressed"]
|
||||
[connection signal="gui_input" from="VBoxContainer/JoystickPanel" to="VBoxContainer/JoystickPanel" method="_on_gui_input"]
|
||||
[connection signal="resized" from="VBoxContainer/JoystickPanel" to="VBoxContainer/JoystickPanel" method="_on_resized"]
|
||||
[node name="Right" type="VBoxContainer" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
theme_override_constants/separation = 0
|
||||
alignment = 2
|
||||
|
||||
[node name="SaveButton" type="Button" parent="HBoxContainer/Right"]
|
||||
unique_name_in_owner = true
|
||||
self_modulate = Color(0, 0, 0, 0.392157)
|
||||
custom_minimum_size = Vector2(120, 120)
|
||||
layout_mode = 2
|
||||
theme_override_styles/focus = SubResource("StyleBoxEmpty_hfsbq")
|
||||
icon = ExtResource("5_2pil1")
|
||||
flat = true
|
||||
icon_alignment = 1
|
||||
expand_icon = true
|
||||
|
||||
[node name="SettingsButton" type="Button" parent="HBoxContainer/Right"]
|
||||
self_modulate = Color(0, 0, 0, 0.392157)
|
||||
custom_minimum_size = Vector2(120, 120)
|
||||
layout_mode = 2
|
||||
theme_override_styles/focus = SubResource("StyleBoxEmpty_x4icw")
|
||||
icon = ExtResource("5_nwwsc")
|
||||
flat = true
|
||||
icon_alignment = 1
|
||||
expand_icon = true
|
||||
|
||||
[connection signal="pressed" from="HBoxContainer/Left/MenuButton" to="." method="_on_menu_button_pressed"]
|
||||
[connection signal="gui_input" from="HBoxContainer/Left/JoystickPanel" to="HBoxContainer/Left/JoystickPanel" method="_on_gui_input"]
|
||||
[connection signal="resized" from="HBoxContainer/Left/JoystickPanel" to="HBoxContainer/Left/JoystickPanel" method="_on_resized"]
|
||||
[connection signal="button_down" from="HBoxContainer/Right/SaveButton" to="." method="_on_save_button_button_down"]
|
||||
[connection signal="button_up" from="HBoxContainer/Right/SaveButton" to="." method="_on_save_button_button_up"]
|
||||
[connection signal="pressed" from="HBoxContainer/Right/SettingsButton" to="." method="_on_settings_button_pressed"]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://bbvbnrcjatkrb"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://bbvbnrcjatkrb"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/monster_list.gd" id="1_jk76e"]
|
||||
[ext_resource type="FontFile" uid="uid://bjaavdnopfh0q" path="res://assets/fonts/aoboshi_one/AoboshiOne-Regular.ttf" id="2_hunv3"]
|
||||
|
|
@ -11,6 +11,8 @@ corner_radius_top_right = 64
|
|||
corner_radius_bottom_right = 64
|
||||
corner_radius_bottom_left = 64
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_flvbu"]
|
||||
|
||||
[node name="MonsterList" type="MarginContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
|
@ -21,10 +23,10 @@ script = ExtResource("1_jk76e")
|
|||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 100
|
||||
theme_override_constants/margin_top = 150
|
||||
theme_override_constants/margin_right = 100
|
||||
theme_override_constants/margin_bottom = 100
|
||||
theme_override_constants/margin_left = 50
|
||||
theme_override_constants/margin_top = 50
|
||||
theme_override_constants/margin_right = 50
|
||||
theme_override_constants/margin_bottom = 50
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
|
@ -35,16 +37,17 @@ layout_mode = 2
|
|||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_top = 32
|
||||
theme_override_constants/margin_left = 40
|
||||
theme_override_constants/margin_top = 30
|
||||
theme_override_constants/margin_right = 40
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
theme_override_fonts/font = ExtResource("2_hunv3")
|
||||
theme_override_font_sizes/font_size = 50
|
||||
theme_override_font_sizes/font_size = 36
|
||||
text = "Your Monsters"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="MonsterListEntryContainer" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
|
||||
|
|
@ -60,9 +63,10 @@ theme_override_constants/margin_bottom = 32
|
|||
[node name="CloseButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/MarginContainer2"]
|
||||
unique_name_in_owner = true
|
||||
self_modulate = Color(0, 0, 0, 1)
|
||||
custom_minimum_size = Vector2(150, 150)
|
||||
custom_minimum_size = Vector2(120, 120)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
theme_override_styles/focus = SubResource("StyleBoxEmpty_flvbu")
|
||||
icon = ExtResource("3_08jy5")
|
||||
flat = true
|
||||
icon_alignment = 1
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ vertical_alignment = 1
|
|||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
theme_override_font_sizes/font_size = 40
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "Name"
|
||||
vertical_alignment = 1
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ unique_name_in_owner = true
|
|||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
theme_override_font_sizes/font_size = 40
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "Lvl"
|
||||
vertical_alignment = 1
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ show_percentage = false
|
|||
[node name="SwapPositionButton" type="Button" parent="."]
|
||||
unique_name_in_owner = true
|
||||
self_modulate = Color(0, 0, 0, 1)
|
||||
custom_minimum_size = Vector2(150, 150)
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
theme_override_styles/focus = SubResource("StyleBoxEmpty_x2rfb")
|
||||
|
|
|
|||
|
|
@ -20,3 +20,23 @@ func _update_ui() -> void:
|
|||
monster_list._update_monster_list()
|
||||
|
||||
print("UI updated")
|
||||
|
||||
|
||||
func _on_ingame_controls_save_button_clicked() -> void:
|
||||
%SaveUI.visible = true
|
||||
|
||||
func _on_ingame_controls_save_button_released() -> void:
|
||||
%SaveUI.visible = false
|
||||
|
||||
func _on_ingame_controls_save_timer_incremented(value) -> void:
|
||||
%SavePercentage.text = str(value)
|
||||
|
||||
|
||||
func _on_ingame_controls_save_timer_reached() -> void:
|
||||
%SavePercentage.text = "Saved!"
|
||||
print("Saved Game")
|
||||
%IngameControls.disable_save_button()
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
%IngameControls.enable_save_button()
|
||||
$SaveUI.visible = false
|
||||
%SavePercentage.text = "0 % ..."
|
||||
|
|
|
|||
|
|
@ -18,9 +18,43 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
script = ExtResource("1_x56x6")
|
||||
|
||||
[node name="SaveUI" type="Control" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="SavePercentage" type="Label" parent="SaveUI"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -11.5
|
||||
offset_right = 20.0
|
||||
offset_bottom = 11.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_colors/font_color = Color(0.3895, 0.856583, 0.95, 1)
|
||||
theme_override_colors/font_outline_color = Color(0.2419, 0.531983, 0.59, 1)
|
||||
theme_override_constants/outline_size = 30
|
||||
theme_override_font_sizes/font_size = 100
|
||||
text = "0 % ..."
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="MainMenu" parent="." instance=ExtResource("3_tcmm8")]
|
||||
|
||||
[node name="IngameControls" parent="." instance=ExtResource("4_likk0")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="MonsterList" parent="." instance=ExtResource("5_qjqu1")]
|
||||
unique_name_in_owner = true
|
||||
|
|
@ -28,3 +62,7 @@ visible = false
|
|||
|
||||
[connection signal="gui_input" from="CameraControlArea" to="CameraControlArea" method="_on_gui_input"]
|
||||
[connection signal="menu_button_clicked" from="IngameControls" to="." method="_on_ingame_controls_menu_button_clicked"]
|
||||
[connection signal="save_button_clicked" from="IngameControls" to="." method="_on_ingame_controls_save_button_clicked"]
|
||||
[connection signal="save_button_released" from="IngameControls" to="." method="_on_ingame_controls_save_button_released"]
|
||||
[connection signal="save_timer_incremented" from="IngameControls" to="." method="_on_ingame_controls_save_timer_incremented"]
|
||||
[connection signal="save_timer_reached" from="IngameControls" to="." method="_on_ingame_controls_save_timer_reached"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue