Bug markers can now be properly shown and hidden between multiple tabs.
This commit is contained in:
parent
ded09a8fa8
commit
53c22e1048
23
bugbot.gd
23
bugbot.gd
@ -9,9 +9,11 @@ enum BugbotMenuItems {
|
||||
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(func(scene:Node):print("Scene has changed from " + scene.scene_file_path + " to ", EditorInterface.get_edited_scene_root().scene_file_path))
|
||||
scene_changed.connect(__on_editor_tab_switched)
|
||||
|
||||
__initialise_project_settings()
|
||||
|
||||
@ -97,7 +99,7 @@ func __initialise_project_settings() -> void:
|
||||
__add_project_setting("bugbot/markers/display/unload_markers_batch", TYPE_INT, 25)
|
||||
#endregion
|
||||
|
||||
func __on_bugbot_menu_item_pressed(id:int):
|
||||
func __on_bugbot_menu_item_pressed(id:int) -> void:
|
||||
match id:
|
||||
BugbotMenuItems.SHOW_BUG_MARKERS:
|
||||
__show_editor_bug_markers()
|
||||
@ -107,11 +109,11 @@ func __on_bugbot_menu_item_pressed(id:int):
|
||||
__bugbot_marker_containers[scene].queue_free()
|
||||
__bugbot_marker_containers.erase(scene)
|
||||
|
||||
func __show_editor_bug_markers():
|
||||
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 __bugbot_marker_containers.has(scene) and __bugbot_marker_containers[scene]:
|
||||
if __marker_root_exists(scene):
|
||||
__bugbot_marker_containers[scene].queue_free()
|
||||
var marker_container : Node3D = Node3D.new()
|
||||
marker_container.name = "BugMarkerContainer"
|
||||
@ -124,8 +126,19 @@ func __show_bug_markers_response(bug_list:Array) -> void:
|
||||
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 __add_project_setting(_setting:String, _type:int, _default_value:Variant, _hint:int = PropertyHint.PROPERTY_HINT_NONE, _hint_string:String = ""):
|
||||
|
||||
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 __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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user