diff --git a/addons/resources_speadsheet_view/editor_view.gd b/addons/resources_speadsheet_view/editor_view.gd index 9e78594..0725c2f 100644 --- a/addons/resources_speadsheet_view/editor_view.gd +++ b/addons/resources_speadsheet_view/editor_view.gd @@ -139,14 +139,16 @@ func _load_resources_from_folder(folderpath : String, sort_by : String, sort_rev column_hints.clear() column_hint_strings.clear() column_editors.clear() + var column_index = -1 for x in res.get_property_list(): if x["usage"] & PROPERTY_USAGE_EDITOR != 0 and x["name"] != "script": + column_index += 1 columns.append(x["name"]) column_types.append(x["type"]) column_hints.append(x["hint"]) column_hint_strings.append(x["hint_string"].split(",")) for y in all_cell_editors: - if y.can_edit_value(res.get(x["name"]), x["type"], x["hint"]): + if y.can_edit_value(res.get(x["name"]), x["type"], x["hint"], column_index): column_editors.append(y) break diff --git a/addons/resources_speadsheet_view/typed_cells/cell_editor.gd b/addons/resources_speadsheet_view/typed_cells/cell_editor.gd index 5d268ba..d525dde 100644 --- a/addons/resources_speadsheet_view/typed_cells/cell_editor.gd +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor.gd @@ -7,7 +7,7 @@ var hint_strings_array := [] # Override to define where the cell should be shown. -func can_edit_value(value, type, property_hint) -> bool: +func can_edit_value(value, type, property_hint, column_index) -> bool: return value != null # Override to change how the cell is created; preload a scene or create nodes from code. @@ -27,6 +27,6 @@ func set_value(node : Control, value): func is_text(): return true - +# Override to change behaviour when there are color cells to the left of this cell. func set_color(node : Control, color : Color): node.get_node("Back").modulate = color * 1.0 diff --git a/addons/resources_speadsheet_view/typed_cells/cell_editor_array.gd b/addons/resources_speadsheet_view/typed_cells/cell_editor_array.gd index 4cbc153..6a0e191 100644 --- a/addons/resources_speadsheet_view/typed_cells/cell_editor_array.gd +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor_array.gd @@ -2,7 +2,7 @@ class_name CellEditorArray extends CellEditor -func can_edit_value(value, type, property_hint) -> bool: +func can_edit_value(value, type, property_hint, column_index) -> bool: return type == TYPE_STRING_ARRAY or type == TYPE_ARRAY diff --git a/addons/resources_speadsheet_view/typed_cells/cell_editor_bool.gd b/addons/resources_speadsheet_view/typed_cells/cell_editor_bool.gd index 04e0e40..488248e 100644 --- a/addons/resources_speadsheet_view/typed_cells/cell_editor_bool.gd +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor_bool.gd @@ -1,7 +1,7 @@ extends CellEditor -func can_edit_value(value, type, property_hint) -> bool: +func can_edit_value(value, type, property_hint, column_index) -> bool: return type == TYPE_BOOL diff --git a/addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd b/addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd index 73ad1f5..9cfc32e 100644 --- a/addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd @@ -15,7 +15,7 @@ func create_cell(caller : Control) -> Control: return node -func can_edit_value(value, type, property_hint) -> bool: +func can_edit_value(value, type, property_hint, column_index) -> bool: return type == TYPE_COLOR diff --git a/addons/resources_speadsheet_view/typed_cells/cell_editor_enum.gd b/addons/resources_speadsheet_view/typed_cells/cell_editor_enum.gd index ae21a94..ddf1391 100644 --- a/addons/resources_speadsheet_view/typed_cells/cell_editor_enum.gd +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor_enum.gd @@ -1,7 +1,7 @@ extends CellEditor -func can_edit_value(value, type, property_hint) -> bool: +func can_edit_value(value, type, property_hint, column_index) -> bool: return type == TYPE_INT and property_hint == PROPERTY_HINT_ENUM diff --git a/addons/resources_speadsheet_view/typed_cells/cell_editor_enum_array.gd b/addons/resources_speadsheet_view/typed_cells/cell_editor_enum_array.gd index f2add8a..e3d2136 100644 --- a/addons/resources_speadsheet_view/typed_cells/cell_editor_enum_array.gd +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor_enum_array.gd @@ -1,8 +1,13 @@ extends CellEditorArray -func can_edit_value(value, type, property_hint) -> bool: - return (type == TYPE_INT_ARRAY or type == TYPE_ARRAY) and property_hint == 26 +func can_edit_value(value, type, property_hint, column_index) -> bool: + if (type != TYPE_INT_ARRAY and type != TYPE_ARRAY) or property_hint != 26: + return false + + print(column_index) + print(hint_strings_array[column_index][0]) + return hint_strings_array[column_index][0].begins_with("2/3:") func _write_value_to_child(value, hint_arr : PoolStringArray, child : Label, colored : bool): diff --git a/addons/resources_speadsheet_view/typed_cells/cell_editor_resource.gd b/addons/resources_speadsheet_view/typed_cells/cell_editor_resource.gd index 87b03b5..733f2e2 100644 --- a/addons/resources_speadsheet_view/typed_cells/cell_editor_resource.gd +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor_resource.gd @@ -3,7 +3,7 @@ extends CellEditor var previewer : EditorResourcePreview -func can_edit_value(value, type, property_hint) -> bool: +func can_edit_value(value, type, property_hint, column_index) -> bool: return type == TYPE_OBJECT diff --git a/addons/resources_speadsheet_view/typed_editors/dock_array.gd b/addons/resources_speadsheet_view/typed_editors/dock_array.gd index 44fa69e..b68e972 100644 --- a/addons/resources_speadsheet_view/typed_editors/dock_array.gd +++ b/addons/resources_speadsheet_view/typed_editors/dock_array.gd @@ -17,8 +17,8 @@ func try_edit_value(value, type, property_hint) -> bool: ): return false - if property_hint == 26: - # Prefer the specialized dock. + if sheet.column_hint_strings[sheet.get_selected_column()][0].begins_with("2/3:"): + # For enums, prefer the specialized dock. return false _stored_type = type diff --git a/addons/resources_speadsheet_view/typed_editors/dock_enum_array.gd b/addons/resources_speadsheet_view/typed_editors/dock_enum_array.gd index 2899006..a7b2fcf 100644 --- a/addons/resources_speadsheet_view/typed_editors/dock_enum_array.gd +++ b/addons/resources_speadsheet_view/typed_editors/dock_enum_array.gd @@ -11,7 +11,7 @@ var _last_column := -1 func try_edit_value(value, type, property_hint) -> bool: - if property_hint != 26: + if !sheet.column_hint_strings[sheet.get_selected_column()][0].begins_with("2/3:"): return false _stored_value = value.duplicate() # Generic arrays are passed by reference diff --git a/example/Random Upgrades/upgrade_data.gd b/example/Random Upgrades/upgrade_data.gd index f85e511..11f6966 100644 --- a/example/Random Upgrades/upgrade_data.gd +++ b/example/Random Upgrades/upgrade_data.gd @@ -11,7 +11,7 @@ enum Attributes { export var color1 := Color.white export var max_duplicates := 0 -export var tags : Array +export(Array, String) var tags : Array export(int, "Weapon", "Passive", "Mastery") var type := 0 export(Array, Attributes) var attributes export var icon : Texture