mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Fix issue where sometimes the camera zoom was not being preserved when switching between projects
This commit is contained in:
parent
10e457bf26
commit
dbe48a4681
|
@ -100,7 +100,6 @@ func _input(event: InputEvent) -> void:
|
||||||
func camera_zoom() -> void:
|
func camera_zoom() -> void:
|
||||||
for camera in Global.cameras:
|
for camera in Global.cameras:
|
||||||
camera.fit_to_frame(Global.current_project.size)
|
camera.fit_to_frame(Global.current_project.size)
|
||||||
camera.save_values_to_project()
|
|
||||||
|
|
||||||
Global.transparent_checker.update_rect()
|
Global.transparent_checker.update_rect()
|
||||||
|
|
||||||
|
|
|
@ -14,18 +14,21 @@ const CAMERA_SPEED_RATE := 15.0
|
||||||
var zoom := Vector2.ONE:
|
var zoom := Vector2.ONE:
|
||||||
set(value):
|
set(value):
|
||||||
zoom = value
|
zoom = value
|
||||||
|
Global.current_project.cameras_zoom[index] = zoom
|
||||||
zoom_changed.emit()
|
zoom_changed.emit()
|
||||||
_update_viewport_transform()
|
_update_viewport_transform()
|
||||||
var camera_angle := 0.0:
|
var camera_angle := 0.0:
|
||||||
set(value):
|
set(value):
|
||||||
camera_angle = wrapf(value, -PI, PI)
|
camera_angle = wrapf(value, -PI, PI)
|
||||||
camera_angle_degrees = rad_to_deg(camera_angle)
|
camera_angle_degrees = rad_to_deg(camera_angle)
|
||||||
|
Global.current_project.cameras_rotation[index] = camera_angle
|
||||||
rotation_changed.emit()
|
rotation_changed.emit()
|
||||||
_update_viewport_transform()
|
_update_viewport_transform()
|
||||||
var camera_angle_degrees := 0.0
|
var camera_angle_degrees := 0.0
|
||||||
var offset := Vector2.ZERO:
|
var offset := Vector2.ZERO:
|
||||||
set(value):
|
set(value):
|
||||||
offset = value
|
offset = value
|
||||||
|
Global.current_project.cameras_offset[index] = offset
|
||||||
offset_changed.emit()
|
offset_changed.emit()
|
||||||
_update_viewport_transform()
|
_update_viewport_transform()
|
||||||
var camera_screen_center := Vector2.ZERO
|
var camera_screen_center := Vector2.ZERO
|
||||||
|
@ -89,9 +92,7 @@ func _input(event: InputEvent) -> void:
|
||||||
else:
|
else:
|
||||||
var dir := Input.get_vector(&"camera_left", &"camera_right", &"camera_up", &"camera_down")
|
var dir := Input.get_vector(&"camera_left", &"camera_right", &"camera_up", &"camera_down")
|
||||||
if dir != Vector2.ZERO and !_has_selection_tool():
|
if dir != Vector2.ZERO and !_has_selection_tool():
|
||||||
offset += (dir.rotated(camera_angle) / zoom) * CAMERA_SPEED_RATE
|
offset = offset + (dir.rotated(camera_angle) / zoom) * CAMERA_SPEED_RATE
|
||||||
|
|
||||||
save_values_to_project()
|
|
||||||
|
|
||||||
|
|
||||||
func zoom_camera(dir: int) -> void:
|
func zoom_camera(dir: int) -> void:
|
||||||
|
@ -181,12 +182,6 @@ func fit_to_frame(size: Vector2) -> void:
|
||||||
Global.integer_zoom = !Global.integer_zoom
|
Global.integer_zoom = !Global.integer_zoom
|
||||||
|
|
||||||
|
|
||||||
func save_values_to_project() -> void:
|
|
||||||
Global.current_project.cameras_rotation[index] = camera_angle
|
|
||||||
Global.current_project.cameras_zoom[index] = zoom
|
|
||||||
Global.current_project.cameras_offset[index] = offset
|
|
||||||
|
|
||||||
|
|
||||||
func update_transparent_checker_offset() -> void:
|
func update_transparent_checker_offset() -> void:
|
||||||
var o := get_global_transform_with_canvas().get_origin()
|
var o := get_global_transform_with_canvas().get_origin()
|
||||||
var s := get_global_transform_with_canvas().get_scale()
|
var s := get_global_transform_with_canvas().get_scale()
|
||||||
|
@ -256,9 +251,9 @@ func _has_selection_tool() -> bool:
|
||||||
|
|
||||||
|
|
||||||
func _project_switched() -> void:
|
func _project_switched() -> void:
|
||||||
|
offset = Global.current_project.cameras_offset[index]
|
||||||
camera_angle = Global.current_project.cameras_rotation[index]
|
camera_angle = Global.current_project.cameras_rotation[index]
|
||||||
zoom = Global.current_project.cameras_zoom[index]
|
zoom = Global.current_project.cameras_zoom[index]
|
||||||
offset = Global.current_project.cameras_offset[index]
|
|
||||||
|
|
||||||
|
|
||||||
func _rotate_camera_around_point(degrees: float, point: Vector2) -> void:
|
func _rotate_camera_around_point(degrees: float, point: Vector2) -> void:
|
||||||
|
|
|
@ -18,7 +18,6 @@ func _zoom_changed() -> void:
|
||||||
|
|
||||||
func _on_PreviewZoomSlider_value_changed(value: float) -> void:
|
func _on_PreviewZoomSlider_value_changed(value: float) -> void:
|
||||||
camera.zoom = Vector2(value, value)
|
camera.zoom = Vector2(value, value)
|
||||||
camera.save_values_to_project()
|
|
||||||
camera.update_transparent_checker_offset()
|
camera.update_transparent_checker_offset()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue