Basic game template addon
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 6s
Create tag and build when new code gets to main / Export (push) Successful in 1m1s

This commit is contained in:
2026-01-30 19:45:56 +01:00
parent b923f6bec2
commit 44f251ed66
406 changed files with 12602 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
@tool
class_name ConfirmationOverlaidWindow
extends OverlaidWindow
signal confirmed
@onready var confirm_button : Button = %ConfirmButton
@export var confirm_button_text : String = "Confirm" :
set(value):
confirm_button_text = value
if update_content and is_inside_tree():
confirm_button.text = confirm_button_text
func confirm():
confirmed.emit()
close()
func _on_confirm_button_pressed():
confirm()

View File

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

View File

@@ -0,0 +1,23 @@
[gd_scene load_steps=3 format=3 uid="uid://cwt4p3bufkke5"]
[ext_resource type="PackedScene" uid="uid://6gdbfi0172ji" path="res://addons/maaacks_game_template/base/nodes/windows/overlaid_window.tscn" id="1_vfkm2"]
[ext_resource type="Script" uid="uid://bgthh72eu0du" path="res://addons/maaacks_game_template/base/nodes/windows/confirmation_overlaid_window.gd" id="2_sw7p1"]
[node name="ConfirmationOverlaidWindow" instance=ExtResource("1_vfkm2")]
script = ExtResource("2_sw7p1")
confirm_button_text = "Confirm"
update_content = true
close_button_text = "Cancel"
[node name="MenuButtons" parent="ContentContainer/BoxContainer/MenuButtonsMargin" index="0"]
vertical = false
[node name="CloseButton" parent="ContentContainer/BoxContainer/MenuButtonsMargin/MenuButtons" index="0"]
text = "Cancel"
[node name="ConfirmButton" type="Button" parent="ContentContainer/BoxContainer/MenuButtonsMargin/MenuButtons" index="1"]
unique_name_in_owner = true
layout_mode = 2
text = "Confirm"
[connection signal="pressed" from="ContentContainer/BoxContainer/MenuButtonsMargin/MenuButtons/ConfirmButton" to="." method="_on_confirm_button_pressed"]

View File

@@ -0,0 +1,63 @@
@tool
class_name OverlaidWindow
extends WindowContainer
@export var pauses_game : bool = false :
set(value):
pauses_game = value
if pauses_game:
process_mode = PROCESS_MODE_ALWAYS
else:
process_mode = PROCESS_MODE_INHERIT
@export var makes_mouse_visible : bool = true
@export var exclusive : bool = true
@export var exclusive_background_color : Color
var _initial_pause_state : bool = false
var _initial_focus_mode : FocusMode = FOCUS_ALL
var _initial_mouse_mode : Input.MouseMode
var _initial_focus_control
var _scene_tree : SceneTree
var _exclusive_control_node : ColorRect
func close() -> void:
if not visible: return
_scene_tree.paused = _initial_pause_state
Input.set_mouse_mode(_initial_mouse_mode)
if is_instance_valid(_initial_focus_control) and _initial_focus_control.is_inside_tree():
_initial_focus_control.focus_mode = _initial_focus_mode
_initial_focus_control.grab_focus()
if _exclusive_control_node:
_exclusive_control_node.queue_free()
super.close()
func _overlaid_window_setup():
if _scene_tree:
_initial_pause_state = _scene_tree.paused
_initial_mouse_mode = Input.get_mouse_mode()
_initial_focus_control = get_viewport().gui_get_focus_owner()
if _initial_focus_control:
_initial_focus_mode = _initial_focus_control.focus_mode
_initial_focus_control.release_focus()
if Engine.is_editor_hint(): return
_scene_tree.paused = pauses_game or _initial_pause_state
if makes_mouse_visible:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if exclusive:
_exclusive_control_node = ColorRect.new()
_exclusive_control_node.name = self.name + "ExclusiveControl"
_exclusive_control_node.color = exclusive_background_color
_exclusive_control_node.set_anchors_preset(PRESET_FULL_RECT)
add_sibling.call_deferred(_exclusive_control_node)
await _exclusive_control_node.draw
get_parent().move_child(_exclusive_control_node, get_index())
func _on_visibility_changed() -> void:
if is_visible_in_tree():
_overlaid_window_setup()
func _enter_tree() -> void:
_scene_tree = get_tree()
if not visibility_changed.is_connected(_on_visibility_changed):
visibility_changed.connect(_on_visibility_changed)
_on_visibility_changed()

View File

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

View File

@@ -0,0 +1,12 @@
[gd_scene load_steps=3 format=3 uid="uid://6gdbfi0172ji"]
[ext_resource type="Script" uid="uid://xfugmpspqbcc" path="res://addons/maaacks_game_template/base/nodes/windows/overlaid_window.gd" id="1_euyj1"]
[ext_resource type="PackedScene" uid="uid://b2s0kvrx8r2kq" path="res://addons/maaacks_game_template/base/nodes/windows/window_container.tscn" id="2_pmk27"]
[node name="OverlaidWindow" instance=ExtResource("2_pmk27")]
process_mode = 0
script = ExtResource("1_euyj1")
pauses_game = false
makes_mouse_visible = true
exclusive = true
exclusive_background_color = Color(0, 0, 0, 0.5)

View File

@@ -0,0 +1,19 @@
@tool
class_name OverlaidWindowContainer
extends OverlaidWindow
var instance : Node
@onready var scene_container : Container = %SceneContainer
@export var packed_scene : PackedScene :
set(value):
packed_scene = value
if is_inside_tree():
for child in scene_container.get_children():
child.queue_free()
if packed_scene:
instance = packed_scene.instantiate()
scene_container.add_child(instance)
func _ready() -> void:
packed_scene = packed_scene

