Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add level progress management #163

Merged
merged 17 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions addons/maaacks_game_template/examples/scenes/game_scene/game_ui.gd

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[gd_scene load_steps=11 format=3 uid="uid://bde0cbmryrv5s"]
[gd_scene load_steps=12 format=3 uid="uid://bde0cbmryrv5s"]

[ext_resource type="Script" path="res://addons/maaacks_game_template/examples/scenes/game_scene/game_ui.gd" id="1_lpkm8"]
[ext_resource type="PackedScene" uid="uid://ta2xbceba8ec" path="res://addons/maaacks_game_template/examples/scenes/win_screen/win_screen.tscn" id="2_3aw6s"]
[ext_resource type="PackedScene" uid="uid://duvowpap0jwaq" path="res://addons/maaacks_game_template/examples/scenes/lose_screen/lose_screen.tscn" id="3_28mfg"]
[ext_resource type="PackedScene" uid="uid://ddxbl58500png" path="res://addons/maaacks_game_template/examples/scenes/level_complete_screen/level_complete_screen.tscn" id="4_gomcd"]
[ext_resource type="Script" path="res://addons/maaacks_game_template/extras/scripts/pause_menu_controller.gd" id="5_fc8fx"]
[ext_resource type="PackedScene" uid="uid://qeqh1euot2d0" path="res://addons/maaacks_game_template/examples/scenes/menus/pause_menu/pause_menu.tscn" id="5_r56ir"]
[ext_resource type="Script" path="res://addons/maaacks_game_template/extras/scripts/level_list_loader.gd" id="6_wd8e4"]
[ext_resource type="Script" path="res://addons/maaacks_game_template/examples/scenes/game_scene/input_display_label.gd" id="7_f87ri"]
[ext_resource type="PackedScene" uid="uid://bkcsjsk2ciff" path="res://addons/maaacks_game_template/base/scenes/music_players/background_music_player.tscn" id="7_yr75v"]
[ext_resource type="PackedScene" uid="uid://dbuv0htkikcv4" path="res://addons/maaacks_game_template/examples/scenes/loading_screen/level_loading_screen.tscn" id="8_0nt60"]
[ext_resource type="Script" path="res://addons/maaacks_game_template/examples/scenes/game_scene/configurable_sub_viewport.gd" id="9_u1dsg"]
[ext_resource type="Script" path="res://addons/maaacks_game_template/extras/scripts/level_list_manager.gd" id="12_ut0t4"]

[node name="GameUI" type="Control"]
layout_mode = 3
Expand All @@ -18,9 +19,6 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_lpkm8")
win_scene = ExtResource("2_3aw6s")
lose_scene = ExtResource("3_28mfg")

[node name="PauseMenuController" type="Node" parent="."]
script = ExtResource("5_fc8fx")
Expand Down Expand Up @@ -69,6 +67,17 @@ horizontal_alignment = 1
autowrap_mode = 2
script = ExtResource("7_f87ri")

[node name="LevelListManager" type="Node" parent="." node_paths=PackedStringArray("level_list_loader", "level_loading_screen")]
process_mode = 3
script = ExtResource("12_ut0t4")
level_list_loader = NodePath("../LevelLoader")
main_menu_scene = "res://addons/maaacks_game_template/examples/scenes/menus/main_menu/main_menu_with_animations.tscn"
ending_scene = "res://addons/maaacks_game_template/examples/scenes/end_credits/end_credits.tscn"
level_loading_screen = NodePath("../LevelLoadingScreen")
win_screen_scene = ExtResource("2_3aw6s")
lose_screen_scene = ExtResource("3_28mfg")
level_complete_screen_scene = ExtResource("4_gomcd")

[connection signal="level_load_started" from="LevelLoader" to="." method="_on_level_loader_level_load_started"]
[connection signal="level_loaded" from="LevelLoader" to="." method="_on_level_loader_level_loaded"]
[connection signal="levels_finished" from="LevelLoader" to="." method="_on_level_loader_levels_finished"]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends "res://addons/maaacks_game_template/extras/scenes/level_complete_screen/level_complete_screen.gd"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://ddxbl58500png"]

