imported main menu scene addon

This commit is contained in:
2026-05-10 15:48:56 +02:00
parent 86d9f75161
commit 71c2850a34
458 changed files with 14881 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
@tool
extends "res://scenes/credits/scrolling_credits.gd"
## Defines the path to the main menu. Hides the Main Menu button if not set.
## Will attempt to read from AppConfig if left empty.
@export_file("*.tscn") var main_menu_scene_path : String
## This option forces the mouse to be visible when the menu shows up.
## Useful for games that capture the mouse, and don't automatically return it.
@export var force_mouse_mode_visible : bool = false
@onready var end_message_panel = %EndMessagePanel
@onready var exit_button = %ExitButton
@onready var menu_button = %MenuButton
@onready var init_mouse_filter : MouseFilter = mouse_filter
func get_main_menu_scene_path() -> String:
if main_menu_scene_path.is_empty():
return AppConfig.main_menu_scene_path
return main_menu_scene_path
func _end_reached() -> void:
end_message_panel.show()
mouse_filter = Control.MOUSE_FILTER_STOP
if force_mouse_mode_visible:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
super._end_reached()
func load_main_menu() -> void:
SceneLoader.load_scene(get_main_menu_scene_path())
func exit_game() -> void:
if OS.has_feature("web"):
load_main_menu()
get_tree().quit()
func _on_visibility_changed() -> void:
if visible:
end_message_panel.hide()
mouse_filter = init_mouse_filter
super._on_visibility_changed()
func _ready() -> void:
if get_main_menu_scene_path().is_empty():
menu_button.hide()
if OS.has_feature("web"):
exit_button.hide()
end_message_panel.hide()
super._ready()
func _unhandled_input(event : InputEvent) -> void:
if event.is_action_released("ui_cancel"):
if not end_message_panel.visible:
_end_reached()
else:
exit_game()
func _on_exit_button_pressed():
exit_game()
func _on_menu_button_pressed():
load_main_menu()

View File

@@ -0,0 +1 @@
uid://qb0nxsu5pjsm

View File

@@ -0,0 +1,88 @@
[gd_scene format=3 uid="uid://chy2p20a0je14"]
[ext_resource type="PackedScene" path="res://scenes/credits/scrolling_credits.tscn" id="1_0sycx"]
[ext_resource type="Script" path="res://scenes/end_credits/end_credits.gd" id="2_2v40y"]
[ext_resource type="PackedScene" path="res://addons/maaacks_game_template/base/nodes/music_players/background_music_player.tscn" id="3_bfvdl"]
[ext_resource type="Script" path="res://addons/maaacks_game_template/base/nodes/utilities/capture_focus.gd" id="4_1kqi1"]
[node name="EndCredits" unique_id=613298766 instance=ExtResource("1_0sycx")]
script = ExtResource("2_2v40y")
main_menu_scene_path = ""
force_mouse_mode_visible = false
[node name="BackgroundMusicPlayer" parent="." index="0" unique_id=1411252862 instance=ExtResource("3_bfvdl")]
[node name="BackgroundColor" type="ColorRect" parent="." index="1" unique_id=813188635]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 1)
[node name="BackgroundTextureRect" type="TextureRect" parent="." index="2" unique_id=1166831285]
layout_mode = 1
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="CenterContainer" type="CenterContainer" parent="." index="4" unique_id=535959837]
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
mouse_filter = 2
[node name="EndMessagePanel" type="Panel" parent="CenterContainer" index="0" unique_id=680051131]
unique_name_in_owner = true
visible = false
custom_minimum_size = Vector2(360, 120)
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/EndMessagePanel" index="0" unique_id=899651798]
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
[node name="ThankPlayer" type="Label" parent="CenterContainer/EndMessagePanel/VBoxContainer" index="0" unique_id=1020885934]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Thanks for playing!"
horizontal_alignment = 1
vertical_alignment = 1
[node name="CenterContainer" type="CenterContainer" parent="CenterContainer/EndMessagePanel/VBoxContainer" index="1" unique_id=1208569595]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/EndMessagePanel/VBoxContainer/CenterContainer" index="0" unique_id=1415249609]
custom_minimum_size = Vector2(256, 0)
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/separation = 16
script = ExtResource("4_1kqi1")
[node name="ExitButton" type="Button" parent="CenterContainer/EndMessagePanel/VBoxContainer/CenterContainer/HBoxContainer" index="0" unique_id=1382070624]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Exit"
[node name="MenuButton" type="Button" parent="CenterContainer/EndMessagePanel/VBoxContainer/CenterContainer/HBoxContainer" index="1" unique_id=1504498101]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Menu"
[connection signal="pressed" from="CenterContainer/EndMessagePanel/VBoxContainer/CenterContainer/HBoxContainer/ExitButton" to="." method="_on_exit_button_pressed"]
[connection signal="pressed" from="CenterContainer/EndMessagePanel/VBoxContainer/CenterContainer/HBoxContainer/MenuButton" to="." method="_on_menu_button_pressed"]