Fixed issue with open last image and turned off pixel perfect drawing by default

This commit is contained in:
OverloadedOrama 2020-05-01 00:02:52 +03:00
parent 82fe186b65
commit 460f86ff8e
6 changed files with 49 additions and 49 deletions

View file

@ -2,7 +2,7 @@ class Drawer:
func reset() -> void:
pass
func set_pixel(sprite: Image, pos: Vector2, new_color: Color) -> void:
func set_pixel(_sprite: Image, _pos: Vector2, _new_color: Color) -> void:
pass
@ -10,8 +10,8 @@ class SimpleDrawer extends Drawer:
func reset() -> void:
pass
func set_pixel(sprite: Image, pos: Vector2, new_color: Color) -> void:
sprite.set_pixel(pos.x, pos.y, new_color)
func set_pixel(_sprite: Image, _pos: Vector2, _new_color: Color) -> void:
_sprite.set_pixel(_pos.x, _pos.y, _new_color)
class PixelPerfectDrawer extends Drawer:
@ -22,9 +22,9 @@ class PixelPerfectDrawer extends Drawer:
func reset():
last_pixels = [null, null]
func set_pixel(sprite: Image, pos: Vector2, new_color: Color) -> void:
last_pixels.push_back([pos, sprite.get_pixel(pos.x, pos.y)])
sprite.set_pixel(pos.x, pos.y, new_color)
func set_pixel(_sprite: Image, _pos: Vector2, _new_color: Color) -> void:
last_pixels.push_back([_pos, _sprite.get_pixel(_pos.x, _pos.y)])
_sprite.set_pixel(_pos.x, _pos.y, _new_color)
var corner = last_pixels.pop_front()
var neighbour = last_pixels[0]
@ -32,6 +32,6 @@ class PixelPerfectDrawer extends Drawer:
if corner == null or neighbour == null:
return
if pos - corner[0] in corners and pos - neighbour[0] in neighbours:
sprite.set_pixel(neighbour[0].x, neighbour[0].y, neighbour[1])
if _pos - corner[0] in corners and _pos - neighbour[0] in neighbours:
_sprite.set_pixel(neighbour[0].x, neighbour[0].y, neighbour[1])
last_pixels[0] = corner

View file

@ -105,8 +105,8 @@ var left_vertical_mirror := false
var right_horizontal_mirror := false
var right_vertical_mirror := false
var left_pixel_perfect := true
var right_pixel_perfect := true
var left_pixel_perfect := false
var right_pixel_perfect := false
# View menu options
var tile_mode := false

View file

@ -210,9 +210,11 @@ func _ready() -> void:
$BackupConfirmation.get_cancel().connect("pressed", self, "_on_BackupConfirmation_delete", [project_paths[0], backup_path])
$BackupConfirmation.popup_centered()
else:
load_last_project()
if Global.open_last_project:
load_last_project()
else:
load_last_project()
if Global.open_last_project:
load_last_project()
func _input(event : InputEvent) -> void:
@ -439,18 +441,17 @@ func help_menu_id_pressed(id : int) -> void:
$AboutDialog.popup_centered()
Global.can_draw = false
func load_last_project():
if Global.open_last_project:
# Check if any project was saved or opened last time
if Global.config_cache.has_section_key("preferences", "last_project_path"):
# Check if file still exists on disk
var file_path = Global.config_cache.get_value("preferences", "last_project_path")
var file_check := File.new()
if file_check.file_exists(file_path): # If yes then load the file
_on_OpenSprite_file_selected(file_path)
else:
# If file doesn't exist on disk then warn user about this
$OpenLastProjectAlertDialog.popup_centered()
func load_last_project() -> void:
# Check if any project was saved or opened last time
if Global.config_cache.has_section_key("preferences", "last_project_path"):
# Check if file still exists on disk
var file_path = Global.config_cache.get_value("preferences", "last_project_path")
var file_check := File.new()
if file_check.file_exists(file_path): # If yes then load the file
_on_OpenSprite_file_selected(file_path)
else:
# If file doesn't exist on disk then warn user about this
$OpenLastProjectAlertDialog.popup_centered()
func _on_UnsavedCanvasDialog_confirmed() -> void:
@ -828,12 +829,13 @@ func _on_BackupConfirmation_delete(project_path : String, backup_path : String)
OpenSave.remove_backup_by_path(project_path, backup_path)
OpenSave.autosave_timer.start()
# Reopen last project
load_last_project()
if Global.open_last_project:
load_last_project()
func _on_LeftPixelPerfectMode_toggled(button_pressed) -> void:
func _on_LeftPixelPerfectMode_toggled(button_pressed : bool) -> void:
Global.left_pixel_perfect = button_pressed
func _on_RightPixelPerfectMode_toggled(button_pressed) -> void:
func _on_RightPixelPerfectMode_toggled(button_pressed : bool) -> void:
Global.right_pixel_perfect = button_pressed