First commit 🎉
This commit is contained in:
commit
43ea213f9b
728 changed files with 37080 additions and 0 deletions
|
@ -0,0 +1,46 @@
|
|||
extends EditorInspectorPlugin ## TODO: create a base class with pointer variables
|
||||
|
||||
const DOCKS_PATH := "res://addons/popochiu/editor/importers/aseprite/docks/"
|
||||
const INSPECTOR_DOCK = preload(DOCKS_PATH + "aseprite_importer_inspector_dock.tscn")
|
||||
const CONFIG_SCRIPT = preload("res://addons/popochiu/editor/config/config.gd")
|
||||
const INSPECTOR_DOCK_CHARACTER := DOCKS_PATH + "aseprite_importer_inspector_dock_character.gd"
|
||||
const INSPECTOR_DOCK_ROOM := DOCKS_PATH + "aseprite_importer_inspector_dock_room.gd"
|
||||
|
||||
var _target_node: Node
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _can_handle(object):
|
||||
if object.has_method("get_parent") and object.get_parent() is Node2D:
|
||||
return false
|
||||
|
||||
return object is PopochiuCharacter || object is PopochiuRoom #|| object is PopochiuInventoryItem
|
||||
|
||||
|
||||
func _parse_begin(object: Object):
|
||||
# Fix showing error messages in Output when inspecting nodes in the Debugger
|
||||
if not object is Node: return
|
||||
|
||||
_target_node = object
|
||||
|
||||
|
||||
func _parse_property(object, type, name, hint_type, hint_string, usage_flags, wide) -> bool:
|
||||
if object.get_class() == "EditorDebuggerRemoteObject":
|
||||
return false
|
||||
if name != 'popochiu_placeholder':
|
||||
return false
|
||||
# Instantiate and configure the dock
|
||||
var dock = INSPECTOR_DOCK.instantiate()
|
||||
# Load the specific script in the dock
|
||||
if object is PopochiuCharacter:
|
||||
dock.set_script(load(INSPECTOR_DOCK_CHARACTER))
|
||||
if object is PopochiuRoom:
|
||||
dock.set_script(load(INSPECTOR_DOCK_ROOM))
|
||||
dock.target_node = object
|
||||
dock.file_system = EditorInterface.get_resource_filesystem()
|
||||
# Add the dock to the inspector
|
||||
add_custom_control(dock)
|
||||
return true
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://dpianc4xo6kcl
|
|
@ -0,0 +1,52 @@
|
|||
extends EditorInspectorPlugin
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _can_handle(object: Object) -> bool:
|
||||
return object is PopochiuAudioCue
|
||||
|
||||
|
||||
func _parse_property(
|
||||
object: Object,
|
||||
type,
|
||||
path: String,
|
||||
hint,
|
||||
hint_text: String,
|
||||
usage,
|
||||
wide: bool
|
||||
) -> bool:
|
||||
if not object is PopochiuAudioCue or path != "bus":
|
||||
return false
|
||||
|
||||
var ep := EditorProperty.new()
|
||||
var ob := OptionButton.new()
|
||||
|
||||
_update_buses_list(ob, object)
|
||||
|
||||
ob.item_selected.connect(_update_audio_cue_bus.bind(object))
|
||||
ob.pressed.connect(_update_buses_list.bind(ob, object))
|
||||
|
||||
ep.add_child(ob)
|
||||
add_property_editor(path, ep)
|
||||
|
||||
return true
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _update_audio_cue_bus(idx: int, audio_cue: PopochiuAudioCue) -> void:
|
||||
audio_cue.bus = AudioServer.get_bus_name(idx)
|
||||
ResourceSaver.save(audio_cue, audio_cue.resource_path)
|
||||
|
||||
|
||||
func _update_buses_list(ob: OptionButton, pac: PopochiuAudioCue) -> void:
|
||||
ob.clear()
|
||||
|
||||
for idx in AudioServer.bus_count:
|
||||
ob.add_item(AudioServer.get_bus_name(idx), idx)
|
||||
|
||||
ob.selected = AudioServer.get_bus_index(pac.bus)
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://d0emjgqvommw4
|
|
@ -0,0 +1,83 @@
|
|||
extends EditorInspectorPlugin
|
||||
|
||||
|
||||
#region Virtual ####################################################################################
|
||||
func _can_handle(object: Object) -> bool:
|
||||
if object is PopochiuCharacter:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _parse_begin(object: Object) -> void:
|
||||
if object.get_class() == "EditorDebuggerRemoteObject":
|
||||
return
|
||||
|
||||
if not object.get_parent() is Node2D: return
|
||||
|
||||
var panel := PanelContainer.new()
|
||||
var hbox := HBoxContainer.new()
|
||||
var button := Button.new()
|
||||
|
||||
hbox.custom_minimum_size.y = 42.0
|
||||
button.text = "* Open Node' scene to edit its properties"
|
||||
button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
button.alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
|
||||
panel.add_theme_stylebox_override(
|
||||
"panel",
|
||||
panel.get_theme_stylebox("sub_inspector_bg11", "Editor")
|
||||
)
|
||||
button.add_theme_color_override("font_color", Color("c46c71"))
|
||||
button.add_theme_color_override("font_color_hover", Color("c46c71"))
|
||||
button.add_theme_color_override("font_color_pressed", Color("c46c71"))
|
||||
|
||||
button.pressed.connect(
|
||||
_open_scene.bind((object as PopochiuCharacter).scene_file_path),
|
||||
CONNECT_DEFERRED
|
||||
)
|
||||
|
||||
hbox.add_child(button)
|
||||
panel.add_child(hbox)
|
||||
|
||||
add_custom_control(panel)
|
||||
|
||||
|
||||
func _parse_property(
|
||||
object: Object,
|
||||
type,
|
||||
path: String,
|
||||
hint,
|
||||
hint_text: String,
|
||||
usage,
|
||||
wide: bool
|
||||
) -> bool:
|
||||
if object.get_class() == "EditorDebuggerRemoteObject":
|
||||
return false
|
||||
|
||||
# NOTE: We could add this as an option of the plugin settings. So devs can add extra properties
|
||||
# if needed.
|
||||
if object and object.get_parent() is Node2D and not path in [
|
||||
"baseline",
|
||||
"walk_to_point",
|
||||
"look_at_point",
|
||||
"position",
|
||||
"visible",
|
||||
"modulate",
|
||||
"self_modulate",
|
||||
"light_mask",
|
||||
]:
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _open_scene(path: String) -> void:
|
||||
EditorInterface.set_main_screen_editor("2D")
|
||||
EditorInterface.open_scene_from_path(path)
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://m7hkqdx4jhem
|
63
addons/popochiu/editor/inspector/prop_inspector_plugin.gd
Normal file
63
addons/popochiu/editor/inspector/prop_inspector_plugin.gd
Normal file
|
@ -0,0 +1,63 @@
|
|||
extends EditorInspectorPlugin
|
||||
|
||||
|
||||
#region Virtual ####################################################################################
|
||||
func _can_handle(object: Object) -> bool:
|
||||
if object is PopochiuProp:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _parse_property(
|
||||
object: Object,
|
||||
type,
|
||||
path: String,
|
||||
hint,
|
||||
hint_text: String,
|
||||
usage,
|
||||
wide: bool
|
||||
) -> bool:
|
||||
if (
|
||||
object.get_class() == "EditorDebuggerRemoteObject"
|
||||
or object is not PopochiuProp
|
||||
or path != "link_to_item"
|
||||
):
|
||||
return false
|
||||
|
||||
var ep := EditorProperty.new()
|
||||
var ob := OptionButton.new()
|
||||
|
||||
_update_items_list(ob, object)
|
||||
|
||||
ob.item_selected.connect(_update_link_to_item.bind(ob, object))
|
||||
ob.pressed.connect(_update_items_list.bind(ob, object))
|
||||
|
||||
ep.add_child(ob)
|
||||
add_property_editor(path, ep)
|
||||
|
||||
return true
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _update_items_list(ob: OptionButton, prop: PopochiuProp) -> void:
|
||||
ob.clear()
|
||||
var inventory_items := PopochiuResources.get_section_keys("inventory_items")
|
||||
var keys_ids_map := {}
|
||||
|
||||
inventory_items.sort()
|
||||
ob.add_item("")
|
||||
for key: String in inventory_items:
|
||||
keys_ids_map[key] = ob.item_count
|
||||
ob.add_item(key)
|
||||
|
||||
if keys_ids_map.has(prop.link_to_item):
|
||||
ob.selected = ob.get_item_index(keys_ids_map[prop.link_to_item])
|
||||
|
||||
|
||||
func _update_link_to_item(idx: int, ob: OptionButton, prop: PopochiuProp) -> void:
|
||||
prop.link_to_item = ob.get_item_text(idx)
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://dsuhln67g2d8k
|
Loading…
Add table
Add a link
Reference in a new issue