mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-26 03:14:42 -04:00
Minor guide and rulers performance boost
Got rid of their _process methods, Guides have input instead, and the rulers get updated when the camera zoom or offset change.
This commit is contained in:
parent
06d19c8e48
commit
b21455cfd0
6 changed files with 34 additions and 30 deletions
|
@ -9,22 +9,12 @@ var minor_subdivision := 4
|
|||
var first : Vector2
|
||||
var last : Vector2
|
||||
|
||||
onready var _prev_camera_offset: Vector2 = Global.camera.offset
|
||||
onready var _prev_camera_zoom: Vector2 = Global.camera.zoom
|
||||
|
||||
func _ready() -> void:
|
||||
Global.main_viewport.connect("item_rect_changed", self, "update")
|
||||
|
||||
# warning-ignore:unused_argument
|
||||
func _process(delta : float) -> void:
|
||||
if Global.camera.offset != _prev_camera_offset:
|
||||
_prev_camera_offset = Global.camera.offset
|
||||
update()
|
||||
if Global.camera.zoom != _prev_camera_zoom:
|
||||
_prev_camera_zoom = Global.camera.zoom
|
||||
update()
|
||||
|
||||
#Code taken and modified from Godot's source code
|
||||
# Code taken and modified from Godot's source code
|
||||
func _draw() -> void:
|
||||
var transform := Transform2D()
|
||||
var ruler_transform := Transform2D()
|
||||
|
@ -68,6 +58,7 @@ func _draw() -> void:
|
|||
else:
|
||||
draw_line(Vector2(RULER_WIDTH * 0.66, position.y), Vector2(RULER_WIDTH, position.y), Color.white)
|
||||
|
||||
|
||||
func _on_VerticalRuler_pressed() -> void:
|
||||
if !Global.show_guides:
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue