Skip to content

Commit

Permalink
Various improvements (#1592)
Browse files Browse the repository at this point in the history
* Various editor improvements

- add F2 and DELETE shortcuts to portrait list
- add F2 shortcut to type sound mood list
- auto-edit newly created portraits/portraitgroups

- fix type in index_class.scan_for_layouts() that prevented layout description from showing as tooltip

- make complex picker select all text on focus for quicker editing.

* Further Character/Portrait improvements 

- make sure DEL shortcut for portraits only works when portrait list is focused
- make default layout use "Fit Scale Height" for portrait containers
- add a setting to change the default layouts size mode of portrait containers
- make the portrait class separate from the default portrait.

* Rename portrait class

* Multiple fixes and improvements

- make sure portrait completion is triggered even if text is already written behind it
- make sure name label is shown if hide_when_empty is false
- make sure missing default sound mood doesn't result in crash
- add default layout name label offset setting
- make sure portrait node is instantly removed from tree
- fix lots of small mistakes in portrait subsystem
- add dialogic background class that should be inherited by custom backgrounds
- simplify default background scene and make it inherit from dialogic_background

- add lots of settings  and improvements to the RPG layout
  • Loading branch information
Jowan-Spooner authored Jun 17, 2023
1 parent 4a4f6b4 commit 6b3962c
Show file tree
Hide file tree
Showing 24 changed files with 444 additions and 216 deletions.
34 changes: 26 additions & 8 deletions addons/dialogic/Editor/CharacterEditor/character_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ func _open_resource(resource:Resource) -> void:
%CharacterName.text = character.unique_short_path

$NoCharacterScreen.hide()




func _save() -> void:
Expand Down Expand Up @@ -239,6 +237,8 @@ func setup_portrait_list_tab() -> void:

%PortraitTree.item_selected.connect(load_selected_portrait)
%PortraitTree.item_edited.connect(_on_item_edited)
%PortraitTree.item_activated.connect(func(): %PortraitTree.get_selected().set_editable(0, true); %PortraitTree.edit_selected())


func open_portrait_folder_select() -> void:
find_parent("EditorView").godot_file_dialog(
Expand Down Expand Up @@ -273,15 +273,21 @@ func add_portrait(portrait_name:String='New portrait', portrait_data:Dictionary=
parent = %PortraitTree.get_selected()
else:
parent = %PortraitTree.get_selected().get_parent()
%PortraitTree.add_portrait_item(portrait_name, portrait_data, parent).select(0)
var item :TreeItem = %PortraitTree.add_portrait_item(portrait_name, portrait_data, parent)
item.set_editable(0, true)
item.select(0)
%PortraitTree.call_deferred('edit_selected')
something_changed()


func add_portrait_group() -> void:
var parent_item :TreeItem = %PortraitTree.get_root()
if %PortraitTree.get_selected() and %PortraitTree.get_selected().get_metadata(0).has('group'):
parent_item = %PortraitTree.get_selected()
%PortraitTree.add_portrait_group("Group", parent_item)
var item :TreeItem = %PortraitTree.add_portrait_group("Group", parent_item)
item.set_editable(0, true)
item.select(0)
%PortraitTree.call_deferred('edit_selected')


func load_portrait_tree() -> void:
Expand Down Expand Up @@ -343,10 +349,10 @@ func list_portraits(tree_items:Array[TreeItem], dict:Dictionary = {}, path_prefi
func load_selected_portrait():
if selected_item and is_instance_valid(selected_item):
selected_item.set_editable(0, false)

selected_item = %PortraitTree.get_selected()

if selected_item and !selected_item.get_metadata(0).has('group'):
if selected_item and selected_item.get_metadata(0) != null and !selected_item.get_metadata(0).has('group'):
%PortraitSettingsSection.show()
var current_portrait_data :Dictionary = selected_item.get_metadata(0)
portrait_selected.emit(%PortraitTree.get_full_item_name(selected_item), current_portrait_data)
Expand Down Expand Up @@ -378,6 +384,17 @@ func duplicate_item(item:TreeItem) -> void:
%PortraitTree.add_portrait_item(item.get_text(0)+'_duplicated', item.get_metadata(0).duplicate(true), item.get_parent()).select(0)


func _input(event:InputEvent) -> void:
if !is_visible_in_tree() or (get_viewport().gui_get_focus_owner()!= null and !name+'/' in str(get_viewport().gui_get_focus_owner().get_path())):
return
if event is InputEventKey and event.pressed:
if event.keycode == KEY_F2 and %PortraitTree.get_selected():
%PortraitTree.get_selected().set_editable(0, true)
%PortraitTree.edit_selected()
get_viewport().set_input_as_handled()
elif event.keycode == KEY_DELETE and get_viewport().gui_get_focus_owner() is Tree and %PortraitTree.get_selected():
delete_portrait_item(%PortraitTree.get_selected())
get_viewport().set_input_as_handled()

func _on_portrait_right_click_menu_index_pressed(id:int) -> void:
# DELETE BUTTON
Expand Down Expand Up @@ -410,6 +427,7 @@ func _on_item_edited():
if selected_item:
if %PreviewLabel.text.trim_prefix('Preview of "').trim_suffix('"') == current_resource.default_portrait:
current_resource.default_portrait = %PortraitTree.get_full_item_name(selected_item)
selected_item.set_editable(0, false)
update_preview()


Expand All @@ -420,7 +438,7 @@ func _on_item_edited():

func update_preview() -> void:
%ScenePreviewWarning.hide()
if selected_item and is_instance_valid(selected_item) and !selected_item.get_metadata(0).has('group'):
if selected_item and is_instance_valid(selected_item) and selected_item.get_metadata(0) != null and !selected_item.get_metadata(0).has('group'):
%PreviewLabel.text = 'Preview of "'+%PortraitTree.get_full_item_name(selected_item)+'"'

var current_portrait_data: Dictionary = selected_item.get_metadata(0)
Expand Down
14 changes: 7 additions & 7 deletions addons/dialogic/Editor/CharacterEditor/character_editor.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ corner_radius_top_right = 2
corner_radius_bottom_right = 2
corner_radius_bottom_left = 2

[sub_resource type="Image" id="Image_brdaj"]
[sub_resource type="Image" id="Image_7bycs"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 93, 93, 55, 255, 97, 97, 58, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
Expand All @@ -25,11 +25,11 @@ data = {
}

[sub_resource type="ImageTexture" id="ImageTexture_mpcxh"]
image = SubResource("Image_brdaj")
image = SubResource("Image_7bycs")

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_4xgdx"]

[sub_resource type="Image" id="Image_y0t2k"]
[sub_resource type="Image" id="Image_2yk54"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 93, 93, 55, 255, 97, 97, 58, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
Expand All @@ -38,8 +38,8 @@ data = {
"width": 16
}

[sub_resource type="ImageTexture" id="ImageTexture_4mqhk"]
image = SubResource("Image_y0t2k")
[sub_resource type="ImageTexture" id="ImageTexture_oq50w"]
image = SubResource("Image_2yk54")

[node name="CharacterEditor" type="MarginContainer"]
self_modulate = Color(0, 0, 0, 1)
Expand Down Expand Up @@ -171,10 +171,10 @@ script = ExtResource("2_vad0i")
size = Vector2i(118, 100)
item_count = 2
item_0/text = "Duplicate"
item_0/icon = SubResource("ImageTexture_4mqhk")
item_0/icon = SubResource("ImageTexture_oq50w")
item_0/id = 0
item_1/text = "Delete"
item_1/icon = SubResource("ImageTexture_4mqhk")
item_1/icon = SubResource("ImageTexture_oq50w")
item_1/id = 1

[node name="RightSection" type="VBoxContainer" parent="Split"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ func create_necessary_group_items(path:String) -> TreeItem:
return last_item


func _on_item_mouse_selected(pos:Vector2, mouse_button_index):
func _on_item_mouse_selected(pos:Vector2, mouse_button_index:int) -> void:
if mouse_button_index == MOUSE_BUTTON_RIGHT:
$PortraitRightClickMenu.set_item_disabled(0, get_selected().get_metadata(0).has('group'))
$PortraitRightClickMenu.popup_on_parent(Rect2(get_global_mouse_position(),Vector2()))



################################################################################
Expand Down
58 changes: 31 additions & 27 deletions addons/dialogic/Editor/Events/Fields/ComplexPicker.gd
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func _ready():
%BG.add_theme_stylebox_override('panel', get_theme_stylebox('normal', 'LineEdit'))
%Focus.add_theme_stylebox_override('panel', get_theme_stylebox('focus', 'LineEdit'))
%Search.text_changed.connect(_on_Search_text_changed)
%Search.focus_entered.connect(_on_Search_focus_entered)
%Search.text_submitted.connect(_on_Search_text_entered)
var scale: float = DialogicUtil.get_editor_scale()
%SelectButton.icon = get_theme_icon("Collapse", "EditorIcons")
Expand Down Expand Up @@ -140,6 +139,7 @@ func _on_Search_text_changed(new_text:String, just_update:bool = false) -> void:
current_selected = -1
%Search.grab_focus()


func get_default_suggestions(input:String) -> Dictionary:
if file_extension.is_empty(): return {'Nothing found!':{'value':''}}
var suggestions: Dictionary = {}
Expand Down Expand Up @@ -185,19 +185,46 @@ func _input(event:InputEvent):
if %Suggestions.visible:
if !%Suggestions.get_global_rect().has_point(get_global_mouse_position()):
hide_suggestions()


func hide_suggestions() -> void:
%SelectButton.button_pressed = false
%Suggestions.hide()

func _on_Search_focus_entered() -> void:
if %Search.text == "" or current_value == null or (typeof(current_value) == TYPE_STRING and current_value.is_empty()):
_on_Search_text_changed("")

func _on_SelectButton_toggled(button_pressed:bool) -> void:
if button_pressed:
_on_Search_text_changed('', true)

func _on_focus_entered():
%Search.grab_focus()



func _on_search_gui_input(event):
if event is InputEventKey and (event.keycode == KEY_DOWN or event.keycode == KEY_UP) and event.pressed:
if !%Suggestions.visible:
_on_Search_text_changed('', true)
current_selected = -1
if event.keycode == KEY_DOWN:
current_selected = wrapi(current_selected+1, 0, %Suggestions.item_count)
if event.keycode == KEY_UP:
current_selected = wrapi(current_selected-1, 0, %Suggestions.item_count)
%Suggestions.select(current_selected)
%Suggestions.ensure_current_is_visible()

func _on_search_focus_entered():
if %Search.text == "" or current_value == null or (typeof(current_value) == TYPE_STRING and current_value.is_empty()):
_on_Search_text_changed("")
%Search.call_deferred('select_all')
%Focus.show()


func _on_search_focus_exited():
%Focus.hide()
if !%Suggestions.get_global_rect().has_point(get_global_mouse_position()):
hide_suggestions()

################################################################################
## DRAG AND DROP
################################################################################
Expand Down Expand Up @@ -227,26 +254,3 @@ func _drop_data(position, data) -> void:
set_value(file)
emit_signal("value_changed", property_name, file)


func _on_focus_entered():
%Search.grab_focus()

func _on_search_gui_input(event):
if event is InputEventKey and (event.keycode == KEY_DOWN or event.keycode == KEY_UP) and event.pressed:
if !%Suggestions.visible:
_on_Search_text_changed('', true)
current_selected = -1
if event.keycode == KEY_DOWN:
current_selected = wrapi(current_selected+1, 0, %Suggestions.item_count)
if event.keycode == KEY_UP:
current_selected = wrapi(current_selected-1, 0, %Suggestions.item_count)
%Suggestions.select(current_selected)
%Suggestions.ensure_current_is_visible()

func _on_search_focus_entered():
%Focus.show()

func _on_search_focus_exited():
%Focus.hide()
if !%Suggestions.get_global_rect().has_point(get_global_mouse_position()):
hide_suggestions()
Loading

0 comments on commit 6b3962c

Please sign in to comment.