2020-08-18 17:03:49 +03:00
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
|
|
|
|
func _draw() -> void:
|
|
|
|
var size : Vector2 = Global.current_project.size
|
2020-11-13 23:42:20 +05:30
|
|
|
var positions : Array = get_tile_positions(size)
|
2020-12-30 18:56:28 +01:00
|
|
|
var tilemode_opacity := Global.tilemode_opacity
|
2020-10-26 00:10:14 +01:00
|
|
|
|
2020-11-23 18:53:21 +02: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)
|
|
|
|
|
2021-01-04 18:30:15 +01:00
|
|
|
var modulate_color := Color(tilemode_opacity, tilemode_opacity, tilemode_opacity, tilemode_opacity) # premultiply alpha blending is applied
|
|
|
|
var current_frame_texture: Texture = Global.canvas.currently_visible_frame.get_texture()
|
|
|
|
for pos in positions:
|
|
|
|
draw_texture(current_frame_texture, pos, modulate_color)
|
2020-11-13 23:42:20 +05:30
|
|
|
|
2020-11-23 18:53:21 +02:00
|
|
|
draw_set_transform(position, rotation, scale)
|
|
|
|
|
2020-11-13 23:42:20 +05:30
|
|
|
|
|
|
|
func get_tile_positions(size):
|
2020-11-24 22:23:18 +05:30
|
|
|
match Global.current_project.tile_mode:
|
2021-01-20 15:59:42 +01:00
|
|
|
Global.TileMode.BOTH:
|
2020-11-13 23:42:20 +05:30
|
|
|
return [
|
2021-01-06 16:11:50 +01:00
|
|
|
Vector2(0, size.y), # Down
|
|
|
|
Vector2(-size.x, size.y), # Down left
|
|
|
|
Vector2(-size.x, 0), # Left
|
|
|
|
-size, # Up left
|
|
|
|
Vector2(0, -size.y), # Up
|
|
|
|
Vector2(size.x, -size.y), # Up right
|
|
|
|
Vector2(size.x, 0), # Right
|
|
|
|
size # Down right
|
2020-11-13 23:42:20 +05:30
|
|
|
]
|
2021-01-20 15:59:42 +01:00
|
|
|
Global.TileMode.X_AXIS:
|
2020-11-13 23:42:20 +05:30
|
|
|
return [
|
2021-01-06 16:11:50 +01:00
|
|
|
Vector2(size.x, 0), # Right
|
|
|
|
Vector2(-size.x, 0), # Left
|
2020-11-13 23:42:20 +05:30
|
|
|
]
|
2021-01-20 15:59:42 +01:00
|
|
|
Global.TileMode.Y_AXIS:
|
2020-11-13 23:42:20 +05:30
|
|
|
return [
|
2021-01-06 16:11:50 +01:00
|
|
|
Vector2(0, size.y), # Down
|
|
|
|
Vector2(0, -size.y), # Up
|
2020-11-13 23:42:20 +05:30
|
|
|
]
|
|
|
|
_:
|
|
|
|
return []
|