diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index be176a523..adf1abb6e 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -21,11 +21,11 @@ enum ColorFrom { THEME, CUSTOM } enum ButtonSize { SMALL, BIG } enum MeasurementMode { NONE, MOVE } -## Enumeration of items present in the File Menu. +## Enumeration of items present in the File Menu. enum FileMenu { NEW, OPEN, OPEN_LAST_PROJECT, RECENT, SAVE, SAVE_AS, EXPORT, EXPORT_AS, QUIT } -## Enumeration of items present in the Edit Menu. +## Enumeration of items present in the Edit Menu. enum EditMenu { UNDO, REDO, COPY, CUT, PASTE, PASTE_IN_PLACE, DELETE, NEW_BRUSH, PREFERENCES } -## Enumeration of items present in the View Menu. +## Enumeration of items present in the View Menu. enum ViewMenu { TILE_MODE, TILE_MODE_OFFSETS, @@ -39,9 +39,9 @@ enum ViewMenu { DISPLAY_LAYER_EFFECTS, SNAP_TO, } -## Enumeration of items present in the Window Menu. +## Enumeration of items present in the Window Menu. enum WindowMenu { WINDOW_OPACITY, PANELS, LAYOUTS, MOVABLE_PANELS, ZEN_MODE, FULLSCREEN_MODE } -## Enumeration of items present in the Image Menu. +## Enumeration of items present in the Image Menu. enum ImageMenu { PROJECT_PROPERTIES, RESIZE_CANVAS, @@ -67,9 +67,9 @@ enum EffectsMenu { GRADIENT_MAP, SHADER } -## Enumeration of items present in the Select Menu. +## Enumeration of items present in the Select Menu. enum SelectMenu { SELECT_ALL, CLEAR_SELECTION, INVERT, TILE_MODE } -## Enumeration of items present in the Help Menu. +## Enumeration of items present in the Help Menu. enum HelpMenu { VIEW_SPLASH_SCREEN, ONLINE_DOCS, @@ -642,7 +642,6 @@ var cel_button_scene: PackedScene = load("res://src/UI/Timeline/CelButton.tscn") ## The patterns popup dialog used to display patterns ## It has the [param PatternsPopup.gd] script attached. @onready var patterns_popup: Popup = control.find_child("PatternsPopup") -@onready var tile_mode_offset_dialog: AcceptDialog = control.find_child("TileModeOffsetsDialog") ## Dialog used to navigate and open images and projects. @onready var open_sprites_dialog: FileDialog = control.find_child("OpenSprite") ## Dialog used to save (.pxo) projects. diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index 177dc3623..aa2eb4a87 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -5,6 +5,7 @@ extends RefCounted signal serialized(dict: Dictionary) signal about_to_deserialize(dict: Dictionary) +signal resized signal timeline_updated var name := "": @@ -422,9 +423,9 @@ func _size_changed(value: Vector2i) -> void: else: tiles.y_basis = Vector2i(0, value.y) tiles.tile_size = value - Global.tile_mode_offset_dialog.change_mask() size = value Global.canvas.crop_rect.reset() + resized.emit() func change_cel(new_frame: int, new_layer := -1) -> void: diff --git a/src/Main.gd b/src/Main.gd index d23a6fc70..3fdcd4d2e 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -20,6 +20,7 @@ var splash_dialog: AcceptDialog: @onready var backup_confirmation: ConfirmationDialog = $Dialogs/BackupConfirmation @onready var save_sprite_dialog := $Dialogs/SaveSprite as FileDialog @onready var save_sprite_html5: ConfirmationDialog = $Dialogs/SaveSpriteHTML5 +@onready var tile_mode_offsets_dialog: ConfirmationDialog = $Dialogs/TileModeOffsetsDialog @onready var quit_dialog: ConfirmationDialog = $Dialogs/QuitDialog @onready var quit_and_save_dialog: ConfirmationDialog = $Dialogs/QuitAndSaveDialog @onready var download_confirmation := $Dialogs/DownloadImageConfirmationDialog as ConfirmationDialog diff --git a/src/UI/Dialogs/TileModeOffsetsDialog.gd b/src/UI/Dialogs/TileModeOffsetsDialog.gd index e3e264571..9dbd44134 100644 --- a/src/UI/Dialogs/TileModeOffsetsDialog.gd +++ b/src/UI/Dialogs/TileModeOffsetsDialog.gd @@ -9,12 +9,22 @@ extends ConfirmationDialog func _ready() -> void: + Global.project_about_to_switch.connect(_project_about_to_switch) + Global.project_switched.connect(_project_switched) Global.project_switched.connect(change_mask) Global.cel_switched.connect(change_mask) await get_tree().process_frame change_mask() +func _project_about_to_switch() -> void: + Global.current_project.resized.disconnect(change_mask) + + +func _project_switched() -> void: + Global.current_project.resized.connect(change_mask) + + func _on_TileModeOffsetsDialog_about_to_show() -> void: tile_mode.draw_center = true tile_mode.tiles = Tiles.new(Global.current_project.size) diff --git a/src/UI/TopMenuContainer/TopMenuContainer.gd b/src/UI/TopMenuContainer/TopMenuContainer.gd index ec9c3beb3..42113e54b 100644 --- a/src/UI/TopMenuContainer/TopMenuContainer.gd +++ b/src/UI/TopMenuContainer/TopMenuContainer.gd @@ -592,7 +592,7 @@ func edit_menu_id_pressed(id: int) -> void: func view_menu_id_pressed(id: int) -> void: match id: Global.ViewMenu.TILE_MODE_OFFSETS: - _popup_dialog(Global.tile_mode_offset_dialog) + _popup_dialog(get_tree().current_scene.tile_mode_offsets_dialog) Global.ViewMenu.GREYSCALE_VIEW: _toggle_greyscale_view() Global.ViewMenu.MIRROR_VIEW: @@ -638,7 +638,7 @@ func _tile_mode_submenu_id_pressed(id: Tiles.MODE) -> void: Global.canvas.tile_mode.queue_redraw() Global.canvas.pixel_grid.queue_redraw() Global.canvas.grid.queue_redraw() - Global.tile_mode_offset_dialog.change_mask() + get_tree().current_scene.tile_mode_offsets_dialog.change_mask() func _snap_to_submenu_id_pressed(id: int) -> void: @@ -846,7 +846,7 @@ func select_menu_id_pressed(id: int) -> void: func help_menu_id_pressed(id: int) -> void: match id: Global.HelpMenu.VIEW_SPLASH_SCREEN: - _popup_dialog(Global.control.splash_dialog) + _popup_dialog(get_tree().current_scene.splash_dialog) Global.HelpMenu.ONLINE_DOCS: OS.shell_open(DOCS_URL) SteamManager.set_achievement("ACH_ONLINE_DOCS")