2022-12-19 22:47:10 +01:00
|
|
|
using CommonHelpers;
|
|
|
|
|
using PowerControl.Helpers;
|
|
|
|
|
|
|
|
|
|
namespace PowerControl.Options
|
|
|
|
|
{
|
|
|
|
|
public static class FPSLimit
|
|
|
|
|
{
|
|
|
|
|
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
|
|
|
|
|
{
|
|
|
|
|
Name = "FPS Limit",
|
2022-12-20 22:52:56 +01:00
|
|
|
PersistentKey = "FPSLimit",
|
2022-12-19 22:47:10 +01:00
|
|
|
ApplyDelay = 500,
|
|
|
|
|
ResetValue = () => { return "Off"; },
|
|
|
|
|
OptionsValues = delegate ()
|
|
|
|
|
{
|
|
|
|
|
var refreshRate = DisplayResolutionController.GetRefreshRate();
|
2022-12-19 23:36:22 +01:00
|
|
|
return new string[]
|
2022-12-19 22:47:10 +01:00
|
|
|
{
|
2022-12-19 23:36:22 +01:00
|
|
|
(refreshRate / 4).ToString(),
|
|
|
|
|
(refreshRate / 2).ToString(),
|
|
|
|
|
refreshRate.ToString(),
|
|
|
|
|
"Off"
|
2022-12-19 22:47:10 +01:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
CurrentValue = delegate ()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
RTSS.LoadProfile();
|
|
|
|
|
if (RTSS.GetProfileProperty("FramerateLimit", out int framerate))
|
2022-12-19 23:36:22 +01:00
|
|
|
return (framerate == 0) ? "Off" : framerate.ToString();
|
2022-12-19 22:47:10 +01:00
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
return null;
|
|
|
|
|
},
|
2022-12-19 23:36:22 +01:00
|
|
|
ApplyValue = (selected) =>
|
2022-12-19 22:47:10 +01:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int framerate = 0;
|
2022-12-19 23:36:22 +01:00
|
|
|
if (selected != "Off")
|
|
|
|
|
framerate = int.Parse(selected);
|
2022-12-19 22:47:10 +01:00
|
|
|
|
|
|
|
|
RTSS.LoadProfile();
|
|
|
|
|
if (!RTSS.SetProfileProperty("FramerateLimit", framerate))
|
|
|
|
|
return null;
|
|
|
|
|
if (!RTSS.GetProfileProperty("FramerateLimit", out framerate))
|
|
|
|
|
return null;
|
|
|
|
|
RTSS.SaveProfile();
|
|
|
|
|
RTSS.UpdateProfiles();
|
2022-12-19 23:36:22 +01:00
|
|
|
return (framerate == 0) ? "Off" : framerate.ToString();
|
2022-12-19 22:47:10 +01:00
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|