mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-30 23:19:49 +00:00
Replace Tweens with SceneTreeTweens
Futureproofing for easier porting to Godot 4.0, and reducing lines of code in the process ;)
This commit is contained in:
parent
d989af77f9
commit
8a8e6929b9
|
@ -495,11 +495,8 @@ func dialog_open(open: bool) -> void:
|
|||
else:
|
||||
can_draw = true
|
||||
|
||||
control.get_node("ModulateTween").interpolate_property(
|
||||
control, "modulate", control.modulate, dim_color, 0.1, Tween.TRANS_LINEAR, Tween.EASE_OUT
|
||||
)
|
||||
|
||||
control.get_node("ModulateTween").start()
|
||||
var tween := create_tween().set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_OUT)
|
||||
tween.tween_property(control, "modulate", dim_color, 0.1)
|
||||
|
||||
|
||||
func disable_button(button: BaseButton, disable: bool) -> void:
|
||||
|
|
|
@ -137,8 +137,6 @@ visible = false
|
|||
[node name="RightCursor" type="Sprite" parent="."]
|
||||
visible = false
|
||||
|
||||
[node name="ModulateTween" type="Tween" parent="."]
|
||||
|
||||
[connection signal="popup_hide" from="Dialogs/SplashDialog" to="." method="_can_draw_true"]
|
||||
[connection signal="popup_hide" from="Dialogs/CreateNewImage" to="." method="_can_draw_true"]
|
||||
[connection signal="files_selected" from="Dialogs/OpenSprite" to="." method="_on_OpenSprite_files_selected"]
|
||||
|
|
|
@ -5,7 +5,6 @@ enum Cameras { MAIN, SECOND, SMALL }
|
|||
const KEY_MOVE_ACTION_NAMES := ["camera_left", "camera_right", "camera_up", "camera_down"]
|
||||
const CAMERA_SPEED_RATE := 15.0
|
||||
|
||||
var tween: Tween
|
||||
var zoom_min := Vector2(0.005, 0.005)
|
||||
var zoom_max := Vector2.ONE
|
||||
var viewport_container: ViewportContainer
|
||||
|
@ -19,9 +18,6 @@ func _ready() -> void:
|
|||
rotating = true
|
||||
viewport_container = get_parent().get_parent()
|
||||
transparent_checker = get_parent().get_node("TransparentChecker")
|
||||
tween = Tween.new()
|
||||
add_child(tween)
|
||||
tween.connect("tween_step", self, "_on_tween_step")
|
||||
update_transparent_checker_offset()
|
||||
|
||||
# signals regarding rotation stats
|
||||
|
@ -180,13 +176,11 @@ func zoom_camera(dir: int) -> void:
|
|||
offset
|
||||
+ (-0.5 * viewport_size + mouse_pos).rotated(rotation) * (zoom - new_zoom)
|
||||
)
|
||||
tween.interpolate_property(
|
||||
self, "zoom", zoom, new_zoom, 0.05, Tween.TRANS_LINEAR, Tween.EASE_IN
|
||||
)
|
||||
tween.interpolate_property(
|
||||
self, "offset", offset, new_offset, 0.05, Tween.TRANS_LINEAR, Tween.EASE_IN
|
||||
)
|
||||
tween.start()
|
||||
var tween := create_tween().set_parallel()
|
||||
tween.set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_IN)
|
||||
tween.connect("step_finished", self, "_on_tween_step")
|
||||
tween.tween_property(self, "zoom", new_zoom, 0.05)
|
||||
tween.tween_property(self, "offset", new_offset, 0.05)
|
||||
|
||||
else:
|
||||
var prev_zoom := zoom
|
||||
|
@ -205,10 +199,9 @@ func zoom_camera_percent(value: float) -> void:
|
|||
var percent: float = 100.0 / value
|
||||
var new_zoom = Vector2(percent, percent)
|
||||
if Global.smooth_zoom:
|
||||
tween.interpolate_property(
|
||||
self, "zoom", zoom, new_zoom, 0.05, Tween.TRANS_LINEAR, Tween.EASE_IN
|
||||
)
|
||||
tween.start()
|
||||
var tween := create_tween().set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_IN)
|
||||
tween.connect("step_finished", self, "_on_tween_step")
|
||||
tween.tween_property(self, "zoom", new_zoom, 0.05)
|
||||
else:
|
||||
zoom = new_zoom
|
||||
zoom_changed()
|
||||
|
@ -234,7 +227,7 @@ func _update_rulers() -> void:
|
|||
Global.vertical_ruler.update()
|
||||
|
||||
|
||||
func _on_tween_step(_object: Object, _key: NodePath, _elapsed: float, _value: Object) -> void:
|
||||
func _on_tween_step(_idx: int) -> void:
|
||||
zoom_changed()
|
||||
|
||||
|
||||
|
|
|
@ -2,26 +2,9 @@ extends Label
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
var tween := $Tween
|
||||
tween.interpolate_property(
|
||||
self,
|
||||
"rect_position",
|
||||
rect_position,
|
||||
Vector2(rect_position.x, rect_position.y - 100),
|
||||
1,
|
||||
Tween.TRANS_LINEAR,
|
||||
Tween.EASE_OUT
|
||||
)
|
||||
tween.interpolate_property(
|
||||
self,
|
||||
"modulate",
|
||||
modulate,
|
||||
Color(modulate.r, modulate.g, modulate.b, 0),
|
||||
1,
|
||||
Tween.TRANS_LINEAR,
|
||||
Tween.EASE_OUT
|
||||
)
|
||||
tween.start()
|
||||
var tw := create_tween().set_parallel().set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_OUT)
|
||||
tw.tween_property(self, "rect_position", Vector2(rect_position.x, rect_position.y - 100), 1)
|
||||
tw.tween_property(self, "modulate", Color(modulate.r, modulate.g, modulate.b, 0), 1)
|
||||
|
||||
|
||||
func _on_Timer_timeout() -> void:
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
[ext_resource path="res://src/UI/NotificationLabel.gd" type="Script" id=2]
|
||||
|
||||
|
||||
|
||||
[node name="NotificationLabel" type="Label"]
|
||||
margin_right = 116.0
|
||||
margin_bottom = 14.0
|
||||
|
@ -14,9 +12,8 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Tween" type="Tween" parent="."]
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
autostart = true
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
|
|
Loading…
Reference in a new issue