Skip to content

Commit 309d867

Browse files
committed
Changes style of category selection
1 parent dc6e746 commit 309d867

File tree

3 files changed

+118
-64
lines changed

3 files changed

+118
-64
lines changed

assets/theme_small.tres

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[gd_resource type="Theme" format=3 uid="uid://bbjcf4njtb4tm"]
2+
3+
[resource]
4+
default_font_size = 20

scenes/menu.tscn

+95-60
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[gd_scene load_steps=10 format=3 uid="uid://yyc1l3e78qgl"]
22

33
[ext_resource type="Script" path="res://scripts/menu.gd" id="1_f4qtc"]
4+
[ext_resource type="Theme" uid="uid://bbjcf4njtb4tm" path="res://assets/theme_small.tres" id="2_7ph5j"]
45

56
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_r2tkh"]
67
bg_color = Color(0.239216, 0.239216, 0.239216, 1)
@@ -49,9 +50,6 @@ border_color = Color(0, 0, 0, 1)
4950
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_eb82c"]
5051
bg_color = Color(0.137255, 0.137255, 0.137255, 1)
5152

52-
[sub_resource type="Theme" id="Theme_31w7n"]
53-
default_font_size = 70
54-
5553
[node name="Menu" type="CanvasLayer"]
5654
script = ExtResource("1_f4qtc")
5755

@@ -126,7 +124,6 @@ theme_override_styles/focus = SubResource("StyleBoxFlat_sdl70")
126124
text = "Quit Game"
127125

128126
[node name="RoundCreation" type="CanvasLayer" parent="."]
129-
visible = false
130127

131128
[node name="ColorRect" type="ColorRect" parent="RoundCreation"]
132129
anchors_preset = 15
@@ -137,80 +134,118 @@ grow_vertical = 2
137134
color = Color(0.137255, 0.137255, 0.137255, 0.431373)
138135

139136
[node name="CreationMenu" type="Panel" parent="RoundCreation"]
140-
anchors_preset = 8
141-
anchor_left = 0.5
142-
anchor_top = 0.5
143-
anchor_right = 0.5
144-
anchor_bottom = 0.5
145-
offset_left = -258.0
146-
offset_top = -454.5
147-
offset_right = 258.0
148-
offset_bottom = 454.5
137+
anchors_preset = 15
138+
anchor_right = 1.0
139+
anchor_bottom = 1.0
140+
offset_left = 660.0
141+
offset_top = 80.0
142+
offset_right = -660.0
143+
offset_bottom = -80.0
149144
grow_horizontal = 2
150145
grow_vertical = 2
151146
theme_override_styles/panel = SubResource("StyleBoxFlat_yhbp7")
152147

