steam-deck-tools/PowerControl/Options/Resolution.cs
Kamil Trzciński 2ff2864f23 PowerControl: Expose all settings and apply them in order
Since some settings impact others, the application will
apply them in a correct order with a fixed delay.

This additionally exposes all settings, just some of them
are not persisted on create, only on change.
2023-01-10 12:01:33 +01:00

54 lines
1.9 KiB
C#

using PowerControl.Helpers;
using PowerControl.Helpers.AMD;
namespace PowerControl.Options
{
public static class Resolution
{
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
{
Name = "Resolution",
PersistentKey = "Resolution",
ApplyDelay = 1000,
ResetValue = () =>
{
if (!GPUScaling.SafeResolutionChange && !Settings.Default.EnableExperimentalFeatures)
return null;
return DisplayResolutionController.GetAllResolutions().Last().ToString();
},
OptionsValues = delegate ()
{
var resolutions = DisplayResolutionController.GetAllResolutions();
if (resolutions.Count() > 1)
return resolutions.Select(item => item.ToString()).ToArray();
return null;
},
CurrentValue = delegate ()
{
if (!GPUScaling.SafeResolutionChange && !Settings.Default.EnableExperimentalFeatures)
return null;
return DisplayResolutionController.GetResolution().ToString();
},
ApplyValue = (selected) =>
{
var selectedResolution = new DisplayResolutionController.DisplayResolution(selected);
DisplayResolutionController.SetResolution(selectedResolution);
return DisplayResolutionController.GetResolution().ToString();
},
Impacts =
{
RefreshRate.Instance,
FPSLimit.Instance
},
AfterApply = () =>
{
// force refresh Refresh Rate
RefreshRate.Instance.Update();
// force reset and refresh of FPS limit
FPSLimit.Instance.Reset();
FPSLimit.Instance.Update();
}
};
}
}