diff --git a/project.godot b/project.godot index 3737bddf8..12285e151 100644 --- a/project.godot +++ b/project.godot @@ -64,6 +64,7 @@ enabled=PackedStringArray("res://addons/aimg_io/plugin.cfg", "res://addons/docka [global_group] CanvasCameras="" +CanvasPreviews="" [importer_defaults] diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 5b8259fae..24ee555f7 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -608,18 +608,8 @@ var cel_button_scene: PackedScene = load("res://src/UI/Timeline/CelButton.tscn") @onready var main_viewport: SubViewportContainer = control.find_child("SubViewportContainer") ## The main canvas node. It has the [param Canvas.gd] script attached. @onready var canvas: Canvas = main_viewport.find_child("Canvas") -## Contains viewport of the second canvas preview. -## It has the [param ViewportContainer.gd] script attached. -@onready var second_viewport: SubViewportContainer = control.find_child("Second Canvas") -## The panel container of the canvas preview. -## It has the [param CanvasPreviewContainer.gd] script attached. -@onready var canvas_preview_container: Container = control.find_child("Canvas Preview") ## The global tool options. It has the [param GlobalToolOptions.gd] script attached. @onready var global_tool_options: PanelContainer = control.find_child("Global Tool Options") -## Contains viewport of the canvas preview. -@onready var small_preview_viewport: SubViewportContainer = canvas_preview_container.find_child( - "PreviewViewportContainer" -) ## Camera of the main canvas. @onready var camera: CanvasCamera = main_viewport.find_child("Camera2D") ## Horizontal ruler of the main canvas. It has the [param HorizontalRuler.gd] script attached. @@ -956,8 +946,8 @@ func undo_or_redo( await RenderingServer.frame_post_draw canvas.queue_redraw() - second_viewport.get_child(0).get_node("CanvasPreview").queue_redraw() - canvas_preview_container.canvas_preview.queue_redraw() + for canvas_preview in get_tree().get_nodes_in_group("CanvasPreviews"): + canvas_preview.queue_redraw() if !project.has_changed: if project == current_project: get_window().title = get_window().title + "(*)" diff --git a/src/UI/CanvasPreviewContainer/CanvasPreviewContainer.tscn b/src/UI/CanvasPreviewContainer/CanvasPreviewContainer.tscn index 097f0c53b..1bc02c895 100644 --- a/src/UI/CanvasPreviewContainer/CanvasPreviewContainer.tscn +++ b/src/UI/CanvasPreviewContainer/CanvasPreviewContainer.tscn @@ -74,7 +74,7 @@ render_target_update_mode = 4 material = SubResource("1") anchors_preset = 0 -[node name="CanvasPreview" parent="VBox/HBox/PreviewViewportContainer/SubViewport" instance=ExtResource("5")] +[node name="CanvasPreview" parent="VBox/HBox/PreviewViewportContainer/SubViewport" groups=["CanvasPreviews"] instance=ExtResource("5")] unique_name_in_owner = true [node name="CameraPreview" type="Node2D" parent="VBox/HBox/PreviewViewportContainer/SubViewport" groups=["CanvasCameras"]] diff --git a/src/UI/Nodes/TransparentChecker.gd b/src/UI/Nodes/TransparentChecker.gd index a1d39cb8a..f01d2250f 100644 --- a/src/UI/Nodes/TransparentChecker.gd +++ b/src/UI/Nodes/TransparentChecker.gd @@ -11,8 +11,8 @@ func update_rect() -> void: set_bounds(Global.current_project.size) if self == Global.transparent_checker: fit_rect(Global.current_project.tiles.get_bounding_rect()) - Global.second_viewport.get_node("SubViewport/TransparentChecker").update_rect() - Global.small_preview_viewport.get_node("SubViewport/TransparentChecker").update_rect() + for canvas_preview in get_tree().get_nodes_in_group("CanvasPreviews"): + canvas_preview.get_viewport().get_node("TransparentChecker").update_rect() material.set_shader_parameter("size", Global.checker_size) material.set_shader_parameter("color1", Global.checker_color_1) material.set_shader_parameter("color2", Global.checker_color_2) diff --git a/src/UI/UI.tscn b/src/UI/UI.tscn index c6b892717..c4406b0c2 100644 --- a/src/UI/UI.tscn +++ b/src/UI/UI.tscn @@ -359,7 +359,7 @@ render_target_update_mode = 0 material = SubResource("3") anchors_preset = 0 -[node name="CanvasPreview" parent="DockableContainer/Second Canvas/SubViewport" instance=ExtResource("2")] +[node name="CanvasPreview" parent="DockableContainer/Second Canvas/SubViewport" groups=["CanvasPreviews"] instance=ExtResource("2")] [node name="Camera2D2" type="Node2D" parent="DockableContainer/Second Canvas/SubViewport" groups=["CanvasCameras"]] script = ExtResource("7")