mirror of
https://github.com/Relintai/godot-resources-as-sheets-plugin.git
synced 2025-02-21 08:34:26 +01:00
Rewrite search behaviour (fixes #8)
This commit is contained in:
parent
fdcd89ef8a
commit
29359a1596
@ -73,7 +73,7 @@ func _on_filesystem_changed():
|
|||||||
var path = editor_interface.get_resource_filesystem().get_filesystem_path(current_path)
|
var path = editor_interface.get_resource_filesystem().get_filesystem_path(current_path)
|
||||||
if !path: return
|
if !path: return
|
||||||
if path.get_file_count() != rows.size():
|
if path.get_file_count() != rows.size():
|
||||||
display_folder(current_path, sorting_by, sorting_reverse, true)
|
refresh()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for k in remembered_paths:
|
for k in remembered_paths:
|
||||||
@ -81,7 +81,7 @@ func _on_filesystem_changed():
|
|||||||
var res = remembered_paths[k]
|
var res = remembered_paths[k]
|
||||||
remembered_paths.erase(k)
|
remembered_paths.erase(k)
|
||||||
remembered_paths[res.resource_path] = res
|
remembered_paths[res.resource_path] = res
|
||||||
display_folder(current_path, sorting_by, sorting_reverse, true)
|
refresh()
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
@ -91,6 +91,9 @@ func display_folder(folderpath : String, sort_by : String = "", sort_reverse : b
|
|||||||
if !folderpath.ends_with("/"):
|
if !folderpath.ends_with("/"):
|
||||||
folderpath += "/"
|
folderpath += "/"
|
||||||
|
|
||||||
|
if search_cond == null:
|
||||||
|
_on_SearchCond_text_entered("true")
|
||||||
|
|
||||||
_load_resources_from_folder(folderpath, sort_by, sort_reverse)
|
_load_resources_from_folder(folderpath, sort_by, sort_reverse)
|
||||||
if columns.size() == 0: return
|
if columns.size() == 0: return
|
||||||
|
|
||||||
@ -100,7 +103,6 @@ func display_folder(folderpath : String, sort_by : String = "", sort_reverse : b
|
|||||||
or current_path != folderpath
|
or current_path != folderpath
|
||||||
or columns.size() != get_node(path_columns).get_child_count()
|
or columns.size() != get_node(path_columns).get_child_count()
|
||||||
)
|
)
|
||||||
_apply_search_cond()
|
|
||||||
current_path = folderpath
|
current_path = folderpath
|
||||||
_update_hidden_columns()
|
_update_hidden_columns()
|
||||||
_update_column_sizes()
|
_update_column_sizes()
|
||||||
@ -110,6 +112,10 @@ func display_folder(folderpath : String, sort_by : String = "", sort_reverse : b
|
|||||||
display_folder(folderpath, sort_by, sort_reverse, force_rebuild)
|
display_folder(folderpath, sort_by, sort_reverse, force_rebuild)
|
||||||
|
|
||||||
|
|
||||||
|
func refresh():
|
||||||
|
display_folder(current_path, sorting_by, sorting_reverse, true)
|
||||||
|
|
||||||
|
|
||||||
func _load_resources_from_folder(folderpath : String, sort_by : String, sort_reverse : bool):
|
func _load_resources_from_folder(folderpath : String, sort_by : String, sort_reverse : bool):
|
||||||
var dir := Directory.new()
|
var dir := Directory.new()
|
||||||
dir.open(folderpath)
|
dir.open(folderpath)
|
||||||
@ -153,6 +159,9 @@ func _load_resources_from_folder(folderpath : String, sort_by : String, sort_rev
|
|||||||
|
|
||||||
|
|
||||||
func _insert_row_sorted(res : Resource, rows : Array, sort_by : String, sort_reverse : bool):
|
func _insert_row_sorted(res : Resource, rows : Array, sort_by : String, sort_reverse : bool):
|
||||||
|
if !search_cond.can_show(res, rows.size()):
|
||||||
|
return
|
||||||
|
|
||||||
for i in rows.size():
|
for i in rows.size():
|
||||||
if sort_reverse == _compare_values(res.get(sort_by), rows[i].get(sort_by)):
|
if sort_reverse == _compare_values(res.get(sort_by), rows[i].get(sort_by)):
|
||||||
rows.insert(i, res)
|
rows.insert(i, res)
|
||||||
@ -222,7 +231,7 @@ func _update_column_sizes():
|
|||||||
|
|
||||||
if table_root.get_child_count() < column_headers.size(): return
|
if table_root.get_child_count() < column_headers.size(): return
|
||||||
if column_headers.size() != columns.size():
|
if column_headers.size() != columns.size():
|
||||||
display_folder(current_path, sorting_by, sorting_reverse, true)
|
refresh()
|
||||||
return
|
return
|
||||||
|
|
||||||
var clip_text : bool = ProjectSettings.get_setting(SettingsGrid.SETTING_PREFIX + "clip_headers")
|
var clip_text : bool = ProjectSettings.get_setting(SettingsGrid.SETTING_PREFIX + "clip_headers")
|
||||||
@ -276,18 +285,6 @@ func _update_row(row_index : int, color_rows : bool = true):
|
|||||||
column_editors[i].set_color(current_node, next_color)
|
column_editors[i].set_color(current_node, next_color)
|
||||||
|
|
||||||
|
|
||||||
func _apply_search_cond():
|
|
||||||
if search_cond == null:
|
|
||||||
_on_SearchCond_text_entered("true")
|
|
||||||
|
|
||||||
var table_elements = get_node(path_table_root).get_children()
|
|
||||||
|
|
||||||
for i in rows.size():
|
|
||||||
var row_visible = search_cond.can_show(rows[i], i)
|
|
||||||
for j in columns.size():
|
|
||||||
table_elements[i * columns.size() + j].visible = row_visible
|
|
||||||
|
|
||||||
|
|
||||||
func _update_hidden_columns():
|
func _update_hidden_columns():
|
||||||
if !hidden_columns.has(current_path):
|
if !hidden_columns.has(current_path):
|
||||||
hidden_columns[current_path] = {}
|
hidden_columns[current_path] = {}
|
||||||
@ -357,7 +354,7 @@ func _on_Path_text_entered(new_text : String = ""):
|
|||||||
display_folder(new_text, "", false, true)
|
display_folder(new_text, "", false, true)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
display_folder(current_path, sorting_by, sorting_reverse, true)
|
refresh()
|
||||||
|
|
||||||
|
|
||||||
func _on_RecentPaths_item_selected(index : int):
|
func _on_RecentPaths_item_selected(index : int):
|
||||||
@ -747,7 +744,7 @@ func _on_SearchCond_text_entered(new_text : String):
|
|||||||
|
|
||||||
var new_script_instance = new_script.new()
|
var new_script_instance = new_script.new()
|
||||||
search_cond = new_script_instance
|
search_cond = new_script_instance
|
||||||
_apply_search_cond()
|
refresh()
|
||||||
|
|
||||||
|
|
||||||
func _on_ProcessExpr_text_entered(new_text : String):
|
func _on_ProcessExpr_text_entered(new_text : String):
|
||||||
|
@ -392,13 +392,12 @@ margin_bottom = 21.0
|
|||||||
rect_min_size = Vector2( 18, 18 )
|
rect_min_size = Vector2( 18, 18 )
|
||||||
hint_tooltip = "Enter an expression. The table only show rows where the expression returns `true`.
|
hint_tooltip = "Enter an expression. The table only show rows where the expression returns `true`.
|
||||||
|
|
||||||
You can use `res.<property_name>` to get a property, and `index` to get row number. Hit ENTER to run the search.
|
You can use `res.<property_name>` to get a property. Hit ENTER to run the search.
|
||||||
|
|
||||||
Try out these:
|
Try out these:
|
||||||
- (res.number_property > 0 and res.number_property < 100)
|
- (res.number_property > 0 and res.number_property < 100)
|
||||||
- (res.text_property != \"\")
|
- (res.text_property != \"\")
|
||||||
- (\"a\" in res.text_property)
|
- (\"a\" in res.text_property)"
|
||||||
- (index < 5)"
|
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
mouse_default_cursor_shape = 16
|
mouse_default_cursor_shape = 16
|
||||||
text = "(?)"
|
text = "(?)"
|
||||||
@ -450,6 +449,7 @@ margin_left = 600.0
|
|||||||
margin_right = 1018.0
|
margin_right = 1018.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 24.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
text = "value"
|
||||||
|
|
||||||
[node name="Control" type="Control" parent="."]
|
[node name="Control" type="Control" parent="."]
|
||||||
margin_left = 3.0
|
margin_left = 3.0
|
||||||
|
@ -5,5 +5,5 @@ description="Edit Many Resources from one Folder as a table.
|
|||||||
|
|
||||||
Heavily inspired by Multi-Cursor-Editing in text editors, so after selecting multiple cells (in the same column!) using Ctrl+Click or Shift+Click, most Basic-to-Intermediate movements should be available."
|
Heavily inspired by Multi-Cursor-Editing in text editors, so after selecting multiple cells (in the same column!) using Ctrl+Click or Shift+Click, most Basic-to-Intermediate movements should be available."
|
||||||
author="Don Tnowe"
|
author="Don Tnowe"
|
||||||
version="1.5.1"
|
version="1.5.2"
|
||||||
script="plugin.gd"
|
script="plugin.gd"
|
||||||
|
Loading…
Reference in New Issue
Block a user