View File

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

View File

@@ -0,0 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://crndfbb22ri4s"]
[ext_resource type="PackedScene" uid="uid://6gdbfi0172ji" path="res://addons/maaacks_game_template/base/nodes/windows/overlaid_window.tscn" id="1_07348"]
[ext_resource type="Script" uid="uid://c6pmyo50c1tqy" path="res://addons/maaacks_game_template/base/nodes/windows/overlaid_window_scene_container.gd" id="2_p673y"]
[node name="OverlaidWindowSceneContainer" instance=ExtResource("1_07348")]
script = ExtResource("2_p673y")
packed_scene = null
[node name="SceneContainer" type="MarginContainer" parent="ContentContainer/BoxContainer/BodyMargin" index="1"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3

View File

@@ -0,0 +1,80 @@
@tool
class_name WindowContainer
extends PanelContainer
signal closed
signal opened
@export var ui_cancel_closes : bool = true
@export_group("Content")
@export var update_content : bool = false
@export_multiline var text : String :
set(value):
text = value
if update_content and is_inside_tree():
description_label.text = text
@export var close_button_text : String = "Close" :
set(value):
close_button_text = value
if update_content and is_inside_tree():
close_button.text = close_button_text
@export_subgroup("Title")
@export var title : String = "Menu" :
set(value):
title = value
if update_content and is_inside_tree():
title_label.text = title
@export_range(0, 1000, 1) var title_font_size : int = 16 :
set(value):
title_font_size = value
if update_content and is_inside_tree():
title_label.set("theme_override_font_sizes/font_size", title_font_size)
@export var title_visible : bool = true :
set(value):
title_visible = value
if update_content and is_inside_tree():
title_margin.visible = title_visible
@onready var content_container : Container = %ContentContainer
@onready var title_label : Label = %TitleLabel
@onready var title_margin : MarginContainer = %TitleMargin
@onready var description_label : RichTextLabel = %DescriptionLabel
@onready var close_button : Button = %CloseButton
@onready var menu_buttons : BoxContainer = %MenuButtons
func _ready() -> void:
update_content = update_content
text = text
close_button_text = close_button_text
title = title
title_font_size = title_font_size
title_visible = title_visible
func close() -> void:
if not visible: return
hide()
closed.emit()
func _handle_cancel_input() -> void:
close()
func _unhandled_input(event : InputEvent) -> void:
if visible and event.is_action_released("ui_cancel") and ui_cancel_closes:
_handle_cancel_input()
get_viewport().set_input_as_handled()
func _on_close_button_pressed() -> void:
close()
func show() -> void:
super.show()
opened.emit()
func _exit_tree():
if Engine.is_editor_hint(): return
close()

View File

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

View File

@@ -0,0 +1,90 @@
[gd_scene load_steps=3 format=3 uid="uid://b2s0kvrx8r2kq"]
[ext_resource type="Script" uid="uid://b3onujul5qho1" path="res://addons/maaacks_game_template/base/nodes/windows/window_container.gd" id="1_te2s1"]
[ext_resource type="Script" uid="uid://1nf36h0gms3q" path="res://addons/maaacks_game_template/base/nodes/utilities/capture_focus.gd" id="2_xihbi"]
[node name="WindowContainer" type="PanelContainer"]
process_mode = 3
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -80.0
offset_top = -50.0
offset_right = 80.0
offset_bottom = 50.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
script = ExtResource("1_te2s1")
[node name="ContentContainer" type="MarginContainer" parent="."]
unique_name_in_owner = true
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="BoxContainer" type="BoxContainer" parent="ContentContainer"]
layout_mode = 2
vertical = true
[node name="TitleMargin" type="MarginContainer" parent="ContentContainer/BoxContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/margin_left = -14
theme_override_constants/margin_top = -14
theme_override_constants/margin_right = -14
theme_override_constants/margin_bottom = 8
[node name="BoxContainer" type="BoxContainer" parent="ContentContainer/BoxContainer/TitleMargin"]
layout_mode = 2
theme_override_constants/separation = 0
vertical = true
[node name="TitleLabel" type="Label" parent="ContentContainer/BoxContainer/TitleMargin/BoxContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_font_sizes/font_size = 16
text = "Menu"
horizontal_alignment = 1
[node name="HSeparator" type="HSeparator" parent="ContentContainer/BoxContainer/TitleMargin/BoxContainer"]
layout_mode = 2
[node name="BodyMargin" type="MarginContainer" parent="ContentContainer/BoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
[node name="DescriptionLabel" type="RichTextLabel" parent="ContentContainer/BoxContainer/BodyMargin"]
unique_name_in_owner = true
layout_mode = 2
bbcode_enabled = true
fit_content = true
horizontal_alignment = 1
vertical_alignment = 1
[node name="MenuButtonsMargin" type="MarginContainer" parent="ContentContainer/BoxContainer"]
layout_mode = 2
theme_override_constants/margin_top = 8
[node name="MenuButtons" type="BoxContainer" parent="ContentContainer/BoxContainer/MenuButtonsMargin"]
unique_name_in_owner = true
custom_minimum_size = Vector2(128, 0)
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/separation = 16
alignment = 1
vertical = true
script = ExtResource("2_xihbi")
[node name="CloseButton" type="Button" parent="ContentContainer/BoxContainer/MenuButtonsMargin/MenuButtons"]
unique_name_in_owner = true
layout_mode = 2
text = "Close"
[connection signal="pressed" from="ContentContainer/BoxContainer/MenuButtonsMargin/MenuButtons/CloseButton" to="." method="_on_close_button_pressed"]