From d73ab82e04a654a385adfb860625bf629b665626 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Sat, 15 Jun 2024 15:58:10 +0300 Subject: [PATCH] Remember display layer effects and snap settings between sessions --- src/Main.gd | 13 +++++++ src/UI/TopMenuContainer/TopMenuContainer.gd | 41 ++++++++++++++++----- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/Main.gd b/src/Main.gd index e4a33378c..2376e6f00 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -590,6 +590,19 @@ func _exit_tree() -> void: Global.config_cache.set_value("view_menu", "show_rulers", Global.show_rulers) Global.config_cache.set_value("view_menu", "show_guides", Global.show_guides) Global.config_cache.set_value("view_menu", "show_mouse_guides", Global.show_mouse_guides) + Global.config_cache.set_value( + "view_menu", "display_layer_effects", Global.display_layer_effects + ) + Global.config_cache.set_value( + "view_menu", "snap_to_rectangular_grid_boundary", Global.snap_to_rectangular_grid_boundary + ) + Global.config_cache.set_value( + "view_menu", "snap_to_rectangular_grid_center", Global.snap_to_rectangular_grid_center + ) + Global.config_cache.set_value("view_menu", "snap_to_guides", Global.snap_to_guides) + Global.config_cache.set_value( + "view_menu", "snap_to_perspective_guides", Global.snap_to_perspective_guides + ) Global.config_cache.save(Global.CONFIG_PATH) diff --git a/src/UI/TopMenuContainer/TopMenuContainer.gd b/src/UI/TopMenuContainer/TopMenuContainer.gd index 92e438347..26e61e4bc 100644 --- a/src/UI/TopMenuContainer/TopMenuContainer.gd +++ b/src/UI/TopMenuContainer/TopMenuContainer.gd @@ -221,32 +221,55 @@ func _setup_view_menu() -> void: view_menu.hide_on_checkable_item_selection = false view_menu.id_pressed.connect(view_menu_id_pressed) + # Load settings from the config file var draw_grid: bool = Global.config_cache.get_value("view_menu", "draw_grid", Global.draw_grid) - if draw_grid != Global.draw_grid: - _toggle_show_grid() - var draw_pixel_grid: bool = Global.config_cache.get_value( "view_menu", "draw_pixel_grid", Global.draw_pixel_grid ) - if draw_pixel_grid != Global.draw_pixel_grid: - _toggle_show_pixel_grid() - var show_rulers: bool = Global.config_cache.get_value( "view_menu", "show_rulers", Global.show_rulers ) - if show_rulers != Global.show_rulers: - _toggle_show_rulers() - var show_guides: bool = Global.config_cache.get_value( "view_menu", "show_guides", Global.show_guides ) var show_mouse_guides: bool = Global.config_cache.get_value( "view_menu", "show_mouse_guides", Global.show_mouse_guides ) + var display_layer_effects: bool = Global.config_cache.get_value( + "view_menu", "display_layer_effects", Global.display_layer_effects + ) + var snap_to_rectangular_grid_boundary: bool = Global.config_cache.get_value( + "view_menu", "snap_to_rectangular_grid_boundary", Global.snap_to_rectangular_grid_boundary + ) + var snap_to_rectangular_grid_center: bool = Global.config_cache.get_value( + "view_menu", "snap_to_rectangular_grid_center", Global.snap_to_rectangular_grid_center + ) + var snap_to_guides: bool = Global.config_cache.get_value( + "view_menu", "snap_to_guides", Global.snap_to_guides + ) + var snap_to_perspective_guides: bool = Global.config_cache.get_value( + "view_menu", "snap_to_perspective_guides", Global.snap_to_perspective_guides + ) + if draw_grid != Global.draw_grid: + _toggle_show_grid() + if draw_pixel_grid != Global.draw_pixel_grid: + _toggle_show_pixel_grid() + if show_rulers != Global.show_rulers: + _toggle_show_rulers() if show_guides != Global.show_guides: _toggle_show_guides() if show_mouse_guides != Global.show_mouse_guides: _toggle_show_mouse_guides() + if display_layer_effects != Global.display_layer_effects: + Global.display_layer_effects = display_layer_effects + if snap_to_rectangular_grid_boundary != Global.snap_to_rectangular_grid_boundary: + _snap_to_submenu_id_pressed(0) + if snap_to_rectangular_grid_center != Global.snap_to_rectangular_grid_center: + _snap_to_submenu_id_pressed(1) + if snap_to_guides != Global.snap_to_guides: + _snap_to_submenu_id_pressed(2) + if snap_to_perspective_guides != Global.snap_to_perspective_guides: + _snap_to_submenu_id_pressed(3) func _setup_tile_mode_submenu(item: String) -> void: