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
|
|
|
|
|
{
|
2023-02-08 19:53:02 +01:00
|
|
|
if (!Dependencies.EnsureRTSS(null))
|
|
|
|
|
return "?";
|
|
|
|
|
|
2022-12-19 22:47:10 +01:00
|
|
|
RTSS.LoadProfile();
|
|
|
|
|
if (RTSS.GetProfileProperty("FramerateLimit", out int framerate))
|
2022-12-19 23:36:22 +01:00
|
|
|
return (framerate == 0) ? "Off" : framerate.ToString();
|
2023-02-08 19:53:02 +01:00
|
|
|
return null;
|
2022-12-19 22:47:10 +01:00
|
|
|
}
|
2023-02-08 19:53:02 +01:00
|
|
|
catch (Exception e)
|
2023-01-17 11:58:27 +01:00
|
|
|
{
|
|
|
|
|
#if DEBUG
|
|
|
|
|
CommonHelpers.Log.TraceException("RTSS", e);
|
|
|
|
|
#endif
|
2023-02-08 19:53:02 +01:00
|
|
|
return "?";
|
2023-01-17 11:58:27 +01:00
|
|
|
}
|
2022-12-19 22:47:10 +01:00
|
|
|
},
|
2022-12-19 23:36:22 +01:00
|
|
|
ApplyValue = (selected) =>
|
2022-12-19 22:47:10 +01:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-02-08 19:53:02 +01:00
|
|
|
if (!Dependencies.EnsureRTSS(Controller.TitleWithVersion))
|
|
|
|
|
return null;
|
|
|
|
|
|
2022-12-19 22:47:10 +01:00
|
|
|
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
|
|
|
}
|
2023-02-08 19:53:02 +01:00
|
|
|
catch (Exception e)
|
2023-01-17 11:58:27 +01:00
|
|
|
{
|
|
|
|
|
CommonHelpers.Log.TraceException("RTSS", e);
|
|
|
|
|
}
|
2022-12-19 22:47:10 +01:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|