diff --git a/.vs/DockerForm/v16/.suo b/.vs/DockerForm/v16/.suo index c4eab2c..49e639a 100644 Binary files a/.vs/DockerForm/v16/.suo and b/.vs/DockerForm/v16/.suo differ diff --git a/DockerForm/DatabaseManager.cs b/DockerForm/DatabaseManager.cs index 66acebd..9735b6a 100644 --- a/DockerForm/DatabaseManager.cs +++ b/DockerForm/DatabaseManager.cs @@ -87,27 +87,9 @@ public static void UpdateFilesAndRegistries(DockerGame game, string path_dest, s continue; } - // use opposite status if current powerstatus is missing - if (setting.data.ContainsKey((updateDB ? path_game : path_dest) + Form1.PowerStatus)) - { - if (updateDB) - path_game += Form1.PowerStatus; - else - path_dest += Form1.PowerStatus; - - crc_value = (updateDB ? path_game : path_dest); - } - else if (setting.data.ContainsKey((updateDB ? path_game : path_dest) + !Form1.PowerStatus)) - { - if (updateDB) - path_game += Form1.PowerStatus; - else - path_dest += Form1.PowerStatus; - - crc_value = (updateDB ? path_game : path_dest); - } - else if (!setting.data.ContainsKey((updateDB ? path_game : path_dest))) - continue; + // check if we have opposite plugged status + if (updateFILE && !setting.data.ContainsKey(path_dest)) + path_dest = path_dest.Replace(":False", ""); if (setting.Type == SettingsType.File) { @@ -132,7 +114,7 @@ public static void UpdateFilesAndRegistries(DockerGame game, string path_dest, s } else { - LogManager.UpdateLog("[" + game.Name + "]" + " " + path_dest + " database update skipped for file [" + file + "] - no data available"); + LogManager.UpdateLog("[" + game.Name + "]" + " " + path_dest + " settings restoration skipped for file [" + file + "] - no data available"); } } } @@ -163,7 +145,7 @@ public static void UpdateFilesAndRegistries(DockerGame game, string path_dest, s } else { - LogManager.UpdateLog("[" + game.Name + "]" + " " + path_dest + " database update skipped for registry entry [" + file + "] - no data available"); + LogManager.UpdateLog("[" + game.Name + "]" + " " + path_dest + " settings restoration skipped for registry entry [" + file + "] - no data available"); } } @@ -175,12 +157,12 @@ public static void UpdateFilesAndRegistries(DockerGame game, string path_dest, s game.SetCrc(crc_value); game.Serialize(); - Form1.SendNotification(game.Name + " settings have been updated for (" + path_dest + ")", pushToast); + Form1.SendNotification(game.Name + " settings have been updated", pushToast); } public static void UpdateFilesAndRegistries(bool updateFILE, bool updateDB) { - string path_db = Form1.CurrentController.Name; + string path_db = Form1.GetCurrentState(); foreach (DockerGame game in GameDB.Values) UpdateFilesAndRegistries(game, path_db, game.GetCrc(), updateDB, updateFILE, false, path_db); @@ -218,7 +200,7 @@ public static bool Equality(byte[] a1, byte[] b1) public static bool SanityCheck() { - string path_db = Form1.CurrentController.Name; + string path_db = Form1.GetCurrentState(); foreach (DockerGame game in GameDB.Values) { @@ -250,14 +232,6 @@ public static bool SanityCheck() continue; } - // use opposite status if current powerstatus is missing - if (setting.data.ContainsKey(path_db + Form1.PowerStatus)) - path_db += Form1.PowerStatus; - else if (setting.data.ContainsKey(path_db + !Form1.PowerStatus)) - path_db += !Form1.PowerStatus; - else if (!setting.data.ContainsKey(path_db)) - continue; - if (setting.Type == SettingsType.File) { file = new FileInfo(filename); diff --git a/DockerForm/Form1.cs b/DockerForm/Form1.cs index 088a1d2..f4f011a 100644 --- a/DockerForm/Form1.cs +++ b/DockerForm/Form1.cs @@ -64,6 +64,11 @@ protected override void WndProc(ref Message m) base.WndProc(ref m); } + private static void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e) + { + IsHardwarePending = true; + } + public static void SendNotification(string input, bool pushToast = false, bool pushLog = false, bool IsError = false) { if (pushLog) @@ -127,12 +132,32 @@ static void stopWatch_EventArrived(object sender, EventArrivedEventArgs e) // Update current title if (game_exe == info_exe || game_uri == info_uri) - DatabaseManager.UpdateFilesAndRegistries(game, CurrentController.Name, CurrentController.Name, true, false, true, CurrentController.Name); + DatabaseManager.UpdateFilesAndRegistries(game, GetCurrentState(), GetCurrentState(), true, false, true, GetCurrentState()); } } catch (Exception ex) { } } + public static string GetCurrentState() + { + string state = CurrentController.Name; + + /* + * NVIDIA GeForce RTX 2070 + * Intel(R) Iris(R) Plus Graphics + * Intel(R) Iris(R) Plus Graphics:False + */ + if (!DockStatus && !PowerStatus) + state += ":" + PowerStatus; + + return state; + } + + public static string GetCurrentPower() + { + return PowerStatus ? "plugged in" : "on battery"; + } + public static void VideoControllerMonitor(object data) { while(IsRunning) @@ -178,15 +203,14 @@ public static void VideoControllerMonitor(object data) { if (IsHardwareNew) { - if (VideoControllers.ContainsKey(Type.Internal)) - LogManager.UpdateLog("iGPU: " + VideoControllers[Type.Internal].Name); if (VideoControllers.ContainsKey(Type.Discrete)) LogManager.UpdateLog("eGPU: " + VideoControllers[Type.Discrete].Name); + else if (VideoControllers.ContainsKey(Type.Internal)) + LogManager.UpdateLog("iGPU: " + VideoControllers[Type.Internal].Name); } - else if (IsPowerNew) - { - LogManager.UpdateLog("Power: " + PowerStatus); - } + + if (IsPowerNew) + LogManager.UpdateLog("Power Status: " + GetCurrentPower()); if (IsFirstBoot) { @@ -230,7 +254,7 @@ public static void UpdateFormIcons() // drawing _instance.BeginInvoke((MethodInvoker)delegate () { - _instance.menuStrip2.Items[0].Text = CurrentController.Name + " (" + (PowerStatus ? "plugged in" : "on battery") + ")"; + _instance.menuStrip2.Items[0].Text = CurrentController.Name + " (" + GetCurrentPower() + ")"; _instance.undockedToolStripMenuItem.Image = ConstructorLogo; _instance.notifyIcon1.Icon = myIcon; _instance.Icon = myIcon; @@ -266,7 +290,7 @@ public void InsertOrUpdateGameItem(DockerGame game, bool Update = true) // Update current title DockerGame output = DatabaseManager.GameDB[game.GUID]; - DatabaseManager.UpdateFilesAndRegistries(output, CurrentController.Name, CurrentController.Name, true, false, true, CurrentController.Name); + DatabaseManager.UpdateFilesAndRegistries(output, GetCurrentState(), GetCurrentState(), true, false, true, GetCurrentState()); GameList.Sort(); } @@ -369,6 +393,9 @@ private void Form1_Shown(object sender, System.EventArgs e) LogManager.UpdateLog("Process monitor has started"); } + + // Monitor Power Status + SystemEvents.PowerModeChanged += OnPowerModeChanged; } private void Form1_FormClosing(Object sender, FormClosingEventArgs e)