@tool extends EditorPlugin enum BugbotMenuItems { SHOW_BUG_MARKERS, HIDE_BUG_MARKERS } var __bugbot_menu_button : BugbotMenuButton var __bugbot_marker_containers : Dictionary var __editor_server_api : BugbotServerAPI var __current_edited_scene_path : String func _enter_tree() -> void: scene_changed.connect(__on_editor_tab_switched) ProjectSettings.settings_changed.connect(__on_project_settings_changed) __initialise_project_settings() __bugbot_menu_button = preload("res://addons/Bugbot/bugbot_menu_button.tscn").instantiate() as BugbotMenuButton add_control_to_container(CustomControlContainer.CONTAINER_SPATIAL_EDITOR_MENU, __bugbot_menu_button) # Setup popup menu var bugbot_menu : PopupMenu = __bugbot_menu_button.get_popup() bugbot_menu.add_item("Show Bug Markers", BugbotMenuItems.SHOW_BUG_MARKERS) bugbot_menu.add_item("Hide Bug Markers", BugbotMenuItems.HIDE_BUG_MARKERS) bugbot_menu.id_pressed.connect(__on_bugbot_menu_item_pressed) func _exit_tree() -> void: remove_control_from_container(CustomControlContainer.CONTAINER_SPATIAL_EDITOR_MENU, __bugbot_menu_button) __bugbot_menu_button.queue_free() func __initialise_project_settings() -> void: #region Placement __add_project_setting("bugbot/bug_placement/precise_placement_distance", TYPE_FLOAT, Bugbot.DEFAULT_PRECISE_PLACEMENT_DISTANCE, PROPERTY_HINT_RANGE, "0.0,100.0,0.1,or_greater") __add_project_setting("bugbot/bug_placement/arbitrary_placement_distance", TYPE_FLOAT, Bugbot.DEFAULT_ARBITRARY_PLACEMENT_DISTANCE, PROPERTY_HINT_RANGE, "0.0,100.0,0.1,or_greater") #endregion #region Reporting __add_project_setting("bugbot/reporting/bug_report_platform", TYPE_INT, BugReportPlatform.BUGZILLA, PROPERTY_HINT_ENUM, "Bugzilla,Gitea,Jira") __add_project_setting("bugbot/reporting/bug_report_widget_depth", TYPE_INT, 10000) #region Bugzilla __add_project_setting("bugbot/reporting/bugzilla/server", TYPE_STRING, "https://bugzilla.example.com") __add_project_setting("bugbot/reporting/bugzilla/REST_URI", TYPE_STRING, "rest/") __add_project_setting("bugbot/reporting/bugzilla/product_name", TYPE_STRING, "") __add_project_setting("bugbot/reporting/bugzilla/API_key", TYPE_STRING, "") __add_project_setting("bugbot/reporting/bugzilla/default_status", TYPE_STRING, "UNCONFIRMED") #endregion #region Gitea __add_project_setting("bugbot/reporting/gitea/server", TYPE_STRING, BugbotServerGiteaAPI.DEFAULT_SERVER) __add_project_setting("bugbot/reporting/gitea/base_URL", TYPE_STRING, BugbotServerGiteaAPI.DEFAULT_BASE_URL) __add_project_setting("bugbot/reporting/gitea/owner_name", TYPE_STRING, BugbotServerGiteaAPI.DEFAULT_OWNER_NAME) __add_project_setting("bugbot/reporting/gitea/repo_name", TYPE_STRING, BugbotServerGiteaAPI.DEFAULT_REPO_NAME) __add_project_setting("bugbot/reporting/gitea/API_key", TYPE_STRING, BugbotServerGiteaAPI.DEFAULT_API_KEY) __add_project_setting("bugbot/reporting/gitea/bug_label", TYPE_STRING, BugbotServerGiteaAPI.DEFAULT_BUG_LABEL) __add_project_setting("bugbot/reporting/gitea/default_status_label", TYPE_STRING, BugbotServerGiteaAPI.DEFAULT_STATUS_LABEL) __add_project_setting("bugbot/reporting/gitea/status_labels/unresolved_statuses", TYPE_ARRAY, Array(), PROPERTY_HINT_ARRAY_TYPE, &"21/:") __add_project_setting("bugbot/reporting/gitea/status_labels/in_progress_statuses", TYPE_ARRAY, Array(), PROPERTY_HINT_ARRAY_TYPE, &"21/:") __add_project_setting("bugbot/reporting/gitea/status_labels/resolved_statuses", TYPE_ARRAY, Array(), PROPERTY_HINT_ARRAY_TYPE, &"21/:") __add_project_setting("bugbot/reporting/gitea/status_labels/version_label_prefix", TYPE_STRING, BugbotServerGiteaAPI.DEFAULT_VERSION_LABEL_PREFIX) __add_project_setting("bugbot/reporting/gitea/status_labels/hardware_label_prefix", TYPE_STRING, BugbotServerGiteaAPI.DEFAULT_HARDWARE_LABEL_PREFIX) __add_project_setting("bugbot/reporting/gitea/status_labels/os_label_prefix", TYPE_STRING, BugbotServerGiteaAPI.DEFAULT_OS_LABEL_PREFIX) __add_project_setting("bugbot/reporting/gitea/status_labels/component_label_prefix", TYPE_STRING, BugbotServerGiteaAPI.DEFAULT_COMPONENT_LABEL_PREFIX) __add_project_setting("bugbot/reporting/gitea/status_labels/priority_label_prefix", TYPE_STRING, BugbotServerGiteaAPI.DEFAULT_PRIORITY_LABEL_PREFIX) __add_project_setting("bugbot/reporting/gitea/status_labels/show_assigned_as_in_progress", TYPE_BOOL, BugbotServerGiteaAPI.DEFAULT_SHOW_ASSIGNED_AS_IN_PROGRESS) #endregion #region Jira __add_project_setting("bugbot/reporting/jira/server", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_SERVER) __add_project_setting("bugbot/reporting/jira/REST_URI", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_REST_URI) __add_project_setting("bugbot/reporting/jira/project_name", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_PROJECT_NAME) __add_project_setting("bugbot/reporting/jira/email", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_EMAIL) __add_project_setting("bugbot/reporting/jira/API_key", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_API_KEY) __add_project_setting("bugbot/reporting/jira/bug_issue_type", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_BUG_ISSUE_TYPE) __add_project_setting("bugbot/reporting/jira/map_name_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_MAP_NAME_FIELD) __add_project_setting("bugbot/reporting/jira/marker_location_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_MARKER_LOCATION_FIELD) __add_project_setting("bugbot/reporting/jira/optional_fields/department_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_DEPARTMENT_FIELD) __add_project_setting("bugbot/reporting/jira/optional_fields/severity_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_SEVERITY_FIELD) __add_project_setting("bugbot/reporting/jira/optional_fields/platform_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_PLATFORM_FIELD) __add_project_setting("bugbot/reporting/jira/optional_fields/version_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_VERSION_FIELD) #endregion #endregion #region Bug Markers __add_project_setting("bugbot/markers/unresolved/show_unresolved_bugs", TYPE_BOOL, true) __add_project_setting("bugbot/markers/unresolved/tint", TYPE_COLOR, BugMarker.UNRESOLVED_TINT) __add_project_setting("bugbot/markers/in_progress/show_in_progress_bugs", TYPE_BOOL, true) __add_project_setting("bugbot/markers/in_progress/tint", TYPE_COLOR, BugMarker.IN_PROGRESS_TINT) __add_project_setting("bugbot/markers/resolved/show_resolved_bugs", TYPE_BOOL, false) __add_project_setting("bugbot/markers/resolved/tint", TYPE_COLOR, BugMarker.RESOLVED_TINT) #endregion #region Batch Loading __add_project_setting("bugbot/markers/display/load_markers_batch", TYPE_INT, 10) __add_project_setting("bugbot/markers/display/unload_markers_batch", TYPE_INT, 25) #endregion func __on_bugbot_menu_item_pressed(id:int) -> void: match id: BugbotMenuItems.SHOW_BUG_MARKERS: __show_editor_bug_markers() BugbotMenuItems.HIDE_BUG_MARKERS: var scene : String = EditorInterface.get_edited_scene_root().scene_file_path if __bugbot_marker_containers.has(scene) and __bugbot_marker_containers[scene]: __bugbot_marker_containers[scene].queue_free() __bugbot_marker_containers.erase(scene) func __show_editor_bug_markers() -> void: var scene_root : Node = EditorInterface.get_edited_scene_root() var scene : String = scene_root.scene_file_path var tree_root : Node = scene_root.get_tree().get_root() if __marker_root_exists(scene): __bugbot_marker_containers[scene].queue_free() var marker_container : Node3D = Node3D.new() marker_container.name = "BugMarkerContainer" __bugbot_marker_containers[scene] = marker_container tree_root.add_child(marker_container) __editor_server_api = BugbotServerAPI._create_new_server_api() __editor_server_api._return_list_of_bugs(scene, __show_bug_markers_response) func __show_bug_markers_response(bug_list:Array) -> void: var scene_root : Node = EditorInterface.get_edited_scene_root() var marker_container : Node3D = __bugbot_marker_containers[scene_root.scene_file_path] Bugbot.load_bug_markers(marker_container, bug_list) func __marker_root_exists(scene_path:String) -> bool: return __bugbot_marker_containers.has(scene_path) and is_instance_valid(__bugbot_marker_containers[scene_path]) func __on_editor_tab_switched(new_scene:Node) -> void: if __marker_root_exists(__current_edited_scene_path): (__bugbot_marker_containers[__current_edited_scene_path] as Node).visible = false if __marker_root_exists(new_scene.scene_file_path): (__bugbot_marker_containers[new_scene.scene_file_path] as Node).visible = true __current_edited_scene_path = new_scene.scene_file_path func __on_project_settings_changed() -> void: Bugbot.adjust_bug_marker_colours() func __add_project_setting(_setting:String, _type:int, _default_value:Variant, _hint:int = PropertyHint.PROPERTY_HINT_NONE, _hint_string:String = "") -> void: var setting_info: Dictionary = { "name": _setting, "type": _type, "hint": _hint, "hint_string": _hint_string } if not ProjectSettings.has_setting(_setting): ProjectSettings.set_setting(_setting, _default_value) ProjectSettings.add_property_info(setting_info) ProjectSettings.set_initial_value(_setting, _default_value)