Implement save and loading games (#8)
This commit is contained in:
@@ -25,24 +25,25 @@ func _on_continue_pressed():
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func switch_language(lang : String):
|
||||
func switch_language(lang: String):
|
||||
TranslationServer.set_locale(lang)
|
||||
|
||||
|
||||
func _on_new_game_pressed():
|
||||
escoria.new_game()
|
||||
|
||||
|
||||
func _on_load_game_pressed():
|
||||
# Show Loading screen
|
||||
pass
|
||||
$Panel/main.hide()
|
||||
$Panel/load_game.refresh_savegames()
|
||||
$Panel/load_game.show()
|
||||
|
||||
|
||||
func _on_options_pressed():
|
||||
$Panel/main.hide()
|
||||
$Panel/options.show()
|
||||
|
||||
|
||||
func _on_quit_pressed():
|
||||
get_tree().quit()
|
||||
|
||||
@@ -50,8 +51,12 @@ func _on_quit_pressed():
|
||||
###########################################################################
|
||||
# OPTIONS
|
||||
|
||||
|
||||
func _on_back_pressed():
|
||||
func _on_options_back_button_pressed():
|
||||
$Panel/options.hide()
|
||||
$Panel/main.show()
|
||||
|
||||
|
||||
func _on_load_game_back_button_pressed():
|
||||
$Panel/load_game.hide()
|
||||
$Panel/main.show()
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://game/ui/commons/main_menu/main_menu.gd" type="Script" id=1]
|
||||
[ext_resource path="res://game/ui/commons/main_menu/main.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/escoria-core/logo/escoria-logo-small.png" type="Texture" id=3]
|
||||
[ext_resource path="res://game/ui/commons/main_menu/options.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://game/ui/commons/options/options.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://game/ui/commons/load/load_game.tscn" type="PackedScene" id=5]
|
||||
|
||||
[node name="main_menu" type="Control"]
|
||||
anchor_right = 1.0
|
||||
@@ -38,11 +39,14 @@ __meta__ = {
|
||||
[node name="options" parent="Panel" instance=ExtResource( 4 )]
|
||||
visible = false
|
||||
|
||||
[node name="load_game" parent="Panel" instance=ExtResource( 5 )]
|
||||
visible = false
|
||||
|
||||
[connection signal="pressed" from="Panel/main/new_game" to="." method="_on_new_game_pressed"]
|
||||
[connection signal="pressed" from="Panel/main/load_game" to="." method="_on_load_game_pressed"]
|
||||
[connection signal="pressed" from="Panel/main/options" to="." method="_on_options_pressed"]
|
||||
[connection signal="pressed" from="Panel/main/quit" to="." method="_on_quit_pressed"]
|
||||
[connection signal="pressed" from="Panel/options/back" to="." method="_on_back_pressed"]
|
||||
[connection signal="back_button_pressed" from="Panel/options" to="." method="_on_options_back_button_pressed"]
|
||||
[connection signal="back_button_pressed" from="Panel/load_game" to="." method="_on_load_game_back_button_pressed"]
|
||||
|
||||
[editable path="Panel/main"]
|
||||
[editable path="Panel/options"]
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
extends Control
|
||||
|
||||
func _ready():
|
||||
initialize_options(escoria.settings)
|
||||
|
||||
func initialize_options(p_settings):
|
||||
$options/general_volume.value = p_settings["master_volume"]
|
||||
$options/sound_volume.value = p_settings["sfx_volume"]
|
||||
$options/music_volume.value = p_settings["music_volume"]
|
||||
|
||||
func greyout_other_languages(except_lang : String) -> void:
|
||||
pass
|
||||
|
||||
func _on_language_input(event : InputEvent, language : String):
|
||||
if event.is_pressed():
|
||||
TranslationServer.set_locale(language)
|
||||
escoria.settings["text_lang"] = language
|
||||
escoria.save_data.save_settings(escoria.settings, null)
|
||||
|
||||
|
||||
func _on_sound_volume_changed(value):
|
||||
escoria.settings["sfx_volume"] = value
|
||||
escoria.save_data.save_settings(escoria.settings, null)
|
||||
escoria._on_settings_loaded(escoria.settings)
|
||||
|
||||
func _on_music_volume_changed(value):
|
||||
escoria.settings["music_volume"] = value
|
||||
escoria.save_data.save_settings(escoria.settings, null)
|
||||
escoria._on_settings_loaded(escoria.settings)
|
||||
|
||||
|
||||
func _on_general_volume_changed(value):
|
||||
escoria.settings["master_volume"] = value
|
||||
escoria.save_data.save_settings(escoria.settings, null)
|
||||
escoria._on_settings_loaded(escoria.settings)
|
||||
@@ -1,132 +0,0 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://game/ui/commons/fonts/caslonantique.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://game/ui/commons/main_menu/flags/en_EN_small.png" type="Texture" id=2]
|
||||
[ext_resource path="res://game/ui/commons/main_menu/flags/fr_FR_small.png" type="Texture" id=3]
|
||||
[ext_resource path="res://game/ui/commons/main_menu/options.gd" type="Script" id=4]
|
||||
|
||||
[node name="options" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 4 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="back" type="Button" parent="."]
|
||||
margin_left = 130.0
|
||||
margin_top = 329.0
|
||||
margin_right = 304.0
|
||||
margin_bottom = 383.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "OPTIONS_BACK"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="options" type="GridContainer" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -275.5
|
||||
margin_top = -75.0
|
||||
margin_right = 275.5
|
||||
margin_bottom = 75.0
|
||||
custom_constants/hseparation = 40
|
||||
columns = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="label" type="Label" parent="options"]
|
||||
margin_top = 27.0
|
||||
margin_right = 220.0
|
||||
margin_bottom = 48.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "OPTIONS_LANGUAGE"
|
||||
|
||||
[node name="flags" type="HBoxContainer" parent="options"]
|
||||
margin_left = 260.0
|
||||
margin_right = 553.0
|
||||
margin_bottom = 75.0
|
||||
size_flags_vertical = 3
|
||||
custom_constants/separation = 30
|
||||
alignment = 1
|
||||
|
||||
[node name="fr" type="TextureRect" parent="options/flags"]
|
||||
margin_right = 113.0
|
||||
margin_bottom = 75.0
|
||||
texture = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="en" type="TextureRect" parent="options/flags"]
|
||||
margin_left = 143.0
|
||||
margin_right = 293.0
|
||||
margin_bottom = 75.0
|
||||
texture = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="label2" type="Label" parent="options"]
|
||||
margin_top = 79.0
|
||||
margin_right = 220.0
|
||||
margin_bottom = 100.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "GENERAL_VOLUME"
|
||||
|
||||
[node name="general_volume" type="HSlider" parent="options"]
|
||||
margin_left = 260.0
|
||||
margin_top = 79.0
|
||||
margin_right = 553.0
|
||||
margin_bottom = 95.0
|
||||
size_flags_horizontal = 3
|
||||
min_value = 0.001
|
||||
max_value = 1.0
|
||||
step = 0.001
|
||||
value = 0.001
|
||||
|
||||
[node name="label3" type="Label" parent="options"]
|
||||
margin_top = 104.0
|
||||
margin_right = 220.0
|
||||
margin_bottom = 125.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "SOUND_VOLUME"
|
||||
|
||||
[node name="sound_volume" type="HSlider" parent="options"]
|
||||
margin_left = 260.0
|
||||
margin_top = 104.0
|
||||
margin_right = 553.0
|
||||
margin_bottom = 120.0
|
||||
size_flags_horizontal = 3
|
||||
min_value = 0.001
|
||||
max_value = 1.0
|
||||
step = 0.001
|
||||
value = 0.001
|
||||
|
||||
[node name="label4" type="Label" parent="options"]
|
||||
margin_top = 129.0
|
||||
margin_right = 220.0
|
||||
margin_bottom = 150.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "MUSIC_VOLUME"
|
||||
|
||||
[node name="music_volume" type="HSlider" parent="options"]
|
||||
margin_left = 260.0
|
||||
margin_top = 129.0
|
||||
margin_right = 553.0
|
||||
margin_bottom = 145.0
|
||||
size_flags_horizontal = 3
|
||||
min_value = 0.001
|
||||
max_value = 1.0
|
||||
step = 0.001
|
||||
value = 0.001
|
||||
|
||||
[connection signal="gui_input" from="options/flags/fr" to="." method="_on_language_input" binds= [ "fr" ]]
|
||||
[connection signal="gui_input" from="options/flags/en" to="." method="_on_language_input" binds= [ "en" ]]
|
||||
[connection signal="value_changed" from="options/general_volume" to="." method="_on_general_volume_changed"]
|
||||
[connection signal="value_changed" from="options/sound_volume" to="." method="_on_sound_volume_changed"]
|
||||
[connection signal="value_changed" from="options/music_volume" to="." method="_on_music_volume_changed"]
|
||||
Reference in New Issue
Block a user