mirror of
https://github.com/Relintai/godot-resources-as-sheets-plugin.git
synced 2025-04-12 22:42:01 +02:00
Added column selection and hiding
This commit is contained in:
parent
41b8737609
commit
07f52150f7
@ -10,6 +10,7 @@ export var path_recent_paths := NodePath("")
|
||||
export var path_table_root := NodePath("")
|
||||
export var path_property_editors := NodePath("")
|
||||
export var path_columns := NodePath("")
|
||||
export var path_hide_columns_button := NodePath("")
|
||||
|
||||
var editor_interface : EditorInterface
|
||||
var editor_plugin : EditorPlugin
|
||||
@ -37,6 +38,8 @@ var edit_cursor_positions := []
|
||||
var inspector_resource : Resource
|
||||
var search_cond : Reference
|
||||
|
||||
var hidden_columns := {}
|
||||
|
||||
|
||||
func _ready():
|
||||
get_node(path_recent_paths).clear()
|
||||
@ -56,6 +59,8 @@ func _ready():
|
||||
for x in as_var["recent_paths"]:
|
||||
add_path_to_recent(x, true)
|
||||
|
||||
hidden_columns = as_var["hidden_columns"]
|
||||
|
||||
# Load cell editors and instantiate them
|
||||
for x in cell_editor_classes:
|
||||
all_cell_editors.append(x.new())
|
||||
@ -101,6 +106,9 @@ func display_folder(folderpath : String, sort_by : String = "", sort_reverse : b
|
||||
)
|
||||
_apply_search_cond()
|
||||
current_path = folderpath
|
||||
_update_hidden_columns()
|
||||
_update_column_sizes()
|
||||
|
||||
yield(get_tree(), "idle_frame")
|
||||
if get_node(path_table_root).get_child_count() == 0:
|
||||
display_folder(folderpath, sort_by, sort_reverse, force_rebuild)
|
||||
@ -200,6 +208,7 @@ func _create_table(columns_changed : bool):
|
||||
new_node.get_node("Button").text = TextEditingUtils.string_snake_to_naming_case(x)
|
||||
new_node.get_node("Button").hint_tooltip = x
|
||||
new_node.get_node("Button").connect("pressed", self, "_set_sorting", [x])
|
||||
new_node.get_node("Button2").connect("pressed", self, "_on_header_extra_pressed", [new_node.get_position_in_parent()])
|
||||
|
||||
var to_free = root_node.get_child_count() - rows.size() * columns.size()
|
||||
while to_free > 0:
|
||||
@ -210,8 +219,6 @@ func _create_table(columns_changed : bool):
|
||||
for i in rows.size():
|
||||
_update_row(i, color_rows)
|
||||
|
||||
_update_column_sizes()
|
||||
|
||||
|
||||
func _update_column_sizes():
|
||||
yield(get_tree(), "idle_frame")
|
||||
@ -286,6 +293,26 @@ func _apply_search_cond():
|
||||
table_elements[i * columns.size() + j].visible = row_visible
|
||||
|
||||
|
||||
func _update_hidden_columns():
|
||||
if !hidden_columns.has(current_path):
|
||||
hidden_columns[current_path] = {}
|
||||
return
|
||||
|
||||
var node_table_root = get_node(path_table_root)
|
||||
var visible_column_count = 0
|
||||
for i in columns.size():
|
||||
var column_visible = !hidden_columns[current_path].has(columns[i])
|
||||
|
||||
get_node(path_columns).get_child(i).visible = column_visible
|
||||
for j in rows.size():
|
||||
node_table_root.get_child(j * columns.size() + i).visible = column_visible
|
||||
|
||||
if column_visible:
|
||||
visible_column_count += 1
|
||||
|
||||
node_table_root.columns = visible_column_count
|
||||
|
||||
|
||||
func add_path_to_recent(path : String, is_loading : bool = false):
|
||||
if path in recent_paths: return
|
||||
|
||||
@ -323,6 +350,7 @@ func save_data():
|
||||
file.store_string(var2str(
|
||||
{
|
||||
"recent_paths" : recent_paths,
|
||||
"hidden_columns" : hidden_columns,
|
||||
}
|
||||
))
|
||||
|
||||
@ -756,3 +784,67 @@ func _on_inspector_property_edited(property : String):
|
||||
|
||||
set_edited_cells_values(values)
|
||||
_try_open_docks(edited_cells[0])
|
||||
|
||||
|
||||
func _on_VisibleCols_pressed():
|
||||
var popup = get_node(path_hide_columns_button).get_child(0)
|
||||
if popup.visible:
|
||||
popup.hide()
|
||||
return
|
||||
|
||||
popup.clear()
|
||||
|
||||
for i in columns.size():
|
||||
popup.add_check_item(TextEditingUtils.string_snake_to_naming_case(columns[i]), i)
|
||||
popup.set_item_checked(i, hidden_columns[current_path].has(columns[i]))
|
||||
|
||||
popup.rect_global_position = get_global_mouse_position()
|
||||
popup.show()
|
||||
|
||||
|
||||
func _on_VisibleCols_id_pressed(id : int):
|
||||
var popup = get_node(path_hide_columns_button).get_child(0)
|
||||
if popup.is_item_checked(id):
|
||||
popup.set_item_checked(id, false)
|
||||
hidden_columns[current_path].erase(columns[id])
|
||||
|
||||
else:
|
||||
popup.set_item_checked(id, true)
|
||||
hidden_columns[current_path][columns[id]] = true
|
||||
|
||||
save_data()
|
||||
_update_hidden_columns()
|
||||
_update_column_sizes()
|
||||
# display_folder(current_path, sorting_by, sorting_reverse, true)
|
||||
|
||||
|
||||
func _on_header_extra_pressed(column : int):
|
||||
var popup = $"Control/HeaderOptions"
|
||||
if popup.visible:
|
||||
popup.hide()
|
||||
popup.disconnect("id_pressed", self, "_on_HeaderOptions_id_pressed")
|
||||
return
|
||||
|
||||
popup.rect_global_position = get_global_mouse_position()
|
||||
if popup.get_item_count() == 0:
|
||||
popup.add_item("Select all cells", 0)
|
||||
popup.add_item("Hide column", 1)
|
||||
|
||||
popup.connect("id_pressed", self, "_on_HeaderOptions_id_pressed", [column])
|
||||
popup.show()
|
||||
|
||||
|
||||
func _on_HeaderOptions_id_pressed(id : int, column : int):
|
||||
$"Control/HeaderOptions".disconnect("id_pressed", self, "_on_HeaderOptions_id_pressed")
|
||||
$"Control/HeaderOptions".hide()
|
||||
if id == 0:
|
||||
deselect_all_cells()
|
||||
select_cell(get_node(path_table_root).get_child(column))
|
||||
select_cells_to(get_node(path_table_root).get_child(column + columns.size() * (rows.size() - 1)))
|
||||
|
||||
else:
|
||||
hidden_columns[current_path][columns[column]] = true
|
||||
save_data()
|
||||
_update_hidden_columns()
|
||||
_update_column_sizes()
|
||||
# display_folder(current_path, sorting_by, sorting_reverse, true)
|
||||
|
@ -57,6 +57,7 @@ path_recent_paths = NodePath("HeaderContentSplit/VBoxContainer/HBoxContainer/HBo
|
||||
path_table_root = NodePath("HeaderContentSplit/MarginContainer/FooterContentSplit/Panel/Scroll/MarginContainer/TableGrid")
|
||||
path_property_editors = NodePath("HeaderContentSplit/MarginContainer/FooterContentSplit/Footer/PropertyEditors")
|
||||
path_columns = NodePath("HeaderContentSplit/VBoxContainer/Columns/Columns")
|
||||
path_hide_columns_button = NodePath("HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer2/VisibleCols")
|
||||
|
||||
[node name="HeaderContentSplit" type="VBoxContainer" parent="."]
|
||||
margin_left = 2.0
|
||||
@ -100,7 +101,7 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="HeaderContentSplit/VBoxContainer/HBoxContainer"]
|
||||
margin_right = 553.0
|
||||
margin_right = 521.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
custom_constants/separation = 0
|
||||
@ -117,7 +118,7 @@ text = "Resource Folder:"
|
||||
[node name="Path" type="LineEdit" parent="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_left = 107.0
|
||||
margin_right = 469.0
|
||||
margin_right = 437.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
caret_blink = true
|
||||
@ -127,8 +128,8 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="SelectDir" type="Button" parent="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer"]
|
||||
margin_left = 469.0
|
||||
margin_right = 497.0
|
||||
margin_left = 437.0
|
||||
margin_right = 465.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Open Folder"
|
||||
icon = SubResource( 2 )
|
||||
@ -139,8 +140,8 @@ __meta__ = {
|
||||
icon_name = "Folder"
|
||||
|
||||
[node name="Refresh" type="Button" parent="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer"]
|
||||
margin_left = 497.0
|
||||
margin_right = 525.0
|
||||
margin_left = 465.0
|
||||
margin_right = 493.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Refresh"
|
||||
icon = SubResource( 2 )
|
||||
@ -151,8 +152,8 @@ __meta__ = {
|
||||
icon_name = "Refresh"
|
||||
|
||||
[node name="DeletePath" type="Button" parent="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer"]
|
||||
margin_left = 525.0
|
||||
margin_right = 553.0
|
||||
margin_left = 493.0
|
||||
margin_right = 521.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Remove Path from Recent"
|
||||
icon = SubResource( 2 )
|
||||
@ -163,7 +164,7 @@ __meta__ = {
|
||||
icon_name = "Remove"
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="HeaderContentSplit/VBoxContainer/HBoxContainer"]
|
||||
margin_left = 565.0
|
||||
margin_left = 533.0
|
||||
margin_right = 1020.0
|
||||
margin_bottom = 24.0
|
||||
|
||||
@ -196,10 +197,27 @@ __meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[node name="Settings" type="Button" parent="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer2"]
|
||||
[node name="VisibleCols" type="Button" parent="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer2"]
|
||||
margin_left = 427.0
|
||||
margin_right = 455.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Hide/Show Columns"
|
||||
icon = SubResource( 2 )
|
||||
script = ExtResource( 4 )
|
||||
icon_name = "GuiVisibilityVisible"
|
||||
|
||||
[node name="PopupMenu" type="PopupMenu" parent="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer2/VisibleCols"]
|
||||
margin_left = 14.0
|
||||
margin_top = 16.0
|
||||
margin_right = 34.0
|
||||
margin_bottom = 36.0
|
||||
hide_on_checkable_item_selection = false
|
||||
allow_search = true
|
||||
|
||||
[node name="Settings" type="Button" parent="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer2"]
|
||||
margin_left = 459.0
|
||||
margin_right = 487.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Settings"
|
||||
icon = SubResource( 2 )
|
||||
script = ExtResource( 4 )
|
||||
@ -614,7 +632,6 @@ margin_left = 330.0
|
||||
margin_top = 84.0
|
||||
margin_right = 404.0
|
||||
margin_bottom = 115.0
|
||||
pressed = true
|
||||
text = "Enable"
|
||||
|
||||
[node name="Label5" type="Label" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"]
|
||||
@ -633,12 +650,20 @@ margin_bottom = 150.0
|
||||
pressed = true
|
||||
text = "Enable"
|
||||
|
||||
[node name="HeaderOptions" type="PopupMenu" parent="Control"]
|
||||
margin_left = 275.0
|
||||
margin_top = 175.0
|
||||
margin_right = 287.0
|
||||
margin_bottom = 195.0
|
||||
|
||||
[connection signal="text_entered" from="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer/Path" to="." method="_on_Path_text_entered"]
|
||||
[connection signal="pressed" from="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer/SelectDir" to="Control/FileDialog" method="popup_centered"]
|
||||
[connection signal="pressed" from="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer/Refresh" to="." method="_on_Path_text_entered"]
|
||||
[connection signal="pressed" from="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer/DeletePath" to="." method="remove_selected_path_from_recent"]
|
||||
[connection signal="item_selected" from="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer2/RecentPaths" to="." method="_on_RecentPaths_item_selected"]
|
||||
[connection signal="pressed" from="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer2/Info" to="Control/Info" method="popup_centered"]
|
||||
[connection signal="pressed" from="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer2/VisibleCols" to="." method="_on_VisibleCols_pressed"]
|
||||
[connection signal="id_pressed" from="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer2/VisibleCols/PopupMenu" to="." method="_on_VisibleCols_id_pressed"]
|
||||
[connection signal="pressed" from="HeaderContentSplit/VBoxContainer/HBoxContainer/HBoxContainer2/Settings" to="Control/Settings" method="popup_centered"]
|
||||
[connection signal="text_entered" from="HeaderContentSplit/MarginContainer/FooterContentSplit/Footer/Search/SearchCond" to="." method="_on_SearchCond_text_entered"]
|
||||
[connection signal="text_entered" from="HeaderContentSplit/MarginContainer/FooterContentSplit/Footer/Search/ProcessExpr" to="." method="_on_ProcessExpr_text_entered"]
|
||||
|
@ -5,5 +5,5 @@ description="Edit Many Resources from one Folder as a table.
|
||||
|
||||
Heavily inspired by Multi-Cursor-Editing in text editors, so after selecting multiple cells (in the same column!) using Ctrl+Click or Shift+Click, most Basic-to-Intermediate movements should be available."
|
||||
author="Don Tnowe"
|
||||
version="1.4.2"
|
||||
version="1.5"
|
||||
script="plugin.gd"
|
||||
|
@ -16,7 +16,7 @@ size_flags_vertical = 0
|
||||
text = "resource_name"
|
||||
clip_text = true
|
||||
|
||||
[node name="Label" type="Button" parent="."]
|
||||
[node name="Button2" type="Button" parent="."]
|
||||
margin_left = 102.0
|
||||
margin_right = 132.0
|
||||
margin_bottom = 20.0
|
||||
|
@ -6,7 +6,7 @@ func can_edit_value(value, type, property_hint) -> bool:
|
||||
|
||||
|
||||
func set_value(node : Control, value):
|
||||
node.text = "<" + hint_strings_array[node.get_position_in_parent() % node.get_parent().columns][value] + ">"
|
||||
node.text = "<" + hint_strings_array[node.get_position_in_parent() % hint_strings_array.size()][value] + ">"
|
||||
node.self_modulate = Color(node.text.hash()) + Color(0.25, 0.25, 0.25, 1.0)
|
||||
node.align = Label.ALIGN_CENTER
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user