Skip to content

Commit ca8a5ce

Browse files
Implement a search bar for portraits (#781)
1 parent 280265b commit ca8a5ce

File tree

3 files changed

+70
-44
lines changed

3 files changed

+70
-44
lines changed

addons/dialogic/Editor/CharacterEditor/CharacterEditor.gd

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ onready var nodes = {
2626
'offset_x': $Split/EditorScroll/Editor/HBoxContainer/OffsetX,
2727
'offset_y': $Split/EditorScroll/Editor/HBoxContainer/OffsetY,
2828

29+
'portrait_search':$Split/EditorScroll/Editor/Portraits/Search,
2930
'portrait_list': $Split/EditorScroll/Editor/PortraitPanel/VBoxContainer/ScrollContainer/VBoxContainer/PortraitList,
3031
'new_portrait_button': $Split/EditorScroll/Editor/PortraitPanel/VBoxContainer/Labels/HBoxContainer/NewPortrait,
3132
'import_from_folder_button': $Split/EditorScroll/Editor/PortraitPanel/VBoxContainer/Labels/HBoxContainer/ImportFromFolder,
@@ -57,6 +58,7 @@ func _ready():
5758
nodes['display_name_checkbox'].connect('toggled', self, '_on_display_name_toggled')
5859
nodes['nickname_checkbox'].connect('toggled', self, '_on_nickname_toggled')
5960

61+
nodes['portrait_search'].connect('text_changed', self, '_on_PortraitSearch_text_changed')
6062
nodes['import_from_folder_button'].connect('pressed', self, '_on_Import_Portrait_Folder_Button_pressed')
6163
nodes['new_portrait_button'].connect('pressed', self, '_on_New_Portrait_Button_pressed')
6264

@@ -87,6 +89,7 @@ func clear_character_editor():
8789
nodes['theme'].text = 'No custom theme'
8890
selected_theme_file = ''
8991

92+
nodes['portrait_search'].text = ''
9093
nodes['portraits'] = []
9194
nodes['scale'].value = 100
9295
nodes['mirror_portraits_checkbox'].pressed = false
@@ -178,23 +181,34 @@ func load_character(filename: String):
178181
nodes['portrait_preview_real'].flip_h = data.get('mirror_portraits', false)
179182
nodes['portrait_preview_real'].rect_scale = Vector2(
180183
float(data.get('scale', 100))/100, float(data.get('scale', 100))/100)
184+
181185
# Portraits
182186
var default_portrait = create_portrait_entry()
183187
default_portrait.get_node('NameEdit').text = 'Default'
184188
default_portrait.get_node('NameEdit').editable = false
185-
if data.has('portraits'):
186-
for p in data['portraits']:
189+
if opened_character_data.has('portraits'):
190+
for p in opened_character_data['portraits']:
191+
var current_item
187192
if p['name'] == 'Default':
188193
default_portrait.get_node('PathEdit').text = p['path']
189194
default_portrait.update_preview(p['path'])
195+
current_item = default_portrait
190196
else:
191-
create_portrait_entry(p['name'], p['path'])
192-
197+
current_item = create_portrait_entry(p['name'], p['path'])
198+
193199

194200
####################################################################################################
195201
## UI FUNCTIONS
196202
####################################################################################################
197203

204+
205+
func _on_PortraitSearch_text_changed(text):
206+
for portrait_item in nodes['portrait_list'].get_children():
207+
if text.empty() or text.to_lower() in portrait_item.get_node("NameEdit").text.to_lower() or text.to_lower() in portrait_item.get_node("PathEdit").text.to_lower():
208+
portrait_item.show()
209+
else:
210+
portrait_item.hide()
211+
198212
func refresh_themes_and_select(file):
199213
selected_theme_file = file
200214
var picker_menu = nodes['theme']

addons/dialogic/Editor/CharacterEditor/CharacterEditor.tscn

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
[gd_scene load_steps=14 format=2]
1+
[gd_scene load_steps=15 format=2]
22

33
[ext_resource path="res://addons/dialogic/Editor/CharacterEditor/PortraitEntry.tscn" type="PackedScene" id=1]
44
[ext_resource path="res://addons/dialogic/Editor/CharacterEditor/CharacterEditor.gd" type="Script" id=2]
55
[ext_resource path="res://addons/dialogic/Editor/Common/TLabel.tscn" type="PackedScene" id=3]
66
[ext_resource path="res://addons/dialogic/Example Assets/portraits/df-3.png" type="Texture" id=4]
7+
[ext_resource path="res://addons/dialogic/Editor/Events/styles/InputFieldsStyle.tres" type="Theme" id=5]
78

89
[sub_resource type="StyleBoxFlat" id=1]
910
bg_color = Color( 0.2, 0.23, 0.31, 1 )
@@ -69,6 +70,7 @@ size = Vector2( 16, 16 )
6970
anchor_right = 1.0
7071
anchor_bottom = 1.0
7172
margin_right = -25.0
73+
theme = ExtResource( 5 )
7274
script = ExtResource( 2 )
7375
__meta__ = {
7476
"_edit_use_anchors_": false
@@ -110,7 +112,7 @@ margin_top = 5.0
110112
margin_right = 130.0
111113
margin_bottom = 19.0
112114
rect_min_size = Vector2( 130, 0 )
113-
text = "Name:"
115+
text = "Name: "
114116
text_key = "Name: "
115117

116118
[node name="ColorPickerButton" type="ColorPickerButton" parent="Split/EditorScroll/Editor/NameAndColor"]
@@ -151,7 +153,7 @@ margin_top = 5.0
151153
margin_right = 130.0
152154
margin_bottom = 19.0
153155
rect_min_size = Vector2( 130, 0 )
154-
text = "Anzeigename:"
156+
text = "Display Name: "
155157
text_key = "Display Name: "
156158

157159
[node name="CheckBox" type="CheckBox" parent="Split/EditorScroll/Editor/DisplayName"]
@@ -188,7 +190,7 @@ margin_top = 5.0
188190
margin_right = 130.0
189191
margin_bottom = 19.0
190192
rect_min_size = Vector2( 130, 0 )
191-
text = "Spitznamen:"
193+
text = "Nicknames: "
192194
text_key = "Nicknames: "
193195

194196
[node name="CheckBox" type="CheckBox" parent="Split/EditorScroll/Editor/DisplayNickname"]
@@ -222,7 +224,7 @@ margin_right = 130.0
222224
margin_bottom = 14.0
223225
rect_min_size = Vector2( 130, 0 )
224226
size_flags_vertical = 0
225-
text = "Beschreibung:"
227+
text = "Description: "
226228
text_key = "Description: "
227229

228230
[node name="TextEdit" type="TextEdit" parent="Split/EditorScroll/Editor/Description"]
@@ -266,36 +268,46 @@ custom_constants/separation = 18
266268
[node name="Portraits" type="HBoxContainer" parent="Split/EditorScroll/Editor"]
267269
margin_top = 184.0
268270
margin_right = 581.0
269-
margin_bottom = 198.0
271+
margin_bottom = 208.0
270272

271273
[node name="Title" parent="Split/EditorScroll/Editor/Portraits" instance=ExtResource( 3 )]
272274
anchor_right = 0.0
273275
anchor_bottom = 0.0
274-
margin_right = 581.0
275-
margin_bottom = 14.0
276+
margin_top = 5.0
277+
margin_right = 457.0
278+
margin_bottom = 19.0
276279
size_flags_horizontal = 3
277280
custom_fonts/font = SubResource( 4 )
278281
text = "Portraits"
279282
valign = 1
280283
text_key = "Portraits"
281284

285+
[node name="Search" type="LineEdit" parent="Split/EditorScroll/Editor/Portraits"]
286+
margin_left = 461.0
287+
margin_right = 581.0
288+
margin_bottom = 24.0
289+
rect_min_size = Vector2( 120, 0 )
290+
size_flags_vertical = 4
291+
expand_to_text_length = true
292+
placeholder_text = "Search"
293+
282294
[node name="HBoxContainer" type="HBoxContainer" parent="Split/EditorScroll/Editor"]
283-
margin_top = 202.0
295+
margin_top = 212.0
284296
margin_right = 581.0
285-
margin_bottom = 226.0
297+
margin_bottom = 236.0
286298

287299
[node name="TLabel11" parent="Split/EditorScroll/Editor/HBoxContainer" instance=ExtResource( 3 )]
288300
anchor_right = 0.0
289301
anchor_bottom = 0.0
290302
margin_top = 5.0
291-
margin_right = 39.0
303+
margin_right = 33.0
292304
margin_bottom = 19.0
293-
text = "Größe"
305+
text = "Scale"
294306
text_key = "Scale"
295307

296308
[node name="Scale" type="SpinBox" parent="Split/EditorScroll/Editor/HBoxContainer"]
297-
margin_left = 43.0
298-
margin_right = 117.0
309+
margin_left = 37.0
310+
margin_right = 113.0
299311
margin_bottom = 24.0
300312
value = 100.0
301313
allow_greater = true
@@ -305,50 +317,50 @@ suffix = "%"
305317
[node name="TLabel12" parent="Split/EditorScroll/Editor/HBoxContainer" instance=ExtResource( 3 )]
306318
anchor_right = 0.0
307319
anchor_bottom = 0.0
308-
margin_left = 121.0
320+
margin_left = 117.0
309321
margin_top = 5.0
310-
margin_right = 207.0
322+
margin_right = 156.0
311323
margin_bottom = 19.0
312-
text = "Verschiebung"
324+
text = "Offset"
313325
text_key = "Offset"
314326

315327
[node name="OffsetX" type="SpinBox" parent="Split/EditorScroll/Editor/HBoxContainer"]
316-
margin_left = 211.0
317-
margin_right = 285.0
328+
margin_left = 160.0
329+
margin_right = 236.0
318330
margin_bottom = 24.0
319331
allow_greater = true
320332
allow_lesser = true
321333
suffix = "X"
322334

323335
[node name="OffsetY" type="SpinBox" parent="Split/EditorScroll/Editor/HBoxContainer"]
324-
margin_left = 289.0
325-
margin_right = 363.0
336+
margin_left = 240.0
337+
margin_right = 316.0
326338
margin_bottom = 24.0
327339
allow_greater = true
328340
allow_lesser = true
329341
suffix = "Y"
330342

331343
[node name="MirrorOption" type="HBoxContainer" parent="Split/EditorScroll/Editor/HBoxContainer"]
332-
margin_left = 367.0
333-
margin_right = 507.0
344+
margin_left = 320.0
345+
margin_right = 445.0
334346
margin_bottom = 24.0
335347

336348
[node name="TLabel11" parent="Split/EditorScroll/Editor/HBoxContainer/MirrorOption" instance=ExtResource( 3 )]
337349
anchor_right = 0.0
338350
anchor_bottom = 0.0
339351
margin_top = 5.0
340-
margin_right = 112.0
352+
margin_right = 97.0
341353
margin_bottom = 19.0
342-
text = "Portraits spiegeln"
354+
text = "Mirror portraits"
343355
text_key = "Mirror portraits"
344356

345357
[node name="MirrorPortraitsCheckBox" type="CheckBox" parent="Split/EditorScroll/Editor/HBoxContainer/MirrorOption"]
346-
margin_left = 116.0
347-
margin_right = 140.0
358+
margin_left = 101.0
359+
margin_right = 125.0
348360
margin_bottom = 24.0
349361

350362
[node name="PortraitPanel" type="PanelContainer" parent="Split/EditorScroll/Editor"]
351-
margin_top = 230.0
363+
margin_top = 240.0
352364
margin_right = 581.0
353365
margin_bottom = 600.0
354366
size_flags_vertical = 3
@@ -358,7 +370,7 @@ custom_styles/panel = SubResource( 7 )
358370
margin_left = 2.0
359371
margin_top = 2.0
360372
margin_right = 579.0
361-
margin_bottom = 368.0
373+
margin_bottom = 358.0
362374

363375
[node name="Labels" type="HBoxContainer" parent="Split/EditorScroll/Editor/PortraitPanel/VBoxContainer"]
364376
margin_right = 577.0
@@ -379,40 +391,40 @@ anchor_right = 0.0
379391
anchor_bottom = 0.0
380392
margin_left = 164.0
381393
margin_top = 4.0
382-
margin_right = 276.0
394+
margin_right = 329.0
383395
margin_bottom = 18.0
384396
size_flags_horizontal = 3
385397
text = "Path"
386398
text_key = "Path"
387399

388400
[node name="HBoxContainer" type="HBoxContainer" parent="Split/EditorScroll/Editor/PortraitPanel/VBoxContainer/Labels"]
389-
margin_left = 280.0
401+
margin_left = 333.0
390402
margin_right = 577.0
391403
margin_bottom = 22.0
392404

393405
[node name="NewPortrait" type="Button" parent="Split/EditorScroll/Editor/PortraitPanel/VBoxContainer/Labels/HBoxContainer"]
394-
margin_right = 130.0
406+
margin_right = 117.0
395407
margin_bottom = 22.0
396-
text = " Neues Portrait"
408+
text = " New portrait"
397409
icon = SubResource( 9 )
398410

399411
[node name="ImportFromFolder" type="Button" parent="Split/EditorScroll/Editor/PortraitPanel/VBoxContainer/Labels/HBoxContainer"]
400-
margin_left = 134.0
401-
margin_right = 297.0
412+
margin_left = 121.0
413+
margin_right = 244.0
402414
margin_bottom = 22.0
403-
text = " Ordner importieren"
415+
text = " Import folder"
404416
icon = SubResource( 9 )
405417

406418
[node name="ScrollContainer" type="ScrollContainer" parent="Split/EditorScroll/Editor/PortraitPanel/VBoxContainer"]
407419
margin_top = 26.0
408420
margin_right = 577.0
409-
margin_bottom = 366.0
421+
margin_bottom = 356.0
410422
size_flags_horizontal = 3
411423
size_flags_vertical = 3
412424

413425
[node name="VBoxContainer" type="VBoxContainer" parent="Split/EditorScroll/Editor/PortraitPanel/VBoxContainer/ScrollContainer"]
414426
margin_right = 577.0
415-
margin_bottom = 340.0
427+
margin_bottom = 330.0
416428
size_flags_horizontal = 3
417429
size_flags_vertical = 3
418430

@@ -436,7 +448,7 @@ anchor_bottom = 0.0
436448
margin_top = 5.0
437449
margin_right = 27.0
438450
margin_bottom = 19.0
439-
text = "Datei"
451+
text = "File:"
440452
text_key = "File:"
441453

442454
[node name="LineEdit" type="LineEdit" parent="Split/EditorScroll/Editor/FileName"]

addons/dialogic/Editor/Events/styles/InputFieldsStyle.tres

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LineEdit/colors/cursor_color = Color( 1, 1, 1, 1 )
2323
LineEdit/colors/font_color = Color( 1, 1, 1, 1 )
2424
LineEdit/colors/font_color_selected = Color( 1, 1, 1, 1 )
2525
LineEdit/colors/font_color_uneditable = Color( 1, 1, 1, 1 )
26-
LineEdit/colors/selection_color = Color( 1, 1, 1, 1 )
26+
LineEdit/colors/selection_color = Color( 1, 1, 1, 0.235294 )
2727
LineEdit/constants/minimum_spaces = 10
2828
LineEdit/fonts/font = null
2929
LineEdit/icons/clear = null

0 commit comments

Comments
 (0)