From ffd729486f7e99690eb81ea8f592a7cec7cd17cd Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Fri, 2 Feb 2024 00:19:53 +0200 Subject: [PATCH] Expose window transparency as an option in the preferences, keep it disabled by default I had to disable it, because for some reason having it be enabled by default does not seem to be working. This may be a good idea anyway, as many people will not need this feature, and having this enabled affects performance. This commit also allows for changing project setting related options in the preferences to also work when running Pixelorama inside Godot. --- Translations/Translations.pot | 14 +++++++++++--- project.godot | 1 - src/Autoload/Global.gd | 21 +++++++++++++++++---- src/Preferences/PreferencesDialog.gd | 7 +++++++ src/Preferences/PreferencesDialog.tscn | 12 ++++++++++++ 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/Translations/Translations.pot b/Translations/Translations.pot index e4a696b6a..f7eacf798 100644 --- a/Translations/Translations.pot +++ b/Translations/Translations.pot @@ -1462,15 +1462,23 @@ msgstr "" msgid "Set application FPS limit:" msgstr "" -msgid "Pause application when it loses focus" -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 "" +msgid "Pause application when it loses focus" +msgstr "" + msgid "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." msgstr "" +#. An option found in the preferences, under the Performance section. +msgid "Enable window transparency" +msgstr "" + +#. Found in the preferences, tooltip of the "Enable window transparency" option. +msgid "If enabled, the application window can become transparent. This affects performance, so keep it off if you don't need it." +msgstr "" + #. Found in the Preferences, under Drivers. Specifies the renderer/video driver being used. msgid "Renderer:" msgstr "" diff --git a/project.godot b/project.godot index b69501bac..43a646d5c 100644 --- a/project.godot +++ b/project.godot @@ -52,7 +52,6 @@ gdscript/warnings/narrowing_conversion=false window/size/viewport_width=1280 window/size/viewport_height=720 -window/per_pixel_transparency/allowed=true window/per_pixel_transparency/allowed.android=false window/per_pixel_transparency/allowed.web=false diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index d2d9a015e..8b5379c6e 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -170,9 +170,9 @@ var use_native_file_dialogs := false: ## Found in Preferences. If [code]true[/code], subwindows are embedded in the main window. var single_window_mode := true: set(value): - single_window_mode = value - if OS.has_feature("editor"): + if value == single_window_mode: return + single_window_mode = value ProjectSettings.set_setting("display/window/subwindows/embed_subwindows", value) ProjectSettings.save_custom(root_directory.path_join(OVERRIDE_FILE)) ## Found in Preferences. The modulation color (or simply color) of icons. @@ -356,6 +356,16 @@ var fps_limit := 0: set(value): fps_limit = value Engine.max_fps = fps_limit +## 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. +var window_transparency := false: + set(value): + if value == window_transparency: + return + window_transparency = value + ProjectSettings.set_setting("display/window/per_pixel_transparency/allowed", value) + ProjectSettings.save_custom(root_directory.path_join(OVERRIDE_FILE)) ## Found in Preferences. The time (in minutes) after which backup is created (if enabled). var autosave_interval := 1.0: @@ -374,9 +384,9 @@ var renderer := 0: ## Found in Preferences. The index of tablet driver used by Pixelorama. var tablet_driver := 0: set(value): - tablet_driver = value - if OS.has_feature("editor"): + if value == tablet_driver: return + tablet_driver = value var tablet_driver_name := DisplayServer.tablet_get_current_driver() ProjectSettings.set_setting("display/window/tablet_driver", tablet_driver_name) ProjectSettings.save_custom(root_directory.path_join(OVERRIDE_FILE)) @@ -553,6 +563,9 @@ func _init() -> void: if ProjectSettings.get_setting("display/window/tablet_driver") == "winink": tablet_driver = 1 single_window_mode = ProjectSettings.get_setting("display/window/subwindows/embed_subwindows") + window_transparency = ProjectSettings.get_setting( + "display/window/per_pixel_transparency/allowed" + ) func _ready() -> void: diff --git a/src/Preferences/PreferencesDialog.gd b/src/Preferences/PreferencesDialog.gd index fc07a0c25..e8a42287d 100644 --- a/src/Preferences/PreferencesDialog.gd +++ b/src/Preferences/PreferencesDialog.gd @@ -101,6 +101,13 @@ var preferences: Array[Preference] = [ Preference.new( "pause_when_unfocused", "Performance/PerformanceContainer/PauseAppFocus", "button_pressed" ), + Preference.new( + "window_transparency", + "Performance/PerformanceContainer/WindowTransparency", + "button_pressed", + true, + false + ), # Preference.new( # "renderer", "Drivers/DriversContainer/Renderer", "selected", true, OS.VIDEO_DRIVER_GLES2 # ), diff --git a/src/Preferences/PreferencesDialog.tscn b/src/Preferences/PreferencesDialog.tscn index 1db38cd78..adbf11737 100644 --- a/src/Preferences/PreferencesDialog.tscn +++ b/src/Preferences/PreferencesDialog.tscn @@ -1054,6 +1054,18 @@ mouse_default_cursor_shape = 2 button_pressed = true text = "On" +[node name="WindowTransparencyLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Performance/PerformanceContainer"] +layout_mode = 2 +tooltip_text = "If enabled, the application window can become transparent. This affects performance, so keep it off if you don't need it." +mouse_filter = 0 +text = "Enable window transparency" + +[node name="WindowTransparency" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Performance/PerformanceContainer"] +layout_mode = 2 +tooltip_text = "If enabled, the application window can become transparent. This affects performance, so keep it off if you don't need it." +mouse_default_cursor_shape = 2 +text = "On" + [node name="Drivers" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide"] visible = false layout_mode = 2