Skip to content

Commit 527b367

Browse files
committed
finish update
- Removed testing code from collection_view. - Fixed warning dialog size not updating. - Updated category filters container. - Fixed update category button disabling/enabling code. - Added text to advanced options where there are no categories. - Reworked options, overwrite is now default. (You can use Select > Add category to selected to just add elements) - Renamed empty_category method from EditorDatabaseCollection to clear_category. - Added clear category option. - Updated version number.
1 parent 207e064 commit 527b367

File tree

7 files changed

+44
-31
lines changed

7 files changed

+44
-31
lines changed

addons/resource_databases/editor_only/editor_data_classes/editor_database_collection.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func remove_category(category: StringName) -> void:
187187
_emit_collection_entries_changed()
188188

189189

190-
func empty_category(category: StringName) -> void:
190+
func clear_category(category: StringName) -> void:
191191
assert(has_category(category))
192192
var was_empty := (_categories_to_ints[category] as Dictionary).size() == 0
193193
(_categories_to_ints[category] as Dictionary).clear()

addons/resource_databases/editor_only/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="Resource Databases"
44
description="Use the fully-fledged database editor to create and modify your resource databases!\n\nLoad them at runtime as the new resource type \"Database\" and load resources dynamically!"
55
author="DarthPapalo"
6-
version="1.2.1"
6+
version="1.3.1"
77
script="plugin.gd"

addons/resource_databases/editor_only/ui/components/collection_view/category_filter/category_filter.tscn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ corner_radius_bottom_left = 6
1919
[node name="CategoryFilter" type="PanelContainer" node_paths=PackedStringArray("_button", "_texture")]
2020
offset_right = 8.0
2121
offset_bottom = 31.0
22+
size_flags_horizontal = 3
2223
theme_override_styles/panel = SubResource("StyleBoxFlat_bnakq")
2324
script = ExtResource("1_iqelm")
2425
_button = NodePath("Button")
@@ -30,6 +31,7 @@ theme_override_styles/focus = SubResource("StyleBoxEmpty_lr1dy")
3031
text = " <category_name>"
3132
flat = true
3233
alignment = 0
34+
text_overrun_behavior = 3
3335

3436
[node name="TextureRect" type="TextureRect" parent="."]
3537
custom_minimum_size = Vector2(0, 24)

