From fdbdca1101e63d209ad19e7894c4e5b4c4644514 Mon Sep 17 00:00:00 2001 From: don-tnowe <67479453+don-tnowe@users.noreply.github.com> Date: Sat, 24 Sep 2022 00:47:42 +0300 Subject: [PATCH] Improve array recent menu --- .../typed_cells/cell_editor_bool.gd | 5 +++-- .../typed_editors/dock_array.gd | 7 +++++++ .../typed_editors/dock_array.tscn | 16 +++++++++++++--- example/upgrades/weapon_chaos_blast.tres | 2 +- example/upgrades/weapon_giga_sword.tres | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) 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..dcd6121 100644 --- a/addons/resources_speadsheet_view/typed_cells/cell_editor_bool.gd +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor_bool.gd @@ -9,8 +9,9 @@ func set_value(node : Control, value): if value is bool: _set_value_internal(node, value) - else: - _set_value_internal(node, !node.text.begins_with("O")) + # Does not work properly with new text input system + # else: + # _set_value_internal(node, !node.text.begins_with("O")) func _set_value_internal(node, value): diff --git a/addons/resources_speadsheet_view/typed_editors/dock_array.gd b/addons/resources_speadsheet_view/typed_editors/dock_array.gd index e415e82..177de64 100644 --- a/addons/resources_speadsheet_view/typed_editors/dock_array.gd +++ b/addons/resources_speadsheet_view/typed_editors/dock_array.gd @@ -71,6 +71,7 @@ func _add_recent(value): var node := Button.new() node.text = str(value) + node.self_modulate = Color(value.hash()) + Color(0.25, 0.25, 0.25, 1.0) node.connect("pressed", self, "_on_recent_clicked", [node, value]) recent_container.add_child(node) @@ -113,3 +114,9 @@ func _on_String_pressed(): func _on_Variant_pressed(): _add_value(str2var(value_input.text)) + + +func _on_AddRecentFromSel_pressed(): + for x in sheet.get_edited_cells_values(): + for y in x: + _add_recent(y) diff --git a/addons/resources_speadsheet_view/typed_editors/dock_array.tscn b/addons/resources_speadsheet_view/typed_editors/dock_array.tscn index f54f51b..0303286 100644 --- a/addons/resources_speadsheet_view/typed_editors/dock_array.tscn +++ b/addons/resources_speadsheet_view/typed_editors/dock_array.tscn @@ -187,21 +187,31 @@ margin_bottom = 52.0 size_flags_horizontal = 3 [node name="Label" type="Label" parent="HBoxContainer/Control2/HBoxContainer/HFlowContainer"] -margin_top = 3.0 +margin_top = 4.0 margin_right = 48.0 -margin_bottom = 17.0 +margin_bottom = 18.0 text = "Recent:" [node name="OptionButton" type="OptionButton" parent="HBoxContainer/Control2/HBoxContainer/HFlowContainer"] margin_left = 52.0 margin_right = 106.0 -margin_bottom = 20.0 +margin_bottom = 22.0 text = "Add" items = [ "Add", null, false, 0, null, "Erase", null, false, 1, null, "Delete From Recent", null, false, 2, null ] selected = 0 +[node name="AddRecentFromSel" type="Button" parent="HBoxContainer/Control2/HBoxContainer/HFlowContainer"] +margin_left = 110.0 +margin_right = 138.0 +margin_bottom = 22.0 +hint_tooltip = "Copy Selection into this List" +icon = SubResource( 2 ) +script = ExtResource( 2 ) +icon_name = "ListSelect" + [connection signal="pressed" from="HBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer/String" to="." method="_on_String_pressed"] [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/Remove" to="." method="_on_Remove_pressed"] +[connection signal="pressed" from="HBoxContainer/Control2/HBoxContainer/HFlowContainer/AddRecentFromSel" to="." method="_on_AddRecentFromSel_pressed"] diff --git a/example/upgrades/weapon_chaos_blast.tres b/example/upgrades/weapon_chaos_blast.tres index 46b8ab8..719b756 100644 --- a/example/upgrades/weapon_chaos_blast.tres +++ b/example/upgrades/weapon_chaos_blast.tres @@ -9,7 +9,7 @@ resource_name = "Weapon: Chaos Blast" script = ExtResource( 1 ) color1 = Color( 1, 1, 0.2, 1 ) max_duplicates = 1 -tags = [ "weapon", "magic", "projectile" ] +tags = [ "weapon", "magic", "projectile", "legendary" ] icon = ExtResource( 2 ) custom_scene = ExtResource( 3 ) color2 = Color( 0.40631, 0.190945, 0.832031, 1 ) diff --git a/example/upgrades/weapon_giga_sword.tres b/example/upgrades/weapon_giga_sword.tres index cfa6e52..52a70ae 100644 --- a/example/upgrades/weapon_giga_sword.tres +++ b/example/upgrades/weapon_giga_sword.tres @@ -9,7 +9,7 @@ resource_name = "Weapon: Giga Sword" script = ExtResource( 1 ) color1 = Color( 1, 1, 0.2, 1 ) max_duplicates = 1 -tags = [ "weapon", "strength", "melee" ] +tags = [ "weapon", "strength", "melee", "legendary" ] icon = ExtResource( 2 ) custom_scene = ExtResource( 3 ) color2 = Color( 0.988235, 0.93848, 0.192157, 1 )