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

Handiling tile modes in each project (#388)

* Handiling tile modes in each project

Co-authored-by: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com>
This commit is contained in:
AbhinavKDev 2020-11-24 22:23:18 +05:30 committed by GitHub
parent d7008362b5
commit 96454a2d57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 12 deletions

View file

@ -74,7 +74,6 @@ var left_square_indicator_visible := true
var right_square_indicator_visible := false
# View menu options
var tile_mode : int = Tile_Mode.NONE
var mirror_view := false
var draw_grid := false
var show_rulers := true

View file

@ -5,6 +5,7 @@ class_name Project extends Reference
var name := "" setget name_changed
var size : Vector2 setget size_changed
var undo_redo : UndoRedo
var tile_mode : int = Global.Tile_Mode.NONE
var undos := 0 # The number of times we added undo properties
var has_changed := false setget has_changed_changed
var frames := [] setget frames_changed # Array of Frames (that contain Cels)

View file

@ -82,7 +82,7 @@ func _get_draw_rect() -> Rect2:
func _get_tile_mode_rect() -> Rect2:
match Global.tile_mode:
match Global.current_project.tile_mode:
Global.Tile_Mode.XAXIS:
return Rect2(Vector2(-Global.current_project.size.x,0), Vector2(Global.current_project.size.x * 3,Global.current_project.size.y))
Global.Tile_Mode.YAXIS:

View file

@ -305,7 +305,7 @@ func draw_tool_brush(position : Vector2) -> void:
func draw_indicator() -> void:
draw_indicator_at(_cursor, Vector2.ZERO, Color.blue)
if Global.tile_mode and _get_tile_mode_rect().has_point(_cursor):
if Global.current_project.tile_mode and _get_tile_mode_rect().has_point(_cursor):
var tile := _line_start if _draw_line else _cursor
if not tile in Global.current_project.selected_pixels:
var offset := tile - tile.posmodv(Global.current_project.size)
@ -336,8 +336,7 @@ func _set_pixel(position : Vector2) -> void:
var project : Project = Global.current_project
if Global.mirror_view:
position.x = project.size.x - position.x - 1
if Global.tile_mode and _get_tile_mode_rect().has_point(position):
if Global.current_project.tile_mode and _get_tile_mode_rect().has_point(position):
position = position.posmodv(project.size)
var entire_image_selected : bool = project.selected_pixels.size() == project.size.x * project.size.y

View file

@ -20,7 +20,7 @@ func _draw() -> void:
for i in range(Global.current_project.layers.size()):
var modulate_color := Color(1, 1, 1, current_cels[i].opacity - tilemode_opacity)
if Global.current_project.layers[i].visible: # if it's visible
if Global.tile_mode:
if Global.current_project.tile_mode:
for pos in positions:
draw_texture(current_cels[i].image_texture, pos, modulate_color)
@ -28,7 +28,7 @@ func _draw() -> void:
func get_tile_positions(size):
match Global.tile_mode:
match Global.current_project.tile_mode:
1:
return [
Vector2(location.x, location.y + size.y), # Down

View file

@ -11,7 +11,7 @@ func _ready() -> void:
material.set_shader_param("color2", Global.checker_color_2)
material.set_shader_param("follow_movement", Global.checker_follow_movement)
material.set_shader_param("follow_scale", Global.checker_follow_scale)
_init_position(Global.tile_mode)
_init_position(Global.current_project.tile_mode)
func update_offset(offset : Vector2, scale : Vector2) -> void:
@ -26,18 +26,18 @@ func _on_TransparentChecker_resized():
func _init_position(id : int):
match id:
0:
Global.tile_mode = Global.Tile_Mode.NONE
Global.current_project.tile_mode = Global.Tile_Mode.NONE
Global.transparent_checker.set_size(Global.current_project.size)
Global.transparent_checker.set_position(Vector2.ZERO)
1:
Global.tile_mode = Global.Tile_Mode.BOTH
Global.current_project.tile_mode = Global.Tile_Mode.BOTH
Global.transparent_checker.set_size(Global.current_project.size*3)
Global.transparent_checker.set_position(-Global.current_project.size)
2:
Global.tile_mode = Global.Tile_Mode.XAXIS
Global.current_project.tile_mode = Global.Tile_Mode.XAXIS
Global.transparent_checker.set_size(Vector2(Global.current_project.size.x*3, Global.current_project.size.y*1))
Global.transparent_checker.set_position(Vector2(-Global.current_project.size.x, 0))
3:
Global.tile_mode = Global.Tile_Mode.YAXIS
Global.current_project.tile_mode = Global.Tile_Mode.YAXIS
Global.transparent_checker.set_size(Vector2(Global.current_project.size.x*1, Global.current_project.size.y*3))
Global.transparent_checker.set_position(Vector2(0, -Global.current_project.size.y))