First commit 🎉

This commit is contained in:
Tony Bark 2025-07-17 01:49:18 -04:00
commit 43ea213f9b
728 changed files with 37080 additions and 0 deletions

View file

@ -0,0 +1,80 @@
@tool
extends "res://addons/popochiu/editor/popups/create_object/create_object.gd"
## Creates a new [PopochiuCharacter].
##
## It creates all the necessary files to make a [PopochiuCharacter] to work and to
## store its state:
## - character_xxx.tscn
## - character_xxx.gd
## - character_xxx.tres
## - character_xxx_state.gd
var _new_character_name := ""
var _factory: PopochiuCharacterFactory
var _show_set_as_pc := false : set = set_show_set_as_pc
@onready var set_as_pc_panel: PanelContainer = %SetAsPCPanel
@onready var rtl_is_pc: RichTextLabel = %RtlIsPC
@onready var btn_is_pc: CheckBox = %BtnIsPC
#region Godot ######################################################################################
func _ready() -> void:
_info_files = _info_files.replace("&t", "character")
super()
#endregion
#region Virtual ####################################################################################
func _create() -> Object:
if _new_character_name.is_empty():
error_feedback.show()
return null
# Setup the prop helper and use it to create the prop ------------------------------------------
_factory = PopochiuCharacterFactory.new()
if _factory.create(_new_character_name, btn_is_pc.button_pressed) != ResultCodes.SUCCESS:
# TODO: show a message in the popup!
return null
await get_tree().create_timer(0.1).timeout
return _factory.get_obj_scene()
func _on_about_to_popup() -> void:
PopochiuEditorHelper.override_font(rtl_is_pc, "normal_font", "main")
PopochiuEditorHelper.override_font(rtl_is_pc, "bold_font", "bold")
PopochiuEditorHelper.override_font(rtl_is_pc, "italics_font", "doc_italic")
_check_if_has_pc()
info.hide()
func _set_info_text() -> void:
_new_character_name = _name.to_snake_case()
_target_folder = PopochiuResources.CHARACTERS_PATH.path_join(_new_character_name)
info.text = (_info_text % _target_folder).replace("&n", _new_character_name)
#endregion
#region SetGet #####################################################################################
func set_show_set_as_pc(value: bool) -> void:
_show_set_as_pc = value
if is_instance_valid(set_as_pc_panel):
set_as_pc_panel.visible = _show_set_as_pc
#endregion
#region Private ####################################################################################
func _check_if_has_pc() -> void:
# Display the checkbox if the game's PC has not been defined yet
_show_set_as_pc = PopochiuResources.get_data_value("setup", "pc", "").is_empty()
#endregion

View file

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

View file

