PowerControl: Update and expose UserProfiles that can persist per-game settings

This commit is contained in:
Kamil Trzciński 2023-01-05 23:35:31 +01:00
parent 3252e799cb
commit 2d5f8c498f
11 changed files with 436 additions and 200 deletions

View file

@ -0,0 +1,71 @@
namespace PowerControl.Options
{
public static class Profiles
{
public static ProfilesController? Controller;
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
{
Name = "Profiles",
OptionsValues = delegate ()
{
var currentProfileSettings = Controller?.CurrentProfileSettings;
if (currentProfileSettings == null)
return null;
if (currentProfileSettings.Exists)
{
return new string[] {
currentProfileSettings.ProfileName,
"Save All",
"Delete"
};
}
else
{
return new string[] {
"None",
"Create New",
"Save All"
};
}
},
CycleOptions = false,
CurrentValue = delegate ()
{
var currentProfileSettings = Controller?.CurrentProfileSettings;
if (currentProfileSettings == null)
return null;
if (currentProfileSettings.Exists)
return currentProfileSettings.ProfileName;
else
return "None";
},
ApplyValue = (selected) =>
{
switch (selected)
{
case "Delete":
Controller?.DeleteProfile();
return "None";
case "Create New":
Controller?.CreateProfile(false);
return Controller?.CurrentProfileSettings?.ProfileName;
case "Save All":
Controller?.CreateProfile(true);
return Controller?.CurrentProfileSettings?.ProfileName;
default:
return selected;
}
},
AfterApply = () =>
{
Instance?.Update();
}
};
}
}

View file

@ -25,7 +25,7 @@ namespace PowerControl.Options
ApplyValue = (selected) =>
{
DisplayResolutionController.SetRefreshRate(int.Parse(selected));
return DisplayResolutionController.GetRefreshRate().ToString();
},
AfterApply = () =>