PowerControl: Decompose MenuStack.cs into Options/

This commit is contained in:
Kamil Trzciński 2022-12-19 22:47:10 +01:00
parent ebe1cdba87
commit f207c12935
18 changed files with 660 additions and 528 deletions

View file

@ -0,0 +1,64 @@
using System.Diagnostics;
using PowerControl.Helpers.AMD;
namespace PowerControl.Options
{
public static class TDP
{
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
{
Name = "TDP",
Options = { "3W", "4W", "5W", "6W", "7W", "8W", "10W", "12W", "15W" },
ApplyDelay = 1000,
ResetValue = () => { return "15W"; },
ActiveOption = "?",
ApplyValue = delegate (object selected)
{
if (!Settings.Default.AckAntiCheat(
Controller.TitleWithVersion,
"TDP",
"Changing TDP requires kernel access for a short period. Leave the game if it uses anti-cheat protection.")
)
return null;
uint mW = uint.Parse(selected.ToString().Replace("W", "")) * 1000;
if (VangoghGPU.IsSupported)
{
return CommonHelpers.Instance.WithGlobalMutex<object>(200, () =>
{
using (var sd = VangoghGPU.Open())
{
if (sd is null)
return null;
sd.SlowTDP = mW;
sd.FastTDP = mW;
}
return selected;
});
}
else
{
uint stampLimit = mW / 10;
Process.Start(new ProcessStartInfo()
{
FileName = "Resources/RyzenAdj/ryzenadj.exe",
ArgumentList = {
"--stapm-limit=" + stampLimit.ToString(),
"--slow-limit=" + mW.ToString(),
"--fast-limit=" + mW.ToString(),
},
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
CreateNoWindow = true
});
return selected;
}
}
};
}
}