Skip to content

Commit 0de0231

Browse files
authored
Category icons squash
Shortens categories and gives them icons and tooltips. I couldn't find the Gnome icons so I edited and used the Godot icons. Loading the icons was not optimized Similar to the idea endlessm#131 (comment) - Check for changes that might break code ![image](https://github.com/user-attachments/assets/f1f68275-a740-4acf-94c9-d5610efc0293)
1 parent 1a0cd11 commit 0de0231

37 files changed

+1272
-19
lines changed

addons/block_code/ui/constants.gd

+25
Original file line numberDiff line numberDiff line change
@@ -21,125 +21,150 @@ const BUILTIN_CATEGORIES_PROPS: Dictionary = {
2121
{
2222
"color": Color("ec3b59"),
2323
"order": 10,
24+
"icon": "PlayStart",
2425
},
2526
"Lifecycle | Spawn":
2627
{
2728
"color": Color("ec3b59"),
2829
"order": 15,
30+
"icon": "Play",
2931
},
3032
"Transform | Position":
3133
{
3234
"color": Color("4b6584"),
3335
"order": 20,
36+
"icon": "ToolMove",
3437
},
3538
"Transform | Rotation":
3639
{
3740
"color": Color("4b6584"),
3841
"order": 30,
42+
"icon": "ToolMove",
3943
},
4044
"Transform | Scale":
4145
{
4246
"color": Color("4b6584"),
4347
"order": 40,
48+
"icon": "ToolMove",
4449
},
4550
"Graphics | Modulate":
4651
{
4752
"color": Color("03aa74"),
4853
"order": 50,
54+
"icon": "Paint",
4955
},
5056
"Graphics | Visibility":
5157
{
5258
"color": Color("03aa74"),
5359
"order": 60,
60+
"icon": "Paint",
5461
},
5562
"Graphics | Viewport":
5663
{
5764
"color": Color("03aa74"),
5865
"order": 61,
66+
"icon": "Paint",
5967
},
6068
"Graphics | Animation":
6169
{
6270
"color": Color("03aa74"),
6371
"order": 62,
72+
"icon": "Paint",
6473
},
6574
"UI":
6675
{
6776
"color": Color("03aa74"),
6877
"order": 65,
78+
"icon": "ThemeDeselectAll",
6979
},
7080
"Sounds":
7181
{
7282
"color": Color("e30fc0"),
7383
"order": 70,
84+
"icon": "AudioStreamPlayer",
7485
},
7586
"Physics | Mass":
7687
{
7788
"color": Color("a5b1c2"),
7889
"order": 80,
90+
"icon": "RigidBody2D",
7991
},
8092
"Physics | Velocity":
8193
{
8294
"color": Color("a5b1c2"),
8395
"order": 90,
96+
"icon": "RigidBody2D",
8497
},
8598
"Input":
8699
{
87100
"color": Color("d54322"),
88101
"order": 100,
102+
"icon": "Slot",
89103
},
90104
"Communication | Methods":
91105
{
92106
"color": Color("4b7bec"),
93107
"order": 110,
108+
"icon": "Signals",
94109
},
95110
"Communication | Nodes":
96111
{
97112
"color": Color("4b7bec"),
98113
"order": 115,
114+
"icon": "Signals",
99115
},
100116
"Communication | Groups":
101117
{
102118
"color": Color("4b7bec"),
103119
"order": 120,
120+
"icon": "Signals",
104121
},
105122
"Info | Score":
106123
{
107124
"color": Color("cf6a87"),
108125
"order": 130,
126+
"icon": "NodeInfo",
109127
},
110128
"Loops":
111129
{
112130
"color": Color("20bf6b"),
113131
"order": 140,
132+
"icon": "RotateRight",
114133
},
115134
"Logic | Conditionals":
116135
{
117136
"color": Color("45aaf2"),
118137
"order": 150,
138+
"icon": "AnimationFilter",
119139
},
120140
"Logic | Comparison":
121141
{
122142
"color": Color("45aaf2"),
123143
"order": 160,
144+
"icon": "AnimationFilter",
124145
},
125146
"Logic | Boolean":
126147
{
127148
"color": Color("45aaf2"),
128149
"order": 170,
150+
"icon": "AnimationFilter",
129151
},
130152
"Variables":
131153
{
132154
"color": Color("ff8f08"),
133155
"order": 180,
156+
"icon": "Key",
134157
},
135158
"Math":
136159
{
137160
"color": Color("a55eea"),
138161
"order": 190,
162+
"icon": "VisualShaderNodeVectorFunc",
139163
},
140164
"Log":
141165
{
142166
"color": Color("002050"),
143167
"order": 200,
168+
"icon": "Debug",
144169
},
145170
}

addons/block_code/ui/picker/categories/block_category.gd

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ extends RefCounted
22

33
var name: String
44
var color: Color
5+
var icon: String
56
var order: int
67

78

8-
func _init(p_name: String = "", p_color: Color = Color.WHITE, p_order: int = 0):
9+
func _init(p_name: String = "", p_color: Color = Color.WHITE, p_icon: String = "FileBroken", p_order: int = 0):
910
name = p_name
1011
color = p_color
12+
icon = p_icon
1113
order = p_order
1214

1315

addons/block_code/ui/picker/categories/block_category_button.gd

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@ signal selected
99
var category: BlockCategory
1010

1111
@onready var _panel := %Panel
12+
@onready var _icon := %Icon
1213
@onready var _label := %Label
14+
@onready var _button := %Button
1315

1416

1517
func _ready():
1618
if not category:
1719
category = BlockCategory.new("Example", Color.RED)
1820

