From 64525c8ba205dc7c47422819aa15f52f6b85a755 Mon Sep 17 00:00:00 2001 From: Paolo Pustorino Date: Sun, 2 Jul 2023 11:11:11 +0200 Subject: [PATCH] refs #37: Open #67 about the heavy polishing, in the meantime this reduce the passing-over of UI elements. --- .../editor/helpers/popochiu_prop_helper.gd | 19 +++++----- .../editor/helpers/popochiu_types_helper.gd | 36 ++----------------- .../editor/main_dock/popochiu_dock.gd | 5 +++ addons/popochiu/editor/main_dock/tab_audio.gd | 1 + addons/popochiu/editor/main_dock/tab_room.gd | 2 ++ .../editor/popups/create_prop/create_prop.gd | 5 +-- 6 files changed, 21 insertions(+), 47 deletions(-) diff --git a/addons/popochiu/editor/helpers/popochiu_prop_helper.gd b/addons/popochiu/editor/helpers/popochiu_prop_helper.gd index 93eaa63b..88fc6eb8 100644 --- a/addons/popochiu/editor/helpers/popochiu_prop_helper.gd +++ b/addons/popochiu/editor/helpers/popochiu_prop_helper.gd @@ -4,12 +4,11 @@ class_name PopochiuPropHelper const PROP_SCRIPT_TEMPLATE := 'res://addons/popochiu/engine/templates/prop_template.gd' const BASE_PROP_PATH := 'res://addons/popochiu/engine/objects/prop/popochiu_prop.tscn' const Constants := preload('res://addons/popochiu/popochiu_resources.gd') -const TabRoom := preload("res://addons/popochiu/editor/main_dock/tab_room.gd") -var _room_tab: VBoxContainer = null -var _ei: EditorInterface +var _room_tab: PopochiuTabRoom = null +var _ei: EditorInterface = null -var _room: Node2D = null +var _room: PopochiuRoom = null var _prop_script_name := '' var _prop_name := '' var _prop_path := '' @@ -20,16 +19,16 @@ var _room_dir := '' # ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ PUBLIC ░░░░ -func init(ei: EditorInterface, room_tab: VBoxContainer) -> void: - _ei = ei - _room_tab = room_tab +func init(main_dock: PopochiuDock) -> void: + _ei = main_dock.ei + _room_tab = main_dock.get_opened_room_tab() func create(prop_name: String, room: PopochiuRoom, is_interactive:bool = false) -> PopochiuProp: - # TODO: Check if another Prop was created in the same PATH. - # TODO: Remove created files if the creation process failed. _open_room(room) _setup_name(prop_name) + # TODO: Check if another Prop was created in the same PATH. + # TODO: Remove created files if the creation process failed. var script_path := _prop_path + '.gd' @@ -105,7 +104,7 @@ func create(prop_name: String, room: PopochiuRoom, is_interactive:bool = false) # ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ # Update the list of Props in the Room tab - (_room_tab as TabRoom).add_to_list( + _room_tab.add_to_list( Constants.Types.PROP, _prop_name, _prop_path + '.tscn' diff --git a/addons/popochiu/editor/helpers/popochiu_types_helper.gd b/addons/popochiu/editor/helpers/popochiu_types_helper.gd index 8794917f..a896aa8b 100644 --- a/addons/popochiu/editor/helpers/popochiu_types_helper.gd +++ b/addons/popochiu/editor/helpers/popochiu_types_helper.gd @@ -23,36 +23,6 @@ static func is_walkable_area(node: Node) -> bool: ## TODO: provide more helpers like this maybe? - -# Functions used to create Popochiu objects of various types. -# They are designed to be used from the Editor plugin, not the Engine code. -static func create_character(): - pass - - -static func create_dialog(): - pass - - -static func create_hotspot(): - pass - - -static func create_inventory_item(): - pass - - -static func create_prop(): - pass - - -static func create_region(): - pass - - -static func create_room(): - pass - - -static func create_walkable_area(): - pass +## TODO: If and when #67 is ready, add static facade metods to create items +## so we can just pass this object as entry point for all operations +## on Popochiu objects \ No newline at end of file diff --git a/addons/popochiu/editor/main_dock/popochiu_dock.gd b/addons/popochiu/editor/main_dock/popochiu_dock.gd index ab7db546..3e22c0dd 100644 --- a/addons/popochiu/editor/main_dock/popochiu_dock.gd +++ b/addons/popochiu/editor/main_dock/popochiu_dock.gd @@ -2,6 +2,7 @@ # Rooms, Characters, Inventory items, Dialog trees. @tool extends Panel +class_name PopochiuDock signal move_folders_pressed @@ -261,6 +262,10 @@ func get_opened_room() -> PopochiuRoom: return _tab_room.opened_room +func get_opened_room_tab() -> VBoxContainer: + return _tab_room + + func open_setup() -> void: setup_dialog.appear() diff --git a/addons/popochiu/editor/main_dock/tab_audio.gd b/addons/popochiu/editor/main_dock/tab_audio.gd index 66f41f04..df22a919 100644 --- a/addons/popochiu/editor/main_dock/tab_audio.gd +++ b/addons/popochiu/editor/main_dock/tab_audio.gd @@ -1,6 +1,7 @@ # Handles the Audio tab in Popochiu's dock. @tool extends VBoxContainer +class_name PopochiuTabAudio const SEARCH_PATH := 'res://popochiu/' const AudioCue := preload('res://addons/popochiu/engine/audio_manager/audio_cue.gd') diff --git a/addons/popochiu/editor/main_dock/tab_room.gd b/addons/popochiu/editor/main_dock/tab_room.gd index edde58c2..1a41c4ec 100644 --- a/addons/popochiu/editor/main_dock/tab_room.gd +++ b/addons/popochiu/editor/main_dock/tab_room.gd @@ -1,5 +1,7 @@ @tool extends VBoxContainer +class_name PopochiuTabRoom + # Handles the Room tab in Popochiu's dock # ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ diff --git a/addons/popochiu/editor/popups/create_prop/create_prop.gd b/addons/popochiu/editor/popups/create_prop/create_prop.gd index 2aa86492..df9dafea 100644 --- a/addons/popochiu/editor/popups/create_prop/create_prop.gd +++ b/addons/popochiu/editor/popups/create_prop/create_prop.gd @@ -6,9 +6,6 @@ extends 'res://addons/popochiu/editor/popups/creation_popup.gd' const Helper := preload("res://addons/popochiu/editor/helpers/popochiu_prop_helper.gd") -const TabRoom := preload("res://addons/popochiu/editor/main_dock/tab_room.gd") - -var room_tab: VBoxContainer = null var _room: Node2D = null var _new_prop_name := '' @@ -32,7 +29,7 @@ func _create() -> void: return _helper = Helper.new() - _helper.init(_main_dock.ei, room_tab) + _helper.init(_main_dock) var prop_instance = _helper.create(_new_prop_name, _room, _interaction_checkbox.button_pressed)