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:
Manolis Papadeas 2021-01-05 20:01:50 +02:00
parent 2d8d522031
commit 8daacbac5e
5 changed files with 84 additions and 3 deletions

View file

@ -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]

View file

@ -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