mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-07-14 22:54:42 -04:00
Use enums instead of strings for tools
This could be a slight increase in performance
This commit is contained in:
parent
bda9e6267d
commit
5b7d161ecf
6 changed files with 71 additions and 72 deletions
|
@ -34,10 +34,10 @@ func _process(_delta : float) -> void:
|
|||
else:
|
||||
visible = true
|
||||
|
||||
if Global.can_draw and Global.has_focus and point_in_rectangle(mouse_pos, polygon[0], polygon[2]) and Global.selected_pixels.size() > 0 and (Global.current_left_tool == "RectSelect" or Global.current_right_tool == "RectSelect"):
|
||||
if Global.can_draw and Global.has_focus and point_in_rectangle(mouse_pos, polygon[0], polygon[2]) and Global.selected_pixels.size() > 0 and (Global.current_left_tool == Global.Tools.RECTSELECT or Global.current_right_tool == Global.Tools.RECTSELECT):
|
||||
get_parent().get_parent().mouse_default_cursor_shape = Input.CURSOR_MOVE
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
if (Global.current_left_tool == "RectSelect" && Input.is_action_just_pressed("left_mouse")) || (Global.current_right_tool == "RectSelect" && Input.is_action_just_pressed("right_mouse")):
|
||||
if (Global.current_left_tool == Global.Tools.RECTSELECT && Input.is_action_just_pressed("left_mouse")) || (Global.current_right_tool == Global.Tools.RECTSELECT && Input.is_action_just_pressed("right_mouse")):
|
||||
# Begin dragging
|
||||
is_dragging = true
|
||||
if Input.is_key_pressed(KEY_SHIFT):
|
||||
|
@ -72,7 +72,7 @@ func _process(_delta : float) -> void:
|
|||
get_parent().get_parent().mouse_default_cursor_shape = Input.CURSOR_ARROW
|
||||
|
||||
if is_dragging:
|
||||
if (Global.current_left_tool == "RectSelect" && Input.is_action_pressed("left_mouse")) || (Global.current_right_tool == "RectSelect" && Input.is_action_pressed("right_mouse")):
|
||||
if (Global.current_left_tool == Global.Tools.RECTSELECT && Input.is_action_pressed("left_mouse")) || (Global.current_right_tool == Global.Tools.RECTSELECT && Input.is_action_pressed("right_mouse")):
|
||||
# Drag
|
||||
start_pos.x = orig_x + mouse_pos_floored.x
|
||||
end_pos.x = diff_x + mouse_pos_floored.x
|
||||
|
@ -84,7 +84,7 @@ func _process(_delta : float) -> void:
|
|||
polygon[2] = end_pos
|
||||
polygon[3] = Vector2(start_pos.x, end_pos.y)
|
||||
|
||||
if (Global.current_left_tool == "RectSelect" && Input.is_action_just_released("left_mouse")) || (Global.current_right_tool == "RectSelect" && Input.is_action_just_released("right_mouse")):
|
||||
if (Global.current_left_tool == Global.Tools.RECTSELECT && Input.is_action_just_released("left_mouse")) || (Global.current_right_tool == Global.Tools.RECTSELECT && Input.is_action_just_released("right_mouse")):
|
||||
# Release Drag
|
||||
is_dragging = false
|
||||
if move_pixels:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue