mirror of
https://github.com/Relintai/godot-resources-as-sheets-plugin.git
synced 2025-04-08 17:41:50 +02:00
Allow multi-edit for Resource arrays
This commit is contained in:
parent
95c73aa818
commit
8250fdcef3
@ -26,10 +26,41 @@ func try_edit_value(value, type, property_hint) -> bool:
|
||||
_stored_value = value.duplicate() # Generic arrays are passed by reference
|
||||
contents_label.text = str(value)
|
||||
|
||||
var is_generic_array = _stored_type == TYPE_ARRAY
|
||||
button_box.get_child(1).visible = is_generic_array or _stored_type == TYPE_PACKED_STRING_ARRAY
|
||||
button_box.get_child(2).visible = is_generic_array or _stored_type == TYPE_PACKED_INT32_ARRAY or _stored_type == TYPE_PACKED_INT64_ARRAY
|
||||
button_box.get_child(3).visible = is_generic_array or _stored_type == TYPE_PACKED_FLOAT32_ARRAY or _stored_type == TYPE_PACKED_FLOAT64_ARRAY
|
||||
var is_generic_array = _stored_type == TYPE_ARRAY and !value.is_typed()
|
||||
button_box.get_child(1).visible = (
|
||||
is_generic_array or value.get_typed_builtin() == TYPE_STRING
|
||||
or _stored_type == TYPE_PACKED_STRING_ARRAY
|
||||
)
|
||||
button_box.get_child(2).visible = (
|
||||
is_generic_array or value.get_typed_builtin() == TYPE_INT
|
||||
or _stored_type == TYPE_PACKED_INT32_ARRAY or _stored_type == TYPE_PACKED_INT64_ARRAY
|
||||
)
|
||||
button_box.get_child(3).visible = (
|
||||
is_generic_array or value.get_typed_builtin() == TYPE_FLOAT
|
||||
or _stored_type == TYPE_PACKED_FLOAT32_ARRAY or _stored_type == TYPE_PACKED_FLOAT64_ARRAY
|
||||
)
|
||||
button_box.get_child(5).visible = (
|
||||
is_generic_array or value.get_typed_builtin() == TYPE_OBJECT
|
||||
)
|
||||
|
||||
if value.get_typed_builtin() == TYPE_OBJECT:
|
||||
if !value_input is EditorResourcePicker:
|
||||
var new_input := EditorResourcePicker.new()
|
||||
new_input.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
new_input.base_type = value.get_typed_class_name()
|
||||
|
||||
value_input.replace_by(new_input)
|
||||
value_input.free()
|
||||
value_input = new_input
|
||||
|
||||
else:
|
||||
if !value_input is LineEdit:
|
||||
var new_input := LineEdit.new()
|
||||
new_input.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||
|
||||
value_input.replace_by(new_input)
|
||||
value_input.free()
|
||||
value_input = new_input
|
||||
|
||||
return true
|
||||
|
||||
@ -94,7 +125,10 @@ func _on_recent_clicked(button, value):
|
||||
|
||||
|
||||
func _on_Remove_pressed():
|
||||
if str_to_var(value_input.text) != null:
|
||||
if value_input is EditorResourcePicker:
|
||||
_remove_value(value_input.edited_resource)
|
||||
|
||||
elif str_to_var(value_input.text) != null:
|
||||
_remove_value(str_to_var(value_input.text))
|
||||
|
||||
else:
|
||||
@ -138,7 +172,19 @@ func _on_String_pressed():
|
||||
|
||||
|
||||
func _on_Variant_pressed():
|
||||
_add_value(str_to_var(value_input.text))
|
||||
if value_input is EditorResourcePicker:
|
||||
_add_value(value_input.edited_resource)
|
||||
|
||||
else:
|
||||
_add_value(str_to_var(value_input.text))
|
||||
|
||||
|
||||
func _on_Resource_pressed():
|
||||
if value_input is LineEdit:
|
||||
_add_value(load(value_input.text))
|
||||
|
||||
elif value_input is EditorResourcePicker:
|
||||
_add_value(value_input.edited_resource)
|
||||
|
||||
|
||||
func _on_AddRecentFromSel_pressed():
|
||||
|
@ -3,7 +3,7 @@
|
||||
[ext_resource type="Script" path="res://addons/resources_spreadsheet_view/typed_editors/dock_array.gd" id="1"]
|
||||
[ext_resource type="Script" path="res://addons/resources_spreadsheet_view/editor_icon_button.gd" id="2"]
|
||||
|
||||
[sub_resource type="Image" id="Image_e2jbh"]
|
||||
[sub_resource type="Image" id="Image_etyvi"]
|
||||
data = {
|
||||
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 93, 93, 55, 255, 97, 97, 58, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
|
||||
"format": "RGBA8",
|
||||
@ -13,7 +13,7 @@ data = {
|
||||
}
|
||||
|
||||
[sub_resource type="ImageTexture" id="ImageTexture_3oshq"]
|
||||
image = SubResource("Image_e2jbh")
|
||||
image = SubResource("Image_etyvi")
|
||||
|
||||
[node name="EditArray" type="VBoxContainer"]
|
||||
anchors_preset = 10
|
||||
@ -85,28 +85,39 @@ text = "Add:"
|
||||
|
||||
[node name="String" type="Button" parent="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Add string"
|
||||
icon = SubResource("ImageTexture_3oshq")
|
||||
script = ExtResource("2")
|
||||
icon_name = "String"
|
||||
|
||||
[node name="Int" type="Button" parent="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Add integer"
|
||||
icon = SubResource("ImageTexture_3oshq")
|
||||
script = ExtResource("2")
|
||||
icon_name = "int"
|
||||
|
||||
[node name="Float" type="Button" parent="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Add float"
|
||||
icon = SubResource("ImageTexture_3oshq")
|
||||
script = ExtResource("2")
|
||||
icon_name = "float"
|
||||
|
||||
[node name="Variant" type="Button" parent="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Guess type and add"
|
||||
icon = SubResource("ImageTexture_3oshq")
|
||||
script = ExtResource("2")
|
||||
icon_name = "Variant"
|
||||
|
||||
[node name="Object" type="Button" parent="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Add resource (by path if string)"
|
||||
icon = SubResource("ImageTexture_3oshq")
|
||||
script = ExtResource("2")
|
||||
icon_name = "Object"
|
||||
|
||||
[node name="Label2" type="Label" parent="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Erase:"
|
||||
@ -170,6 +181,7 @@ icon_name = "ListSelect"
|
||||
[connection signal="pressed" from="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer/Int" to="." method="_on_Int_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer/Float" to="." method="_on_Float_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer/Variant" to="." method="_on_Variant_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer/Object" to="." method="_on_Resource_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer/Remove" to="." method="_on_Remove_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer/Remove2" to="." method="_on_RemoveLast_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/Control2/HBoxContainer/HFlowContainer/AddRecentFromSel" to="." method="_on_AddRecentFromSel_pressed"]
|
||||
|
Loading…
Reference in New Issue
Block a user