mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-08-11 12:34:43 -04:00
Cache tile mode rects (#443)
* Cache tile mode rects * Make TransparentChecker don't calculate tile mode rect on its own * Minor fixes - typo - formatting - moved unlock() call to the method where matching lock() was called
This commit is contained in:
parent
4db21dae95
commit
4001a32f2b
4 changed files with 23 additions and 32 deletions
|
@ -284,7 +284,7 @@ func view_menu_id_pressed(id : int) -> void:
|
|||
|
||||
func tile_mode_submenu_id_pressed(id : int) -> void:
|
||||
Global.current_project.tile_mode = id
|
||||
Global.transparent_checker._init_position(id)
|
||||
Global.transparent_checker.fit_rect(Global.current_project.get_tile_mode_rect())
|
||||
for i in Global.TileMode.values():
|
||||
Global.tile_mode_submenu.set_item_checked(i, i == id)
|
||||
Global.canvas.tile_mode.update()
|
||||
|
|
|
@ -3,7 +3,8 @@ extends ColorRect
|
|||
|
||||
func _ready() -> void:
|
||||
rect_size = Global.current_project.size
|
||||
if get_parent().get_parent() == Global.main_viewport:
|
||||
if self == Global.transparent_checker:
|
||||
fit_rect(Global.current_project.get_tile_mode_rect())
|
||||
Global.second_viewport.get_node("Viewport/TransparentChecker")._ready()
|
||||
Global.small_preview_viewport.get_node("Viewport/TransparentChecker")._ready()
|
||||
material.set_shader_param("size", Global.checker_size)
|
||||
|
@ -11,7 +12,6 @@ func _ready() -> void:
|
|||
material.set_shader_param("color2", Global.checker_color_2)
|
||||
material.set_shader_param("follow_movement", Global.checker_follow_movement)
|
||||
material.set_shader_param("follow_scale", Global.checker_follow_scale)
|
||||
_init_position(Global.current_project.tile_mode)
|
||||
|
||||
|
||||
func update_offset(offset : Vector2, scale : Vector2) -> void:
|
||||
|
@ -23,17 +23,6 @@ func _on_TransparentChecker_resized() -> void:
|
|||
material.set_shader_param("rect_size", rect_size)
|
||||
|
||||
|
||||
func _init_position(tile_mode : int) -> void:
|
||||
match tile_mode:
|
||||
Global.TileMode.NONE:
|
||||
Global.transparent_checker.set_size(Global.current_project.size)
|
||||
Global.transparent_checker.set_position(Vector2.ZERO)
|
||||
Global.TileMode.BOTH:
|
||||
Global.transparent_checker.set_size(Global.current_project.size*3)
|
||||
Global.transparent_checker.set_position(-Global.current_project.size)
|
||||
Global.TileMode.X_AXIS:
|
||||
Global.transparent_checker.set_size(Vector2(Global.current_project.size.x*3, Global.current_project.size.y*1))
|
||||
Global.transparent_checker.set_position(Vector2(-Global.current_project.size.x, 0))
|
||||
Global.TileMode.Y_AXIS:
|
||||
Global.transparent_checker.set_size(Vector2(Global.current_project.size.x*1, Global.current_project.size.y*3))
|
||||
Global.transparent_checker.set_position(Vector2(0, -Global.current_project.size.y))
|
||||
func fit_rect(rect : Rect2) -> void:
|
||||
rect_position = rect.position
|
||||
rect_size = rect.size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue