2020-08-18 14:03:49 +00:00
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
|
|
|
|
var location := Vector2.ZERO
|
|
|
|
|
|
|
|
|
|
|
|
func _draw() -> void:
|
|
|
|
var current_cels : Array = Global.current_project.frames[Global.current_project.current_frame].cels
|
|
|
|
var size : Vector2 = Global.current_project.size
|
2020-11-13 18:12:20 +00:00
|
|
|
var positions : Array = get_tile_positions(size)
|
2020-12-30 17:56:28 +00:00
|
|
|
var tilemode_opacity := Global.tilemode_opacity
|
2020-10-25 23:10:14 +00:00
|
|
|
|
2020-11-23 16:53:21 +00:00
|
|
|
var _position := position
|
|
|
|
var _scale := scale
|
|
|
|
if Global.mirror_view:
|
|
|
|
_position.x = _position.x + Global.current_project.size.x
|
|
|
|
_scale.x = -1
|
|
|
|
draw_set_transform(_position, rotation, _scale)
|
|
|
|
|
2020-08-18 14:03:49 +00:00
|
|
|
for i in range(Global.current_project.layers.size()):
|
2020-12-30 17:56:28 +00:00
|
|
|
var modulate_color := Color(1, 1, 1, current_cels[i].opacity * tilemode_opacity)
|
2020-08-18 14:03:49 +00:00
|
|
|
if Global.current_project.layers[i].visible: # if it's visible
|
2020-11-24 16:53:18 +00:00
|
|
|
if Global.current_project.tile_mode:
|
2020-08-18 14:03:49 +00:00
|
|
|
for pos in positions:
|
|
|
|
draw_texture(current_cels[i].image_texture, pos, modulate_color)
|
2020-11-13 18:12:20 +00:00
|
|
|
|
2020-11-23 16:53:21 +00:00
|
|
|
draw_set_transform(position, rotation, scale)
|
|
|
|
|
2020-11-13 18:12:20 +00:00
|
|
|
|
|
|
|
func get_tile_positions(size):
|
2020-11-24 16:53:18 +00:00
|
|
|
match Global.current_project.tile_mode:
|
2020-11-13 18:12:20 +00:00
|
|
|
1:
|
|
|
|
return [
|
|
|
|
Vector2(location.x, location.y + size.y), # Down
|
|
|
|
Vector2(location.x - size.x, location.y + size.y), # Down left
|
|
|
|
Vector2(location.x - size.x, location.y), # Left
|
|
|
|
location - size, # Up left
|
|
|
|
Vector2(location.x, location.y - size.y), # Up
|
|
|
|
Vector2(location.x + size.x, location.y - size.y), # Up right
|
|
|
|
Vector2(location.x + size.x, location.y), # Right
|
|
|
|
location + size # Down right
|
|
|
|
]
|
|
|
|
2:
|
|
|
|
return [
|
|
|
|
Vector2(location.x + size.x, location.y), # Right
|
|
|
|
Vector2(location.x - size.x, location.y), # Left
|
|
|
|
]
|
|
|
|
3:
|
|
|
|
return [
|
|
|
|
Vector2(location.x, location.y + size.y), # Down
|
|
|
|
Vector2(location.x, location.y - size.y), # Up
|
|
|
|
]
|
|
|
|
_:
|
|
|
|
return []
|