First commit 🎉
This commit is contained in:
commit
43ea213f9b
728 changed files with 37080 additions and 0 deletions
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
uid://5wo0sonbxku7
|
|
@ -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)."
|
Loading…
Add table
Add a link
Reference in a new issue