Skip to content

Commit

Permalink
fixed everything ApplyMask related. Now using enum.
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed May 20, 2021
1 parent 8d2c33f commit fa85f8a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DockerForm/DockerForm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="profiles\default.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
17 changes: 9 additions & 8 deletions DockerForm/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ private void OnPowerModeChanged(object s, PowerModeChangedEventArgs e)

private static bool CanRunProfile(PowerProfile profile, bool IsFirstBoot)
{
bool isOnBattery = (profile.ApplyMask & (byte)ProfileMask.OnBattery) == (byte)ProfileMask.OnBattery;
bool isPluggedIn = (profile.ApplyMask & (byte)ProfileMask.PluggedIn) == (byte)ProfileMask.PluggedIn;
bool isExtGPU = (profile.ApplyMask & (byte)ProfileMask.ExternalGPU) == (byte)ProfileMask.ExternalGPU;
bool isOnBoot = (profile.ApplyMask & (byte)ProfileMask.OnStartup) == (byte)ProfileMask.OnStartup;
bool isOnStatusChange = (profile.ApplyMask & (byte)ProfileMask.OnStatusChange) == (byte)ProfileMask.OnStatusChange;
bool isOnScreen = (profile.ApplyMask & (byte)ProfileMask.ExternalScreen) == (byte)ProfileMask.ExternalScreen;
bool isOnBattery = profile._ApplyMask.HasFlag(ProfileMask.OnBattery);
bool isPluggedIn = profile._ApplyMask.HasFlag(ProfileMask.PluggedIn);
bool isExtGPU = profile._ApplyMask.HasFlag(ProfileMask.ExternalGPU);
bool isOnBoot = profile._ApplyMask.HasFlag(ProfileMask.OnStartup);
bool isOnStatusChange = profile._ApplyMask.HasFlag(ProfileMask.OnStatusChange);
bool isOnScreen = profile._ApplyMask.HasFlag(ProfileMask.ExternalScreen);

if (IsFirstBoot && !isOnBoot)
return false;
Expand Down Expand Up @@ -586,7 +586,7 @@ public void InsertOrUpdateGameItem(DockerGame game, bool auto)

public void UpdateGameList()
{
// Read all the game files (xml)
// Read all the game files (dat)
string[] fileEntries = Directory.GetFiles(path_database, "*.dat");
foreach (string filename in fileEntries)
{
Expand Down Expand Up @@ -809,7 +809,7 @@ public Form1()
}

// update MCHBAR
string command = "/Min /Nologo /Stdout /command=\"Delay 1000;rpci32 0 0 0 0x48;rwexit\"";
string command = "/Min /Nologo /Stdout /command=\"Delay 1000;rpci32 0 0 0 0x48;Delay 1000;rwexit\"";
var proc = new Process
{
StartInfo = new ProcessStartInfo
Expand All @@ -834,6 +834,7 @@ public Form1()
MCHBAR = MCHBAR.Substring(0, 6) + "59";
break;
}
proc.Dispose();

/* string ProcessorID = GetProcessorID();
switch (ProcessorID.Substring(ProcessorID.Length - 5))
Expand Down
22 changes: 15 additions & 7 deletions DockerForm/PowerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ namespace DockerForm
[Flags]
public enum ProfileMask
{
OnBattery = 0x01, // 0000 0000 0000 0001
PluggedIn = 0x02, // 0000 0000 0000 0010
ExternalGPU = 0x04, // 0000 0000 0000 0100
OnStartup = 0x08, // 0000 0000 0000 1000
ExternalScreen = 0x16, // 0000 0000 0001 0000
OnStatusChange = 0x32, // 0000 0000 0010 0000
None = 0,
OnBattery = 1,
PluggedIn = 2,
ExternalGPU = 4,
OnStartup = 8,
ExternalScreen = 16,
OnStatusChange = 32,
All = OnBattery | PluggedIn | ExternalGPU | OnStartup | ExternalScreen | OnStatusChange
}

public static class StringExtension
Expand All @@ -40,7 +42,13 @@ public class PowerProfile : IDisposable
public string CPUCore, IntelGPU, CPUCache, SystemAgent;
public string PowerBalanceCPU, PowerBalanceGPU;
public string ProfileName = "";
public byte ApplyMask = 0;
[XmlIgnore]
public ProfileMask _ApplyMask = ProfileMask.None;
public int ApplyMask
{
get { return (int)_ApplyMask; }
set { _ApplyMask = (ProfileMask)value; }
}
public int ApplyPriority = 0;

[NonSerialized()] public bool RunMe;
Expand Down
4 changes: 2 additions & 2 deletions DockerForm/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.1")]
[assembly: AssemblyFileVersion("0.1.0.1")]
[assembly: AssemblyVersion("0.1.0.3")]
[assembly: AssemblyFileVersion("0.1.0.3")]
11 changes: 7 additions & 4 deletions DockerForm/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ public Settings(Form1 form, DockerGame game)

foreach (PowerProfile profile in Form1.ProfileDB.Values)
{
bool isOnBattery = (profile.ApplyMask & (byte)ProfileMask.OnBattery) == (byte)ProfileMask.OnBattery;
bool isPluggedIn = (profile.ApplyMask & (byte)ProfileMask.PluggedIn) == (byte)ProfileMask.PluggedIn;
bool isExtGPU = (profile.ApplyMask & (byte)ProfileMask.ExternalGPU) == (byte)ProfileMask.ExternalGPU;
bool isOnScreen = (profile.ApplyMask & (byte)ProfileMask.ExternalScreen) == (byte)ProfileMask.ExternalScreen;
bool isOnBattery = profile._ApplyMask.HasFlag(ProfileMask.OnBattery);
bool isPluggedIn = profile._ApplyMask.HasFlag(ProfileMask.PluggedIn);
bool isExtGPU = profile._ApplyMask.HasFlag(ProfileMask.ExternalGPU);
bool isOnBoot = profile._ApplyMask.HasFlag(ProfileMask.OnStartup);
bool isOnStatusChange = profile._ApplyMask.HasFlag(ProfileMask.OnStatusChange);
bool isOnScreen = profile._ApplyMask.HasFlag(ProfileMask.ExternalScreen);

ListViewItem newProfile = new ListViewItem(new string[] { profile.ProfileName, isOnBattery.ToString(), isPluggedIn.ToString(), isExtGPU.ToString(), isOnScreen.ToString() }, profile.ProfileName);

// skip default
Expand Down

0 comments on commit fa85f8a

Please sign in to comment.