diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bfcba1c5..793c961be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ Kawan Weege ([@DragonOfWar](https://github.com/DragonOfWar)), Martin Novák ([@n - Changed pixel grid shortcut on macOS because it conflicted with a system hotkey. [#494](https://github.com/Orama-Interactive/Pixelorama/pull/494) - The shading tool now has correct Hue, Saturation and Value changes, as well as some other tweaks, like limiting the darkening hue to 240 instead of 270. [#519](https://github.com/Orama-Interactive/Pixelorama/pull/519) and [#522](https://github.com/Orama-Interactive/Pixelorama/pull/522) - The disabled buttons on the light theme are no longer invisible. [#518](https://github.com/Orama-Interactive/Pixelorama/issues/518) +- Fix the canvas preview having incorrect zoom when switching between projects.

## [v0.8.3] - 2021-05-04 diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 546619285..cc73e951d 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -125,6 +125,7 @@ var tabs : Tabs var main_viewport : ViewportContainer var second_viewport : ViewportContainer var small_preview_viewport : ViewportContainer +var canvas_preview_container : Container var camera : Camera2D var camera2 : Camera2D var camera_preview : Camera2D @@ -223,7 +224,8 @@ func _ready() -> void: tabs = control.find_node("Tabs") main_viewport = control.find_node("ViewportContainer") second_viewport = control.find_node("ViewportContainer2") - small_preview_viewport = control.find_node("PreviewViewportContainer") + canvas_preview_container = control.find_node("CanvasPreviewContainer") + small_preview_viewport = canvas_preview_container.find_node("PreviewViewportContainer") camera = main_viewport.find_node("Camera2D") camera2 = control.find_node("Camera2D2") camera_preview = control.find_node("CameraPreview") diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index bd0fe7220..caaf10c4b 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -32,6 +32,7 @@ var has_selection := false # For every camera (currently there are 3) var cameras_zoom := [Vector2(0.15, 0.15), Vector2(0.15, 0.15), Vector2(0.15, 0.15)] # Array of Vector2 var cameras_offset := [Vector2.ZERO, Vector2.ZERO, Vector2.ZERO] # Array of Vector2 +var cameras_zoom_max := [Vector2.ONE, Vector2.ONE, Vector2.ONE] # Array of Vector2 # Export directory path and export file name var directory_path := "" @@ -228,6 +229,12 @@ func change_project() -> void: var i := 0 for camera in [Global.camera, Global.camera2, Global.camera_preview]: + camera.zoom_max = cameras_zoom_max[i] + if camera == Global.camera_preview: + Global.preview_zoom_slider.disconnect("value_changed", Global.canvas_preview_container, "_on_PreviewZoomSlider_value_changed") + Global.preview_zoom_slider.min_value = -camera.zoom_max.x + Global.preview_zoom_slider.connect("value_changed", Global.canvas_preview_container, "_on_PreviewZoomSlider_value_changed") + camera.zoom = cameras_zoom[i] camera.offset = cameras_offset[i] camera.zoom_changed() diff --git a/src/UI/Canvas/CameraMovement.gd b/src/UI/Canvas/CameraMovement.gd index 00dc0856b..86915bd92 100644 --- a/src/UI/Canvas/CameraMovement.gd +++ b/src/UI/Canvas/CameraMovement.gd @@ -273,9 +273,12 @@ func save_values_to_project() -> void: if name == "Camera2D": Global.current_project.cameras_zoom[0] = zoom Global.current_project.cameras_offset[0] = offset + Global.current_project.cameras_zoom_max[0] = zoom_max elif name == "Camera2D2": Global.current_project.cameras_zoom[1] = zoom Global.current_project.cameras_offset[1] = offset + Global.current_project.cameras_zoom_max[1] = zoom_max elif name == "CameraPreview": Global.current_project.cameras_zoom[2] = zoom Global.current_project.cameras_offset[2] = offset + Global.current_project.cameras_zoom_max[2] = zoom_max