mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-30 23:19: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:
parent
92332cc52e
commit
f2136236b1
|
@ -308,7 +308,7 @@ func draw_indicator() -> 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:
|
||||
position -= (_brush_image.get_size() / 2).floor()
|
||||
position -= offset
|
||||
|
|
|
@ -10,6 +10,7 @@ var cursor_image_has_changed := false
|
|||
var sprite_changed_this_frame := false # for optimization purposes
|
||||
|
||||
onready var grid = $Grid
|
||||
onready var indicators = $Indicators
|
||||
|
||||
|
||||
# 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, 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:
|
||||
# Don't process anything below if the input isn't a mouse event, or Shift/Ctrl.
|
||||
|
|
|
@ -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/Grid.gd" type="Script" id=2]
|
||||
[ext_resource path="res://src/UI/Canvas/Indicators.gd" type="Script" id=3]
|
||||
|
||||
[node name="Canvas" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Grid" type="Node2D" parent="."]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Indicators" type="Node2D" parent="."]
|
||||
script = ExtResource( 3 )
|
||||
|
|
12
src/UI/Canvas/Indicators.gd
Normal file
12
src/UI/Canvas/Indicators.gd
Normal 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()
|
Loading…
Reference in a new issue