mirror of
https://github.com/Relintai/godot-resources-as-sheets-plugin.git
synced 2025-04-12 22:42:01 +02:00
Fix bug with typed arrays seen as enum arrays
This commit is contained in:
parent
50b6916352
commit
475e958c5b
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user