Skip to content

Commit 4068a6e

Browse files
committed
add button to sort by quality(default behavior)
1 parent 033337e commit 4068a6e

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

material_maker/windows/add_node_popup/sort_menu.gd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ func load_button_state() -> void:
7171
Sorting.CATEGORY_DESCENDING:
7272
%Category.icon_name = "category_descending"
7373
%Category.button_pressed = true
74+
Sorting.QUALITY_DESCENDING:
75+
%Quality.button_pressed = true
7476

7577
# update button icons
7678
for btn in $PanelContainer/VBoxContainer.get_children():
@@ -93,6 +95,8 @@ func save_button_state(btn : SimpleButton) -> void:
9395
sort = Sorting.ALPHABETICAL_ASCENDING if ascending else Sorting.ALPHABETICAL_DESCENDING
9496
"category":
9597
sort = Sorting.CATEGORY_ASCENDING if ascending else Sorting.CATEGORY_DESCENDING
98+
"quality":
99+
sort = Sorting.QUALITY_DESCENDING
96100
mm_globals.set_config("add_node_popup_sort", sort)
97101
get_parent().item_sort_mode = sort
98102

@@ -110,3 +114,7 @@ func _on_category_pressed() -> void:
110114
toggle_button_icon(%Category)
111115
save_button_state(%Category)
112116
sorting_changed.emit()
117+
118+
func _on_quality_pressed() -> void:
119+
save_button_state(%Quality)
120+
sorting_changed.emit()

material_maker/windows/add_node_popup/sort_menu.tscn

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[node name="SortMenuPanel" type="PopupPanel" unique_id=348406576]
88
oversampling_override = 1.0
9-
size = Vector2i(56, 94)
9+
size = Vector2i(56, 124)
1010
visible = true
1111
theme_type_variation = &"MM_PanelMenuSubPanelLabel"
1212
script = ExtResource("1_a3m20")
@@ -15,11 +15,23 @@ script = ExtResource("1_a3m20")
1515
offset_left = 4.0
1616
offset_top = 4.0
1717
offset_right = 52.0
18-
offset_bottom = 90.0
18+
offset_bottom = 120.0
1919

2020
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer" unique_id=1741003019]
2121
layout_mode = 2
2222

23+
[node name="Quality" type="Button" parent="PanelContainer/VBoxContainer" unique_id=1545685784]
24+
unique_name_in_owner = true
25+
custom_minimum_size = Vector2(26, 26)
26+
layout_mode = 2
27+
tooltip_text = "Sort items by best match"
28+
toggle_mode = true
29+
button_group = ExtResource("2_eswfh")
30+
icon_alignment = 1
31+
expand_icon = true
32+
script = ExtResource("1_uh4sk")
33+
icon_name = "zoom"
34+
2335
[node name="Frequency" type="Button" parent="PanelContainer/VBoxContainer" unique_id=491345268]
2436
unique_name_in_owner = true
2537
custom_minimum_size = Vector2(26, 26)
@@ -56,6 +68,7 @@ expand_icon = true
5668
script = ExtResource("1_uh4sk")
5769
icon_name = "category_ascending"
5870

71+
[connection signal="pressed" from="PanelContainer/VBoxContainer/Quality" to="." method="_on_quality_pressed"]
5972
[connection signal="pressed" from="PanelContainer/VBoxContainer/Frequency" to="." method="_on_frequency_pressed"]
6073
[connection signal="pressed" from="PanelContainer/VBoxContainer/Alphabetical" to="." method="_on_alphabetical_pressed"]
6174
[connection signal="pressed" from="PanelContainer/VBoxContainer/Category" to="." method="_on_category_pressed"]

0 commit comments

Comments
 (0)