From 243ed2c98d88e50fd88952f3f68aa720b60986f3 Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Sun, 1 Sep 2024 23:35:29 +0200 Subject: [PATCH 01/11] added category group parsing --- scenes/menu.tscn | 10 ++++++++++ scripts/menu.gd | 22 +++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/scenes/menu.tscn b/scenes/menu.tscn index f0b8d96..314db49 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -201,6 +201,16 @@ layout_direction = 3 layout_mode = 2 theme_override_constants/separation = 3 +[node name="Categories" type="Tree" parent="RoundCreation/CreationMenu"] +layout_mode = 0 +offset_left = 58.0 +offset_top = 295.0 +offset_right = 478.0 +offset_bottom = 775.0 +columns = 2 +column_titles_visible = true +hide_root = true + [node name="RoundDuration" type="SpinBox" parent="RoundCreation/CreationMenu"] layout_mode = 1 anchors_preset = 6 diff --git a/scripts/menu.gd b/scripts/menu.gd index f842317..5853a0c 100644 --- a/scripts/menu.gd +++ b/scripts/menu.gd @@ -20,13 +20,21 @@ func on_category_response(success: bool, categories: Dictionary={}): update_category_list(categories) ## update_category_list updates the category selection list with the given dictionary (mapping String to int). -func update_category_list(categories: Dictionary): - for category in categories: - var c = CATEGORY.instantiate() - c.get_child(1).max_value = categories[category] - c.get_child(2).text = category - c.show() - $RoundCreation/CreationMenu/CategoryBox/Categories.add_child(c) +func update_category_list(groups: Dictionary): + var category_tree: Tree = $RoundCreation/CreationMenu/Categories + var tree_root: TreeItem = category_tree.create_item() + category_tree.set_column_title(0, "Group") + category_tree.set_column_title(1, "Category") + for group in groups: + var tree_group: TreeItem = category_tree.create_item(tree_root) + tree_group.set_text(0, group) + for cat in groups[group]: + var category: TreeItem = category_tree.create_item(tree_group) + category.set_text(0, cat.title) + category.set_tooltip_text(0, cat.description) + category.set_range(1, 0) + category.set_range_config(1, 0, cat.count, 1) + category.set_editable(1, true) ## on_btn_start_pressed is called when pressed the start game button. ## It collects all the selected categories and creates a new game on the server. From 6b9d751df00384ca0f21d3d20410d7f6fab7cfdb Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Sat, 7 Sep 2024 13:16:28 +0200 Subject: [PATCH 02/11] correctly set range in category menu --- scripts/menu.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/menu.gd b/scripts/menu.gd index 5853a0c..d98828f 100644 --- a/scripts/menu.gd +++ b/scripts/menu.gd @@ -32,7 +32,7 @@ func update_category_list(groups: Dictionary): var category: TreeItem = category_tree.create_item(tree_group) category.set_text(0, cat.title) category.set_tooltip_text(0, cat.description) - category.set_range(1, 0) + category.set_cell_mode(1, TreeItem.CELL_MODE_RANGE) category.set_range_config(1, 0, cat.count, 1) category.set_editable(1, true) From 4e6efe8b1ab777084201e9937c08a3ce934f77e6 Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Sat, 7 Sep 2024 13:33:25 +0200 Subject: [PATCH 03/11] removed old CategoryBox --- scenes/menu.tscn | 19 ------------------- scripts/menu.gd | 5 ----- 2 files changed, 24 deletions(-) diff --git a/scenes/menu.tscn b/scenes/menu.tscn index 314db49..a7b4e2f 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -182,25 +182,6 @@ offset_right = 299.0 offset_bottom = 114.0 theme_override_font_sizes/font_size = 40 -[node name="CategoryBox" type="ScrollContainer" parent="RoundCreation/CreationMenu"] -layout_direction = 2 -layout_mode = 1 -anchors_preset = 4 -anchor_top = 0.5 -anchor_bottom = 0.5 -offset_left = 126.0 -offset_top = -182.5 -offset_right = 269.0 -offset_bottom = 310.5 -grow_vertical = 2 -follow_focus = true -horizontal_scroll_mode = 0 - -[node name="Categories" type="VBoxContainer" parent="RoundCreation/CreationMenu/CategoryBox"] -layout_direction = 3 -layout_mode = 2 -theme_override_constants/separation = 3 - [node name="Categories" type="Tree" parent="RoundCreation/CreationMenu"] layout_mode = 0 offset_left = 58.0 diff --git a/scripts/menu.gd b/scripts/menu.gd index d98828f..0637c51 100644 --- a/scripts/menu.gd +++ b/scripts/menu.gd @@ -42,11 +42,6 @@ func on_btn_start_pressed(): $RoundCreation/CreationMenu/Start.disabled = true round_duration = $RoundCreation/CreationMenu/RoundDuration.value var categories: Dictionary = {} - for category: HBoxContainer in $RoundCreation/CreationMenu/CategoryBox/Categories.get_children(): - var amount: int = category.get_child(1).value - if amount == 0: - continue - categories[category.get_child(2).text] = amount var game_data: Dictionary = {} game_data["categories"] = categories From 337ef7f36b9c0a9cd3822a7bc8762e517078bf37 Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Sat, 7 Sep 2024 13:34:17 +0200 Subject: [PATCH 04/11] renamed new category box --- scenes/menu.tscn | 2 +- scripts/menu.gd | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/scenes/menu.tscn b/scenes/menu.tscn index a7b4e2f..1e9591b 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -182,7 +182,7 @@ offset_right = 299.0 offset_bottom = 114.0 theme_override_font_sizes/font_size = 40 -[node name="Categories" type="Tree" parent="RoundCreation/CreationMenu"] +[node name="CategoryBox" type="Tree" parent="RoundCreation/CreationMenu"] layout_mode = 0 offset_left = 58.0 offset_top = 295.0 diff --git a/scripts/menu.gd b/scripts/menu.gd index 0637c51..0ebfc10 100644 --- a/scripts/menu.gd +++ b/scripts/menu.gd @@ -21,17 +21,16 @@ func on_category_response(success: bool, categories: Dictionary={}): ## update_category_list updates the category selection list with the given dictionary (mapping String to int). func update_category_list(groups: Dictionary): - var category_tree: Tree = $RoundCreation/CreationMenu/Categories + var category_tree: Tree = $RoundCreation/CreationMenu/CategoryBox var tree_root: TreeItem = category_tree.create_item() - category_tree.set_column_title(0, "Group") - category_tree.set_column_title(1, "Category") + category_tree.set_column_title(0, "Category") + category_tree.set_column_title(1, "Amount") for group in groups: var tree_group: TreeItem = category_tree.create_item(tree_root) tree_group.set_text(0, group) for cat in groups[group]: var category: TreeItem = category_tree.create_item(tree_group) - category.set_text(0, cat.title) - category.set_tooltip_text(0, cat.description) + category.set_text(0, cat.description) category.set_cell_mode(1, TreeItem.CELL_MODE_RANGE) category.set_range_config(1, 0, cat.count, 1) category.set_editable(1, true) From dc6e746234c48aee056302f5782e7d8ed92d4623 Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Sat, 7 Sep 2024 14:23:30 +0200 Subject: [PATCH 05/11] added category count --- scripts/menu.gd | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scripts/menu.gd b/scripts/menu.gd index 0ebfc10..3f4b889 100644 --- a/scripts/menu.gd +++ b/scripts/menu.gd @@ -35,12 +35,30 @@ func update_category_list(groups: Dictionary): category.set_range_config(1, 0, cat.count, 1) category.set_editable(1, true) + var category_data: CategoryData = CategoryData.new() + category_data.id = cat.title + category_data.group = group + category.set_metadata(0, category_data) + ## on_btn_start_pressed is called when pressed the start game button. ## It collects all the selected categories and creates a new game on the server. func on_btn_start_pressed(): $RoundCreation/CreationMenu/Start.disabled = true round_duration = $RoundCreation/CreationMenu/RoundDuration.value var categories: Dictionary = {} + var category: TreeItem = $RoundCreation/CreationMenu/CategoryBox.get_root().get_first_child() + while category != null: + var amount: int = int(category.get_range(1)) + if amount == 0: + category = category.get_next_in_tree() + continue + var category_data: CategoryData = category.get_metadata(0) + categories[category_data.id] = amount + category = category.get_next_in_tree() + + if categories.size() == 0: + print("no categories selected!") + return var game_data: Dictionary = {} game_data["categories"] = categories @@ -62,3 +80,7 @@ func on_play_pressed(): func on_quit_pressed(): get_tree().quit() + +class CategoryData: + var id: String + var group: String From 309d867ff4d3f7a537880f268840f3e879a796f2 Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Sat, 7 Sep 2024 20:09:23 +0200 Subject: [PATCH 06/11] Changes style of category selection --- assets/theme_small.tres | 4 ++ scenes/menu.tscn | 155 ++++++++++++++++++++++++---------------- scripts/menu.gd | 23 ++++-- 3 files changed, 118 insertions(+), 64 deletions(-) create mode 100644 assets/theme_small.tres diff --git a/assets/theme_small.tres b/assets/theme_small.tres new file mode 100644 index 0000000..2cd1f58 --- /dev/null +++ b/assets/theme_small.tres @@ -0,0 +1,4 @@ +[gd_resource type="Theme" format=3 uid="uid://bbjcf4njtb4tm"] + +[resource] +default_font_size = 20 diff --git a/scenes/menu.tscn b/scenes/menu.tscn index 1e9591b..87740a5 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -1,6 +1,7 @@ [gd_scene load_steps=10 format=3 uid="uid://yyc1l3e78qgl"] [ext_resource type="Script" path="res://scripts/menu.gd" id="1_f4qtc"] +[ext_resource type="Theme" uid="uid://bbjcf4njtb4tm" path="res://assets/theme_small.tres" id="2_7ph5j"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_r2tkh"] bg_color = Color(0.239216, 0.239216, 0.239216, 1) @@ -49,9 +50,6 @@ border_color = Color(0, 0, 0, 1) [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_eb82c"] bg_color = Color(0.137255, 0.137255, 0.137255, 1) -[sub_resource type="Theme" id="Theme_31w7n"] -default_font_size = 70 - [node name="Menu" type="CanvasLayer"] script = ExtResource("1_f4qtc") @@ -126,7 +124,6 @@ theme_override_styles/focus = SubResource("StyleBoxFlat_sdl70") text = "Quit Game" [node name="RoundCreation" type="CanvasLayer" parent="."] -visible = false [node name="ColorRect" type="ColorRect" parent="RoundCreation"] anchors_preset = 15 @@ -137,25 +134,93 @@ grow_vertical = 2 color = Color(0.137255, 0.137255, 0.137255, 0.431373) [node name="CreationMenu" type="Panel" parent="RoundCreation"] -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -258.0 -offset_top = -454.5 -offset_right = 258.0 -offset_bottom = 454.5 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 660.0 +offset_top = 80.0 +offset_right = -660.0 +offset_bottom = -80.0 grow_horizontal = 2 grow_vertical = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_yhbp7") +[node name="ModeSelect" type="OptionButton" parent="RoundCreation/CreationMenu"] +layout_mode = 1 +offset_left = 40.0 +offset_top = 100.0 +offset_right = 180.0 +offset_bottom = 140.0 +theme = ExtResource("2_7ph5j") +theme_override_font_sizes/font_size = 40 + +[node name="Label" type="Label" parent="RoundCreation/CreationMenu/ModeSelect"] +layout_mode = 1 +offset_top = -40.0 +offset_right = 120.0 +theme = ExtResource("2_7ph5j") +text = "Game Mode" +vertical_alignment = 1 + +[node name="RoundDuration" type="SpinBox" parent="RoundCreation/CreationMenu"] +layout_mode = 1 +offset_left = 40.0 +offset_top = 200.0 +offset_right = 135.0 +offset_bottom = 240.0 +theme = ExtResource("2_7ph5j") +min_value = 5.0 +max_value = 90.0 +value = 30.0 +suffix = "s" +custom_arrow_step = 5.0 + +[node name="Label" type="Label" parent="RoundCreation/CreationMenu/RoundDuration"] +layout_mode = 1 +offset_top = -40.0 +offset_right = 160.0 +theme = ExtResource("2_7ph5j") +text = "Round Duration" +vertical_alignment = 1 + +[node name="CategoryBox" type="Tree" parent="RoundCreation/CreationMenu"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 38.0 +offset_top = 260.0 +offset_right = -38.0 +offset_bottom = -114.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_colors/font_color = Color(0.6, 0.6, 0.6, 1) +theme_override_colors/relationship_line_color = Color(0.301961, 0.301961, 0.301961, 1) +theme_override_colors/parent_hl_line_color = Color(1, 1, 1, 1) +theme_override_colors/children_hl_line_color = Color(0.6, 0.6, 0.6, 1) +theme_override_constants/inner_item_margin_left = 5 +theme_override_constants/draw_relationship_lines = 1 +theme_override_constants/relationship_line_width = 2 +theme_override_constants/parent_hl_line_width = 3 +theme_override_constants/children_hl_line_width = 3 +theme_override_constants/draw_guides = 0 +columns = 2 +column_titles_visible = true +hide_root = true + [node name="Cancel" type="Button" parent="RoundCreation/CreationMenu"] -layout_mode = 0 -offset_left = 45.0 -offset_top = 821.0 -offset_right = 233.0 -offset_bottom = 896.0 +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -220.0 +offset_top = -100.0 +offset_right = -32.0 +offset_bottom = -25.0 +grow_horizontal = 2 +grow_vertical = 0 theme_override_font_sizes/font_size = 30 theme_override_styles/normal = SubResource("StyleBoxFlat_r78im") theme_override_styles/hover = SubResource("StyleBoxFlat_v1l70") @@ -163,54 +228,24 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_eb82c") text = "Cancel" [node name="Start" type="Button" parent="RoundCreation/CreationMenu"] -layout_mode = 0 -offset_left = 286.0 -offset_top = 821.0 -offset_right = 474.0 -offset_bottom = 896.0 +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = 40.0 +offset_top = -100.0 +offset_right = 228.0 +offset_bottom = -25.0 +grow_horizontal = 2 +grow_vertical = 0 theme_override_font_sizes/font_size = 30 theme_override_styles/normal = SubResource("StyleBoxFlat_r78im") theme_override_styles/hover = SubResource("StyleBoxFlat_v1l70") theme_override_styles/pressed = SubResource("StyleBoxFlat_eb82c") text = "Start Game" -[node name="ModeSelect" type="OptionButton" parent="RoundCreation/CreationMenu"] -layout_mode = 1 -offset_left = 43.0 -offset_top = 44.0 -offset_right = 299.0 -offset_bottom = 114.0 -theme_override_font_sizes/font_size = 40 - -[node name="CategoryBox" type="Tree" parent="RoundCreation/CreationMenu"] -layout_mode = 0 -offset_left = 58.0 -offset_top = 295.0 -offset_right = 478.0 -offset_bottom = 775.0 -columns = 2 -column_titles_visible = true -hide_root = true - -[node name="RoundDuration" type="SpinBox" parent="RoundCreation/CreationMenu"] -layout_mode = 1 -anchors_preset = 6 -anchor_left = 1.0 -anchor_top = 0.5 -anchor_right = 1.0 -anchor_bottom = 0.5 -offset_left = -472.0 -offset_top = -304.5 -offset_right = -199.775 -offset_bottom = -216.5 -grow_horizontal = 0 -grow_vertical = 2 -theme = SubResource("Theme_31w7n") -min_value = 5.0 -max_value = 90.0 -value = 30.0 -suffix = "s" - [connection signal="pressed" from="Buttons/Play" to="." method="on_play_pressed"] [connection signal="pressed" from="Buttons/Quit" to="." method="on_quit_pressed"] [connection signal="pressed" from="RoundCreation/CreationMenu/Cancel" to="." method="on_cancel_pressed"] diff --git a/scripts/menu.gd b/scripts/menu.gd index 3f4b889..ec77206 100644 --- a/scripts/menu.gd +++ b/scripts/menu.gd @@ -12,8 +12,15 @@ func _ready(): $RoundCreation/CreationMenu/RoundDuration.value = round_duration api.category(on_category_response) + var category_tree: Tree = $RoundCreation/CreationMenu/CategoryBox + category_tree.create_item() + category_tree.set_column_title(0, "Category") + category_tree.set_column_title(1, "Amount") + category_tree.set_column_expand(1, false) + category_tree.set_column_custom_minimum_width(1, 100) + ## on_category_response is called as when the categories api call completed. -func on_category_response(success: bool, categories: Dictionary={}): +func on_category_response(success: bool, categories: Dictionary = {}): if !success: print("failed to get categories!") return @@ -22,18 +29,26 @@ func on_category_response(success: bool, categories: Dictionary={}): ## update_category_list updates the category selection list with the given dictionary (mapping String to int). func update_category_list(groups: Dictionary): var category_tree: Tree = $RoundCreation/CreationMenu/CategoryBox - var tree_root: TreeItem = category_tree.create_item() - category_tree.set_column_title(0, "Category") - category_tree.set_column_title(1, "Amount") + var tree_root: TreeItem = category_tree.get_root() for group in groups: var tree_group: TreeItem = category_tree.create_item(tree_root) tree_group.set_text(0, group) + tree_group.set_custom_bg_color(0, Color(0.23, 0.23, 0.23)) + tree_group.set_custom_bg_color(1, Color(0.23, 0.23, 0.23)) + var bg_light: bool = false for cat in groups[group]: var category: TreeItem = category_tree.create_item(tree_group) category.set_text(0, cat.description) category.set_cell_mode(1, TreeItem.CELL_MODE_RANGE) category.set_range_config(1, 0, cat.count, 1) category.set_editable(1, true) + if bg_light: + category.set_custom_bg_color(0, Color(0.15, 0.15, 0.15)) + category.set_custom_bg_color(1, Color(0.15, 0.15, 0.15)) + else: + category.set_custom_bg_color(0, Color(0.05, 0.05, 0.05)) + category.set_custom_bg_color(1, Color(0.05, 0.05, 0.05)) + bg_light = !bg_light var category_data: CategoryData = CategoryData.new() category_data.id = cat.title From c2e1256a90f88407217bd434e84c2e729abce862 Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Sun, 21 Jul 2024 07:38:19 +0200 Subject: [PATCH 07/11] added start flag to override host --- scripts/api.gd | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/api.gd b/scripts/api.gd index 847b12c..d22a285 100644 --- a/scripts/api.gd +++ b/scripts/api.gd @@ -1,7 +1,7 @@ class_name API extends Node var ws: WebSocketPeer = WebSocketPeer.new() -const host: String = "https://api.cake4everyone.de/quiz" +var host: String = "https://api.cake4everyone.de/quiz" var api_token: String = "" var category_callback: Callable @@ -13,6 +13,12 @@ var streamervote_callback: Callable # Called when the node enters the scene tree for the first time. func _ready(): + var flags: PackedStringArray = OS.get_cmdline_args() + for flag in flags: + if flag.begins_with("--host="): + host = flag.trim_prefix("--host=") + print("[DEBUG] overwrote host with ", host) + $HTTP_Category.request_completed.connect(category_resp) $HTTP_GameInfo.request_completed.connect(game_info_resp) $HTTP_GameQuit.request_completed.connect(game_quit_resp) From 2859ee96ec0645ed3b279e3495e3b2da8a2be38a Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Sun, 8 Sep 2024 18:56:40 +0200 Subject: [PATCH 08/11] added group IDs --- scripts/menu.gd | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/menu.gd b/scripts/menu.gd index ec77206..eba3ffc 100644 --- a/scripts/menu.gd +++ b/scripts/menu.gd @@ -30,13 +30,16 @@ func on_category_response(success: bool, categories: Dictionary = {}): func update_category_list(groups: Dictionary): var category_tree: Tree = $RoundCreation/CreationMenu/CategoryBox var tree_root: TreeItem = category_tree.get_root() - for group in groups: + print(groups) + for group_id in groups: + print(group_id) + var group: Dictionary = groups[group_id] var tree_group: TreeItem = category_tree.create_item(tree_root) - tree_group.set_text(0, group) + tree_group.set_text(0, group.title) tree_group.set_custom_bg_color(0, Color(0.23, 0.23, 0.23)) tree_group.set_custom_bg_color(1, Color(0.23, 0.23, 0.23)) var bg_light: bool = false - for cat in groups[group]: + for cat in group.categories: var category: TreeItem = category_tree.create_item(tree_group) category.set_text(0, cat.description) category.set_cell_mode(1, TreeItem.CELL_MODE_RANGE) @@ -52,7 +55,7 @@ func update_category_list(groups: Dictionary): var category_data: CategoryData = CategoryData.new() category_data.id = cat.title - category_data.group = group + category_data.group = group_id category.set_metadata(0, category_data) ## on_btn_start_pressed is called when pressed the start game button. From f7917158e0656fbffa36083ae459067fd53fb9af Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Sun, 8 Sep 2024 19:09:45 +0200 Subject: [PATCH 09/11] renamed category id fields --- scripts/menu.gd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/menu.gd b/scripts/menu.gd index eba3ffc..eef0bf2 100644 --- a/scripts/menu.gd +++ b/scripts/menu.gd @@ -41,7 +41,7 @@ func update_category_list(groups: Dictionary): var bg_light: bool = false for cat in group.categories: var category: TreeItem = category_tree.create_item(tree_group) - category.set_text(0, cat.description) + category.set_text(0, cat.title) category.set_cell_mode(1, TreeItem.CELL_MODE_RANGE) category.set_range_config(1, 0, cat.count, 1) category.set_editable(1, true) @@ -54,7 +54,7 @@ func update_category_list(groups: Dictionary): bg_light = !bg_light var category_data: CategoryData = CategoryData.new() - category_data.id = cat.title + category_data.id = cat.id category_data.group = group_id category.set_metadata(0, category_data) From 2132c9ef505b569e5c3782c901813bea91b0c879 Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Sun, 8 Sep 2024 20:26:17 +0200 Subject: [PATCH 10/11] refactored category groups --- scripts/menu.gd | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/menu.gd b/scripts/menu.gd index eef0bf2..7414808 100644 --- a/scripts/menu.gd +++ b/scripts/menu.gd @@ -31,9 +31,8 @@ func update_category_list(groups: Dictionary): var category_tree: Tree = $RoundCreation/CreationMenu/CategoryBox var tree_root: TreeItem = category_tree.get_root() print(groups) - for group_id in groups: - print(group_id) - var group: Dictionary = groups[group_id] + for group_color in groups: + var group: Dictionary = groups[group_color] var tree_group: TreeItem = category_tree.create_item(tree_root) tree_group.set_text(0, group.title) tree_group.set_custom_bg_color(0, Color(0.23, 0.23, 0.23)) @@ -55,7 +54,7 @@ func update_category_list(groups: Dictionary): var category_data: CategoryData = CategoryData.new() category_data.id = cat.id - category_data.group = group_id + category_data.group = group.id category.set_metadata(0, category_data) ## on_btn_start_pressed is called when pressed the start game button. From 2ad7ecc8924ffa972cf53885c35ec0c7750a2222 Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Fri, 13 Sep 2024 21:02:34 +0200 Subject: [PATCH 11/11] displaying actual round title in question scenes --- scripts/question.gd | 2 +- scripts/question_end.gd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/question.gd b/scripts/question.gd index 4d52306..d9e44b2 100644 --- a/scripts/question.gd +++ b/scripts/question.gd @@ -65,7 +65,7 @@ func on_round_next_response(success: bool, data: Dictionary={}): func show_round_data(data: Dictionary): print(data) $Countdown.show() - $RoundCounter.text = "Runde %d/%d (%s)" % [data.current_round, data.max_round, data.category] + $RoundCounter.text = "Runde %d/%d (%s)" % [data.current_round, data.max_round, data.category.title] $RoundCounter.show() $Quiz/Question/Label.text = data.question diff --git a/scripts/question_end.gd b/scripts/question_end.gd index 87dfe52..dfc1411 100644 --- a/scripts/question_end.gd +++ b/scripts/question_end.gd @@ -6,7 +6,7 @@ func _ready(): ## show_round_data displays the given round_data data on screen. func show_round_data(data: Dictionary): print(data) - $RoundCounter.text = "Runde %d/%d (%s)" % [data.current_round, data.max_round, data.category] + $RoundCounter.text = "Runde %d/%d (%s)" % [data.current_round, data.max_round, data.category.title] $Quiz/Question/Label.text = data.question $Quiz/Answers/A/Label.text = data.answers[0]