148+
[node name="ModeSelect" type="OptionButton" parent="RoundCreation/CreationMenu"]
149+
layout_mode = 1
150+
offset_left = 40.0
151+
offset_top = 100.0
152+
offset_right = 180.0
153+
offset_bottom = 140.0
154+
theme = ExtResource("2_7ph5j")
155+
theme_override_font_sizes/font_size = 40
156+
157+
[node name="Label" type="Label" parent="RoundCreation/CreationMenu/ModeSelect"]
158+
layout_mode = 1
159+
offset_top = -40.0
160+
offset_right = 120.0
161+
theme = ExtResource("2_7ph5j")
162+
text = "Game Mode"
163+
vertical_alignment = 1
164+
165+
[node name="RoundDuration" type="SpinBox" parent="RoundCreation/CreationMenu"]
166+
layout_mode = 1
167+
offset_left = 40.0
168+
offset_top = 200.0
169+
offset_right = 135.0
170+
offset_bottom = 240.0
171+
theme = ExtResource("2_7ph5j")
172+
min_value = 5.0
173+
max_value = 90.0
174+
value = 30.0
175+
suffix = "s"
176+
custom_arrow_step = 5.0
177+
178+
[node name="Label" type="Label" parent="RoundCreation/CreationMenu/RoundDuration"]
179+
layout_mode = 1
180+
offset_top = -40.0
181+
offset_right = 160.0
182+
theme = ExtResource("2_7ph5j")
183+
text = "Round Duration"
184+
vertical_alignment = 1
185+
186+
[node name="CategoryBox" type="Tree" parent="RoundCreation/CreationMenu"]
187+
layout_mode = 1
188+
anchors_preset = 15
189+
anchor_right = 1.0
190+
anchor_bottom = 1.0
191+
offset_left = 38.0
192+
offset_top = 260.0
193+
offset_right = -38.0
194+
offset_bottom = -114.0
195+
grow_horizontal = 2
196+
grow_vertical = 2
197+
theme_override_colors/font_color = Color(0.6, 0.6, 0.6, 1)
198+
theme_override_colors/relationship_line_color = Color(0.301961, 0.301961, 0.301961, 1)
199+
theme_override_colors/parent_hl_line_color = Color(1, 1, 1, 1)
200+
theme_override_colors/children_hl_line_color = Color(0.6, 0.6, 0.6, 1)
201+
theme_override_constants/inner_item_margin_left = 5
202+
theme_override_constants/draw_relationship_lines = 1
203+
theme_override_constants/relationship_line_width = 2
204+
theme_override_constants/parent_hl_line_width = 3
205+
theme_override_constants/children_hl_line_width = 3
206+
theme_override_constants/draw_guides = 0
207+
columns = 2
208+
column_titles_visible = true
209+
hide_root = true
210+
153211
[node name="Cancel" type="Button" parent="RoundCreation/CreationMenu"]
154-
layout_mode = 0
155-
offset_left = 45.0
156-
offset_top = 821.0
157-
offset_right = 233.0
158-
offset_bottom = 896.0
212+
layout_mode = 1
213+
anchors_preset = 7
214+
anchor_left = 0.5
215+
anchor_top = 1.0
216+
anchor_right = 0.5
217+
anchor_bottom = 1.0
218+
offset_left = -220.0
219+
offset_top = -100.0
220+
offset_right = -32.0
221+
offset_bottom = -25.0
222+
grow_horizontal = 2
223+
grow_vertical = 0
159224
theme_override_font_sizes/font_size = 30
160225
theme_override_styles/normal = SubResource("StyleBoxFlat_r78im")
161226
theme_override_styles/hover = SubResource("StyleBoxFlat_v1l70")
162227
theme_override_styles/pressed = SubResource("StyleBoxFlat_eb82c")
163228
text = "Cancel"
164229

165230
[node name="Start" type="Button" parent="RoundCreation/CreationMenu"]
166-
layout_mode = 0
167-
offset_left = 286.0
168-
offset_top = 821.0
169-
offset_right = 474.0
170-
offset_bottom = 896.0
231+
layout_mode = 1
232+
anchors_preset = 7
233+
anchor_left = 0.5
234+
anchor_top = 1.0
235+
anchor_right = 0.5
236+
anchor_bottom = 1.0
237+
offset_left = 40.0
238+
offset_top = -100.0
239+
offset_right = 228.0
240+
offset_bottom = -25.0
241+
grow_horizontal = 2
242+
grow_vertical = 0
171243
theme_override_font_sizes/font_size = 30
172244
theme_override_styles/normal = SubResource("StyleBoxFlat_r78im")
173245
theme_override_styles/hover = SubResource("StyleBoxFlat_v1l70")
174246
theme_override_styles/pressed = SubResource("StyleBoxFlat_eb82c")
175247
text = "Start Game"
176248