addons/resource_databases/editor_only/ui/components/collection_view/collection_view.gd

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ const CATEGORY_FILTER_SCENE := preload("res://addons/resource_databases/editor_o
2222
@export_subgroup("Filters components")
2323
@export var _filters_check_button: CheckButton
2424
@export var _filters_panel: PanelContainer
25-
@export var _category_filters_container: HFlowContainer
25+
@export var _category_filters_container: VBoxContainer
2626
@export var _expression_filter_text_edit: TextEdit
2727
# Advanced filter options
2828
@export var _advanced_filter_options: VBoxContainer
29-
@export var overwrite_check_box: CheckBox
29+
@export var _no_categories_label: Label
3030
@export var _categories_option_button: OptionButton
3131
@export var _update_category_button: Button
32+
@export var _clear_category_button: Button
3233

3334
var DatabaseEditor := Namespace.get_editor_singleton()
3435
var DatabaseSettings := Namespace.get_settings_singleton()
@@ -303,6 +304,10 @@ func _on_collection_categories_changed(categories: Dictionary) -> void:
303304
_categories_option_button.add_item(String(category))
304305
_categories_option_button.set_item_metadata(_categories_option_button.item_count - 1, category)
305306
_update_entries()
307+
_update_category_button.disabled = _categories_option_button.selected == -1
308+
_clear_category_button.disabled = _categories_option_button.selected == -1
309+
_no_categories_label.visible = _categories_option_button.selected == -1
310+
_categories_option_button.visible = _categories_option_button.selected != -1
306311
#endregion
307312

308313

@@ -453,25 +458,21 @@ func _on_filters_check_button_toggled(toggled_on: bool) -> void:
453458
#region Advanced filter options
454459
func _on_advanced_filter_options_check_button_toggled(toggled_on: bool) -> void:
455460
_advanced_filter_options.visible = toggled_on
456-
_update_category_button.disabled = _categories_option_button.selected == -1
457461

458462

459463
func _on_update_category_button_pressed() -> void:
460-
if not await DatabaseEditor.warn("Update category", "Are you sure you want to update the selected category with the currently filtered IDs?"):
464+
var category: StringName = _categories_option_button.get_item_metadata(_categories_option_button.selected)
465+
if not await DatabaseEditor.warn("Update category", "Are you sure you want to update the [b]%s[/b] category with the currently filtered IDs?" % category):
461466
return
462467
var filtered_ids := _get_filtered_ids()
463-
var category: StringName = _categories_option_button.get_item_metadata(_categories_option_button.selected)
464-
if overwrite_check_box.button_pressed:
465-
_get_collection().empty_category(category)
468+
_get_collection().clear_category(category)
466469
for id: int in filtered_ids:
467470
_get_collection().add_category_to_resource(category, id, false)
468-
#endregion
469471

470472

471-
# TESTING
472-
func _on_testing_button_pressed() -> void:
473-
#print(load(_get_collection().get_entries()[&"ints_to_locators"][0] as String).get_script().get_script_property_list())
474-
#print("Size: ", DatabaseEditor.get_database().get_collection(collection_uid).collection_size)
475-
for u in 5:
476-
_get_collection().register_test_res()
477-
pass
473+
func _on_clear_category_button_pressed() -> void:
474+
var category: StringName = _categories_option_button.get_item_metadata(_categories_option_button.selected)
475+
if not await DatabaseEditor.warn("Clear category", "Are you sure you want to clear the [b]%s[/b] category?" % category):
476+
return
477+
_get_collection().clear_category(category)
478+
#endregion

addons/resource_databases/editor_only/ui/components/collection_view/collection_view.tscn

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ member_keyword_colors = {
4343
"res_type": Color(1, 0.713726, 0.756863, 1)
4444
}
4545

46-
[node name="CollectionView" type="PanelContainer" node_paths=PackedStringArray("_collection_button", "_selection_button", "_selected_collection_label", "_collection_entries_container", "_search_line_edit", "_entries_view_page_counter", "_filters_check_button", "_filters_panel", "_category_filters_container", "_expression_filter_text_edit", "_advanced_filter_options", "overwrite_check_box", "_categories_option_button", "_update_category_button")]
46+
[node name="CollectionView" type="PanelContainer" node_paths=PackedStringArray("_collection_button", "_selection_button", "_selected_collection_label", "_collection_entries_container", "_search_line_edit", "_entries_view_page_counter", "_filters_check_button", "_filters_panel", "_category_filters_container", "_expression_filter_text_edit", "_advanced_filter_options", "_no_categories_label", "_categories_option_button", "_update_category_button", "_clear_category_button")]
4747
anchors_preset = 15
4848
anchor_right = 1.0
4949
anchor_bottom = 1.0
@@ -65,9 +65,10 @@ _filters_panel = NodePath("VBoxContainer/HSplitContainer/FiltersContainer")
6565
_category_filters_container = NodePath("VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/ScrollContainer/CategoryFiltersContainer")
6666
_expression_filter_text_edit = NodePath("VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/ExpressionFilterTextEdit")
6767
_advanced_filter_options = NodePath("VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions")
68-
overwrite_check_box = NodePath("VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions/OverwriteCheckBox")
68+
_no_categories_label = NodePath("VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions/NoCategoriesLabel")
6969
_categories_option_button = NodePath("VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions/CategoriesOptionButton")
7070
_update_category_button = NodePath("VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions/UpdateCategoryButton")
71+
_clear_category_button = NodePath("VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions/ClearCategoryButton")
7172

7273
[node name="VBoxContainer" type="VBoxContainer" parent="."]
7374
layout_mode = 2
@@ -136,11 +137,6 @@ popup/item_8/text = "Remove category from selected"
136137
popup/item_8/id = 8
137138
popup/item_8/disabled = true
138139

139-
[node name="TestingButton" type="Button" parent="VBoxContainer/ToolsPanel/ToolsContainer"]
140-
visible = false
141-
layout_mode = 2
142-
text = "Testing"
143-
144140
[node name="FiltersCheckButton" type="CheckButton" parent="VBoxContainer/ToolsPanel/ToolsContainer"]
145141
layout_mode = 2
146142
size_flags_horizontal = 10
@@ -215,12 +211,10 @@ layout_mode = 2
215211
size_flags_vertical = 3
216212
size_flags_stretch_ratio = 2.0
217213

218-
[node name="CategoryFiltersContainer" type="HFlowContainer" parent="VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/ScrollContainer"]
214+
[node name="CategoryFiltersContainer" type="VBoxContainer" parent="VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/ScrollContainer"]
219215
layout_mode = 2
220216
size_flags_horizontal = 3
221217
size_flags_vertical = 3
222-
theme_override_constants/h_separation = 6
223-
theme_override_constants/v_separation = 6
224218

225219
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer"]
226220
layout_mode = 2
@@ -269,21 +263,29 @@ text = "Advanced"
269263
visible = false
270264
layout_mode = 2
271265

272-
[node name="OverwriteCheckBox" type="CheckBox" parent="VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions"]
266+
[node name="NoCategoriesLabel" type="Label" parent="VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions"]
273267
layout_mode = 2
274-
text = "Overwrite"
268+
text = "No categories"
269+
horizontal_alignment = 1
275270

276271
[node name="CategoriesOptionButton" type="OptionButton" parent="VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions"]
272+
visible = false
277273
layout_mode = 2
278274
text_overrun_behavior = 3
279275
fit_to_longest_item = false
280276

281277
[node name="UpdateCategoryButton" type="Button" parent="VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions"]
282278
layout_mode = 2
279+
disabled = true
283280
text = "Update category"
284281
flat = true
285282

286-
[connection signal="pressed" from="VBoxContainer/ToolsPanel/ToolsContainer/TestingButton" to="." method="_on_testing_button_pressed"]
283+
[node name="ClearCategoryButton" type="Button" parent="VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions"]
284+
layout_mode = 2
285+
disabled = true
286+
text = "Clear category"
287+
flat = true
288+
287289
[connection signal="toggled" from="VBoxContainer/ToolsPanel/ToolsContainer/FiltersCheckButton" to="." method="_on_filters_check_button_toggled"]
288290
[connection signal="text_changed" from="VBoxContainer/HSplitContainer/EntriesElements/VBoxContainer/SearchLineEdit" to="." method="_on_search_line_edit_text_changed"]
289291
[connection signal="change_page_requested" from="VBoxContainer/HSplitContainer/EntriesElements/VBoxContainer/ViewPageCounter" to="." method="_on_view_page_counter_change_page_requested"]
@@ -292,3 +294,4 @@ flat = true
292294
[connection signal="pressed" from="VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/ExpressionOptionsContainer/ClearExpressionButton" to="." method="_on_clear_expression_button_pressed"]
293295
[connection signal="toggled" from="VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptionsCheckButton" to="." method="_on_advanced_filter_options_check_button_toggled"]
294296
[connection signal="pressed" from="VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions/UpdateCategoryButton" to="." method="_on_update_category_button_pressed"]
297+
[connection signal="pressed" from="VBoxContainer/HSplitContainer/FiltersContainer/VBoxContainer/AdvancedFilterOptions/ClearCategoryButton" to="." method="_on_clear_category_button_pressed"]

addons/resource_databases/editor_only/ui/components/dialogs/warning_dialog/warning_dialog.gd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ func _on_accept_button_pressed() -> void:
2020
func _on_cancel_button_pressed() -> void:
2121
hide()
2222
decision.emit(false)
23+
24+
25+
func _on_about_to_popup() -> void:
26+
# Forces the window to adopt the minimum size
27+
size = Vector2i.ZERO

addons/resource_databases/editor_only/ui/components/dialogs/warning_dialog/warning_dialog.tscn

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ anchor_bottom = 1.0
2525
grow_horizontal = 2
2626
grow_vertical = 2
2727
size_flags_horizontal = 6
28-
size_flags_vertical = 2
28+
size_flags_vertical = 6
2929
theme_type_variation = &"DialogPanel"
3030

3131
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
3232
layout_mode = 2
33+
size_flags_horizontal = 4
3334
theme_override_constants/separation = 20
3435
alignment = 1
3536

@@ -55,6 +56,7 @@ text = "Accept"
5556
layout_mode = 2
5657
text = "Cancel"
5758

59+
[connection signal="about_to_popup" from="." to="." method="_on_about_to_popup"]
5860
[connection signal="close_requested" from="." to="." method="_on_cancel_button_pressed"]
5961
[connection signal="pressed" from="PanelContainer/VBoxContainer/HBoxContainer/AcceptButton" to="." method="_on_accept_button_pressed"]
6062
[connection signal="pressed" from="PanelContainer/VBoxContainer/HBoxContainer/CancelButton" to="." method="_on_cancel_button_pressed"]

0 commit comments

Comments
 (0)