mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-05-05 18:34:48 -04:00
Added "Performance" tab in Preferences that exposes options related to the application's FPS to the user
This also makes the behavior added in #394 toggle-able.
This commit is contained in:
parent
2d8d522031
commit
8daacbac5e
5 changed files with 84 additions and 3 deletions
|
@ -371,6 +371,9 @@ msgstr ""
|
||||||
msgid "Backup"
|
msgid "Backup"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Performance"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Indicators"
|
msgid "Indicators"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -849,6 +852,18 @@ msgstr ""
|
||||||
msgid "Only custom preset can be modified"
|
msgid "Only custom preset can be modified"
|
||||||
msgstr ""
|
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:"
|
msgid "Brush:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ var checker_color_2 := Color(0.34, 0.35, 0.34, 1)
|
||||||
var checker_follow_movement := false
|
var checker_follow_movement := false
|
||||||
var checker_follow_scale := false
|
var checker_follow_scale := false
|
||||||
var tilemode_opacity := 1.0
|
var tilemode_opacity := 1.0
|
||||||
|
var fps_limit_focus := true
|
||||||
|
var fps_limit := 0
|
||||||
|
|
||||||
var autosave_interval := 1.0
|
var autosave_interval := 1.0
|
||||||
var enable_autosave := true
|
var enable_autosave := true
|
||||||
|
|
|
@ -141,9 +141,11 @@ func _notification(what : int) -> void:
|
||||||
MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit
|
MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit
|
||||||
show_quit_dialog()
|
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 the mouse isn't in the window anymore
|
||||||
|
if Global.fps_limit_focus:
|
||||||
Engine.set_target_fps(1) # then set the fps to 1 to relieve the cpu
|
Engine.set_target_fps(1) # then set the fps to 1 to relieve the cpu
|
||||||
MainLoop.NOTIFICATION_WM_MOUSE_ENTER: # Opposite of the above
|
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:
|
func _on_files_dropped(_files : PoolStringArray, _screen : int) -> void:
|
||||||
|
|
|
@ -29,6 +29,9 @@ var preferences = [
|
||||||
["checker_follow_movement", "Canvas/CheckerOptions/CheckerFollowMovement", "pressed", Global.checker_follow_movement],
|
["checker_follow_movement", "Canvas/CheckerOptions/CheckerFollowMovement", "pressed", Global.checker_follow_movement],
|
||||||
["checker_follow_scale", "Canvas/CheckerOptions/CheckerFollowScale", "pressed", Global.checker_follow_scale],
|
["checker_follow_scale", "Canvas/CheckerOptions/CheckerFollowScale", "pressed", Global.checker_follow_scale],
|
||||||
["tilemode_opacity", "Canvas/CheckerOptions/TileModeOpacity", "value", Global.tilemode_opacity],
|
["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
|
var selected_item := 0
|
||||||
|
@ -135,6 +138,9 @@ func preference_update(prop : String) -> void:
|
||||||
if guide is Guide:
|
if guide is Guide:
|
||||||
guide.default_color = Global.guide_color
|
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")
|
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("Image"))
|
||||||
list.add_item(" " + tr("Shortcuts"))
|
list.add_item(" " + tr("Shortcuts"))
|
||||||
list.add_item(" " + tr("Backup"))
|
list.add_item(" " + tr("Backup"))
|
||||||
|
list.add_item(" " + tr("Performance"))
|
||||||
list.add_item(" " + tr("Indicators"))
|
list.add_item(" " + tr("Indicators"))
|
||||||
|
|
||||||
list.select(1 if changed_language else selected_item)
|
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:
|
func _on_List_item_selected(index : int) -> void:
|
||||||
selected_item = index
|
selected_item = index
|
||||||
for child in right_side.get_children():
|
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":
|
if OS.get_name() == "HTML5":
|
||||||
content_list.erase("Startup")
|
content_list.erase("Startup")
|
||||||
child.visible = child.name == content_list[index]
|
child.visible = child.name == content_list[index]
|
||||||
|
|
|
@ -887,6 +887,61 @@ __meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_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"]
|
[node name="Indicators" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
||||||
visible = false
|
visible = false
|
||||||
margin_top = 54.0
|
margin_top = 54.0
|
||||||
|
|
Loading…
Add table
Reference in a new issue