From b0aabe4e8a40c5eb632f7b0ccaaf37f9910e1caf Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:28:54 +0300 Subject: [PATCH] Add a preference to change max undo steps --- Translations/Translations.pot | 4 ++++ src/Autoload/Global.gd | 10 +++++++++- src/Classes/Project.gd | 1 + src/Preferences/PreferencesDialog.gd | 1 + src/Preferences/PreferencesDialog.tscn | 26 ++++++++++++++++++-------- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Translations/Translations.pot b/Translations/Translations.pot index 522571def..75768947d 100644 --- a/Translations/Translations.pot +++ b/Translations/Translations.pot @@ -1650,6 +1650,10 @@ msgstr "" msgid "Sets the limit of the application's frames per second. The lower the number, the lower the CPU usage, but the application gets slower, choppier and unresponsive. 0 means that there is no limit." msgstr "" +#. Found in the Preferences, under the Performance section. Changes the value of the maximum undo steps projects can use. +msgid "Max undo steps:" +msgstr "" + #. An option found in the preferences, under the Performance section. msgid "Pause application when it loses focus" msgstr "" diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 783d60e76..45aadc01e 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -466,13 +466,21 @@ var selection_border_color_2 := Color.BLACK: ## Found in Preferences. If [code]true[/code], Pixelorama pauses when unfocused to save cpu usage. var pause_when_unfocused := true -## Found in Preferences. The max fps, Pixelorama is allowed to use (does not limit fps if it is 0). +## Found in Preferences. The maximum FPS value Pixelorama can reach. 0 means no limit. var fps_limit := 0: set(value): if value == fps_limit: return fps_limit = value Engine.max_fps = fps_limit +## Found in Preferences. The maximum amount of undo steps projects can use. 0 means no limit. +var max_undo_steps := 0: + set(value): + if value == max_undo_steps: + return + max_undo_steps = value + for project in projects: + project.undo_redo.max_steps = max_undo_steps ## Found in Preferences. Affects the per_pixel_transparency project setting. ## If [code]true[/code], it allows for the window to be transparent. ## This affects performance, so keep it [code]false[/code] if you don't need it. diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index 5103cb1b5..bb75514e3 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -93,6 +93,7 @@ func _init(_frames: Array[Frame] = [], _name := tr("untitled"), _size := Vector2 tiles = Tiles.new(size) selection_map.copy_from(Image.create(size.x, size.y, false, Image.FORMAT_LA8)) Global.tabs.add_tab(name) + undo_redo.max_steps = Global.max_undo_steps x_symmetry_point = size.x - 1 y_symmetry_point = size.y - 1 diff --git a/src/Preferences/PreferencesDialog.gd b/src/Preferences/PreferencesDialog.gd index bea75ff3e..c2490a64f 100644 --- a/src/Preferences/PreferencesDialog.gd +++ b/src/Preferences/PreferencesDialog.gd @@ -169,6 +169,7 @@ var preferences: Array[Preference] = [ "selection_border_color_2", "Selection/SelectionOptions/BorderColor2", "color", Color.BLACK ), Preference.new("fps_limit", "Performance/PerformanceContainer/SetFPSLimit", "value", 0), + Preference.new("max_undo_steps", "Performance/PerformanceContainer/MaxUndoSteps", "value", 0), Preference.new( "pause_when_unfocused", "Performance/PerformanceContainer/PauseAppFocus", diff --git a/src/Preferences/PreferencesDialog.tscn b/src/Preferences/PreferencesDialog.tscn index 48bb579b3..8bf8cba7e 100644 --- a/src/Preferences/PreferencesDialog.tscn +++ b/src/Preferences/PreferencesDialog.tscn @@ -295,10 +295,9 @@ text = "Tool button size:" layout_mode = 2 size_flags_horizontal = 3 mouse_default_cursor_shape = 2 -item_count = 2 selected = 0 +item_count = 2 popup/item_0/text = "Small" -popup/item_0/id = 0 popup/item_1/text = "Big" popup/item_1/id = 1 @@ -309,10 +308,9 @@ text = "Icon color from:" [node name="IconColorOptionButton" type="OptionButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/ButtonOptions"] layout_mode = 2 mouse_default_cursor_shape = 2 -item_count = 2 selected = 0 +item_count = 2 popup/item_0/text = "Theme" -popup/item_0/id = 0 popup/item_1/text = "Custom" popup/item_1/id = 1 @@ -508,10 +506,9 @@ layout_mode = 2 size_flags_horizontal = 3 tooltip_text = "Sets the type of the grid between rectangular, isometric or both" mouse_default_cursor_shape = 2 -item_count = 3 selected = 0 +item_count = 3 popup/item_0/text = "Rectangular" -popup/item_0/id = 0 popup/item_1/text = "Isometric" popup/item_1/id = 1 popup/item_2/text = "All" @@ -803,10 +800,9 @@ text = "Background color from:" layout_mode = 2 size_flags_horizontal = 3 mouse_default_cursor_shape = 2 -item_count = 2 selected = 0 +item_count = 2 popup/item_0/text = "Theme" -popup/item_0/id = 0 popup/item_1/text = "Custom" popup/item_1/id = 1 @@ -1043,6 +1039,20 @@ tooltip_text = "Sets the limit of the application's frames per second. The lower mouse_default_cursor_shape = 2 max_value = 144.0 +[node name="MaxUndoStepsLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Performance/PerformanceContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +mouse_filter = 0 +text = "Max undo steps:" + +[node name="MaxUndoSteps" type="SpinBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Performance/PerformanceContainer"] +custom_minimum_size = Vector2(95, 0) +layout_mode = 2 +size_flags_horizontal = 3 +mouse_default_cursor_shape = 2 +max_value = 1000.0 +allow_greater = true + [node name="PauseAppFocusLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Performance/PerformanceContainer"] layout_mode = 2 tooltip_text = "If this is toggled on, when the application's window loses focus, it gets paused. This helps lower CPU usage when idle. The application gets unpaused when the mouse enters the application's window."