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)."