[ext_resource type="PackedScene" uid="uid://cpa0hksdk0vjv" path="res://addons/maaacks_game_template/extras/scenes/level_complete_screen/level_complete_screen.tscn" id="1_67ooa"]
[ext_resource type="Script" path="res://addons/maaacks_game_template/examples/scenes/level_complete_screen/level_complete_screen.gd" id="1_fgelo"]

[node name="LevelCompleteScreen" instance=ExtResource("1_67ooa")]
script = ExtResource("1_fgelo")
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@

[node name="LoseScreen" instance=ExtResource("1_exl4x")]
script = ExtResource("2_ay3xf")
main_menu_scene = "res://addons/maaacks_game_template/examples/scenes/menus/main_menu/main_menu_with_animations.tscn"
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@

[node name="WinScreen" instance=ExtResource("1_n1ig8")]
script = ExtResource("2_hckpo")
next_scene = "res://addons/maaacks_game_template/examples/scenes/end_credits/end_credits.tscn"
main_menu_scene = "res://addons/maaacks_game_template/examples/scenes/menus/main_menu/main_menu_with_animations.tscn"
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
extends CanvasLayer

signal continue_pressed
signal restart_pressed
signal main_menu_pressed

func _input(event):
if event.is_action_pressed("ui_cancel"):
if $ConfirmMainMenu.visible:
$ConfirmMainMenu.hide()
get_viewport().set_input_as_handled()

func _on_main_menu_button_pressed():
$ConfirmMainMenu.popup_centered()

func _on_continue_button_pressed():
continue_pressed.emit()

func _on_confirm_main_menu_confirmed():
main_menu_pressed.emit()

func _on_restart_button_pressed():
restart_pressed.emit()
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[gd_scene load_steps=4 format=3 uid="uid://cpa0hksdk0vjv"]

[ext_resource type="Script" path="res://addons/maaacks_game_template/extras/scenes/level_complete_screen/level_complete_screen.gd" id="1_fgelo"]
[ext_resource type="Script" path="res://addons/maaacks_game_template/base/scripts/ui_sound_controller.gd" id="2_p87ka"]
[ext_resource type="Script" path="res://addons/maaacks_game_template/base/scripts/capture_focus.gd" id="3_h5el0"]

[node name="LevelCompleteScreen" type="CanvasLayer"]
process_mode = 3
layer = 10
script = ExtResource("1_fgelo")

[node name="UISoundController" type="Node" parent="."]
script = ExtResource("2_p87ka")

[node name="BackgroundColor" type="ColorRect" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 0.501961)

