Bug markers' colours are now actually affected by project settings, including actively in the editor when changing the associated project settings.

This commit is contained in:
Jamie Greunbaum 2024-05-26 19:26:56 -04:00
parent 53c22e1048
commit 87c49f7b2f
2 changed files with 25 additions and 1 deletions

View File

@ -240,8 +240,11 @@ func _physics_process(_delta:float) -> void:
static func instantiate(tree:SceneTree) -> void: static func instantiate(tree:SceneTree) -> void:
tree.root.add_child(load("res://addons/Bugbot/Scenes/bugbot_player.tscn").instantiate() as CharacterBody3D) tree.root.add_child(load("res://addons/Bugbot/Scenes/bugbot_player.tscn").instantiate() as CharacterBody3D)
static func load_bug_markers(marker_root:Node3D, bug_list:Array): static func load_bug_markers(marker_root:Node3D, bug_list:Array) -> void:
var bug_marker_preload : PackedScene = preload("res://addons/Bugbot/Scenes/bug_marker.tscn") var bug_marker_preload : PackedScene = preload("res://addons/Bugbot/Scenes/bug_marker.tscn")
Bugbot.adjust_bug_marker_colours()
for bugbot_data:Resource in bug_list: for bugbot_data:Resource in bug_list:
if bugbot_data is BugbotBugData: if bugbot_data is BugbotBugData:
var bug_status : BugMarker.BugStatus = BugMarker.BugStatus.NEUTRAL var bug_status : BugMarker.BugStatus = BugMarker.BugStatus.NEUTRAL
@ -261,6 +264,23 @@ static func load_bug_markers(marker_root:Node3D, bug_list:Array):
bug_marker.global_position = bugbot_data.marker_position bug_marker.global_position = bugbot_data.marker_position
bug_marker.set_rotation_to_normal(bugbot_data.marker_normal) bug_marker.set_rotation_to_normal(bugbot_data.marker_normal)
static func adjust_bug_marker_colours() -> void:
var unresolved_colour : Color = ProjectSettings.get_setting("bugbot/markers/unresolved/tint")
var in_progress_colour : Color = ProjectSettings.get_setting("bugbot/markers/in_progress/tint")
var resolved_colour : Color = ProjectSettings.get_setting("bugbot/markers/resolved/tint")
var unresolved_material : BugMarkerMaterialPack = load("res://addons/Bugbot/Materials/BugMarker/bug_marker_unresolved.res")
(unresolved_material.arrow as ShaderMaterial).set_shader_parameter("colour", unresolved_colour)
(unresolved_material.icon as ShaderMaterial).set_shader_parameter("colour", unresolved_colour)
var in_progress_material : BugMarkerMaterialPack = load("res://addons/Bugbot/Materials/BugMarker/bug_marker_in_progress.res")
(in_progress_material.arrow as ShaderMaterial).set_shader_parameter("colour", in_progress_colour)
(in_progress_material.icon as ShaderMaterial).set_shader_parameter("colour", in_progress_colour)
var resolved_material : BugMarkerMaterialPack = load("res://addons/Bugbot/Materials/BugMarker/bug_marker_resolved.res")
(resolved_material.arrow as ShaderMaterial).set_shader_parameter("colour", resolved_colour)
(resolved_material.icon as ShaderMaterial).set_shader_parameter("colour", resolved_colour)
func __calculate_movement_speed() -> void: func __calculate_movement_speed() -> void:
if Input.is_action_pressed(&"bugbot_movement_speed_down") or Input.is_action_just_pressed(&"bugbot_movement_speed_down"): if Input.is_action_pressed(&"bugbot_movement_speed_down") or Input.is_action_just_pressed(&"bugbot_movement_speed_down"):

View File

@ -14,6 +14,7 @@ var __current_edited_scene_path : String
func _enter_tree() -> void: func _enter_tree() -> void:
scene_changed.connect(__on_editor_tab_switched) scene_changed.connect(__on_editor_tab_switched)
ProjectSettings.settings_changed.connect(__on_project_settings_changed)
__initialise_project_settings() __initialise_project_settings()
@ -137,6 +138,9 @@ func __on_editor_tab_switched(new_scene:Node) -> void:
(__bugbot_marker_containers[new_scene.scene_file_path] as Node).visible = true (__bugbot_marker_containers[new_scene.scene_file_path] as Node).visible = true
__current_edited_scene_path = new_scene.scene_file_path __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: 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 = { var setting_info: Dictionary = {