mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +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:
parent
d7008362b5
commit
96454a2d57
|
@ -74,7 +74,6 @@ var left_square_indicator_visible := true
|
||||||
var right_square_indicator_visible := false
|
var right_square_indicator_visible := false
|
||||||
|
|
||||||
# View menu options
|
# View menu options
|
||||||
var tile_mode : int = Tile_Mode.NONE
|
|
||||||
var mirror_view := false
|
var mirror_view := false
|
||||||
var draw_grid := false
|
var draw_grid := false
|
||||||
var show_rulers := true
|
var show_rulers := true
|
||||||
|
|
|
@ -5,6 +5,7 @@ class_name Project extends Reference
|
||||||
var name := "" setget name_changed
|
var name := "" setget name_changed
|
||||||
var size : Vector2 setget size_changed
|
var size : Vector2 setget size_changed
|
||||||
var undo_redo : UndoRedo
|
var undo_redo : UndoRedo
|
||||||
|
var tile_mode : int = Global.Tile_Mode.NONE
|
||||||
var undos := 0 # The number of times we added undo properties
|
var undos := 0 # The number of times we added undo properties
|
||||||
var has_changed := false setget has_changed_changed
|
var has_changed := false setget has_changed_changed
|
||||||
var frames := [] setget frames_changed # Array of Frames (that contain Cels)
|
var frames := [] setget frames_changed # Array of Frames (that contain Cels)
|
||||||
|
|
|
@ -82,7 +82,7 @@ func _get_draw_rect() -> Rect2:
|
||||||
|
|
||||||
|
|
||||||
func _get_tile_mode_rect() -> Rect2:
|
func _get_tile_mode_rect() -> Rect2:
|
||||||
match Global.tile_mode:
|
match Global.current_project.tile_mode:
|
||||||
Global.Tile_Mode.XAXIS:
|
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))
|
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:
|
Global.Tile_Mode.YAXIS:
|
||||||
|
|
|
@ -305,7 +305,7 @@ func draw_tool_brush(position : Vector2) -> void:
|
||||||
|
|
||||||
func draw_indicator() -> void:
|
func draw_indicator() -> void:
|
||||||
draw_indicator_at(_cursor, Vector2.ZERO, Color.blue)
|
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
|
var tile := _line_start if _draw_line else _cursor
|
||||||
if not tile in Global.current_project.selected_pixels:
|
if not tile in Global.current_project.selected_pixels:
|
||||||
var offset := tile - tile.posmodv(Global.current_project.size)
|
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
|
var project : Project = Global.current_project
|
||||||
if Global.mirror_view:
|
if Global.mirror_view:
|
||||||
position.x = project.size.x - position.x - 1
|
position.x = project.size.x - position.x - 1
|
||||||
|
if Global.current_project.tile_mode and _get_tile_mode_rect().has_point(position):
|
||||||
if Global.tile_mode and _get_tile_mode_rect().has_point(position):
|
|
||||||
position = position.posmodv(project.size)
|
position = position.posmodv(project.size)
|
||||||
|
|
||||||
var entire_image_selected : bool = project.selected_pixels.size() == project.size.x * project.size.y
|
var entire_image_selected : bool = project.selected_pixels.size() == project.size.x * project.size.y
|
||||||
|
|
|
@ -20,7 +20,7 @@ func _draw() -> void:
|
||||||
for i in range(Global.current_project.layers.size()):
|
for i in range(Global.current_project.layers.size()):
|
||||||
var modulate_color := Color(1, 1, 1, current_cels[i].opacity - tilemode_opacity)
|
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.current_project.layers[i].visible: # if it's visible
|
||||||
if Global.tile_mode:
|
if Global.current_project.tile_mode:
|
||||||
for pos in positions:
|
for pos in positions:
|
||||||
draw_texture(current_cels[i].image_texture, pos, modulate_color)
|
draw_texture(current_cels[i].image_texture, pos, modulate_color)
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func _draw() -> void:
|
||||||
|
|
||||||
|
|
||||||
func get_tile_positions(size):
|
func get_tile_positions(size):
|
||||||
match Global.tile_mode:
|
match Global.current_project.tile_mode:
|
||||||
1:
|
1:
|
||||||
return [
|
return [
|
||||||
Vector2(location.x, location.y + size.y), # Down
|
Vector2(location.x, location.y + size.y), # Down
|
||||||
|
|
|
@ -11,7 +11,7 @@ func _ready() -> void:
|
||||||
material.set_shader_param("color2", Global.checker_color_2)
|
material.set_shader_param("color2", Global.checker_color_2)
|
||||||
material.set_shader_param("follow_movement", Global.checker_follow_movement)
|
material.set_shader_param("follow_movement", Global.checker_follow_movement)
|
||||||
material.set_shader_param("follow_scale", Global.checker_follow_scale)
|
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:
|
func update_offset(offset : Vector2, scale : Vector2) -> void:
|
||||||
|
@ -26,18 +26,18 @@ func _on_TransparentChecker_resized():
|
||||||
func _init_position(id : int):
|
func _init_position(id : int):
|
||||||
match id:
|
match id:
|
||||||
0:
|
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_size(Global.current_project.size)
|
||||||
Global.transparent_checker.set_position(Vector2.ZERO)
|
Global.transparent_checker.set_position(Vector2.ZERO)
|
||||||
1:
|
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_size(Global.current_project.size*3)
|
||||||
Global.transparent_checker.set_position(-Global.current_project.size)
|
Global.transparent_checker.set_position(-Global.current_project.size)
|
||||||
2:
|
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_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))
|
Global.transparent_checker.set_position(Vector2(-Global.current_project.size.x, 0))
|
||||||
3:
|
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_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))
|
Global.transparent_checker.set_position(Vector2(0, -Global.current_project.size.y))
|
||||||
|
|
Loading…
Reference in a new issue