diff --git a/Translations/Translations.pot b/Translations/Translations.pot index 6da963d..68a5746 100644 --- a/Translations/Translations.pot +++ b/Translations/Translations.pot @@ -371,6 +371,9 @@ msgstr "" msgid "Backup" msgstr "" +msgid "Performance" +msgstr "" + msgid "Indicators" msgstr "" @@ -849,6 +852,18 @@ msgstr "" msgid "Only custom preset can be modified" msgstr "" +msgid "Set application FPS limit:" +msgstr "" + +msgid "Limit FPS to 1 when app 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 "If this is toggled on, when the application's window loses focus, the FPS limit of the application is set to 1. This helps lower CPU usage when idle. The FPS limit is being reset when the mouse enters the application's window." +msgstr "" + msgid "Brush:" msgstr "" diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index f9e27c1..4c1d08a 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -63,6 +63,8 @@ var checker_color_2 := Color(0.34, 0.35, 0.34, 1) var checker_follow_movement := false var checker_follow_scale := false var tilemode_opacity := 1.0 +var fps_limit_focus := true +var fps_limit := 0 var autosave_interval := 1.0 var enable_autosave := true diff --git a/src/Main.gd b/src/Main.gd index e7e074e..aadf61b 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -141,9 +141,11 @@ func _notification(what : int) -> void: MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit show_quit_dialog() MainLoop.NOTIFICATION_WM_FOCUS_OUT: # Called when the mouse isn't in the window anymore - Engine.set_target_fps(1) # then set the fps to 1 to relieve the cpu + if Global.fps_limit_focus: + Engine.set_target_fps(1) # then set the fps to 1 to relieve the cpu MainLoop.NOTIFICATION_WM_MOUSE_ENTER: # Opposite of the above - Engine.set_target_fps(0) # 0 stands for maximum fps + if Global.fps_limit_focus: + Engine.set_target_fps(Global.fps_limit) # 0 stands for maximum fps func _on_files_dropped(_files : PoolStringArray, _screen : int) -> void: diff --git a/src/Preferences/PreferencesDialog.gd b/src/Preferences/PreferencesDialog.gd index 0df93fe..1363497 100644 --- a/src/Preferences/PreferencesDialog.gd +++ b/src/Preferences/PreferencesDialog.gd @@ -29,6 +29,9 @@ var preferences = [ ["checker_follow_movement", "Canvas/CheckerOptions/CheckerFollowMovement", "pressed", Global.checker_follow_movement], ["checker_follow_scale", "Canvas/CheckerOptions/CheckerFollowScale", "pressed", Global.checker_follow_scale], ["tilemode_opacity", "Canvas/CheckerOptions/TileModeOpacity", "value", Global.tilemode_opacity], + + ["fps_limit", "Performance/PerformanceContainer/SetFPSLimit", "value", Global.fps_limit], + ["fps_limit_focus", "Performance/PerformanceContainer/EnableLimitFPSFocus", "pressed", Global.fps_limit_focus], ] var selected_item := 0 @@ -135,6 +138,9 @@ func preference_update(prop : String) -> void: if guide is Guide: guide.default_color = Global.guide_color + if prop in ["fps_limit"]: + Engine.set_target_fps(Global.fps_limit) + Global.config_cache.save("user://cache.ini") @@ -157,6 +163,7 @@ func _on_PreferencesDialog_about_to_show(changed_language := false) -> void: list.add_item(" " + tr("Image")) list.add_item(" " + tr("Shortcuts")) list.add_item(" " + tr("Backup")) + list.add_item(" " + tr("Performance")) list.add_item(" " + tr("Indicators")) list.select(1 if changed_language else selected_item) @@ -170,7 +177,7 @@ func _on_PreferencesDialog_popup_hide() -> void: func _on_List_item_selected(index : int) -> void: selected_item = index for child in right_side.get_children(): - var content_list = ["Startup", "Languages", "Interface", "Canvas", "Image", "Shortcuts", "Backup", "Indicators"] + var content_list = ["Startup", "Languages", "Interface", "Canvas", "Image", "Shortcuts", "Backup", "Performance", "Indicators"] if OS.get_name() == "HTML5": content_list.erase("Startup") child.visible = child.name == content_list[index] diff --git a/src/Preferences/PreferencesDialog.tscn b/src/Preferences/PreferencesDialog.tscn index cbf9c59..6ac5eda 100644 --- a/src/Preferences/PreferencesDialog.tscn +++ b/src/Preferences/PreferencesDialog.tscn @@ -887,6 +887,61 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Performance" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"] +visible = false +margin_top = 28.0 +margin_right = 498.0 +margin_bottom = 80.0 + +[node name="PerformanceContainer" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance"] +margin_right = 498.0 +margin_bottom = 52.0 +columns = 3 + +[node name="SetFPSLimitLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"] +margin_top = 5.0 +margin_right = 158.0 +margin_bottom = 19.0 +hint_tooltip = "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." +mouse_filter = 0 +size_flags_horizontal = 0 +text = "Set application FPS limit:" + +[node name="SetFPSLimit" type="SpinBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"] +margin_left = 162.0 +margin_right = 257.0 +margin_bottom = 24.0 +rect_min_size = Vector2( 95, 0 ) +hint_tooltip = "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." +mouse_default_cursor_shape = 2 +size_flags_horizontal = 0 +max_value = 144.0 +align = 2 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="EnableLimitFPSFocusLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"] +margin_left = 261.0 +margin_top = 5.0 +margin_right = 490.0 +margin_bottom = 19.0 +hint_tooltip = "If this is toggled on, when the application's window loses focus, the FPS limit of the application is set to 1. This helps lower CPU usage when idle. The FPS limit is being reset when the mouse enters the application's window." +mouse_filter = 0 +text = "Limit FPS to 1 when app loses focus" + +[node name="EnableLimitFPSFocus" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"] +margin_top = 28.0 +margin_right = 158.0 +margin_bottom = 52.0 +hint_tooltip = "If this is toggled on, when the application's window loses focus, the FPS limit of the application is set to 1. This helps lower CPU usage when idle. The FPS limit is being reset when the mouse enters the application's window." +mouse_default_cursor_shape = 2 +pressed = true +text = "On" +__meta__ = { +"_edit_use_anchors_": false +} + [node name="Indicators" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"] visible = false margin_top = 54.0