|
@@ -13,27 +13,27 @@ signal ended
|
|
|
@export var move_trans: Tween.TransitionType = Tween.TRANS_SINE
|
|
|
@export var move_ease: Tween.EaseType = Tween.EASE_IN_OUT
|
|
|
|
|
|
-@export_group("Zoom", "zoom_")
|
|
|
-@export var zoom_duration: float = 1.0
|
|
|
-@export var zoom_trans: Tween.TransitionType = Tween.TRANS_SINE
|
|
|
-@export var zoom_closer_ease: Tween.EaseType = Tween.EASE_IN
|
|
|
-@export var zoom_wider_ease: Tween.EaseType = Tween.EASE_OUT
|
|
|
+@export_group("Scope", "scope_")
|
|
|
+@export var scope_duration: float = 1.0
|
|
|
+@export var scope_trans: Tween.TransitionType = Tween.TRANS_SINE
|
|
|
+@export var scope_closer_ease: Tween.EaseType = Tween.EASE_IN
|
|
|
+@export var scope_wider_ease: Tween.EaseType = Tween.EASE_OUT
|
|
|
|
|
|
var tween: Tween
|
|
|
+var scope: Vector2 : get = get_scope, set = set_scope
|
|
|
|
|
|
|
|
|
-func focus_on(pos: Vector2, scope: float) -> void:
|
|
|
+func focus_on(pos: Vector2, scalar_scale: float) -> void:
|
|
|
if tween:
|
|
|
tween.kill()
|
|
|
|
|
|
- var target_zoom = Vector2.ONE / scope
|
|
|
- var is_wider = target_zoom.x < get_zoom().x
|
|
|
- var min_zoom = target_zoom if is_wider else get_zoom()
|
|
|
- var zoom_ease = zoom_wider_ease if is_wider else zoom_closer_ease
|
|
|
+ var target_scope = Vector2.ONE * scalar_scale
|
|
|
+ var is_wider = target_scope.x > get_scope().x
|
|
|
+ var scope_ease = scope_wider_ease if is_wider else scope_closer_ease
|
|
|
|
|
|
tween = create_tween().set_parallel(tween_is_parallel)
|
|
|
tween.tween_property(self, "position", pos, move_duration).set_trans(move_trans).set_ease(move_ease)
|
|
|
- tween.tween_property(self, "zoom", target_zoom, zoom_duration).set_trans(zoom_trans).set_ease(zoom_ease)
|
|
|
+ tween.tween_property(self, "scope", target_scope, scope_duration).set_trans(scope_trans).set_ease(scope_ease)
|
|
|
tween.tween_callback(end)
|
|
|
|
|
|
|
|
@@ -41,5 +41,19 @@ func end():
|
|
|
ended.emit()
|
|
|
|
|
|
|
|
|
-func _on_show_new_focus(pos: Vector2, scope: float) -> void:
|
|
|
- focus_on(pos, scope)
|
|
|
+func get_scope() -> Vector2:
|
|
|
+ return _invert_vector(get_zoom())
|
|
|
+
|
|
|
+
|
|
|
+func set_scope(new_scope: Vector2) -> void:
|
|
|
+ assert(new_scope.x > 0)
|
|
|
+ assert(new_scope.y > 0)
|
|
|
+ set_zoom(_invert_vector(new_scope))
|
|
|
+
|
|
|
+
|
|
|
+func _on_show_new_focus(pos: Vector2, scalar_scale: float) -> void:
|
|
|
+ focus_on(pos, scalar_scale)
|
|
|
+
|
|
|
+
|
|
|
+func _invert_vector(vec: Vector2) -> Vector2:
|
|
|
+ return Vector2(1.0 / vec.x, 1.0 / vec.y)
|