mirror of
https://github.com/Relintai/godot-resources-as-sheets-plugin.git
synced 2025-04-08 17:41:50 +02:00
The text field in collection docks now does stuff!
This commit is contained in:
parent
9816ddc146
commit
627a4d66fa
@ -19,7 +19,10 @@ func _write_value_to_child(value, key, hint_arr : PackedStringArray, child : Lab
|
||||
var found := hint_arr[0].find(":") + 1
|
||||
value_str = hint_arr[0].substr(hint_arr[0].find(":") + 1)
|
||||
|
||||
else:
|
||||
elif value < hint_arr.size():
|
||||
value_str = hint_arr[value]
|
||||
|
||||
else:
|
||||
value_str = "?:%s" % value
|
||||
|
||||
super(value_str, value_str, hint_arr, child, colored)
|
||||
|
@ -10,6 +10,11 @@ var _stored_value
|
||||
var _stored_type := 0
|
||||
|
||||
|
||||
func _ready():
|
||||
super()
|
||||
contents_label.text_changed.connect(_on_contents_edit_text_changed)
|
||||
|
||||
|
||||
func try_edit_value(value, type, property_hint) -> bool:
|
||||
if (
|
||||
type != TYPE_ARRAY and type != TYPE_PACKED_STRING_ARRAY
|
||||
@ -199,3 +204,19 @@ func _on_AddRecentFromSel_pressed():
|
||||
for x in sheet.get_edited_cells_values():
|
||||
for y in x:
|
||||
_add_recent(y)
|
||||
|
||||
|
||||
func _on_contents_edit_text_changed():
|
||||
var value := str_to_var(contents_label.text)
|
||||
if !value is Array:
|
||||
return
|
||||
|
||||
var values = sheet.get_edited_cells_values()
|
||||
for i in values.size():
|
||||
values[i] = values[i].duplicate()
|
||||
values[i].resize(value.size())
|
||||
for j in value.size():
|
||||
values[i][j] = value[j]
|
||||
|
||||
_stored_value = value
|
||||
sheet.set_edited_cells_values(values)
|
||||
|
@ -29,7 +29,7 @@ func try_edit_value(value, type, property_hint) -> bool:
|
||||
if type == TYPE_DICTIONARY:
|
||||
_stored_value = value.duplicate()
|
||||
|
||||
contents_label.text = str(value)
|
||||
contents_label.text = var_to_str_no_sort(value)
|
||||
|
||||
return true
|
||||
|
||||
@ -147,3 +147,50 @@ func _on_AddRecentFromSel_pressed():
|
||||
else:
|
||||
for y in x:
|
||||
super._add_recent(y)
|
||||
|
||||
|
||||
func _on_contents_edit_text_changed():
|
||||
var value := str_to_var(contents_label.text)
|
||||
if !value is Dictionary:
|
||||
return
|
||||
|
||||
var values = sheet.get_edited_cells_values()
|
||||
for i in values.size():
|
||||
values[i] = value.duplicate()
|
||||
|
||||
_stored_value = value
|
||||
sheet.set_edited_cells_values(values)
|
||||
|
||||
|
||||
func var_to_str_no_sort(value, indent = " ", cur_indent = ""):
|
||||
var lines : Array[String] = []
|
||||
|
||||
if value is Array:
|
||||
cur_indent += indent
|
||||
lines.resize(value.size())
|
||||
for i in lines.size():
|
||||
if value[i] is Array || value[i] is Dictionary:
|
||||
lines[i] = "%s%s" % [cur_indent, var_to_str_no_sort(value[i])]
|
||||
|
||||
else:
|
||||
lines[i] = "%s%s" % [cur_indent, var_to_str(value[i])]
|
||||
|
||||
cur_indent = cur_indent.substr(0, cur_indent.length() - indent.length())
|
||||
return "[\n" + ",\n".join(lines) + "\n]"
|
||||
|
||||
if value is Dictionary:
|
||||
var keys : Array = value.keys()
|
||||
var values : Array = value.values()
|
||||
cur_indent += indent
|
||||
lines.resize(keys.size())
|
||||
for i in lines.size():
|
||||
if values[i] is Array || values[i] is Dictionary:
|
||||
lines[i] = "%s%s : %s" % [cur_indent, var_to_str(keys[i]), var_to_str_no_sort(values[i])]
|
||||
|
||||
else:
|
||||
lines[i] = "%s%s : %s" % [cur_indent, var_to_str(keys[i]), var_to_str(values[i])]
|
||||
|
||||
cur_indent = cur_indent.substr(0, cur_indent.length() - indent.length())
|
||||
return "{\n" + ",\n".join(lines) + "\n}"
|
||||
|
||||
return ",\n".join(lines)
|
||||
|
@ -10,6 +10,11 @@ var _stored_value
|
||||
var _last_column := -1
|
||||
|
||||
|
||||
func _ready():
|
||||
super()
|
||||
contents_label.text_changed.connect(_on_contents_edit_text_changed)
|
||||
|
||||
|
||||
func try_edit_value(value, type, property_hint) -> bool:
|
||||
if !sheet.column_hint_strings[sheet.get_selected_column()][0].begins_with("2/2:"):
|
||||
return false
|
||||
@ -105,3 +110,23 @@ func _on_Remove_pressed():
|
||||
values[i] = cur_value
|
||||
|
||||
sheet.set_edited_cells_values(values)
|
||||
|
||||
|
||||
func _on_contents_edit_text_changed():
|
||||
var value := str_to_var(contents_label.text)
|
||||
if !value is Array:
|
||||
return
|
||||
|
||||
for x in value:
|
||||
if !x is int:
|
||||
return
|
||||
|
||||
var values = sheet.get_edited_cells_values()
|
||||
for i in values.size():
|
||||
values[i] = values[i].duplicate()
|
||||
values[i].resize(value.size())
|
||||
for j in value.size():
|
||||
values[i][j] = value[j]
|
||||
|
||||
_stored_value = value
|
||||
sheet.set_edited_cells_values(values)
|
||||
|
Loading…
Reference in New Issue
Block a user