@ -0,0 +1,36 @@
[gd_scene load_steps=3 format=3 uid="uid://q0mx8fu63d03"]
[ext_resource type="PackedScene" uid="uid://c1pfl2gwjjot5" path="res://addons/popochiu/editor/popups/create_object/create_object.tscn" id="1_dtng2"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/create_object/create_character/create_character.gd" id="2_8yo43"]
[node name="CreateCharacterConfirmation" instance=ExtResource("1_dtng2")]
script = ExtResource("2_8yo43")
[node name="Label" parent="PanelContainer/VBoxContainer/InputContainer" index="0"]
text = "Character name:"
[node name="Guide" parent="PanelContainer/VBoxContainer" index="3"]
text = "Use a descriptive name in PascalCase (e.g. Glottis, MannyCalavera, HectorLeMans)."
[node name="SetAsPCPanel" type="PanelContainer" parent="PanelContainer/VBoxContainer" index="4"]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer/SetAsPCPanel" index="0"]
layout_mode = 2
[node name="RtlIsPC" type="RichTextLabel" parent="PanelContainer/VBoxContainer/SetAsPCPanel/HBoxContainer" index="0"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
bbcode_enabled = true
text = "You don't have a Player-controlled Character ([b]PC[/b]) yet. Do you want this character to become the [b]PC[/b]?
[i]You can change this later in the context menu for each character or by code during runtime.[/i]"
fit_content = true
scroll_active = false
[node name="BtnIsPC" type="CheckBox" parent="PanelContainer/VBoxContainer/SetAsPCPanel/HBoxContainer" index="1"]
unique_name_in_owner = true
layout_mode = 2

View file

@ -0,0 +1,46 @@
@tool
extends "res://addons/popochiu/editor/popups/create_object/create_object.gd"
## Creates a new [PopochiuDialog].
##
## It creates all the necessary files to make a [PopochiuDialog] to work:
## - dialog_xxx.gd (The script where the behavior for each dialog option is defined)
## - dialog_xxx.tres (The Resource file used to create the dialog options in the Inspector)
var _new_dialog_name := ""
var _factory: PopochiuDialogFactory
#region Godot ######################################################################################
func _ready() -> void:
_info_files = "[code]- &t_&n.gd\n- &t_&n.tres[/code]"
_info_files = _info_files.replace("&t", "dialog")
super()
#endregion
#region Virtual ####################################################################################
func _create() -> Object:
if _new_dialog_name.is_empty():
error_feedback.show()
return null
# Setup the prop helper and use it to create the prop ------------------------------------------
_factory = PopochiuDialogFactory.new()
if _factory.create(_new_dialog_name) != ResultCodes.SUCCESS:
# TODO: show a message in the popup!
return null
await get_tree().create_timer(0.1).timeout
return _factory.get_obj_resource()
func _set_info_text() -> void:
_new_dialog_name = _name.to_snake_case()
_target_folder = PopochiuResources.DIALOGS_PATH.path_join(_new_dialog_name)
info.text = (_info_text % _target_folder).replace("&n", _new_dialog_name)
#endregion

View file

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

View file

@ -0,0 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://dlhcgfucwffgr"]
[ext_resource type="PackedScene" uid="uid://c1pfl2gwjjot5" path="res://addons/popochiu/editor/popups/create_object/create_object.tscn" id="1_i1dna"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/create_object/create_dialog/create_dialog.gd" id="2_ep8bb"]
[node name="CreateDialogConfirmation" instance=ExtResource("1_i1dna")]
script = ExtResource("2_ep8bb")
[node name="Label" parent="PanelContainer/VBoxContainer/InputContainer" index="0"]
text = "Dialog name:"
[node name="Guide" parent="PanelContainer/VBoxContainer" index="3"]
text = "Use a descriptive name in PascalCase (e.g. GarageGlottis, OfficeEvaDesk)."

View file

@ -0,0 +1,41 @@
@tool
extends "res://addons/popochiu/editor/popups/create_object/create_room_object.gd"
## Creates a new hotspot in the room.
var _new_hotspot_name := ""
var _factory: PopochiuHotspotFactory
#region Godot ######################################################################################
func _ready() -> void:
_group_folder = "hotspots"
_info_files = _info_files.replace("&t", "hotspot")
super()
#endregion
#region Virtual ####################################################################################
func _create() -> Object:
# Setup the region helper and use it to create the hotspot -------------------------------------
_factory = PopochiuHotspotFactory.new()
var param := PopochiuHotspotFactory.PopochiuHotspotFactoryParam.new()
param.obj_name = _new_hotspot_name
param.room = _room
if _factory.create(param) != ResultCodes.SUCCESS:
# TODO: show a message in the popup!
return null
await get_tree().create_timer(0.1).timeout
return _factory.get_obj_scene()
func _set_info_text() -> void:
_new_hotspot_name = _name.to_snake_case()
_target_folder = _group_folder % _new_hotspot_name
info.text = _info_text.replace("&n", _new_hotspot_name)
#endregion

View file

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

View file

@ -0,0 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://b7nvdcut38577"]
[ext_resource type="PackedScene" uid="uid://c1pfl2gwjjot5" path="res://addons/popochiu/editor/popups/create_object/create_object.tscn" id="1_feyc5"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/create_object/create_hotspot/create_hotspot.gd" id="2_hf5i2"]
[node name="CreateHotspotConfirmation" instance=ExtResource("1_feyc5")]
script = ExtResource("2_hf5i2")
title = "Create PopochiuHotspot"
[node name="Label" parent="PanelContainer/VBoxContainer/InputContainer" index="0"]
text = "Hotspot name:"
[node name="Guide" parent="PanelContainer/VBoxContainer" index="3"]
text = "Use a descriptive name in PascalCase (e.g. Sky, CaveEntrance)."

View file

@ -0,0 +1,48 @@
@tool
extends "res://addons/popochiu/editor/popups/create_object/create_object.gd"
## Creates a [PopochiuInventoryItem].
##
## It creates all the necessary files to make a [PopochiuInventoryItem] to work and
## to store its state:
## - inventory_item_xxx.tscn
## - inventory_item_xxx.gd
## - inventory_item_xxx.tres
## - inventory_item_xxx_state.gd
var _new_item_name := ""
var _factory: PopochiuInventoryItemFactory
#region Godot ######################################################################################
func _ready() -> void:
_info_files = _info_files.replace("&t", "inventory_item")
super()
#endregion
#region Virtual ####################################################################################
func _create() -> Object:
if _new_item_name.is_empty():
error_feedback.show()
return null
# Setup the prop helper and use it to create the prop ------------------------------------------
_factory = PopochiuInventoryItemFactory.new()
if _factory.create(_new_item_name) != ResultCodes.SUCCESS:
# TODO: show a message in the popup!
return null
await get_tree().create_timer(0.1).timeout
return _factory.get_obj_scene()
func _set_info_text() -> void:
_new_item_name = _name.to_snake_case()
_target_folder = PopochiuResources.INVENTORY_ITEMS_PATH.path_join(_new_item_name)
info.text = (_info_text % _target_folder).replace("&n", _new_item_name)
#endregion

View file

@ -0,0 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://dl6pj0tylid8w"]
[ext_resource type="PackedScene" uid="uid://c1pfl2gwjjot5" path="res://addons/popochiu/editor/popups/create_object/create_object.tscn" id="1_rtecw"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/create_object/create_inventory_item/create_inventory_item.gd" id="2_3sytb"]
[node name="CreateInventoryItemConfirmation" instance=ExtResource("1_rtecw")]
script = ExtResource("2_3sytb")
title = "Create PopochiuInventoryItem"
[node name="Label" parent="PanelContainer/VBoxContainer/InputContainer" index="0"]
text = "Item name:"
[node name="Guide" parent="PanelContainer/VBoxContainer" index="3"]
text = "Use a descriptive name in PascalCase (e.g. Scythe, WorkOrder, DeckOfCards)."

View file

@ -0,0 +1,41 @@
@tool
extends "res://addons/popochiu/editor/popups/create_object/create_room_object.gd"
# Creates a new marker in the room.
var _new_marker_name := ""
var _factory: PopochiuMarkerFactory
#region Godot ######################################################################################
func _ready() -> void:
_group_folder = "markers"
_info_files = "[code]- marker_&n.tscn[/code]"
super()
#endregion
#region Virtual ####################################################################################
func _create() -> Object:
# Setup the region helper and use it to create the marker
_factory = PopochiuMarkerFactory.new()
var param := PopochiuMarkerFactory.PopochiuRoomObjFactoryParam.new()
param.obj_name = _new_marker_name
param.room = _room
if _factory.create(param) != ResultCodes.SUCCESS:
# TODO: show a message in the popup!
return null
await get_tree().create_timer(0.1).timeout
return _factory.get_obj_scene()
func _set_info_text() -> void:
_new_marker_name = _name.to_snake_case()
_target_folder = _group_folder % _new_marker_name
info.text = _info_text.replace("&n", _new_marker_name)
#endregion

View file

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

View file

@ -0,0 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://cju64rmwue0hb"]
[ext_resource type="PackedScene" uid="uid://c1pfl2gwjjot5" path="res://addons/popochiu/editor/popups/create_object/create_object.tscn" id="1_vwqi7"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/create_object/create_marker/create_marker.gd" id="2_0x1s8"]
[node name="CreateMarkerConfirmation" instance=ExtResource("1_vwqi7")]
script = ExtResource("2_0x1s8")
[node name="Label" parent="PanelContainer/VBoxContainer/InputContainer" index="0"]
text = "Marker name:"
[node name="Guide" parent="PanelContainer/VBoxContainer" index="3"]
text = "Use a descriptive name in PascalCase (e.g. Left, SouthEast)."

View file

@ -0,0 +1,111 @@
@tool
extends Control
signal content_changed
@export var title := ""
var _info_folder := "In [b]%s[/b] the following files will be created:\n\n"
var _info_files := "[code]- &t_&n.tscn\n- &t_&n.gd\n- &t_&n.tres\n- &t_&n_state.gd[/code]"
var _info_text := ""
var _name := ""
var _target_folder := ""
var _dflt_size := Vector2.ZERO
@onready var input: LineEdit = %Input
@onready var error_container: HBoxContainer = %ErrorContainer
@onready var error_icon: TextureRect = %ErrorIcon
@onready var error_feedback: Label = %ErrorFeedback
@onready var info: RichTextLabel = %Info
#region Godot ######################################################################################
func _ready() -> void:
_info_text = _info_folder + _info_files
# Connect to children's signals
input.text_changed.connect(_update_name)
error_container.hide()
#endregion
#region Virtual ####################################################################################
func _create() -> Object:
return null
func _on_about_to_popup() -> void:
pass
func _set_info_text() -> void:
pass
#endregion
#region Public #####################################################################################
func on_about_to_popup() -> void:
PopochiuEditorHelper.override_font(info, "normal_font", "main")
PopochiuEditorHelper.override_font(info, "bold_font", "bold")
PopochiuEditorHelper.override_font(info, "mono_font", "source")
error_icon.texture = get_theme_icon("StatusError", "EditorIcons")
error_feedback.add_theme_color_override("font_color", get_theme_color("error_color", "Editor"))
_on_about_to_popup()
await get_tree().process_frame
_dflt_size = get_child(0).size
content_changed.emit()
func create() -> void:
var created_object := await _create()
if not created_object or not is_instance_valid(created_object):
return
await PopochiuEditorHelper.filesystem_scanned()
# Open the scene in the editor and select the file in the FileSystem dock ----------------------
if created_object is Node:
EditorInterface.select_file(created_object.scene_file_path)
EditorInterface.open_scene_from_path(created_object.scene_file_path)
else:
EditorInterface.select_file(created_object.resource_path)
EditorInterface.edit_resource(load(created_object.resource_path))
#endregion
#region Private ####################################################################################
func _update_name(new_text: String) -> void:
if error_container.visible:
error_container.hide()
_name = new_text.to_pascal_case()
if _name.is_empty():
info.text = ""
info.hide()
else:
_set_info_text()
info.show()
# Check if another object with the same name is already created
if DirAccess.dir_exists_absolute(_target_folder):
error_feedback.text = "Another object with that name already exists!"
error_container.show()
_info_updated()
(get_parent() as ConfirmationDialog).get_ok_button().disabled = error_container.visible
func _info_updated() -> void:
await get_tree().process_frame
get_child(0).size.y = _dflt_size.y
content_changed.emit()
#endregion

View file

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

View file

@ -0,0 +1,76 @@
[gd_scene load_steps=3 format=3 uid="uid://c1pfl2gwjjot5"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/create_object/create_object.gd" id="1_ksc3t"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_kdu1t"]
[node name="CreateObjectConfirmation" 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_ksc3t")
[node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 66.0
grow_horizontal = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_kdu1t")
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
layout_mode = 2
[node name="InputContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/InputContainer"]
layout_mode = 2
text = "Name:"
[node name="Input" type="LineEdit" parent="PanelContainer/VBoxContainer/InputContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
draw_control_chars = true
[node name="ErrorContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
[node name="ErrorIcon" type="TextureRect" parent="PanelContainer/VBoxContainer/ErrorContainer"]
unique_name_in_owner = true
layout_mode = 2
expand_mode = 2
stretch_mode = 5
[node name="ErrorFeedback" type="Label" parent="PanelContainer/VBoxContainer/ErrorContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(320, 0)
layout_mode = 2
size_flags_horizontal = 3
text = "Error!"
autowrap_mode = 2
[node name="HSeparator" type="HSeparator" parent="PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="Guide" type="Label" parent="PanelContainer/VBoxContainer"]
modulate = Color(1, 1, 1, 0.698039)
custom_minimum_size = Vector2(320, 0)
layout_mode = 2
text = "Use a descriptive name in PascalCase (e.g. xxx)."
autowrap_mode = 2
[node name="Info" type="RichTextLabel" parent="PanelContainer/VBoxContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
bbcode_enabled = true
text = "Additional info..."
fit_content = true
scroll_active = false

View file

@ -0,0 +1,70 @@
@tool
extends "res://addons/popochiu/editor/popups/create_object/create_room_object.gd"
## Allows you to create a new Prop for a room.
##
## If it has interaction, it will be assigned a script that will be saved in the prop's folder.
var _new_prop_name := ""
var _factory: PopochiuPropFactory
@onready var interaction_checkbox: CheckBox = %InteractionCheckbox
#region Godot ######################################################################################
func _ready() -> void:
_group_folder = "props"
_info_files = _info_files.replace("&t", "prop")
super()
# Connect to children's signals
interaction_checkbox.toggled.connect(_interaction_toggled)
#endregion
#region Virtual ####################################################################################
func _create() -> Object:
if _new_prop_name.is_empty():
error_feedback.show()
return null
# Setup the prop helper and use it to create the prop ------------------------------------------
_factory = PopochiuPropFactory.new()
var param := PopochiuPropFactory.PopochiuPropFactoryParam.new()
param.obj_name = _new_prop_name
param.room = _room
param.is_interactive = interaction_checkbox.button_pressed
if _factory.create(param) != ResultCodes.SUCCESS:
# TODO: show a message in the popup!
return null
await get_tree().create_timer(0.1).timeout
return _factory.get_obj_scene()
func _set_info_text() -> void:
_new_prop_name = _name.to_snake_case()
_target_folder = _group_folder % _new_prop_name
_update_info()
#endregion
#region Private ####################################################################################
func _interaction_toggled(is_pressed: bool) -> void:
if is_pressed and not _name.is_empty():
_update_info()
else:
info.text = ""
_info_updated()
func _update_info() -> void:
info.text = _info_text.replace("&n", _new_prop_name)
#endregion

View file

@ -0,0 +1 @@
uid://5wo0sonbxku7

View file

@ -0,0 +1,32 @@
[gd_scene load_steps=3 format=3 uid="uid://cpqg77rjfaa0l"]
[ext_resource type="PackedScene" uid="uid://c1pfl2gwjjot5" path="res://addons/popochiu/editor/popups/create_object/create_object.tscn" id="1_l6xki"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/create_object/create_prop/create_prop.gd" id="2_c5stu"]
[node name="CreatePropConfirmation" instance=ExtResource("1_l6xki")]
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("2_c5stu")
title = "Create PopochiuProp"
[node name="Label" parent="PanelContainer/VBoxContainer/InputContainer" index="0"]
text = "Prop name:"
[node name="InteractionContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer" index="1"]
layout_mode = 2
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/InteractionContainer" index="0"]
layout_mode = 2
text = "Will this prop have interaction?"
[node name="InteractionCheckbox" type="CheckBox" parent="PanelContainer/VBoxContainer/InteractionContainer" index="1"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="ErrorFeedback" parent="PanelContainer/VBoxContainer" index="2"]
text = "Prop name is mandatory!"
[node name="Guide" parent="PanelContainer/VBoxContainer" index="4"]
text = "Use a descriptive name in PascalCase (e.g. Bucket or WineBottle)."

View file

@ -0,0 +1,45 @@
@tool
extends "res://addons/popochiu/editor/popups/create_object/create_room_object.gd"
## Allows you to create a new Region for a room.
var _new_region_name := ""
var _factory: PopochiuRegionFactory
#region Godot ######################################################################################
func _ready() -> void:
_group_folder = "regions"
_info_files = _info_files.replace("&t", "region")
super()
#endregion
#region Virtual ####################################################################################
func _create() -> Object:
if _new_region_name.is_empty():
error_feedback.show()
return null
# Setup the region helper and use it to create the region --------------------------------------
_factory = PopochiuRegionFactory.new()
var param := PopochiuRegionFactory.PopochiuRegionFactoryParam.new()
param.obj_name = _new_region_name
param.room = _room
if _factory.create(param) != ResultCodes.SUCCESS:
# TODO: show a message in the popup!
return null
await get_tree().create_timer(0.1).timeout
return _factory.get_obj_scene()
func _set_info_text() -> void:
_new_region_name = _name.to_snake_case()
_target_folder = _group_folder % _new_region_name
info.text = _info_text.replace("&n", _new_region_name)
#endregion

View file

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

View file

@ -0,0 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://crtkojrvhklpp"]
[ext_resource type="PackedScene" uid="uid://c1pfl2gwjjot5" path="res://addons/popochiu/editor/popups/create_object/create_object.tscn" id="1_haco6"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/create_object/create_region/create_region.gd" id="2_ft6um"]
[node name="CreateRegionConfirmation" instance=ExtResource("1_haco6")]
script = ExtResource("2_ft6um")
[node name="Label" parent="PanelContainer/VBoxContainer/InputContainer" index="0"]
text = "Region name:"
[node name="Guide" parent="PanelContainer/VBoxContainer" index="3"]
text = "Use a descriptive name in PascalCase (e.g. Sand, StickyFloor)."

View file

@ -0,0 +1,80 @@
@tool
extends "res://addons/popochiu/editor/popups/create_object/create_object.gd"
## Creates a [PopochiuRoom].
##
## It creates all the necessary files to make a [PopochiuRoom] to work and
## to store its state:
## - room_xxx.tscn
## - room_xxx.gd
## - room_xxx.tres
## - room_xxx_state.gd
var _new_room_name := ""
var _factory: PopochiuRoomFactory
var _show_set_as_main := false : set = set_show_set_as_main
@onready var set_as_main_panel: PanelContainer = %SetAsMainPanel
@onready var rtl_is_main = %RtlIsMain
@onready var btn_is_main: CheckBox = %BtnIsMain
#region Godot ######################################################################################
func _ready() -> void:
_info_files = _info_files.replace("&t", "room")
super()
#endregion
#region Virtual ####################################################################################
func _create() -> Object:
if _new_room_name.is_empty():
error_feedback.show()
return null
# Setup the prop helper and use it to create the prop ------------------------------------------
_factory = PopochiuRoomFactory.new()
if _factory.create(_new_room_name, btn_is_main.button_pressed) != ResultCodes.SUCCESS:
# TODO: show a message in the popup!
return null
await get_tree().create_timer(0.1).timeout
return _factory.get_obj_scene()
func _on_about_to_popup() -> void:
PopochiuEditorHelper.override_font(rtl_is_main, "normal_font", "main")
PopochiuEditorHelper.override_font(rtl_is_main, "bold_font", "bold")
PopochiuEditorHelper.override_font(rtl_is_main, "mono_font", "source")
_check_if_first_room()
info.hide()
func _set_info_text() -> void:
_new_room_name = _name.to_snake_case()
_target_folder = PopochiuResources.ROOMS_PATH.path_join(_new_room_name)
info.text = (_info_text % _target_folder).replace("&n", _new_room_name)
#endregion
#region SetGet #####################################################################################
func set_show_set_as_main(value: bool) -> void:
_show_set_as_main = value
if is_instance_valid(set_as_main_panel):
set_as_main_panel.visible = _show_set_as_main
#endregion
#region Private ####################################################################################
func _check_if_first_room() -> void:
# Display a checkbox if no main scene has been defined for the project yet
_show_set_as_main = ProjectSettings.get_setting(PopochiuResources.MAIN_SCENE, "").is_empty()
#endregion

View file

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

View file

@ -0,0 +1,38 @@
[gd_scene load_steps=3 format=3 uid="uid://bsl3blhb8sw5"]
[ext_resource type="PackedScene" uid="uid://c1pfl2gwjjot5" path="res://addons/popochiu/editor/popups/create_object/create_object.tscn" id="1_t4kty"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/create_object/create_room/create_room.gd" id="2_s1x3y"]
[node name="CreateRoomConfirmation" instance=ExtResource("1_t4kty")]
script = ExtResource("2_s1x3y")
title = "Create PopochiuRoom"
[node name="Label" parent="PanelContainer/VBoxContainer/InputContainer" index="0"]
text = "Room name:"
[node name="ErrorFeedback" parent="PanelContainer/VBoxContainer" index="1"]
text = "A room name is mandatory!"
[node name="Guide" parent="PanelContainer/VBoxContainer" index="3"]
text = "Use a descriptive name in PascalCase (e.g. Garage or CasinoInterior)."
[node name="SetAsMainPanel" type="PanelContainer" parent="PanelContainer/VBoxContainer" index="4"]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer/SetAsMainPanel" index="0"]
layout_mode = 2
[node name="RtlIsMain" type="RichTextLabel" parent="PanelContainer/VBoxContainer/SetAsMainPanel/HBoxContainer" index="0"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
bbcode_enabled = true
text = "You don't have a main scene. Do you want this room to become the main scene of the project? This will modify [code]ProjectSettings.application/run/main_scene[/code]."
fit_content = true
scroll_active = false
[node name="BtnIsMain" type="CheckBox" parent="PanelContainer/VBoxContainer/SetAsMainPanel/HBoxContainer" index="1"]
unique_name_in_owner = true
layout_mode = 2

View file

@ -0,0 +1,37 @@
@tool
extends "res://addons/popochiu/editor/popups/create_object/create_object.gd"
var _room: Node2D = null
var _group_folder := ""
#region Godot ######################################################################################
func _init() -> void:
_info_folder = "In [b]%s[/b] the following files will be created:\n\n"
_info_files = "[code]- &t_&n.tscn\n- &t_&n.gd[/code]"
func _ready() -> void:
if PopochiuEditorHelper.is_room(EditorInterface.get_edited_scene_root()):
_room = EditorInterface.get_edited_scene_root()
_group_folder = _room.scene_file_path.get_base_dir().path_join(_group_folder + "/%s")
_info_folder = _info_folder % _group_folder.replace("/%s", "/&n")
super()
#endregion
#region Public #####################################################################################
func create() -> void:
var created_node: Node = await _create()
if not created_node or not is_instance_valid(created_node):
return
await PopochiuEditorHelper.filesystem_scanned()
# Select the node in the Scene tree and its file in the FileSystem dock ------------------------
EditorInterface.edit_node(created_node)
EditorInterface.select_file(created_node.scene_file_path)
#endregion

View file

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

View file

@ -0,0 +1,41 @@
@tool
extends "res://addons/popochiu/editor/popups/create_object/create_room_object.gd"
## Creates a new walkable area in a room.
var _new_walkable_area_name := ""
var _factory: PopochiuWalkableAreaFactory
#region Godot ######################################################################################
func _ready() -> void:
_group_folder = "walkable_areas"
_info_files = _info_files.replace("&t", "walkable_area")
super()
#endregion
#region Virtual ####################################################################################
func _create() -> Object:
# Setup the region helper and use it to create the region --------------------------------------
_factory = PopochiuWalkableAreaFactory.new()
var param := PopochiuWalkableAreaFactory.PopochiuWalkableAreaFactoryParam.new()
param.obj_name = _new_walkable_area_name
param.room = _room
if _factory.create(param) != ResultCodes.SUCCESS:
# TODO: show a message in the popup!
return null
await get_tree().create_timer(0.1).timeout
return _factory.get_obj_scene()
func _set_info_text() -> void:
_new_walkable_area_name = _name.to_snake_case()
_target_folder = _group_folder % _new_walkable_area_name
info.text = _info_text.replace("&n", _new_walkable_area_name)
#endregion

View file

@ -0,0 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://ya4nebuu2575"]
[ext_resource type="PackedScene" uid="uid://c1pfl2gwjjot5" path="res://addons/popochiu/editor/popups/create_object/create_object.tscn" id="1_4gtmy"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/create_object/create_walkable_area/create_walkable_area.gd" id="2_ey5rs"]
[node name="CreateWalkableAreaConfirmation" instance=ExtResource("1_4gtmy")]
script = ExtResource("2_ey5rs")
title = "Create PopochiuWalkableArea"
[node name="Label" parent="PanelContainer/VBoxContainer/InputContainer" index="0"]
text = "Walkable area name:"
[node name="Guide" parent="PanelContainer/VBoxContainer" index="3"]
text = "Use a descriptive name in PascalCase (e.g. Floor, SuspendedBridge)."

View file

@ -0,0 +1,30 @@
@tool
extends Control
var title := ""
var message := ""
var ask := ""
var on_confirmed: Callable
var on_canceled: Callable
@onready var message_rtl: RichTextLabel = %Message
@onready var extra: PanelContainer = %Extra
@onready var ask_rtl: RichTextLabel = %Ask
@onready var check_box: CheckBox = %CheckBox
#region Public #####################################################################################
func on_about_to_popup() -> void:
PopochiuEditorHelper.override_font(message_rtl, "normal_font", "main")
PopochiuEditorHelper.override_font(message_rtl, "bold_font", "bold")
PopochiuEditorHelper.override_font(message_rtl, "mono_font", "source")
PopochiuEditorHelper.override_font(ask_rtl, "normal_font", "main")
PopochiuEditorHelper.override_font(ask_rtl, "bold_font", "bold")
PopochiuEditorHelper.override_font(ask_rtl, "mono_font", "source")
message_rtl.text = message
ask_rtl.text = ask
extra.visible = !ask.is_empty()
#endregion

View file

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

View file

@ -0,0 +1,50 @@
[gd_scene load_steps=2 format=3 uid="uid://bcb865akap0mt"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/delete_confirmation/delete_confirmation.gd" id="1_j7hpd"]
[node name="DeleteConfirmation" 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_j7hpd")
[node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
layout_mode = 2
[node name="Message" type="RichTextLabel" parent="PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
bbcode_enabled = true
text = "You're gonna delete [b]something[/b]"
fit_content = true
[node name="Extra" type="PanelContainer" parent="PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer/Extra"]
layout_mode = 2
[node name="Ask" type="RichTextLabel" parent="PanelContainer/VBoxContainer/Extra/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 0
bbcode_enabled = true
text = "Delete also [b]this[/b]?"
fit_content = true
[node name="CheckBox" type="CheckBox" parent="PanelContainer/VBoxContainer/Extra/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2

View file

@ -0,0 +1,34 @@
@tool
extends HBoxContainer
@onready var check_box: CheckBox = $CheckBox
@onready var description: RichTextLabel = $Description
@onready var progress: TextureRect = $Progress
#region Godot ######################################################################################
func _ready() -> void:
PopochiuEditorHelper.override_font(description, "normal_font", "output_source")
PopochiuEditorHelper.override_font(description, "bold_font", "output_source_bold")
PopochiuEditorHelper.override_font(description, "italics_font", "output_source_italic")
progress.hide()
#endregion
#region Public #####################################################################################
func start() -> void:
var idx := 1
progress.visible = true
while progress.visible:
progress.texture = get_theme_icon("Progress%d" % idx, "EditorIcons")
await PopochiuEditorHelper.secs_passed(0.1)
idx = wrapi(idx + 1, 1, 9)
func stop() -> void:
progress.visible = false
#endregion

View file

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

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,44 @@
@tool
extends PanelContainer
const MIGRATION_STEP_SCENE = preload(
"res://addons/popochiu/editor/popups/migrations_panel/migration_step.tscn"
)
const MigrationStep = preload(
"res://addons/popochiu/editor/popups/migrations_panel/migration_step.gd"
)
@onready var description: Label = %Description
@onready var steps: VBoxContainer = %Steps
#region Public #####################################################################################
func set_steps(steps_texts: Array) -> void:
for text: String in steps_texts:
var step: MigrationStep = MIGRATION_STEP_SCENE.instantiate()
steps.add_child(step)
step.description.text = text
func start_step(idx: int) -> void:
(steps.get_child(idx) as MigrationStep).start()
func update_steps(popochiu_migration: PopochiuMigration) -> void:
for idx: int in popochiu_migration.completed:
var step: MigrationStep = steps.get_child(idx)
step.check_box.set_pressed_no_signal(true)
step.stop()
for idx: int in popochiu_migration.ignored:
var step: MigrationStep = steps.get_child(idx)
step.check_box.set_pressed_no_signal(false)
step.modulate.a = 0.5
step.stop()
func get_total_height() -> float:
return description.size.y + steps.size.y
#endregion

View file

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

View file

@ -0,0 +1,35 @@
[gd_scene load_steps=2 format=3 uid="uid://c1ivmn6tasatp"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/migrations_panel/migration_tab.gd" id="1_2mn16"]
[node name="MigrationTab" type="PanelContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_2mn16")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 2
[node name="Description" type="Label" parent="VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "The migration Description"
[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="Steps" type="VBoxContainer" parent="VBoxContainer/MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/separation = 8

View file

@ -0,0 +1,50 @@
@tool
extends Control
const MIGRATION_TAB_SCENE = preload(
"res://addons/popochiu/editor/popups/migrations_panel/migration_tab.tscn"
)
const MigrationTab = preload(
"res://addons/popochiu/editor/popups/migrations_panel/migration_tab.gd"
)
@onready var tab_container: TabContainer = %TabContainer
@onready var reload_label: Label = %ReloadLabel
#region Godot ######################################################################################
func _ready() -> void:
reload_label.hide()
#endregion
#region Public #####################################################################################
func add_migration(popochiu_migration: PopochiuMigration) -> void:
var migration := MIGRATION_TAB_SCENE.instantiate()
tab_container.add_child.call_deferred(migration)
await migration.ready
migration.name = popochiu_migration.get_migration_name()
migration.anchors_preset = Control.PRESET_FULL_RECT
migration.description.text = popochiu_migration.DESCRIPTION
migration.set_steps(popochiu_migration.STEPS)
func start_step(popochiu_migration: PopochiuMigration, idx: int) -> void:
var migration_tab: MigrationTab = tab_container.get_node(
popochiu_migration.get_migration_name()
)
tab_container.current_tab = migration_tab.get_index()
migration_tab.start_step(idx)
func update_steps(popochiu_migration: PopochiuMigration) -> void:
var migration_tab: MigrationTab = tab_container.get_node(
popochiu_migration.get_migration_name()
)
tab_container.current_tab = migration_tab.get_index()
migration_tab.update_steps(popochiu_migration)
#endregion

View file

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

View file

@ -0,0 +1,36 @@
[gd_scene load_steps=2 format=3 uid="uid://dws64ahd0a1s6"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/migrations_panel/migrations_panel.gd" id="1_brkhu"]
[node name="MigrationsPanel" 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_brkhu")
[node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
layout_mode = 2
[node name="TabContainer" type="TabContainer" parent="PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
[node name="ReloadLabel" type="Label" parent="PanelContainer/VBoxContainer"]
unique_name_in_owner = true
visible = false
custom_minimum_size = Vector2(320, 0)
layout_mode = 2
text = "The engine will restart after clicking OK."
autowrap_mode = 2

View file

@ -0,0 +1,13 @@
@tool
extends Control
@onready var label: Label = %Label
@onready var progress_bar: ProgressBar = %ProgressBar
#region Public #####################################################################################
func close() -> void:
get_parent().queue_free()
#endregion

View file

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

View file

@ -0,0 +1,40 @@
[gd_scene load_steps=2 format=3 uid="uid://2smr378ligwp"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/progress/progress.gd" id="1_hl3vb"]
[node name="ProgressDialog" 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_hl3vb")
[node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 54.0
grow_horizontal = 2
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"]
layout_mode = 2
alignment = 1
[node name="Label" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Text..."
horizontal_alignment = 1
[node name="ProgressBar" type="ProgressBar" parent="PanelContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 4

View file

@ -0,0 +1,4 @@
extends Button
@export_multiline var description := ""
@export var reference: Texture

View file

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

View file

@ -0,0 +1,322 @@
@tool
extends Control
signal template_copy_completed
signal size_calculated
enum GameTypes {
CUSTOM,
HD,
RETRO_PIXEL,
}
const SCALE_MESSAGE =\
"[center]▶ Base size = 356x200 | [b]scale = ( %.2f, %.2f )[/b] ◀[/center]\n\
By default the GUI will match your native game resolution. You can change this with the\
[code]Project Settings > Popochiu > GUI > Experimental Scale Gui[/code] checkbox."
const COPY_ALPHA = 0.1
const GUITemplateButton = preload(
"res://addons/popochiu/editor/popups/setup/gui_template_button.gd"
)
const PopochiuGuiTemplatesHelper = preload(
"res://addons/popochiu/editor/helpers/popochiu_gui_templates_helper.gd"
)
var _selected_template: GUITemplateButton
var _is_closing := false
var _es := EditorInterface.get_editor_settings()
@onready var welcome: RichTextLabel = %Welcome
@onready var game_width: SpinBox = %GameWidth
@onready var game_height: SpinBox = %GameHeight
@onready var scale_message: RichTextLabel = %ScaleMessage
@onready var test_width: SpinBox = %TestWidth
@onready var test_height: SpinBox = %TestHeight
@onready var game_type: OptionButton = %GameType
# ---- GUI templates section -----------------------------------------------------------------------
@onready var gui_templates: HBoxContainer = %GUITemplates
@onready var gui_templates_title: Label = %GUITemplatesTitle
@onready var gui_templates_description: Label = %GUITemplatesDescription
@onready var template_description_container: PanelContainer = %TemplateDescriptionContainer
@onready var template_description: RichTextLabel = %TemplateDescription
@onready var btn_change_template: Button = %BtnChangeTemplate
@onready var copy_process_container: MarginContainer = %CopyProcessContainer
@onready var copy_process_panel: PanelContainer = %CopyProcessPanel
@onready var copy_process_label: Label = %CopyProcessLabel
@onready var copy_process_bar: ProgressBar = %CopyProcessBar
#region Godot ######################################################################################
func _ready() -> void:
# Connect to child signals
game_width.value_changed.connect(_update_scale)
game_height.value_changed.connect(_update_scale)
btn_change_template.pressed.connect(_show_template_change_confirmation)
# Set default state
template_description_container.hide()
template_description.text = ""
#endregion
#region Public #####################################################################################
func on_about_to_popup() -> void:
welcome.add_theme_font_override("bold_font", get_theme_font("bold", "EditorFonts"))
scale_message.add_theme_font_override("normal_font", get_theme_font("main", "EditorFonts"))
scale_message.add_theme_font_override("bold_font", get_theme_font("bold", "EditorFonts"))
scale_message.add_theme_font_override("mono_font", get_theme_font("doc_source", "EditorFonts"))
gui_templates_title.add_theme_font_override("font", get_theme_font("bold", "EditorFonts"))
gui_templates_description.add_theme_font_override(
"font", get_theme_font("doc_source", "EditorFonts")
)
template_description.add_theme_font_override("bold_font", get_theme_font("bold", "EditorFonts"))
func on_close() -> void:
if _is_closing:
return
_is_closing = true
ProjectSettings.set_setting(PopochiuResources.DISPLAY_WIDTH, int(game_width.value))
ProjectSettings.set_setting(PopochiuResources.DISPLAY_HEIGHT, int(game_height.value))
ProjectSettings.set_setting(PopochiuResources.TEST_WIDTH, int(test_width.value))
ProjectSettings.set_setting(PopochiuResources.TEST_HEIGHT, int(test_height.value))
match game_type.selected:
GameTypes.HD:
ProjectSettings.set_setting(PopochiuResources.STRETCH_MODE, "canvas_items")
ProjectSettings.set_setting(PopochiuResources.STRETCH_ASPECT, "expand")
PopochiuConfig.set_pixel_art_textures(false)
GameTypes.RETRO_PIXEL:
ProjectSettings.set_setting(PopochiuResources.STRETCH_MODE, "canvas_items")
ProjectSettings.set_setting(PopochiuResources.STRETCH_ASPECT, "keep")
PopochiuConfig.set_pixel_art_textures(true)
if not PopochiuResources.is_setup_done() or not PopochiuResources.is_gui_set():
PopochiuResources.set_data_value("setup", "done", true)
await _copy_template(true)
get_parent().queue_free()
func define_content(show_welcome := false) -> void:
_is_closing = false
_selected_template = null
btn_change_template.hide()
copy_process_container.hide()
scale_message.modulate = Color(
"#000" if "Light3D" in _es.get_setting("interface/theme/preset") else "#fff"
)
scale_message.modulate.a = 0.8
copy_process_panel.add_theme_stylebox_override(
"panel", get_theme_stylebox("panel", "PopupPanel")
)
if not show_welcome:
welcome.text = "[center][b]POPOCHIU [shake]\\( u )3(u)/[/shake][/b][/center]"
btn_change_template.disabled = true
btn_change_template.show()
# ---- Set initial values for fields ---------------------------------------
game_width.value = ProjectSettings.get_setting(PopochiuResources.DISPLAY_WIDTH)
game_height.value = ProjectSettings.get_setting(PopochiuResources.DISPLAY_HEIGHT)
test_width.value = ProjectSettings.get_setting(PopochiuResources.TEST_WIDTH)
test_height.value = ProjectSettings.get_setting(PopochiuResources.TEST_HEIGHT)
scale_message.text = _get_scale_message()
game_type.selected = GameTypes.CUSTOM
if ProjectSettings.get_setting(PopochiuResources.STRETCH_MODE) == "canvas_items":
match ProjectSettings.get_setting(PopochiuResources.STRETCH_ASPECT):
"expand":
game_type.selected = GameTypes.HD
"keep":
game_type.selected = GameTypes.RETRO_PIXEL
# Load the list of templates
await _load_templates()
_select_config_template()
if show_welcome:
# Make Pixel the default game type checked during first run
game_type.selected = GameTypes.RETRO_PIXEL
if PopochiuResources.GUI_GAME_SCENE in EditorInterface.get_open_scenes():
_show_gui_warning()
for btn: Button in gui_templates.get_children():
btn.disabled = true
template_description_container.hide()
_update_size()
#endregion
#region Private ####################################################################################
func _update_scale(_value: float) -> void:
scale_message.text = _get_scale_message()
func _get_scale_message() -> String:
var scale := Vector2(game_width.value, game_height.value) / PopochiuResources.RETRO_RESOLUTION
return SCALE_MESSAGE % [scale.x, scale.y]
func _on_gui_template_selected(button: GUITemplateButton) -> void:
for btn in gui_templates.get_children():
if not btn is GUITemplateButton: continue
(btn as GUITemplateButton).set_pressed_no_signal(false)
button.set_pressed_no_signal(true)
_selected_template = button
template_description.text = button.description
template_description_container.show()
if PopochiuResources.get_data_value("setup", "done", false) == true:
btn_change_template.disabled = (
_selected_template.name == PopochiuResources.get_data_value("ui", "template", "")
)
_update_size()
func _select_config_template() -> void:
var current_template: String = PopochiuResources.get_data_value("ui", "template", "")
for btn: Button in gui_templates.get_children():
if not btn is GUITemplateButton: continue
btn.disabled = false
if not btn.pressed.is_connected(_on_gui_template_selected):
btn.pressed.connect(_on_gui_template_selected.bind(btn))
if current_template == btn.name:
_on_gui_template_selected(btn)
if not _selected_template:
_on_gui_template_selected(gui_templates.get_child(3))
func _show_gui_warning() -> void:
var warning_dialog := AcceptDialog.new()
_setup_inner_dialog(
warning_dialog,
"GUI template warning",
"The GUI scene (gui.tscn) is currently opened in the Editor.\n\n" +\
"In order to change the GUI template please close that scene first."
)
add_child(warning_dialog)
warning_dialog.popup_centered()
func _show_template_change_confirmation() -> void:
var confirmation_dialog := ConfirmationDialog.new()
_setup_inner_dialog(
confirmation_dialog,
"Confirm GUI template change",
"You changed the GUI template, making this will override any changes you made to the files\
in res://game/gui/.\n\nAre you sure you want to make the change?"
)
confirmation_dialog.confirmed.connect(
func():
confirmation_dialog.queue_free()
_copy_template()
)
add_child(confirmation_dialog)
confirmation_dialog.popup_centered()
func _setup_inner_dialog(dialog: Window, ttl: String, txt: String) -> void:
dialog.title = ttl
dialog.dialog_text = txt
dialog.dialog_autowrap = true
dialog.min_size.x = size.x - 64
func _load_templates() -> void:
for idx in range(1, gui_templates.get_child_count()):
gui_templates.get_child(idx).free()
# This is better than awating for SceneTree.process_frame
await get_tree().process_frame
for dir_name: String in DirAccess.get_directories_at(PopochiuResources.GUI_TEMPLATES_FOLDER):
var template_info: PopochiuGUIInfo = load(PopochiuResources.GUI_TEMPLATES_FOLDER.path_join(
"%s/%s_gui_info.tres" % [dir_name, dir_name]
))
var button := GUITemplateButton.new()
button.toggle_mode = true
button.custom_minimum_size = Vector2.ONE * 128.0
button.name = dir_name.to_pascal_case()
button.text = (
dir_name.capitalize() if template_info.title.is_empty() else template_info.title
)
button.description = template_info.description
button.icon = template_info.icon
button.icon_alignment = HORIZONTAL_ALIGNMENT_CENTER
button.vertical_icon_alignment = VERTICAL_ALIGNMENT_TOP
button.expand_icon = true
button.texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
gui_templates.add_child(button)
func _copy_template(is_first_copy := false) -> void:
get_parent().get_ok_button().disabled = true
$PanelContainer/VBoxContainer.modulate.a = COPY_ALPHA
copy_process_label.text = ""
copy_process_bar.value = 0
PopochiuGuiTemplatesHelper.copy_gui_template(
_selected_template.name, _template_copy_progressed, _template_copy_completed
)
copy_process_container.show()
# if true, make the popup visible so devs can see the copy process feedback
if is_first_copy:
get_parent().visible = true
await template_copy_completed
func _template_copy_progressed(value: int, message: String) -> void:
copy_process_label.text = message
copy_process_bar.value = value
func _template_copy_completed() -> void:
get_parent().get_ok_button().disabled = false
btn_change_template.disabled = true
$PanelContainer/VBoxContainer.modulate.a = 1
copy_process_container.hide()
template_copy_completed.emit()
func _update_size() -> void:
# Wait for the popup content to be rendered in order to get its size
await get_tree().create_timer(0.05).timeout
custom_minimum_size = get_child(0).size
size_calculated.emit()
#endregion

View file

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

View file

@ -0,0 +1,307 @@
[gd_scene load_steps=5 format=3 uid="uid://c3r8juwutb1gr"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/setup/setup.gd" id="1_vjboj"]
[ext_resource type="Script" path="res://addons/popochiu/editor/popups/setup/gui_template_button.gd" id="3_jf6nd"]
[ext_resource type="Texture2D" uid="uid://c00kw8v34vtsb" path="res://addons/popochiu/icons/ico_custom.png" id="5_joicf"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ntnwv"]
content_margin_left = 8.0
content_margin_top = 8.0
content_margin_right = 8.0
content_margin_bottom = 8.0
bg_color = Color(0.698039, 0.698039, 0.698039, 1)
draw_center = false
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4
[node name="Setup" type="Control"]
custom_minimum_size = Vector2(560, 608)
layout_mode = 3
anchors_preset = 0
offset_right = 560.0
offset_bottom = 608.0
script = ExtResource("1_vjboj")
[node name="PanelContainer" type="PanelContainer" parent="."]
custom_minimum_size = Vector2(560, 608)
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 607.0
grow_horizontal = 2
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
layout_mode = 2
theme_override_constants/separation = 12
[node name="Welcome" type="RichTextLabel" parent="PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
bbcode_enabled = true
text = "[center]Welcome to [shake]Popochiu \\( o )3(o)/[/shake][/center]
This popup will appear automatically just this time. You can open it later with the Setup button at the bottom of Popochiu's dock."
fit_content = true
scroll_active = false
meta_underlined = false
hint_underlined = false
[node name="WelcomeSeparator" type="HSeparator" parent="PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
[node name="SizeContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="GameSize" type="Label" parent="PanelContainer/VBoxContainer/SizeContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 0
tooltip_text = "The width and height of the game's window. Changing this will update display/window/size/width and display/window/size/height."
mouse_filter = 0
text = "Native game resolution"
[node name="VBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer/SizeContainer"]
layout_mode = 2
[node name="WidthContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/SizeContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="GameWidth" type="SpinBox" parent="PanelContainer/VBoxContainer/SizeContainer/VBoxContainer/WidthContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
min_value = 64.0
max_value = 1440.0
value = 320.0
rounded = true
allow_greater = true
[node name="Width" type="Label" parent="PanelContainer/VBoxContainer/SizeContainer/VBoxContainer/WidthContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "width"
[node name="HeightContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/SizeContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="GameHeight" type="SpinBox" parent="PanelContainer/VBoxContainer/SizeContainer/VBoxContainer/HeightContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
min_value = 64.0
max_value = 1440.0
value = 180.0
rounded = true
allow_greater = true
[node name="Height" type="Label" parent="PanelContainer/VBoxContainer/SizeContainer/VBoxContainer/HeightContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "height"
[node name="ScaleMessage" type="RichTextLabel" parent="PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
bbcode_enabled = true
fit_content = true
scroll_active = false
[node name="TestContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="TestSize" type="Label" parent="PanelContainer/VBoxContainer/TestContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 0
tooltip_text = "The width and height of the game's test window. Changing this will update display/window/size/test_width and display/window/size/test_height."
mouse_filter = 0
text = "Playing window resolution"
[node name="VBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer/TestContainer"]
layout_mode = 2
[node name="WidthContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/TestContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="TestWidth" type="SpinBox" parent="PanelContainer/VBoxContainer/TestContainer/VBoxContainer/WidthContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
max_value = 1440.0
value = 640.0
rounded = true
allow_greater = true
[node name="Width" type="Label" parent="PanelContainer/VBoxContainer/TestContainer/VBoxContainer/WidthContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "width"
[node name="HeightContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/TestContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="TestHeight" type="SpinBox" parent="PanelContainer/VBoxContainer/TestContainer/VBoxContainer/HeightContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
max_value = 1440.0
value = 360.0
rounded = true
allow_greater = true
[node name="Height" type="Label" parent="PanelContainer/VBoxContainer/TestContainer/VBoxContainer/HeightContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "height"
[node name="TypeContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="Type" type="Label" parent="PanelContainer/VBoxContainer/TypeContainer"]
layout_mode = 2
size_flags_horizontal = 3
tooltip_text = "The type of game modifies the stretch mode and the default preset for importing 2D images.
Default: No stretch. Texture2D import preset set to: 2D.
2D: Stretch mode set to 2D and stretch aspect set to keep. Texture2D import preset set to: 2D.
Pixel: Stretch mode set to 2D and stretch aspect set to keep. Texture2D import preset set to: 2D Pixel."
mouse_filter = 0
text = "Game type"
[node name="GameType" type="OptionButton" parent="PanelContainer/VBoxContainer/TypeContainer"]
unique_name_in_owner = true
layout_mode = 2
item_count = 3
popup/item_0/text = "Custom"
popup/item_1/text = "2D"
popup/item_1/id = 1
popup/item_2/text = "Pixel"
popup/item_2/id = 2
[node name="TemplateSeparator" type="HSeparator" parent="PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
[node name="GUITemplatesPanel" type="PanelContainer" parent="PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="GUITemplatesContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/GUITemplatesPanel"]
layout_mode = 2
[node name="GUITemplatesTitle" type="Label" parent="PanelContainer/VBoxContainer/GUITemplatesPanel/GUITemplatesContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(544, 0)
layout_mode = 2
text = "GUI Template"
horizontal_alignment = 1
autowrap_mode = 3
[node name="GUITemplatesDescription" type="Label" parent="PanelContainer/VBoxContainer/GUITemplatesPanel/GUITemplatesContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(544, 0)
layout_mode = 2
text = "Select a template to define the look and feel of your game. Click each button to see a short description."
horizontal_alignment = 1
autowrap_mode = 3
[node name="PanelContainer" type="PanelContainer" parent="PanelContainer/VBoxContainer/GUITemplatesPanel/GUITemplatesContainer"]
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_ntnwv")
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/GUITemplatesPanel/GUITemplatesContainer/PanelContainer"]
layout_mode = 2
[node name="GUITemplates" type="HBoxContainer" parent="PanelContainer/VBoxContainer/GUITemplatesPanel/GUITemplatesContainer/PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
alignment = 1
[node name="Custom" type="Button" parent="PanelContainer/VBoxContainer/GUITemplatesPanel/GUITemplatesContainer/PanelContainer/VBoxContainer/GUITemplates"]
visible = false
texture_filter = 1
custom_minimum_size = Vector2(128, 128)
layout_mode = 2
mouse_default_cursor_shape = 2
toggle_mode = true
text = "Custom"
icon = ExtResource("5_joicf")
icon_alignment = 1
vertical_icon_alignment = 0
expand_icon = true
script = ExtResource("3_jf6nd")
description = "You are an adventorous developer who wants to implement each own Graphic Interface. [shake]You rock!!![/shake]"
[node name="TemplateDescriptionContainer" type="PanelContainer" parent="PanelContainer/VBoxContainer/GUITemplatesPanel/GUITemplatesContainer/PanelContainer/VBoxContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer/GUITemplatesPanel/GUITemplatesContainer/PanelContainer/VBoxContainer/TemplateDescriptionContainer"]
layout_mode = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TemplateDescription" type="RichTextLabel" parent="PanelContainer/VBoxContainer/GUITemplatesPanel/GUITemplatesContainer/PanelContainer/VBoxContainer/TemplateDescriptionContainer/MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
bbcode_enabled = true
fit_content = true
scroll_active = false
[node name="BtnChangeTemplate" type="Button" parent="PanelContainer/VBoxContainer/GUITemplatesPanel/GUITemplatesContainer/PanelContainer/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 48)
layout_mode = 2
size_flags_horizontal = 4
mouse_default_cursor_shape = 2
text = "Use this GUI Template"
[node name="CopyProcessContainer" type="MarginContainer" parent="PanelContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/margin_left = 0
theme_override_constants/margin_top = 0
theme_override_constants/margin_right = 0
theme_override_constants/margin_bottom = 0
[node name="Overlay" type="ColorRect" parent="PanelContainer/CopyProcessContainer"]
layout_mode = 2
color = Color(0, 0, 0, 0)
[node name="CopyProcessPanel" type="PanelContainer" parent="PanelContainer/CopyProcessContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 4
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/CopyProcessContainer/CopyProcessPanel"]
layout_mode = 2
size_flags_vertical = 4
[node name="CopyProcessBar" type="ProgressBar" parent="PanelContainer/CopyProcessContainer/CopyProcessPanel/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 4
value = 50.0
[node name="CopyProcessLabel" type="Label" parent="PanelContainer/CopyProcessContainer/CopyProcessPanel/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Starting GUI template application"
horizontal_alignment = 1
vertical_alignment = 1
uppercase = true