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,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,23 @@
[gd_scene 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" unique_id=1482267070 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" parent_id_path=PackedInt32Array(1413292752) index="0" unique_id=1371114575]
vertical = false
[node name="CloseButton" parent="ContentContainer/BoxContainer/MenuButtonsMargin/MenuButtons" index="0" unique_id=314526102]
text = "Cancel"
[node name="ConfirmButton" type="Button" parent="ContentContainer/BoxContainer/MenuButtonsMargin/MenuButtons" index="1" unique_id=1052970550]
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,77 @@
@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_mouse_mode : Input.MouseMode
var _initial_focus_control
var _initial_node_focus_modes : Dictionary
var _scene_tree : SceneTree
var _exclusive_control_node : ColorRect
func _set_focus_none(node : Node) -> void:
for child in node.get_children():
if child == self: continue
if child is Control:
_initial_node_focus_modes[child] = child.focus_mode
child.focus_mode = Control.FOCUS_NONE
_set_focus_none(child)
func _set_focus_initial() -> void:
for node in _initial_node_focus_modes:
if is_instance_valid(node) and node is Control:
node.focus_mode = _initial_node_focus_modes[node]
_initial_node_focus_modes.clear()
func close() -> void:
if not visible: return
_scene_tree.paused = _initial_pause_state
Input.set_mouse_mode(_initial_mouse_mode)
_set_focus_initial()
if is_instance_valid(_initial_focus_control) and _initial_focus_control.is_inside_tree():
_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_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:
_set_focus_none(get_tree().current_scene)
_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 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" unique_id=343706911 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,13 @@
[gd_scene 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" unique_id=232665413 instance=ExtResource("1_07348")]
script = ExtResource("2_p673y")
packed_scene = null
[node name="SceneContainer" type="MarginContainer" parent="ContentContainer/BoxContainer/BodyMargin" parent_id_path=PackedInt32Array(590613964) index="1" unique_id=1464754606]
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 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" unique_id=2023947717]
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_id=1755486830]
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" unique_id=394030069]
layout_mode = 2
vertical = true
[node name="TitleMargin" type="MarginContainer" parent="ContentContainer/BoxContainer" unique_id=1262022916]
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" unique_id=1788474031]
layout_mode = 2
theme_override_constants/separation = 0
vertical = true
[node name="TitleLabel" type="Label" parent="ContentContainer/BoxContainer/TitleMargin/BoxContainer" unique_id=1049966061]
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" unique_id=33373596]
layout_mode = 2
[node name="BodyMargin" type="MarginContainer" parent="ContentContainer/BoxContainer" unique_id=590613964]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
[node name="DescriptionLabel" type="RichTextLabel" parent="ContentContainer/BoxContainer/BodyMargin" unique_id=617407155]
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" unique_id=1413292752]
layout_mode = 2
theme_override_constants/margin_top = 8
[node name="MenuButtons" type="BoxContainer" parent="ContentContainer/BoxContainer/MenuButtonsMargin" unique_id=1371114575]
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_id=314526102]
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"]