"save" & animate main menu, fix pause menu & restart (#3)

pause menu had classic issues of mouse inputs being eaten by something else (gravity)
restart didn't have working code anymore because of level logic changes
also remove the demo scene which I believe is unused beyond the jam version
This commit is contained in:
Taevas 2025-04-27 21:30:03 +02:00
parent 71441a9335
commit 38897c706a
Signed by: Taevas
SSH key fingerprint: SHA256:Y5Hv18xwPvUKSlgkx1sPnRO3L2mc03ehC7BzrnZVEyY
5 changed files with 184 additions and 75 deletions

View file

@ -13,6 +13,7 @@ var changing_level: bool = false
var main_menu: Node
var current_level: Level
var current_level_scene: PackedScene
const res_main_menu = preload(\"res://menus/main/main_menu.tscn\")
@ -41,17 +42,19 @@ func _ready() -> void:
func set_main_menu():
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
main_menu = res_main_menu.instantiate()
main_menu.connect(\"request_play_level\", start_level)
if !is_instance_valid(main_menu):
main_menu = res_main_menu.instantiate()
main_menu.connect(\"request_play_level\", start_level)
add_child(main_menu)
func start_level(level: Level) -> void:
func start_level(level: Level, scene: PackedScene) -> void:
if is_instance_valid(current_level):
current_level.queue_free()
if is_instance_valid(main_menu):
main_menu.queue_free()
if is_instance_valid(main_menu) and self.is_ancestor_of(main_menu):
self.remove_child(main_menu)
current_level = level
current_level_scene = scene
add_child(current_level)
current_level.connect(\"completed\", finish_current_level)
@ -62,6 +65,7 @@ func start_level(level: Level) -> void:
$GUI.show()
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
pause_game(false)
playing = true
PhysicsServer3D.area_set_param(
@ -98,20 +102,25 @@ func win_game() -> void:
$VictoryScreen.hide()
func restart_level() -> void:
return #idk yet
if !current_level:
return
if current_level_scene is not PackedScene:
print(\"Tried to restart the level despite not having the level scene\")
return
start_level(current_level_scene.instantiate(), current_level_scene)
func pause_game(to_pause: bool) -> void:
if is_instance_valid(current_level) or changing_level:
if !is_instance_valid(current_level) or changing_level:
return
SaveFiles.change_property(\"played_for\", gui_timer.seconds_spent_total, SaveFiles.selected_file)
if to_pause:
$Levels.process_mode = Node.PROCESS_MODE_DISABLED
current_level.process_mode = Node.PROCESS_MODE_DISABLED
playing = false
pause_menu.show()
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
$Levels.process_mode = Node.PROCESS_MODE_INHERIT
current_level.process_mode = Node.PROCESS_MODE_INHERIT
playing = true
pause_menu.hide()
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
@ -150,7 +159,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
mouse_filter = 2
[node name="TopLeft" type="MarginContainer" parent="GUI"]
layout_mode = 1
@ -202,6 +211,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="Label" type="Label" parent="VictoryScreen"]
layout_mode = 1
@ -215,8 +225,6 @@ label_settings = SubResource("LabelSettings_1bs00")
horizontal_alignment = 1
vertical_alignment = 1
[node name="PauseMenu" parent="." instance=ExtResource("4_3bfj3")]
[node name="DevInfos" type="Label" parent="."]
anchors_preset = 12
anchor_top = 1.0
@ -226,3 +234,5 @@ offset_top = -23.0
grow_horizontal = 2
grow_vertical = 0
horizontal_alignment = 1
[node name="PauseMenu" parent="." instance=ExtResource("4_3bfj3")]