steam-deck-tools/PowerControl/Helpers/ProfileSettings.cs
maniman303 3252e799cb PowerControl: Base Profiles Implementation (#38)
Small refactor of menu with options

Fix protection error on menuwithoptions

Make profiles controller non static

Dynamicall set and load options

Use IsOSDForeground when retriveing current game name

Better alt-tab functionality

Get rid off thread.sleep

Merged #38
2023-01-09 20:32:05 +01:00

54 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using CommonHelpers;
namespace PowerControl.Helper
{
public class ProfileSettings : BaseSettings
{
private static string profilesPath = Path.Combine(Directory.GetCurrentDirectory(), "Profiles");
static ProfileSettings()
{
Directory.CreateDirectory(profilesPath);
}
public ProfileSettings(string profileName) : base("Profile")
{
this.TouchSettings = true;
this.ConfigFile = Path.Combine(profilesPath, profileName + ".ini");
this.SettingChanging += delegate { };
this.SettingChanged += delegate { };
}
public T Get<T>(string key, T defaultValue)
{
return base.Get(key, defaultValue);
}
public new bool Set<T>(string key, T value)
{
return base.Set(key, value);
}
public static bool CheckIfExists(string profileName)
{
foreach (FileInfo fi in Directory.CreateDirectory(profilesPath).GetFiles())
{
if (fi.Name[^4..].Equals(".ini") && fi.Name[..^4].Equals(profileName))
{
return true;
}
}
return false;
}
}
}