Skip to content

Commit

Permalink
implemented power profile OnStatusChange
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed May 20, 2021
1 parent c361d5d commit 2f76ee9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
5 changes: 3 additions & 2 deletions DockerForm/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,14 @@ private static bool CanRunProfile(PowerProfile profile, bool IsFirstBoot)
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;

// exclusive conditions ...
if (IsFirstBoot && !isOnBoot)
return false;
else if (isOnStatusChange && isOnBoot)
return false;

// inclusive conditions ...
if (PowerStatus && isPluggedIn)
return true;
else if (!PowerStatus && isOnBattery)
Expand Down
1 change: 1 addition & 0 deletions DockerForm/PowerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum ProfileMask
ExternalGPU = 0x04, // 0000 0000 0000 0100
OnStartup = 0x08, // 0000 0000 0000 1000
ExternalScreen = 0x16, // 0000 0000 0001 0000
OnStatusChange = 0x32, // 0000 0000 0010 0000
}

public static class StringExtension
Expand Down
10 changes: 1 addition & 9 deletions DockerForm/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions DockerForm/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ public Settings(Form1 form, DockerGame game)
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 isOnScreen = (profile.ApplyMask & (byte)ProfileMask.ExternalScreen) == (byte)ProfileMask.ExternalScreen;
ListViewItem newProfile = new ListViewItem(new string[] { profile.ProfileName, isOnBattery.ToString(), isPluggedIn.ToString(), isExtGPU.ToString(), isOnBoot.ToString(), isOnScreen.ToString() }, profile.ProfileName);
ListViewItem newProfile = new ListViewItem(new string[] { profile.ProfileName, isOnBattery.ToString(), isPluggedIn.ToString(), isExtGPU.ToString(), isOnScreen.ToString() }, profile.ProfileName);

if (isOnBoot || profile.ApplyPriority == -1)
// skip default
if (profile.ApplyPriority == -1)
continue;

if (thisGame.Profiles.ContainsKey(profile.ProfileName))
Expand Down

0 comments on commit 2f76ee9

Please sign in to comment.