177-
[node name="ModeSelect" type="OptionButton" parent="RoundCreation/CreationMenu"]
178-
layout_mode = 1
179-
offset_left = 43.0
180-
offset_top = 44.0
181-
offset_right = 299.0
182-
offset_bottom = 114.0
183-
theme_override_font_sizes/font_size = 40
184-
185-
[node name="CategoryBox" type="Tree" parent="RoundCreation/CreationMenu"]
186-
layout_mode = 0
187-
offset_left = 58.0
188-
offset_top = 295.0
189-
offset_right = 478.0
190-
offset_bottom = 775.0
191-
columns = 2
192-
column_titles_visible = true
193-
hide_root = true
194-
195-
[node name="RoundDuration" type="SpinBox" parent="RoundCreation/CreationMenu"]
196-
layout_mode = 1
197-
anchors_preset = 6
198-
anchor_left = 1.0
199-
anchor_top = 0.5
200-
anchor_right = 1.0
201-
anchor_bottom = 0.5
202-
offset_left = -472.0
203-
offset_top = -304.5
204-
offset_right = -199.775
205-
offset_bottom = -216.5
206-
grow_horizontal = 0
207-
grow_vertical = 2
208-
theme = SubResource("Theme_31w7n")
209-
min_value = 5.0
210-
max_value = 90.0
211-
value = 30.0
212-
suffix = "s"
213-
214249
[connection signal="pressed" from="Buttons/Play" to="." method="on_play_pressed"]
215250
[connection signal="pressed" from="Buttons/Quit" to="." method="on_quit_pressed"]
216251
[connection signal="pressed" from="RoundCreation/CreationMenu/Cancel" to="." method="on_cancel_pressed"]

scripts/menu.gd

+19-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ func _ready():
1212
$RoundCreation/CreationMenu/RoundDuration.value = round_duration
1313
api.category(on_category_response)
1414

15+
var category_tree: Tree = $RoundCreation/CreationMenu/CategoryBox
16+
category_tree.create_item()
17+
category_tree.set_column_title(0, "Category")
18+
category_tree.set_column_title(1, "Amount")
19+
category_tree.set_column_expand(1, false)
20+
category_tree.set_column_custom_minimum_width(1, 100)
21+
1522
## on_category_response is called as when the categories api call completed.
16-
func on_category_response(success: bool, categories: Dictionary={}):
23+
func on_category_response(success: bool, categories: Dictionary = {}):
1724
if !success:
1825
print("failed to get categories!")
1926
return
@@ -22,18 +29,26 @@ func on_category_response(success: bool, categories: Dictionary={}):
2229
## update_category_list updates the category selection list with the given dictionary (mapping String to int).
2330
func update_category_list(groups: Dictionary):
2431
var category_tree: Tree = $RoundCreation/CreationMenu/CategoryBox
25-
var tree_root: TreeItem = category_tree.create_item()
26-
category_tree.set_column_title(0, "Category")
27-
category_tree.set_column_title(1, "Amount")
32+
var tree_root: TreeItem = category_tree.get_root()
2833
for group in groups:
2934
var tree_group: TreeItem = category_tree.create_item(tree_root)
3035
tree_group.set_text(0, group)
36+
tree_group.set_custom_bg_color(0, Color(0.23, 0.23, 0.23))
37+
tree_group.set_custom_bg_color(1, Color(0.23, 0.23, 0.23))
38+
var bg_light: bool = false
3139
for cat in groups[group]:
3240
var category: TreeItem = category_tree.create_item(tree_group)
3341
category.set_text(0, cat.description)
3442
category.set_cell_mode(1, TreeItem.CELL_MODE_RANGE)
3543
category.set_range_config(1, 0, cat.count, 1)
3644
category.set_editable(1, true)
45+
if bg_light:
46+
category.set_custom_bg_color(0, Color(0.15, 0.15, 0.15))
47+
category.set_custom_bg_color(1, Color(0.15, 0.15, 0.15))
48+
else:
49+
category.set_custom_bg_color(0, Color(0.05, 0.05, 0.05))
50+
category.set_custom_bg_color(1, Color(0.05, 0.05, 0.05))
51+
bg_light = !bg_light
3752

3853
var category_data: CategoryData = CategoryData.new()
3954
category_data.id = cat.title

0 commit comments

Comments
 (0)