[node name="BackgroundTextureRect" type="TextureRect" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
expand_mode = 1
stretch_mode = 5

[node name="PanelContainer" type="PanelContainer" parent="."]
custom_minimum_size = Vector2(410, 240)
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -205.0
offset_top = -120.0
offset_right = 205.0
offset_bottom = 120.0
grow_horizontal = 2
grow_vertical = 2

[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
layout_mode = 2
theme_override_constants/margin_left = 16
theme_override_constants/margin_top = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_bottom = 16

[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"]
layout_mode = 2
alignment = 1

[node name="LevelCompleteMessage" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
text = "Level complete!"
horizontal_alignment = 1
vertical_alignment = 1

[node name="ButtonsContainer" type="HBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 16
alignment = 1
script = ExtResource("3_h5el0")

[node name="MainMenuButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/ButtonsContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(128, 40)
layout_mode = 2
text = "Main Menu"

[node name="RestartButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/ButtonsContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(128, 40)
layout_mode = 2
text = "Restart"

[node name="ContinueButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/ButtonsContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(128, 40)
layout_mode = 2
text = "Continue"

[node name="ConfirmMainMenu" type="ConfirmationDialog" parent="."]
initial_position = 2
dialog_text = "Go back to main menu?"

[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/ButtonsContainer/MainMenuButton" to="." method="_on_main_menu_button_pressed"]
[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/ButtonsContainer/RestartButton" to="." method="_on_restart_button_pressed"]
[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/ButtonsContainer/ContinueButton" to="." method="_on_continue_button_pressed"]
[connection signal="confirmed" from="ConfirmMainMenu" to="." method="_on_confirm_main_menu_confirmed"]
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extends CanvasLayer

@export_file("*.tscn") var main_menu_scene : String
signal restart_pressed
signal main_menu_pressed

func _input(event):
if event.is_action_pressed("ui_cancel"):
Expand All @@ -10,15 +11,9 @@ func _input(event):
$ConfirmMainMenu.hide()
get_viewport().set_input_as_handled()

func _setup_main_menu():
if main_menu_scene.is_empty():
%MainMenuButton.hide()

func _ready():
if OS.has_feature("web"):
%ExitButton.hide()
_setup_main_menu()
InGameMenuController.scene_tree = get_tree()

func _on_exit_button_pressed():
$ConfirmExit.popup_centered()
Expand All @@ -27,13 +22,10 @@ func _on_main_menu_button_pressed():
$ConfirmMainMenu.popup_centered()

func _on_restart_button_pressed():
SceneLoader.reload_current_scene()
InGameMenuController.close_menu()
restart_pressed.emit()

func _on_confirm_main_menu_confirmed():
SceneLoader.load_scene(main_menu_scene)
InGameMenuController.close_menu()
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
main_menu_pressed.emit()

func _on_confirm_exit_confirmed():
get_tree().quit()
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
process_mode = 3
layer = 10
script = ExtResource("1_vd50a")
main_menu_scene = "res://addons/maaacks_game_template/base/scenes/menus/main_menu/main_menu.tscn"

[node name="UISoundController" type="Node" parent="."]
script = ExtResource("2_haoyh")
Expand Down Expand Up @@ -46,10 +45,10 @@ grow_vertical = 2

[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
theme_override_constants/margin_left = 16
theme_override_constants/margin_top = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_bottom = 16

[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"]
layout_mode = 2
Expand All @@ -59,12 +58,13 @@ alignment = 1
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
text = "You lose."
text = "You lost..."
horizontal_alignment = 1
vertical_alignment = 1

[node name="ButtonsContainer" type="HBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 16
alignment = 1
script = ExtResource("3_mqffv")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends CanvasLayer

@export_file("*.tscn") var next_scene : String
@export_file("*.tscn") var main_menu_scene : String
signal continue_pressed
signal main_menu_pressed

func _input(event):
if event.is_action_pressed("ui_cancel"):
Expand All @@ -11,20 +11,9 @@ func _input(event):
$ConfirmMainMenu.hide()
get_viewport().set_input_as_handled()

func _setup_continue():
if next_scene.is_empty():
%ContinueButton.hide()

func _setup_main_menu():
if main_menu_scene.is_empty():
%MainMenuButton.hide()

func _ready():
if OS.has_feature("web"):
%ExitButton.hide()
_setup_continue()
_setup_main_menu()
InGameMenuController.scene_tree = get_tree()

func _on_exit_button_pressed():
$ConfirmExit.popup_centered()
Expand All @@ -33,13 +22,10 @@ func _on_main_menu_button_pressed():
$ConfirmMainMenu.popup_centered()

func _on_continue_button_pressed():
SceneLoader.load_scene(next_scene)
InGameMenuController.close_menu()
continue_pressed.emit()

func _on_confirm_main_menu_confirmed():
SceneLoader.load_scene(main_menu_scene)
InGameMenuController.close_menu()
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
main_menu_pressed.emit()

func _on_confirm_exit_confirmed():
get_tree().quit()
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
process_mode = 3
layer = 10
script = ExtResource("1_elvr7")
main_menu_scene = "res://addons/maaacks_game_template/base/scenes/Menus/MainMenu/MainMenu.tscn"

[node name="UISoundController" type="Node" parent="."]
script = ExtResource("2_g47g8")
Expand Down Expand Up @@ -46,10 +45,10 @@ grow_vertical = 2

[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
theme_override_constants/margin_left = 16
theme_override_constants/margin_top = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_bottom = 16

[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"]
layout_mode = 2
Expand All @@ -65,17 +64,20 @@ vertical_alignment = 1

[node name="ButtonsContainer" type="HBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 16
alignment = 1
script = ExtResource("3_am347")

[node name="ExitButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/ButtonsContainer"]
unique_name_in_owner = true
visible = false
custom_minimum_size = Vector2(128, 40)
layout_mode = 2
text = "Exit"

[node name="MainMenuButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/ButtonsContainer"]
unique_name_in_owner = true
visible = false
custom_minimum_size = Vector2(128, 40)
layout_mode = 2
text = "Main Menu"
Expand Down
Loading