1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Move left and right cursor sprite nodes to Main.gd

This commit is contained in:
Emmanouil Papadeas 2022-08-24 14:22:40 +03:00
parent 615491052a
commit b9f0f0a647
4 changed files with 14 additions and 15 deletions

View file

@ -143,10 +143,8 @@ var palettes := {}
# Nodes
var notification_label_node: PackedScene = preload("res://src/UI/NotificationLabel.tscn")
onready var control: Node = get_tree().get_root().get_node("Control")
onready var control: Node = get_tree().current_scene
onready var left_cursor: Sprite = control.find_node("LeftCursor")
onready var right_cursor: Sprite = control.find_node("RightCursor")
onready var canvas: Canvas = control.find_node("Canvas")
onready var tabs: Tabs = control.find_node("Tabs")
onready var main_viewport: ViewportContainer = control.find_node("ViewportContainer")

View file

@ -232,9 +232,7 @@ func _ready() -> void:
if not tool_name in tools:
tool_name = "Eraser"
set_tool(tool_name, BUTTON_RIGHT)
update_tool_buttons()
update_tool_cursors()
horizontal_mirror = Global.config_cache.get_value("preferences", "horizontal_mirror", false)
vertical_mirror = Global.config_cache.get_value("preferences", "vertical_mirror", false)
@ -248,6 +246,7 @@ func _ready() -> void:
assign_color(color_value, BUTTON_LEFT, false)
color_value = Global.config_cache.get_value(_slots[BUTTON_RIGHT].kname, "color", Color.white)
assign_color(color_value, BUTTON_RIGHT, false)
update_tool_cursors()
func add_tool_button(t: Tool) -> void:
@ -351,9 +350,9 @@ func update_hint_tooltips() -> void:
func update_tool_cursors() -> void:
var left_tool: Tool = tools[_slots[BUTTON_LEFT].tool_node.name]
Global.left_cursor.texture = left_tool.cursor_icon
Global.control.left_cursor.texture = left_tool.cursor_icon
var right_tool: Tool = tools[_slots[BUTTON_RIGHT].tool_node.name]
Global.right_cursor.texture = right_tool.cursor_icon
Global.control.right_cursor.texture = right_tool.cursor_icon
func draw_indicator() -> void:

View file

@ -7,8 +7,10 @@ var cursor_image: Texture = preload("res://assets/graphics/cursor.png")
onready var ui := $MenuAndUI/UI/DockableContainer
onready var backup_confirmation: ConfirmationDialog = $Dialogs/BackupConfirmation
onready var quit_dialog: ConfirmationDialog = find_node("QuitDialog")
onready var quit_and_save_dialog: ConfirmationDialog = find_node("QuitAndSaveDialog")
onready var quit_dialog: ConfirmationDialog = $Dialogs/QuitDialog
onready var quit_and_save_dialog: ConfirmationDialog = $Dialogs/QuitAndSaveDialog
onready var left_cursor: Sprite = $LeftCursor
onready var right_cursor: Sprite = $RightCursor
func _init() -> void:
@ -78,8 +80,8 @@ func _ready() -> void:
func _input(event: InputEvent) -> void:
Global.left_cursor.position = get_global_mouse_position() + Vector2(-32, 32)
Global.right_cursor.position = get_global_mouse_position() + Vector2(32, 32)
left_cursor.position = get_global_mouse_position() + Vector2(-32, 32)
right_cursor.position = get_global_mouse_position() + Vector2(32, 32)
if event is InputEventKey and (event.scancode == KEY_ENTER or event.scancode == KEY_KP_ENTER):
if get_focus_owner() is LineEdit:

View file

@ -8,11 +8,11 @@ func _ready() -> void:
func _on_ViewportContainer_mouse_entered() -> void:
Global.has_focus = true
Global.left_cursor.visible = Global.show_left_tool_icon
Global.right_cursor.visible = Global.show_right_tool_icon
Global.control.left_cursor.visible = Global.show_left_tool_icon
Global.control.right_cursor.visible = Global.show_right_tool_icon
func _on_ViewportContainer_mouse_exited() -> void:
Global.has_focus = false
Global.left_cursor.visible = false
Global.right_cursor.visible = false
Global.control.left_cursor.visible = false
Global.control.right_cursor.visible = false