Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions addons/pandora/ui/editor/property_editor/property_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var current_entity: PandoraEntity


func _ready() -> void:
property_bar.property_added.connect(_add_property)
property_bar.property_added.connect(_add_property.bind(true))
set_entity(null)


Expand Down Expand Up @@ -58,7 +58,9 @@ func set_entity(entity: PandoraEntity) -> void:
_add_property_control(control, property)


func _add_property(scene: PackedScene) -> void:
# The focus parameter is optional, and only used to ask the editor to also focus to the
# specified property
func _add_property(scene: PackedScene, focus: bool = false) -> void:
if not current_entity is PandoraCategory:
print("Cannot add custom properties to non-categories!")
return
Expand All @@ -69,10 +71,10 @@ func _add_property(scene: PackedScene) -> void:
control.type
)
if property != null:
_add_property_control(control, property)
_add_property_control(control, property, focus)


func _add_property_control(control: PandoraPropertyControl, property: PandoraProperty) -> void:
func _add_property_control(control: PandoraPropertyControl, property: PandoraProperty, focus: bool = false) -> void:
var control_kvp = PropertyControlKvp.instantiate()
control.init(property)
control_kvp.init(property, control, Pandora._entity_backend)
Expand All @@ -84,11 +86,12 @@ func _add_property_control(control: PandoraPropertyControl, property: PandoraPro
property_list.add_child(control_kvp)
control_kvp.property_key_edit.grab_focus()
control_kvp.original_property_selected.connect(property_settings_container.set_property)
await get_tree().process_frame
# First scroll to the control node and then apply an offset.
# It's important to wait a frame before scrolling as for the documentation.
scroll_container.ensure_control_visible(control_kvp)
scroll_container.scroll_vertical = scroll_container.scroll_vertical + 100
if focus:
await get_tree().process_frame
scroll_container.ensure_control_visible(control_kvp)
scroll_container.scroll_vertical = scroll_container.scroll_vertical + 100


func _generate_property_name(type: String, entity: PandoraEntity) -> String:
Expand Down