Basic game template addon
This commit is contained in:
12
menus/scenes/game_scene/configurable_sub_viewport.gd
Normal file
12
menus/scenes/game_scene/configurable_sub_viewport.gd
Normal file
@@ -0,0 +1,12 @@
|
||||
extends SubViewport
|
||||
## Script to apply the anti-aliasing setting from [PlayerConfig] to a [SubViewport].
|
||||
|
||||
## The name of the anti-aliasing variable in the [ConfigFile].
|
||||
@export var anti_aliasing_key : StringName = "Anti-aliasing"
|
||||
## The name of the section of the anti-aliasing variable in the [ConfigFile].
|
||||
@export var video_section : StringName = AppSettings.VIDEO_SECTION
|
||||
|
||||
func _ready() -> void:
|
||||
var anti_aliasing : int = PlayerConfig.get_config(video_section, anti_aliasing_key, Viewport.MSAA_DISABLED)
|
||||
msaa_2d = anti_aliasing as MSAA
|
||||
msaa_3d = anti_aliasing as MSAA
|
||||
1
menus/scenes/game_scene/configurable_sub_viewport.gd.uid
Normal file
1
menus/scenes/game_scene/configurable_sub_viewport.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://sriramsx75sj
|
||||
61
menus/scenes/game_scene/game_ui.tscn
Normal file
61
menus/scenes/game_scene/game_ui.tscn
Normal file
@@ -0,0 +1,61 @@
|
||||
[gd_scene format=3 uid="uid://c3cpdpo8fcass"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/maaacks_game_template/base/nodes/utilities/pause_menu_controller.gd" id="1_78lb1"]
|
||||
[ext_resource type="PackedScene" path="res://menus/scenes/windows/pause_menu_layer.tscn" id="2_fc12x"]
|
||||
[ext_resource type="Script" path="res://addons/maaacks_game_template/extras/scripts/level_loader.gd" id="3_xinp6"]
|
||||
[ext_resource type="Script" path="res://addons/maaacks_game_template/extras/scripts/level_manager.gd" id="4_8vrg7"]
|
||||
[ext_resource type="PackedScene" path="res://menus/scenes/windows/game_won_window.tscn" id="5_5qwaf"]
|
||||
[ext_resource type="PackedScene" path="res://menus/scenes/windows/level_lost_window.tscn" id="6_0tw8m"]
|
||||
[ext_resource type="PackedScene" path="res://menus/scenes/windows/level_won_window.tscn" id="7_gpclb"]
|
||||
[ext_resource type="Script" path="res://addons/maaacks_game_template/extras/scripts/scene_lister.gd" id="8_yl32o"]
|
||||
[ext_resource type="Script" path="res://menus/scenes/game_scene/configurable_sub_viewport.gd" id="9_iioxl"]
|
||||
|
||||
[node name="GameUI" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="PauseMenuController" type="Node" parent="." node_paths=PackedStringArray("focused_viewport")]
|
||||
script = ExtResource("1_78lb1")
|
||||
pause_menu_packed = ExtResource("2_fc12x")
|
||||
focused_viewport = NodePath("../ViewportContainer/ConfigurableSubViewport")
|
||||
|
||||
[node name="LevelLoader" type="Node" parent="." node_paths=PackedStringArray("level_container")]
|
||||
script = ExtResource("3_xinp6")
|
||||
level_container = NodePath("../ViewportContainer/ConfigurableSubViewport")
|
||||
|
||||
[node name="LevelManager" type="Node" parent="." node_paths=PackedStringArray("level_loader", "scene_lister")]
|
||||
script = ExtResource("4_8vrg7")
|
||||
level_loader = NodePath("../LevelLoader")
|
||||
starting_level_path = "res://menus/scenes/game_scene/levels/level_1.tscn"
|
||||
scene_lister = NodePath("SceneLister")
|
||||
main_menu_scene_path = "res://menus/scenes/menus/main_menu/main_menu_with_animations.tscn"
|
||||
ending_scene_path = "res://menus/scenes/end_credits/end_credits.tscn"
|
||||
game_won_scene = ExtResource("5_5qwaf")
|
||||
level_lost_scene = ExtResource("6_0tw8m")
|
||||
level_won_scene = ExtResource("7_gpclb")
|
||||
|
||||
[node name="SceneLister" type="Node" parent="LevelManager"]
|
||||
script = ExtResource("8_yl32o")
|
||||
files = Array[String](["res://menus/scenes/game_scene/levels/level_1.tscn", "res://menus/scenes/game_scene/levels/level_2.tscn", "res://menus/scenes/game_scene/levels/level_3.tscn"])
|
||||
directory = "res://menus/scenes/game_scene/levels"
|
||||
|
||||
[node name="ViewportContainer" type="SubViewportContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
stretch = true
|
||||
|
||||
[node name="ConfigurableSubViewport" type="SubViewport" parent="ViewportContainer"]
|
||||
handle_input_locally = false
|
||||
audio_listener_enable_2d = true
|
||||
audio_listener_enable_3d = true
|
||||
size = Vector2i(1280, 720)
|
||||
render_target_update_mode = 4
|
||||
script = ExtResource("9_iioxl")
|
||||
21
menus/scenes/game_scene/input_display_label.gd
Normal file
21
menus/scenes/game_scene/input_display_label.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
extends Label
|
||||
|
||||
@onready var action_names := AppSettings.get_action_names()
|
||||
|
||||
func _get_inputs_as_string() -> String:
|
||||
var all_inputs : String = ""
|
||||
var is_first : bool = true
|
||||
for action_name in action_names:
|
||||
if Input.is_action_pressed(action_name):
|
||||
if is_first:
|
||||
is_first = false
|
||||
all_inputs += action_name
|
||||
else:
|
||||
all_inputs += " + " + action_name
|
||||
return all_inputs
|
||||
|
||||
func _process(_delta : float) -> void:
|
||||
if Input.is_anything_pressed():
|
||||
text = _get_inputs_as_string()
|
||||
else:
|
||||
text = ""
|
||||
1
menus/scenes/game_scene/input_display_label.gd.uid
Normal file
1
menus/scenes/game_scene/input_display_label.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dno0fo2wvo8nn
|
||||
24
menus/scenes/game_scene/levels/level.gd
Normal file
24
menus/scenes/game_scene/levels/level.gd
Normal file
@@ -0,0 +1,24 @@
|
||||
extends Node
|
||||
|
||||
signal level_lost
|
||||
signal level_won(level_path : String)
|
||||
@warning_ignore("unused_signal")
|
||||
signal level_changed(level_path : String)
|
||||
|
||||
## Optional path to the next level if using an open world level system.
|
||||
@export_file("*.tscn") var next_level_path : String
|
||||
|
||||
func _on_lose_button_pressed() -> void:
|
||||
level_lost.emit()
|
||||
|
||||
func _on_win_button_pressed() -> void:
|
||||
level_won.emit(next_level_path)
|
||||
|
||||
func open_tutorials() -> void:
|
||||
%TutorialManager.open_tutorials()
|
||||
|
||||
func _ready() -> void:
|
||||
open_tutorials()
|
||||
|
||||
func _on_tutorial_button_pressed() -> void:
|
||||
open_tutorials()
|
||||
1
menus/scenes/game_scene/levels/level.gd.uid
Normal file
1
menus/scenes/game_scene/levels/level.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d3st2mmp4nlec
|
||||
91
menus/scenes/game_scene/levels/level_1.tscn
Normal file
91
menus/scenes/game_scene/levels/level_1.tscn
Normal file
@@ -0,0 +1,91 @@
|
||||
[gd_scene format=3 uid="uid://blhb80jdsu3j5"]
|
||||
|
||||
[ext_resource type="Script" path="res://menus/scenes/game_scene/levels/level.gd" id="1_urxkg"]
|
||||
[ext_resource type="Script" path="res://addons/maaacks_game_template/base/nodes/utilities/capture_focus.gd" id="2_7sa42"]
|
||||
[ext_resource type="Script" path="res://menus/scenes/game_scene/input_display_label.gd" id="3_l3jem"]
|
||||
[ext_resource type="Script" path="res://menus/scenes/game_scene/tutorial_manager.gd" id="4_rqjq6"]
|
||||
[ext_resource type="PackedScene" path="res://menus/scenes/game_scene/tutorials/tutorial_1.tscn" id="5_n53h6"]
|
||||
|
||||
[node name="Level1" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_urxkg")
|
||||
next_level_path = "res://menus/scenes/game_scene/levels/level_2.tscn"
|
||||
|
||||
[node name="BackgroundColor" type="ColorRect" parent="."]
|
||||
unique_name_in_owner = true
|
||||
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="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 32
|
||||
theme_override_constants/margin_top = 32
|
||||
theme_override_constants/margin_right = 32
|
||||
theme_override_constants/margin_bottom = 32
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 16
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Example Level #1"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 32
|
||||
script = ExtResource("2_7sa42")
|
||||
|
||||
[node name="LoseButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Lose"
|
||||
|
||||
[node name="WinButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Win"
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TutorialButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "Tutorial"
|
||||
|
||||
[node name="InputDisplayLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
horizontal_alignment = 1
|
||||
script = ExtResource("3_l3jem")
|
||||
|
||||
[node name="TutorialManager" type="Node" parent="."]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("4_rqjq6")
|
||||
tutorial_scenes = Array[PackedScene]([ExtResource("5_n53h6")])
|
||||
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/LoseButton" to="." method="_on_lose_button_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/WinButton" to="." method="_on_win_button_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/TutorialButton" to="." method="_on_tutorial_button_pressed"]
|
||||
97
menus/scenes/game_scene/levels/level_2.tscn
Normal file
97
menus/scenes/game_scene/levels/level_2.tscn
Normal file
@@ -0,0 +1,97 @@
|
||||
[gd_scene format=3 uid="uid://j11k4ykeskdk"]
|
||||
|
||||
[ext_resource type="Script" path="res://menus/scenes/game_scene/levels/level.gd" id="1_dm1lp"]
|
||||
[ext_resource type="Script" path="res://addons/maaacks_game_template/base/nodes/utilities/capture_focus.gd" id="2_xr7u2"]
|
||||
[ext_resource type="Script" path="res://menus/scenes/game_scene/input_display_label.gd" id="3_30wab"]
|
||||
[ext_resource type="Script" path="res://menus/scenes/game_scene/tutorial_manager.gd" id="4_wuxsx"]
|
||||
[ext_resource type="PackedScene" path="res://menus/scenes/game_scene/tutorials/tutorial_2.tscn" id="5_bab38"]
|
||||
|
||||
[node name="Level2" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_dm1lp")
|
||||
next_level_path = "res://menus/scenes/game_scene/levels/level_3.tscn"
|
||||
|
||||
[node name="BackgroundColor" type="ColorRect" parent="."]
|
||||
unique_name_in_owner = true
|
||||
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="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 32
|
||||
theme_override_constants/margin_top = 32
|
||||
theme_override_constants/margin_right = 32
|
||||
theme_override_constants/margin_bottom = 32
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 16
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Example Level #2"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 32
|
||||
script = ExtResource("2_xr7u2")
|
||||
|
||||
[node name="LoseButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Lose"
|
||||
|
||||
[node name="WinButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Win"
|
||||
|
||||
[node name="LoseButton2" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Lose"
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TutorialButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "Tutorial"
|
||||
|
||||
[node name="InputDisplayLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
horizontal_alignment = 1
|
||||
script = ExtResource("3_30wab")
|
||||
|
||||
[node name="TutorialManager" type="Node" parent="."]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("4_wuxsx")
|
||||
tutorial_scenes = Array[PackedScene]([ExtResource("5_bab38")])
|
||||
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/LoseButton" to="." method="_on_lose_button_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/WinButton" to="." method="_on_win_button_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/LoseButton2" to="." method="_on_lose_button_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/TutorialButton" to="." method="_on_tutorial_button_pressed"]
|
||||
102
menus/scenes/game_scene/levels/level_3.tscn
Normal file
102
menus/scenes/game_scene/levels/level_3.tscn
Normal file
@@ -0,0 +1,102 @@
|
||||
[gd_scene format=3 uid="uid://cbxhfrfjktqmp"]
|
||||
|
||||
[ext_resource type="Script" path="res://menus/scenes/game_scene/levels/level.gd" id="1_ufhlx"]
|
||||
[ext_resource type="Script" path="res://addons/maaacks_game_template/base/nodes/utilities/capture_focus.gd" id="2_rjwxn"]
|
||||
[ext_resource type="Script" path="res://menus/scenes/game_scene/input_display_label.gd" id="3_m48ar"]
|
||||
[ext_resource type="Script" path="res://menus/scenes/game_scene/tutorial_manager.gd" id="4_j0xup"]
|
||||
[ext_resource type="PackedScene" path="res://menus/scenes/game_scene/tutorials/tutorial_3.tscn" id="5_hpu0q"]
|
||||
|
||||
[node name="Level3" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_ufhlx")
|
||||
|
||||
[node name="BackgroundColor" type="ColorRect" parent="."]
|
||||
unique_name_in_owner = true
|
||||
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="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 32
|
||||
theme_override_constants/margin_top = 32
|
||||
theme_override_constants/margin_right = 32
|
||||
theme_override_constants/margin_bottom = 32
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 16
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Example Level #3"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 32
|
||||
script = ExtResource("2_rjwxn")
|
||||
|
||||
[node name="WinButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Win"
|
||||
|
||||
[node name="LoseButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Lose"
|
||||
|
||||
[node name="LoseButton2" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Lose"
|
||||
|
||||
[node name="LoseButton3" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Lose"
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TutorialButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "Tutorial"
|
||||
|
||||
[node name="InputDisplayLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
horizontal_alignment = 1
|
||||
script = ExtResource("3_m48ar")
|
||||
|
||||
[node name="TutorialManager" type="Node" parent="."]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("4_j0xup")
|
||||
tutorial_scenes = Array[PackedScene]([ExtResource("5_hpu0q")])
|
||||
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/WinButton" to="." method="_on_win_button_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/LoseButton" to="." method="_on_lose_button_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/LoseButton2" to="." method="_on_lose_button_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/LoseButton3" to="." method="_on_lose_button_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/TutorialButton" to="." method="_on_tutorial_button_pressed"]
|
||||
27
menus/scenes/game_scene/tutorial_manager.gd
Normal file
27
menus/scenes/game_scene/tutorial_manager.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends Node
|
||||
## A script to add into a level or game scene to display tutorial windows.
|
||||
|
||||
## A list of tutorial scenes to open, one after the other.
|
||||
@export var tutorial_scenes : Array[PackedScene]
|
||||
## If true, open the tutorials when the scene becomes ready.
|
||||
@export var auto_open : bool = false
|
||||
## Delay before opening the tutorials when the scene becomes ready.
|
||||
@export var auto_open_delay : float = 0.25
|
||||
|
||||
func open_tutorials() -> void:
|
||||
var _initial_focus_control : Control = get_viewport().gui_get_focus_owner()
|
||||
for tutorial_scene in tutorial_scenes:
|
||||
var tutorial_menu : Control = tutorial_scene.instantiate()
|
||||
if tutorial_menu == null:
|
||||
push_warning("tutorial failed to open %s" % tutorial_scene)
|
||||
return
|
||||
get_tree().current_scene.call_deferred("add_child", tutorial_menu)
|
||||
await tutorial_menu.tree_exited
|
||||
if is_inside_tree() and _initial_focus_control:
|
||||
_initial_focus_control.grab_focus()
|
||||
|
||||
func _ready() -> void:
|
||||
if auto_open:
|
||||
if auto_open_delay > 0.0:
|
||||
await get_tree().create_timer(auto_open_delay, false).timeout
|
||||
open_tutorials.call_deferred()
|
||||
1
menus/scenes/game_scene/tutorial_manager.gd.uid
Normal file
1
menus/scenes/game_scene/tutorial_manager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dnuloyvbcw7jd
|
||||
19
menus/scenes/game_scene/tutorials/tutorial_1.tscn
Normal file
19
menus/scenes/game_scene/tutorials/tutorial_1.tscn
Normal file
@@ -0,0 +1,19 @@
|
||||
[gd_scene format=3 uid="uid://ccho26xthu50o"]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://addons/maaacks_game_template/base/nodes/windows/overlaid_window.tscn" id="1_jp4os"]
|
||||
|
||||
[node name="OverlaidWindow" instance=ExtResource("1_jp4os")]
|
||||
custom_minimum_size = Vector2(420, 200)
|
||||
update_content = true
|
||||
text = "Click the Win button to progress.
|
||||
Click the Lose button to try again."
|
||||
title = "Tutorial"
|
||||
title_font_size = 20
|
||||
|
||||
[node name="TitleLabel" parent="ContentContainer/BoxContainer/TitleMargin/BoxContainer" index="0"]
|
||||
theme_override_font_sizes/font_size = 20
|
||||
text = "Tutorial"
|
||||
|
||||
[node name="DescriptionLabel" parent="ContentContainer/BoxContainer/BodyMargin" index="0"]
|
||||
text = "Click the Win button to progress.
|
||||
Click the Lose button to try again."
|
||||
17
menus/scenes/game_scene/tutorials/tutorial_2.tscn
Normal file
17
menus/scenes/game_scene/tutorials/tutorial_2.tscn
Normal file
@@ -0,0 +1,17 @@
|
||||
[gd_scene format=3 uid="uid://vv0uamr284l6"]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://addons/maaacks_game_template/base/nodes/windows/overlaid_window.tscn" id="1_83bj0"]
|
||||
|
||||
[node name="OverlaidWindow" instance=ExtResource("1_83bj0")]
|
||||
custom_minimum_size = Vector2(420, 200)
|
||||
update_content = true
|
||||
text = "Pressing Escape will open the Pause Menu."
|
||||
title = "Tutorial"
|
||||
title_font_size = 20
|
||||
|
||||
[node name="TitleLabel" parent="ContentContainer/BoxContainer/TitleMargin/BoxContainer" index="0"]
|
||||
theme_override_font_sizes/font_size = 20
|
||||
text = "Tutorial"
|
||||
|
||||
[node name="DescriptionLabel" parent="ContentContainer/BoxContainer/BodyMargin" index="0"]
|
||||
text = "Pressing Escape will open the Pause Menu."
|
||||
17
menus/scenes/game_scene/tutorials/tutorial_3.tscn
Normal file
17
menus/scenes/game_scene/tutorials/tutorial_3.tscn
Normal file
@@ -0,0 +1,17 @@
|
||||
[gd_scene format=3 uid="uid://bxxaeanswkvyy"]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://addons/maaacks_game_template/base/nodes/windows/overlaid_window.tscn" id="1_301qr"]
|
||||
|
||||
[node name="OverlaidWindow" instance=ExtResource("1_301qr")]
|
||||
custom_minimum_size = Vector2(420, 200)
|
||||
update_content = true
|
||||
text = "The label at the bottom-center displays the current input action detected, if any are setup for the project."
|
||||
title = "Tutorial"
|
||||
title_font_size = 20
|
||||
|
||||
[node name="TitleLabel" parent="ContentContainer/BoxContainer/TitleMargin/BoxContainer" index="0"]
|
||||
theme_override_font_sizes/font_size = 20
|
||||
text = "Tutorial"
|
||||
|
||||
[node name="DescriptionLabel" parent="ContentContainer/BoxContainer/BodyMargin" index="0"]
|
||||
text = "The label at the bottom-center displays the current input action detected, if any are setup for the project."
|
||||
Reference in New Issue
Block a user