1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Moved canvas indicator drawing to a new script

Cursor indicators now appear on top of the grid again
This commit is contained in:
OverloadedOrama 2020-08-18 16:35:05 +03:00
parent 92332cc52e
commit f2136236b1
4 changed files with 19 additions and 6 deletions

View file

@ -308,7 +308,7 @@ func draw_indicator() -> void:
func draw_indicator_at(position : Vector2, offset : Vector2, color : Color) -> void: func draw_indicator_at(position : Vector2, offset : Vector2, color : Color) -> void:
var canvas = Global.canvas var canvas = Global.canvas.indicators
if _brush.type in [Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM] and not _draw_line: if _brush.type in [Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM] and not _draw_line:
position -= (_brush_image.get_size() / 2).floor() position -= (_brush_image.get_size() / 2).floor()
position -= offset position -= offset

View file

@ -10,6 +10,7 @@ var cursor_image_has_changed := false
var sprite_changed_this_frame := false # for optimization purposes var sprite_changed_this_frame := false # for optimization purposes
onready var grid = $Grid onready var grid = $Grid
onready var indicators = $Indicators
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
@ -44,10 +45,6 @@ func _draw() -> void:
draw_texture(current_cels[i].image_texture, Vector2(location.x + size.x, location.y), modulate_color) # Right draw_texture(current_cels[i].image_texture, Vector2(location.x + size.x, location.y), modulate_color) # Right
draw_texture(current_cels[i].image_texture, location + size, modulate_color) # Down right draw_texture(current_cels[i].image_texture, location + size, modulate_color) # Down right
# Draw rectangle to indicate the pixel currently being hovered on
if Global.has_focus and Global.can_draw:
Tools.draw_indicator()
func _input(event : InputEvent) -> void: func _input(event : InputEvent) -> void:
# Don't process anything below if the input isn't a mouse event, or Shift/Ctrl. # Don't process anything below if the input isn't a mouse event, or Shift/Ctrl.

View file

@ -1,10 +1,14 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://src/UI/Canvas/Canvas.gd" type="Script" id=1] [ext_resource path="res://src/UI/Canvas/Canvas.gd" type="Script" id=1]
[ext_resource path="res://src/UI/Canvas/Grid.gd" type="Script" id=2] [ext_resource path="res://src/UI/Canvas/Grid.gd" type="Script" id=2]
[ext_resource path="res://src/UI/Canvas/Indicators.gd" type="Script" id=3]
[node name="Canvas" type="Node2D"] [node name="Canvas" type="Node2D"]
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="Grid" type="Node2D" parent="."] [node name="Grid" type="Node2D" parent="."]
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="Indicators" type="Node2D" parent="."]
script = ExtResource( 3 )

View file

@ -0,0 +1,12 @@
extends Node2D
func _input(event : InputEvent) -> void:
if Global.has_focus and event is InputEventMouseMotion:
update()
func _draw() -> void:
# Draw rectangle to indicate the pixel currently being hovered on
if Global.has_focus and Global.can_draw:
Tools.draw_indicator()