From 491d81f393e69d16145a9f4e42adf98c9dd21cc1 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Thu, 21 Mar 2024 01:51:19 +0200 Subject: [PATCH] Minor config file section key re-organization --- src/Autoload/OpenSave.gd | 4 ++-- src/Autoload/Tools.gd | 7 ++++--- src/Main.gd | 4 ++-- src/UI/Canvas/CropRect.gd | 8 ++++---- src/UI/GlobalToolOptions/GlobalToolOptions.gd | 8 ++++---- src/UI/TopMenuContainer/TopMenuContainer.gd | 2 +- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Autoload/OpenSave.gd b/src/Autoload/OpenSave.gd index 333ca0adb..9554674f0 100644 --- a/src/Autoload/OpenSave.gd +++ b/src/Autoload/OpenSave.gd @@ -258,7 +258,7 @@ func open_pxo_file(path: String, untitled_backup := false, replace_empty := true Global.main_window.title = path.get_file() + " - Pixelorama " + Global.current_version Global.save_sprites_dialog.current_path = path # Set last opened project path and save - Global.config_cache.set_value("preferences", "last_project_path", path) + Global.config_cache.set_value("data", "last_project_path", path) Global.config_cache.save("user://cache.ini") new_project.directory_path = path.get_base_dir() new_project.file_name = path.get_file().trim_suffix(".pxo") @@ -420,7 +420,7 @@ func save_pxo_file( Global.main_window.title = path.get_file() + " - Pixelorama " + Global.current_version # Set last opened project path and save - Global.config_cache.set_value("preferences", "last_project_path", path) + Global.config_cache.set_value("data", "last_project_path", path) Global.config_cache.save("user://cache.ini") if !project.was_exported: project.file_name = path.get_file().trim_suffix(".pxo") diff --git a/src/Autoload/Tools.gd b/src/Autoload/Tools.gd index 2bb94936b..2fed00271 100644 --- a/src/Autoload/Tools.gd +++ b/src/Autoload/Tools.gd @@ -329,9 +329,10 @@ func _ready() -> void: set_tool(tool_name, MOUSE_BUTTON_RIGHT) update_tool_buttons() - horizontal_mirror = Global.config_cache.get_value("preferences", "horizontal_mirror", false) - vertical_mirror = Global.config_cache.get_value("preferences", "vertical_mirror", false) - pixel_perfect = Global.config_cache.get_value("preferences", "pixel_perfect", false) + horizontal_mirror = Global.config_cache.get_value("tools", "horizontal_mirror", false) + vertical_mirror = Global.config_cache.get_value("tools", "vertical_mirror", false) + pixel_perfect = Global.config_cache.get_value("tools", "pixel_perfect", false) + alpha_locked = Global.config_cache.get_value("tools", "alpha_locked", false) # Yield is necessary for the color picker nodes to update their color values await get_tree().process_frame diff --git a/src/Main.gd b/src/Main.gd index 661e81efc..162140c2b 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -251,9 +251,9 @@ func load_last_project() -> void: if OS.get_name() == "Web": return # Check if any project was saved or opened last time - if Global.config_cache.has_section_key("preferences", "last_project_path"): + if Global.config_cache.has_section_key("data", "last_project_path"): # Check if file still exists on disk - var file_path = Global.config_cache.get_value("preferences", "last_project_path") + var file_path = Global.config_cache.get_value("data", "last_project_path") if FileAccess.file_exists(file_path): # If yes then load the file OpenSave.open_pxo_file(file_path) # Sync file dialogs diff --git a/src/UI/Canvas/CropRect.gd b/src/UI/Canvas/CropRect.gd index e26d593e3..adb4aa120 100644 --- a/src/UI/Canvas/CropRect.gd +++ b/src/UI/Canvas/CropRect.gd @@ -29,14 +29,14 @@ var tool_count := 0: func _ready() -> void: updated.connect(queue_redraw) Global.project_switched.connect(reset) - mode = Global.config_cache.get_value("preferences", "crop_mode", 0) - locked_size = Global.config_cache.get_value("preferences", "crop_locked_size", false) + mode = Global.config_cache.get_value("tools", "crop_mode", 0) + locked_size = Global.config_cache.get_value("tools", "crop_locked_size", false) reset() func _exit_tree(): - Global.config_cache.set_value("preferences", "crop_mode", mode) - Global.config_cache.set_value("preferences", "crop_locked_size", locked_size) + Global.config_cache.set_value("tools", "crop_mode", mode) + Global.config_cache.set_value("tools", "crop_locked_size", locked_size) func _draw() -> void: diff --git a/src/UI/GlobalToolOptions/GlobalToolOptions.gd b/src/UI/GlobalToolOptions/GlobalToolOptions.gd index f93341470..1adebe82f 100644 --- a/src/UI/GlobalToolOptions/GlobalToolOptions.gd +++ b/src/UI/GlobalToolOptions/GlobalToolOptions.gd @@ -62,7 +62,7 @@ func _on_resized() -> void: func _on_Horizontal_toggled(button_pressed: bool) -> void: Tools.horizontal_mirror = button_pressed - Global.config_cache.set_value("preferences", "horizontal_mirror", button_pressed) + Global.config_cache.set_value("tools", "horizontal_mirror", button_pressed) Global.show_y_symmetry_axis = button_pressed Global.current_project.y_symmetry_axis.visible = ( Global.show_y_symmetry_axis and Global.show_guides @@ -77,7 +77,7 @@ func _on_Horizontal_toggled(button_pressed: bool) -> void: func _on_Vertical_toggled(button_pressed: bool) -> void: Tools.vertical_mirror = button_pressed - Global.config_cache.set_value("preferences", "vertical_mirror", button_pressed) + Global.config_cache.set_value("tools", "vertical_mirror", button_pressed) Global.show_x_symmetry_axis = button_pressed # If the button is not pressed but another button is, keep the symmetry guide visible Global.current_project.x_symmetry_axis.visible = ( @@ -93,7 +93,7 @@ func _on_Vertical_toggled(button_pressed: bool) -> void: func _on_PixelPerfect_toggled(button_pressed: bool) -> void: Tools.pixel_perfect = button_pressed - Global.config_cache.set_value("preferences", "pixel_perfect", button_pressed) + Global.config_cache.set_value("tools", "pixel_perfect", button_pressed) var texture_button: TextureRect = pixel_perfect.get_node("TextureRect") var file_name := "pixel_perfect_on.png" if !button_pressed: @@ -103,7 +103,7 @@ func _on_PixelPerfect_toggled(button_pressed: bool) -> void: func _on_alpha_lock_toggled(toggled_on: bool) -> void: Tools.alpha_locked = toggled_on - Global.config_cache.set_value("preferences", "alpha_locked", toggled_on) + Global.config_cache.set_value("tools", "alpha_locked", toggled_on) var texture_button: TextureRect = alpha_lock.get_node("TextureRect") var file_name := "alpha_lock_on.png" if not toggled_on: diff --git a/src/UI/TopMenuContainer/TopMenuContainer.gd b/src/UI/TopMenuContainer/TopMenuContainer.gd index 86f0c76b3..773428ebc 100644 --- a/src/UI/TopMenuContainer/TopMenuContainer.gd +++ b/src/UI/TopMenuContainer/TopMenuContainer.gd @@ -453,7 +453,7 @@ func _open_project_file() -> void: func _on_open_last_project_file_menu_option_pressed() -> void: - if Global.config_cache.has_section_key("preferences", "last_project_path"): + if Global.config_cache.has_section_key("data", "last_project_path"): Global.control.load_last_project() else: Global.error_dialog.set_text("You haven't saved or opened any project in Pixelorama yet!")