mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Add idle fps setting and fix bug when moving the mouse outside of the application (#543)
This commit is contained in:
parent
6ebead2e6f
commit
502c7d9409
|
@ -1055,13 +1055,13 @@ msgstr ""
|
|||
msgid "Set application FPS limit:"
|
||||
msgstr ""
|
||||
|
||||
msgid "Limit FPS to 1 when app loses focus"
|
||||
msgid "Limit FPS to the idle FPS 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."
|
||||
msgid "If this is toggled on, when the application's window loses focus, the FPS limit of the application is set to the idle FPS. This helps lower CPU usage when idle. The FPS limit is being reset when the mouse enters the application's window."
|
||||
msgstr ""
|
||||
|
||||
msgid "Brush:"
|
||||
|
@ -1772,3 +1772,9 @@ msgstr ""
|
|||
|
||||
msgid "Position:"
|
||||
msgstr ""
|
||||
|
||||
msgid "Set idle FPS:"
|
||||
msgstr ""
|
||||
|
||||
msgid "Sets how many FPS Pixelorama uses when out of focus. The less the better the performance."
|
||||
msgstr ""
|
||||
|
|
|
@ -88,6 +88,7 @@ var selection_border_color_2 := Color.black
|
|||
|
||||
var fps_limit_focus := true
|
||||
var fps_limit := 0
|
||||
var idle_fps := 1
|
||||
|
||||
var autosave_interval := 1.0
|
||||
var enable_autosave := true
|
||||
|
|
|
@ -276,13 +276,16 @@ func _notification(what : int) -> void:
|
|||
match what:
|
||||
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
|
||||
MainLoop.NOTIFICATION_WM_FOCUS_OUT: # Called when another program is currently focused
|
||||
Global.has_focus = false
|
||||
if Global.fps_limit_focus:
|
||||
Engine.set_target_fps(1) # then set the fps to 1 to relieve the cpu
|
||||
Engine.set_target_fps(Global.idle_fps) # then set the fps to the idle fps (by default 1) to facilitate the cpu
|
||||
MainLoop.NOTIFICATION_WM_MOUSE_ENTER: # Opposite of the above
|
||||
if Global.fps_limit_focus:
|
||||
Engine.set_target_fps(Global.fps_limit) # 0 stands for maximum fps
|
||||
MainLoop.NOTIFICATION_WM_MOUSE_EXIT: # if the mouse exits the window and another application has the focus set the fps to the idle fps
|
||||
if !OS.is_window_focused() and Global.fps_limit_focus:
|
||||
Engine.set_target_fps(Global.idle_fps)
|
||||
|
||||
|
||||
func _on_files_dropped(_files : PoolStringArray, _screen : int) -> void:
|
||||
|
|
|
@ -48,6 +48,7 @@ var preferences = [
|
|||
|
||||
["fps_limit", "Performance/PerformanceContainer/SetFPSLimit", "value", Global.fps_limit],
|
||||
["fps_limit_focus", "Performance/PerformanceContainer/EnableLimitFPSFocus", "pressed", Global.fps_limit_focus],
|
||||
["idle_fps", "Performance/PerformanceContainer/IdleFPS", "value", Global.idle_fps]
|
||||
]
|
||||
|
||||
var selected_item := 0
|
||||
|
@ -58,6 +59,7 @@ onready var autosave_interval : SpinBox = $HSplitContainer/ScrollContainer/VBoxC
|
|||
onready var restore_default_button_scene = preload("res://src/Preferences/RestoreDefaultButton.tscn")
|
||||
onready var shrink_label : Label = $HSplitContainer/ScrollContainer/VBoxContainer/Interface/ShrinkContainer/ShrinkLabel
|
||||
onready var themes : BoxContainer = $"HSplitContainer/ScrollContainer/VBoxContainer/Interface/Themes"
|
||||
onready var idle_fps_spinbox : SpinBox = $HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer/IdleFPS
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -159,6 +161,9 @@ func preference_update(prop : String) -> void:
|
|||
|
||||
if prop in ["fps_limit"]:
|
||||
Engine.set_target_fps(Global.fps_limit)
|
||||
|
||||
if prop in ["fps_limit_focus"]:
|
||||
idle_fps_spinbox.editable = !idle_fps_spinbox.editable
|
||||
|
||||
if prop in ["selection_animated_borders", "selection_border_color_1", "selection_border_color_2"]:
|
||||
Global.canvas.selection.marching_ants_outline.material.set_shader_param("animated", Global.selection_animated_borders)
|
||||
|
|
|
@ -1376,11 +1376,11 @@ __meta__ = {
|
|||
[node name="Performance" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
||||
visible = false
|
||||
margin_top = 28.0
|
||||
margin_right = 498.0
|
||||
margin_right = 553.0
|
||||
margin_bottom = 80.0
|
||||
|
||||
[node name="PerformanceContainer" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance"]
|
||||
margin_right = 498.0
|
||||
margin_right = 553.0
|
||||
margin_bottom = 52.0
|
||||
columns = 3
|
||||
|
||||
|
@ -1408,19 +1408,19 @@ __meta__ = {
|
|||
}
|
||||
|
||||
[node name="EnableLimitFPSFocusLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"]
|
||||
margin_left = 261.0
|
||||
margin_left = 324.0
|
||||
margin_top = 5.0
|
||||
margin_right = 490.0
|
||||
margin_right = 553.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."
|
||||
hint_tooltip = "If this is toggled on, when the application's window loses focus, the FPS limit of the application is set to the idle FPS. 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"
|
||||
text = "Limit FPS to the idle FPS 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."
|
||||
hint_tooltip = "If this is toggled on, when the application's window loses focus, the FPS limit of the application is set to the idle FPS. 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"
|
||||
|
@ -1428,6 +1428,33 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="IdleFPSLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"]
|
||||
margin_left = 162.0
|
||||
margin_top = 33.0
|
||||
margin_right = 320.0
|
||||
margin_bottom = 47.0
|
||||
hint_tooltip = "Sets how many FPS Pixelorama uses when out of focus."
|
||||
mouse_filter = 0
|
||||
size_flags_horizontal = 0
|
||||
text = "Set idle FPS:"
|
||||
|
||||
[node name="IdleFPS" type="SpinBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"]
|
||||
margin_left = 324.0
|
||||
margin_top = 28.0
|
||||
margin_right = 419.0
|
||||
margin_bottom = 52.0
|
||||
rect_min_size = Vector2( 95, 0 )
|
||||
hint_tooltip = "Sets how many FPS Pixelorama uses when out of focus."
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
min_value = 1.0
|
||||
max_value = 60.0
|
||||
value = 1.0
|
||||
align = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Indicators" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
||||
visible = false
|
||||
margin_top = 54.0
|
||||
|
|
Loading…
Reference in a new issue