Basic game template addon
This commit is contained in:
63
menus/scenes/end_credits/end_credits.gd
Normal file
63
menus/scenes/end_credits/end_credits.gd
Normal file
@@ -0,0 +1,63 @@
|
||||
@tool
|
||||
extends "res://menus/scenes/credits/scrolling_credits.gd"
|
||||
|
||||
## Defines the path to the main menu. Hides the Main Menu button if not set.
|
||||
@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
|
||||
## If Maaack's Scene Loader is installed, then it will be used to change scenes.
|
||||
@onready var scene_loader_node = get_tree().root.get_node_or_null(^"SceneLoader")
|
||||
|
||||
func get_main_menu_scene_path() -> String:
|
||||
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:
|
||||
if scene_loader_node:
|
||||
scene_loader_node.load_scene(get_main_menu_scene_path())
|
||||
else:
|
||||
get_tree().change_scene_to_file(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()
|
||||
1
menus/scenes/end_credits/end_credits.gd.uid
Normal file
1
menus/scenes/end_credits/end_credits.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://do6bw0acofct2
|
||||
85
menus/scenes/end_credits/end_credits.tscn
Normal file
85
menus/scenes/end_credits/end_credits.tscn
Normal file
@@ -0,0 +1,85 @@
|
||||
[gd_scene format=3 uid="uid://bn4qfscxapbnx"]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://menus/scenes/credits/scrolling_credits.tscn" id="1_eh07o"]
|
||||
[ext_resource type="Script" path="res://menus/scenes/end_credits/end_credits.gd" id="2_5f0mc"]
|
||||
[ext_resource type="Script" path="res://addons/maaacks_game_template/base/nodes/utilities/capture_focus.gd" id="3_ixi0r"]
|
||||
|
||||
[node name="EndCredits" instance=ExtResource("1_eh07o")]
|
||||
script = ExtResource("2_5f0mc")
|
||||
main_menu_scene_path = "res://menus/scenes/menus/main_menu/main_menu_with_animations.tscn"
|
||||
force_mouse_mode_visible = false
|
||||
|
||||
[node name="BackgroundColor" type="ColorRect" parent="." index="0"]
|
||||
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="1"]
|
||||
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="3"]
|
||||
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_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"]
|
||||
layout_mode = 0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="ThankPlayer" type="Label" parent="CenterContainer/EndMessagePanel/VBoxContainer" index="0"]
|
||||
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"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/EndMessagePanel/VBoxContainer/CenterContainer" index="0"]
|
||||
custom_minimum_size = Vector2(256, 0)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 16
|
||||
script = ExtResource("3_ixi0r")
|
||||
|
||||
[node name="ExitButton" type="Button" parent="CenterContainer/EndMessagePanel/VBoxContainer/CenterContainer/HBoxContainer" index="0"]
|
||||
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_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"]
|
||||
Reference in New Issue
Block a user