1921
if not Util.node_is_part_of_edited_scene(self):
20-
var new_stylebox: StyleBoxFlat = _panel.get_theme_stylebox("panel").duplicate()
21-
new_stylebox.bg_color = category.color
22-
_panel.add_theme_stylebox_override("panel", new_stylebox)
22+
var texture = load("res://addons/block_code/ui/picker/categories/category_icons/" + category.icon + ".svg")
23+
_icon.texture = texture
24+
_panel.modulate = category.color
2325

24-
_label.text = category.name
26+
_label.text = category.name.get_slice("| ", 1)
27+
_button.tooltip_text = category.name.get_slice(" |", 0)
2528

2629

2730
func _on_button_pressed():
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
[gd_scene load_steps=7 format=3 uid="uid://bdtetj0gs45hv"]
1+
[gd_scene load_steps=8 format=3 uid="uid://bdtetj0gs45hv"]
22

33
[ext_resource type="Script" path="res://addons/block_code/ui/picker/categories/block_category_button.gd" id="1_pxxnl"]
4+
[ext_resource type="Texture2D" uid="uid://cn4ub7dwl4ae5" path="res://addons/block_code/ui/picker/categories/category_icons/block_code_node.svg" id="2_s8lmp"]
45

5-
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_eogpc"]
6-
bg_color = Color(1, 0, 0, 1)
7-
corner_radius_top_left = 100
8-
corner_radius_top_right = 100
9-
corner_radius_bottom_right = 100
10-
corner_radius_bottom_left = 100
6+
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_w0e7p"]
7+
bg_color = Color(1, 1, 1, 1)
8+
corner_radius_top_left = 4
9+
corner_radius_top_right = 4
10+
corner_radius_bottom_right = 4
11+
corner_radius_bottom_left = 4
1112

12-
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ousiv"]
13+
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_dgecf"]
1314

1415
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fyk0j"]
1516
bg_color = Color(1, 1, 1, 0.196078)
1617

1718
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ha83k"]
1819
bg_color = Color(1, 1, 1, 0.392157)
1920

20-
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_dgecf"]
21+
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ousiv"]
2122

2223
[node name="BlockCategoryButton" type="MarginContainer"]
23-
custom_minimum_size = Vector2(150, 0)
24+
custom_minimum_size = Vector2(140, 0)
2425
offset_right = 148.0
2526
offset_bottom = 32.0
2627
script = ExtResource("1_pxxnl")
@@ -39,19 +40,33 @@ theme_override_constants/margin_bottom = 8
3940
[node name="Panel" type="Panel" parent="HBoxContainer/MarginContainer"]
4041
unique_name_in_owner = true
4142
layout_mode = 2
42-
theme_override_styles/panel = SubResource("StyleBoxFlat_eogpc")
43+
theme_override_styles/panel = SubResource("StyleBoxFlat_w0e7p")
44+
45+
[node name="MarginContainer" type="MarginContainer" parent="HBoxContainer/MarginContainer"]
46+
layout_mode = 2
47+
theme_override_constants/margin_left = 4
48+
theme_override_constants/margin_top = 4
49+
theme_override_constants/margin_right = 4
50+
theme_override_constants/margin_bottom = 4
51+
52+
[node name="Icon" type="TextureRect" parent="HBoxContainer/MarginContainer/MarginContainer"]
53+
unique_name_in_owner = true
54+
layout_mode = 2
55+
texture = ExtResource("2_s8lmp")
4356

4457
[node name="Label" type="Label" parent="HBoxContainer"]
4558
unique_name_in_owner = true
4659
layout_mode = 2
4760
text = "Example"
4861

4962
[node name="Button" type="Button" parent="."]
63+
unique_name_in_owner = true
5064
layout_mode = 2
65+
tooltip_text = "Example"
5166
mouse_default_cursor_shape = 2
52-
theme_override_styles/normal = SubResource("StyleBoxEmpty_ousiv")
67+
theme_override_styles/focus = SubResource("StyleBoxEmpty_dgecf")
5368
theme_override_styles/hover = SubResource("StyleBoxFlat_fyk0j")
5469
theme_override_styles/pressed = SubResource("StyleBoxFlat_ha83k")
55-
theme_override_styles/focus = SubResource("StyleBoxEmpty_dgecf")
70+
theme_override_styles/normal = SubResource("StyleBoxEmpty_ousiv")
5671

5772
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]

addons/block_code/ui/picker/categories/category_factory.gd

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ static func get_all_categories(custom_categories: Array[BlockCategory] = []) ->
1212
for category_name in Constants.BUILTIN_CATEGORIES_PROPS:
1313
var props: Dictionary = Constants.BUILTIN_CATEGORIES_PROPS.get(category_name, {})
1414
var color: Color = props.get("color", Color.SLATE_GRAY)
15+
var icon: String = props.get("icon", 0)
1516
var order: int = props.get("order", 0)
16-
result.append(BlockCategory.new(category_name, color, order))
17+
result.append(BlockCategory.new(category_name, color, icon, order))
1718

1819
# TODO: Should we deduplicate custom_categories here?
1920
result.append_array(custom_categories)
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://dewgvf1lr8qod"
6+
path="res://.godot/imported/AnimationFilter.svg-bc406d34aedc59dac64e8f11add2985a.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://addons/block_code/ui/picker/categories/category_icons/AnimationFilter.svg"
14+
dest_files=["res://.godot/imported/AnimationFilter.svg-bc406d34aedc59dac64e8f11add2985a.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1
35+
svg/scale=1.0
36+
editor/scale_with_editor_scale=false
37+
editor/convert_colors_with_editor_theme=false
Loading

0 commit comments

Comments
 (0)