Tag selection buttons now populate the form entry menu with available tags.

This commit is contained in:
Jamie Greunbaum 2024-05-23 17:00:41 -04:00
parent 64f6193701
commit ab74bda6f0
4 changed files with 50 additions and 48 deletions

View File

@ -270,7 +270,7 @@ func __calculate_movement() -> void:
func __calculate_button_presses() -> void: func __calculate_button_presses() -> void:
if Input.is_action_just_pressed(&"bugbot_place_marker") and __raycast_collision: 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"): if Input.is_action_just_released(&"bugbot_exit_placement"):
__exit_placement_timer.stop() __exit_placement_timer.stop()
@ -295,21 +295,27 @@ func __raycast_to_world():
else: else:
__laser_beam.visible = false __laser_beam.visible = false
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
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):
process_mode = Node.PROCESS_MODE_PAUSABLE
var marker : BugMarker = (load(bug_marker) as PackedScene).instantiate() as BugMarker var marker : BugMarker = (load(bug_marker) as PackedScene).instantiate() as BugMarker
get_tree().get_root().add_child(marker) get_tree().get_root().add_child(marker)
marker.global_position = _position marker.global_position = _position
marker.set_rotation_to_normal(_normal) marker.set_rotation_to_normal(_normal)
marker.marker_status = BugMarker.BugStatus.UNRESOLVED marker.marker_status = BugMarker.BugStatus.UNRESOLVED
__bugbot_server._prepare_form(__bug_report_form_data_prepared) __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): func __bug_report_form_data_prepared(tag_lists:Array):
var bug_report_form : Control = preload("res://addons/Bugbot/UI/bug_report_form.tscn").instantiate() var bug_report_form : Control = preload("res://addons/Bugbot/UI/bug_report_form.tscn").instantiate()
add_child(bug_report_form) add_child(bug_report_form)

View File

@ -2,6 +2,7 @@ class_name BugbotServerAPI
extends Resource extends Resource
enum BugbotServerError { OK, THREAD_NULL, THREAD_BUSY, API_RESPONSE_ERROR } enum BugbotServerError { OK, THREAD_NULL, THREAD_BUSY, API_RESPONSE_ERROR }
enum BugbotTagArray { VERSION, HARDWARE, OS, COMPONENT, SEVERITY, MAX }
var __bugbot_server_thread : Thread var __bugbot_server_thread : Thread

View File

@ -132,11 +132,13 @@ func __prepare_form_thread(callback:Callable) -> void:
if __validate_server_response(response_data) != Error.OK: if __validate_server_response(response_data) != Error.OK:
return return
var version_tags : Array var tag_lists : Array
var hardware_tags : Array tag_lists.resize(BugbotTagArray.MAX)
var os_tags : Array tag_lists[BugbotTagArray.VERSION] = Array()
var component_tags : Array tag_lists[BugbotTagArray.HARDWARE] = Array()
var priority_tags : 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 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 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) 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) 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: for label_in:Dictionary in response_data:
if version_prefix and label_in["name"].begins_with(version_prefix): 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): 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): 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): 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): if priority_prefix and label_in["name"].begins_with(priority_prefix):
priority_tags.append(label_in) tag_lists[BugbotTagArray.SEVERITY].append(label_in)
version_tags.sort_custom(func(a,b):return a["id"] < b["id"]) tag_lists[BugbotTagArray.VERSION].sort_custom(func(a,b):return a["id"] < b["id"])
hardware_tags.sort_custom(func(a,b):return a["id"] < b["id"]) tag_lists[BugbotTagArray.HARDWARE].sort_custom(func(a,b):return a["id"] < b["id"])
os_tags.sort_custom(func(a,b):return a["id"] < b["id"]) tag_lists[BugbotTagArray.OS].sort_custom(func(a,b):return a["id"] < b["id"])
component_tags.sort_custom(func(a,b):return a["id"] < b["id"]) tag_lists[BugbotTagArray.COMPONENT].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].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) callback.call_deferred(tag_lists)
__bugbot_server_thread.call_deferred("wait_to_finish") __bugbot_server_thread.call_deferred("wait_to_finish")

View File

@ -15,6 +15,8 @@ var __severity_items : Array
var __stored_mouse_mode : int var __stored_mouse_mode : int
const __button_disabled_message : StringName = &"Not available"
func _enter_tree(): func _enter_tree():
__stored_mouse_mode = Input.mouse_mode __stored_mouse_mode = Input.mouse_mode
@ -23,28 +25,20 @@ func _enter_tree():
func _exit_tree(): func _exit_tree():
Input.mouse_mode = __stored_mouse_mode Input.mouse_mode = __stored_mouse_mode
func fill_tags(tag_list:Array): func fill_tags(tag_list:Array):
var version_menu : PopupMenu = __version_button.get_popup() __fill_item_list(__version_button, __version_items, tag_list[BugbotServerAPI.BugbotTagArray.VERSION])
var version_list : Array = tag_list[0] __fill_item_list(__hardware_button, __hardware_items, tag_list[BugbotServerAPI.BugbotTagArray.HARDWARE])
for i in version_list.size(): __fill_item_list(__os_button, __os_items, tag_list[BugbotServerAPI.BugbotTagArray.OS])
version_menu.add_item(version_list[i]["name"], i) __fill_item_list(__component_button, __component_items, tag_list[BugbotServerAPI.BugbotTagArray.COMPONENT])
__fill_item_list(__severity_button, __severity_items, tag_list[BugbotServerAPI.BugbotTagArray.SEVERITY])
var hardware_menu : PopupMenu = __hardware_button.get_popup() func __fill_item_list(menu_button:MenuButton, menu_options:Array, tag_list:Array):
var hardware_list : Array = tag_list[1] menu_options = tag_list
for i in hardware_list.size(): if menu_options.is_empty():
hardware_menu.add_item(hardware_list[i]["name"], i) menu_button.text = __button_disabled_message
menu_button.disabled = true
var os_menu : PopupMenu = __os_button.get_popup() else:
var os_list : Array = tag_list[2] var menu : PopupMenu = menu_button.get_popup()
for i in os_list.size(): for i in menu_options.size():
os_menu.add_item(os_list[i]["name"], i) menu.add_item(menu_options[i]["name"], i)
menu.id_pressed.connect(func(id:int): menu_button.text = menu_options[id]["name"])
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)