Fix for slow editing and inspector crash

This commit is contained in:
don-tnowe 2023-01-24 11:50:58 +02:00
parent 8160628672
commit 1b36e5a7cc
4 changed files with 23 additions and 23 deletions

View File

@ -2,7 +2,6 @@
extends Control
signal grid_updated()
signal cells_selected(cells)
signal cells_context(cells)
@export @onready var node_folder_path : LineEdit = $"HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer/Path"
@ -294,8 +293,8 @@ func set_edited_cells_values(new_cell_values : Array):
column,
new_cell_values.duplicate()
)
editor_plugin.undo_redo.commit_action()
editor_interface.get_resource_filesystem().scan()
editor_plugin.undo_redo.commit_action(true)
# editor_interface.get_resource_filesystem().scan()
func rename_row(row, new_name):
@ -352,6 +351,7 @@ func _update_resources(update_rows : Array, update_row_indices : Array[int], upd
values[i],
row
)
continue
if column_types[update_column] == TYPE_COLOR:
for j in columns.size() - update_column:
if j != 0 and column_types[j + update_column] == TYPE_COLOR:
@ -364,8 +364,8 @@ func _update_resources(update_rows : Array, update_row_indices : Array[int], upd
values[i]
)
io.save_entries(rows, update_row_indices)
node_columns._update_column_sizes()
io.save_entries(rows, update_row_indices)
func _try_convert(value, type):

View File

@ -4,7 +4,6 @@ extends SpreadsheetEditFormatTres
var import_data
var csv_rows = []
var resource_original_positions = {}
var timer : SceneTreeTimer
func get_value(entry, key : String):

View File

@ -1,18 +1,21 @@
class_name SpreadsheetEditFormatTres
extends SpreadsheetEditFormat
var timer : SceneTreeTimer
func get_value(entry, key : String):
return entry.get(key)
return entry[key]
func set_value(entry, key : String, value, index : int):
entry.set(key, value)
entry[key] = value
func save_entries(all_entries : Array, indices : Array):
for x in indices:
ResourceSaver.save(all_entries[x])
func save_entries(all_entries : Array, indices : Array, repeat : bool = true):
# No need to save. Resources are saved with Ctrl+S
# (likely because plugin.edit_resource is called to show inspector)
return
func create_resource(entry) -> Resource:

View File

@ -75,8 +75,9 @@ func select_cell(cell : Control):
if can_select_cell(cell):
_add_cell_to_selection(cell)
_try_open_docks(cell)
# inspector_resource = rows[get_cell_row(cell)].duplicate() #
inspector_resource = editor_view.rows[get_cell_row(cell)]
# inspector_resource = editor_view.rows[get_cell_row(cell)].duplicate()
# inspector_resource.resource_path = ""
editor_view.editor_plugin.get_editor_interface().edit_resource(inspector_resource)
cells_selected.emit(edited_cells)
@ -176,16 +177,9 @@ func _on_inspector_property_edited(property : String):
if !editor_view.is_visible_in_tree(): return
if inspector_resource == null: return
var value = inspector_resource[property]
var values = []
values.resize(edited_cells.size())
for i in edited_cells.size():
values[i] = value
var columns = editor_view.columns
var previously_edited = edited_cells
if columns[get_cell_column(edited_cells[0])] != property:
previously_edited = previously_edited.duplicate()
if editor_view.columns[get_cell_column(edited_cells[0])] != property:
var columns = editor_view.columns
var previously_edited = edited_cells.duplicate()
var new_column := columns.find(property)
deselect_all_cells()
var index := 0
@ -193,5 +187,9 @@ func _on_inspector_property_edited(property : String):
index = get_cell_row(previously_edited[i]) * columns.size() + new_column
_add_cell_to_selection(editor_view.node_table_root.get_child(index - editor_view.first_row))
editor_view.set_edited_cells_values(values)
var values = []
values.resize(edited_cells.size())
values.fill(inspector_resource[property])
editor_view.call_deferred(&"set_edited_cells_values", values)
_try_open_docks(edited_cells[0])