From ab74bda6f04709260887d3e715a1c2e1e7362e8d Mon Sep 17 00:00:00 2001 From: Jamie Greunbaum Date: Thu, 23 May 2024 17:00:41 -0400 Subject: [PATCH] Tag selection buttons now populate the form entry menu with available tags. --- Scenes/bugbot_player.gd | 22 ++++++++++++------- Scripts/server_api.gd | 1 + Scripts/server_gitea_api.gd | 33 +++++++++++++++-------------- UI/bug_report_form.gd | 42 ++++++++++++++++--------------------- 4 files changed, 50 insertions(+), 48 deletions(-) diff --git a/Scenes/bugbot_player.gd b/Scenes/bugbot_player.gd index 284649d..67e9ea2 100644 --- a/Scenes/bugbot_player.gd +++ b/Scenes/bugbot_player.gd @@ -270,7 +270,7 @@ func __calculate_movement() -> void: func __calculate_button_presses() -> void: if Input.is_action_just_pressed(&"bugbot_place_marker") and __raycast_collision: - __place_marker(__raycast_collision["position"], __raycast_collision["normal"]) + __select_at_location(__raycast_collision["position"], __raycast_collision["normal"]) if Input.is_action_just_released(&"bugbot_exit_placement"): __exit_placement_timer.stop() @@ -295,21 +295,27 @@ func __raycast_to_world(): else: __laser_beam.visible = false + +func __select_at_location(_position:Vector3, _normal:Vector3): + var collider : Area3D = __raycast_collision["collider"] as Area3D + if collider and collider.is_in_group("BugMarkerInfo"): + __pop_up_marker_info(_position, _normal) + else: + __place_marker(_position, _normal) + func __place_marker(_position:Vector3, _normal:Vector3): - if __raycast_collision: - var collider : Area3D = __raycast_collision["collider"] as Area3D - if collider and collider.is_in_group("BugMarkerInfo"): - print("Pop up bug marker info here.") - return - + process_mode = Node.PROCESS_MODE_PAUSABLE var marker : BugMarker = (load(bug_marker) as PackedScene).instantiate() as BugMarker get_tree().get_root().add_child(marker) marker.global_position = _position marker.set_rotation_to_normal(_normal) marker.marker_status = BugMarker.BugStatus.UNRESOLVED - __bugbot_server._prepare_form(__bug_report_form_data_prepared) +func __pop_up_marker_info(_position:Vector3, _normal:Vector3): + print("Pop up bug marker info here.") + + func __bug_report_form_data_prepared(tag_lists:Array): var bug_report_form : Control = preload("res://addons/Bugbot/UI/bug_report_form.tscn").instantiate() add_child(bug_report_form) diff --git a/Scripts/server_api.gd b/Scripts/server_api.gd index da36b15..695c683 100644 --- a/Scripts/server_api.gd +++ b/Scripts/server_api.gd @@ -2,6 +2,7 @@ class_name BugbotServerAPI extends Resource enum BugbotServerError { OK, THREAD_NULL, THREAD_BUSY, API_RESPONSE_ERROR } +enum BugbotTagArray { VERSION, HARDWARE, OS, COMPONENT, SEVERITY, MAX } var __bugbot_server_thread : Thread diff --git a/Scripts/server_gitea_api.gd b/Scripts/server_gitea_api.gd index 72c03fe..76c3216 100644 --- a/Scripts/server_gitea_api.gd +++ b/Scripts/server_gitea_api.gd @@ -132,11 +132,13 @@ func __prepare_form_thread(callback:Callable) -> void: if __validate_server_response(response_data) != Error.OK: return - var version_tags : Array - var hardware_tags : Array - var os_tags : Array - var component_tags : Array - var priority_tags : Array + var tag_lists : Array + tag_lists.resize(BugbotTagArray.MAX) + tag_lists[BugbotTagArray.VERSION] = Array() + tag_lists[BugbotTagArray.HARDWARE] = Array() + tag_lists[BugbotTagArray.OS] = Array() + tag_lists[BugbotTagArray.COMPONENT] = Array() + tag_lists[BugbotTagArray.SEVERITY] = Array() var version_prefix : String = ProjectSettings.get_setting("bugbot/reporting/gitea/status_labels/version_label_prefix", DEFAULT_VERSION_LABEL_PREFIX) var hardware_prefix : String = ProjectSettings.get_setting("bugbot/reporting/gitea/status_labels/hardware_label_prefix", DEFAULT_HARDWARE_LABEL_PREFIX) var os_prefix : String = ProjectSettings.get_setting("bugbot/reporting/gitea/status_labels/os_label_prefix", DEFAULT_OS_LABEL_PREFIX) @@ -144,22 +146,21 @@ func __prepare_form_thread(callback:Callable) -> void: var priority_prefix : String = ProjectSettings.get_setting("bugbot/reporting/gitea/status_labels/priority_label_prefix", DEFAULT_PRIORITY_LABEL_PREFIX) for label_in:Dictionary in response_data: if version_prefix and label_in["name"].begins_with(version_prefix): - version_tags.append(label_in) + tag_lists[BugbotTagArray.VERSION].append(label_in) if hardware_prefix and label_in["name"].begins_with(hardware_prefix): - hardware_tags.append(label_in) + tag_lists[BugbotTagArray.HARDWARE].append(label_in) if os_prefix and label_in["name"].begins_with(os_prefix): - os_tags.append(label_in) + tag_lists[BugbotTagArray.OS].append(label_in) if component_prefix and label_in["name"].begins_with(component_prefix): - component_tags.append(label_in) + tag_lists[BugbotTagArray.COMPONENT].append(label_in) if priority_prefix and label_in["name"].begins_with(priority_prefix): - priority_tags.append(label_in) - version_tags.sort_custom(func(a,b):return a["id"] < b["id"]) - hardware_tags.sort_custom(func(a,b):return a["id"] < b["id"]) - os_tags.sort_custom(func(a,b):return a["id"] < b["id"]) - component_tags.sort_custom(func(a,b):return a["id"] < b["id"]) - priority_tags.sort_custom(func(a,b): return a["id"] < b["id"]) + tag_lists[BugbotTagArray.SEVERITY].append(label_in) + tag_lists[BugbotTagArray.VERSION].sort_custom(func(a,b):return a["id"] < b["id"]) + tag_lists[BugbotTagArray.HARDWARE].sort_custom(func(a,b):return a["id"] < b["id"]) + tag_lists[BugbotTagArray.OS].sort_custom(func(a,b):return a["id"] < b["id"]) + tag_lists[BugbotTagArray.COMPONENT].sort_custom(func(a,b):return a["id"] < b["id"]) + tag_lists[BugbotTagArray.SEVERITY].sort_custom(func(a,b): return a["id"] < b["id"]) - var tag_lists : Array = [version_tags, hardware_tags, os_tags, component_tags, priority_tags] callback.call_deferred(tag_lists) __bugbot_server_thread.call_deferred("wait_to_finish") diff --git a/UI/bug_report_form.gd b/UI/bug_report_form.gd index f79a1ed..2bffe56 100644 --- a/UI/bug_report_form.gd +++ b/UI/bug_report_form.gd @@ -15,6 +15,8 @@ var __severity_items : Array var __stored_mouse_mode : int +const __button_disabled_message : StringName = &"Not available" + func _enter_tree(): __stored_mouse_mode = Input.mouse_mode @@ -23,28 +25,20 @@ func _enter_tree(): func _exit_tree(): Input.mouse_mode = __stored_mouse_mode + func fill_tags(tag_list:Array): - var version_menu : PopupMenu = __version_button.get_popup() - var version_list : Array = tag_list[0] - for i in version_list.size(): - version_menu.add_item(version_list[i]["name"], i) - - var hardware_menu : PopupMenu = __hardware_button.get_popup() - var hardware_list : Array = tag_list[1] - for i in hardware_list.size(): - hardware_menu.add_item(hardware_list[i]["name"], i) - - var os_menu : PopupMenu = __os_button.get_popup() - var os_list : Array = tag_list[2] - for i in os_list.size(): - os_menu.add_item(os_list[i]["name"], i) - - var component_menu : PopupMenu = __component_button.get_popup() - var component_list : Array = tag_list[3] - for i in component_list.size(): - component_menu.add_item(component_list[i]["name"], i) - - var severity_menu : PopupMenu = __severity_button.get_popup() - var severity_list : Array = tag_list[4] - for i in severity_list.size(): - severity_menu.add_item(severity_list[i]["name"], i) + __fill_item_list(__version_button, __version_items, tag_list[BugbotServerAPI.BugbotTagArray.VERSION]) + __fill_item_list(__hardware_button, __hardware_items, tag_list[BugbotServerAPI.BugbotTagArray.HARDWARE]) + __fill_item_list(__os_button, __os_items, tag_list[BugbotServerAPI.BugbotTagArray.OS]) + __fill_item_list(__component_button, __component_items, tag_list[BugbotServerAPI.BugbotTagArray.COMPONENT]) + __fill_item_list(__severity_button, __severity_items, tag_list[BugbotServerAPI.BugbotTagArray.SEVERITY]) +func __fill_item_list(menu_button:MenuButton, menu_options:Array, tag_list:Array): + menu_options = tag_list + if menu_options.is_empty(): + menu_button.text = __button_disabled_message + menu_button.disabled = true + else: + var menu : PopupMenu = menu_button.get_popup() + for i in menu_options.size(): + menu.add_item(menu_options[i]["name"], i) + menu.id_pressed.connect(func(id:int): menu_button.text = menu_options[id]["name"])