diff --git a/AM2RLauncher/AM2RLauncher.Wpf/Program.cs b/AM2RLauncher/AM2RLauncher.Wpf/Program.cs index 4c2b424..0cb289a 100644 --- a/AM2RLauncher/AM2RLauncher.Wpf/Program.cs +++ b/AM2RLauncher/AM2RLauncher.Wpf/Program.cs @@ -43,7 +43,7 @@ internal static class MainClass #endif //Log Wine - if (Core.IsThisRunningFromWine) log.Info("Currently running from WINE!"); + if (OS.IsThisRunningFromWine) log.Info("Currently running from WINE!"); // Try catch in case it ever crashes before actually getting to the Eto application try diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs index 52af7ab..b3cf138 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs @@ -80,7 +80,7 @@ namespace AM2RLauncher private static readonly bool isInternetThere = AM2RLauncherLib.Core.IsInternetThere; - private static readonly bool isThisRunningFromWine = AM2RLauncherLib.Core.IsThisRunningFromWine; + private static readonly bool isThisRunningFromWine = AM2RLauncherLib.OS.IsThisRunningFromWine; private static bool singleInstance; diff --git a/AM2RLauncher/AM2RLauncherLib/Core.cs b/AM2RLauncher/AM2RLauncherLib/Core.cs index cb08405..33883b5 100644 --- a/AM2RLauncher/AM2RLauncherLib/Core.cs +++ b/AM2RLauncher/AM2RLauncherLib/Core.cs @@ -42,25 +42,6 @@ public static class Core /// public static readonly string ModsPath = CrossPlatformOperations.CurrentPath + "/Mods"; - /// - /// Checks if this is run via WINE. - /// - public static readonly bool IsThisRunningFromWine = CheckIfRunFromWINE(); - - /// - /// Checks if the Launcher is ran from WINE. - /// - /// if run from WINE, if not. - private static bool CheckIfRunFromWINE() - { - // We check for wine by seeing if a reg entry exists. - // Not the best way, and could be removed from the future, but good enough for our purposes. - if (OS.IsWindows && (Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Wine") != null)) - return true; - - return false; - } - /// /// This is used on Windows only. This sets a window to be in foreground, is used i.e. to fix am2r just being hidden. /// diff --git a/AM2RLauncher/AM2RLauncherLib/HelperMethods.cs b/AM2RLauncher/AM2RLauncherLib/HelperMethods.cs index a968468..7e0fd29 100644 --- a/AM2RLauncher/AM2RLauncherLib/HelperMethods.cs +++ b/AM2RLauncher/AM2RLauncherLib/HelperMethods.cs @@ -33,9 +33,7 @@ public static class HelperMethods if (!dir.Exists) { - throw new DirectoryNotFoundException( - "Source directory does not exist or could not be found: " - + sourceDirName); + throw new DirectoryNotFoundException($"Source directory does not exist or could not be found: {sourceDirName}"); } DirectoryInfo[] dirs = dir.GetDirectories(); @@ -96,6 +94,8 @@ public static class HelperMethods /// /// Full Path to the file whose MD5 hash is supposed to be calculated. /// The MD5 hash as a , empty string if file does not exist. + /*TODO: in the future we should use sha256, as both md5 and sha1 are unsafe. + This however needs to wait, until we somehow can find a way to publish the windows launcher as .net core...*/ public static string CalculateMD5(string filename) { // Check if File exists first @@ -150,7 +150,7 @@ public static class HelperMethods HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://github.com"); try { - HttpWebResponse _ = (HttpWebResponse)request.GetResponse(); + request.GetResponse(); } catch (WebException) { diff --git a/AM2RLauncher/AM2RLauncherLib/OS.cs b/AM2RLauncher/AM2RLauncherLib/OS.cs index c2c03f1..16fd640 100644 --- a/AM2RLauncher/AM2RLauncherLib/OS.cs +++ b/AM2RLauncher/AM2RLauncherLib/OS.cs @@ -43,7 +43,26 @@ public static class OS return "Linux"; if (IsMac) return "Mac"; - + return "Unknown OS"; } + + /// + /// Checks if this is run via WINE. + /// + public static readonly bool IsThisRunningFromWine = CheckIfRunFromWINE(); + + /// + /// Checks if the Launcher is ran from WINE. + /// + /// if run from WINE, if not. + private static bool CheckIfRunFromWINE() + { + // We check for wine by seeing if a reg entry exists. + // Not the best way, and could be removed from the future, but good enough for our purposes. + if (IsWindows && (Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Wine") != null)) + return true; + + return false; + } } \ No newline at end of file diff --git a/AM2RLauncher/AM2RLauncherLib/Profile.cs b/AM2RLauncher/AM2RLauncherLib/Profile.cs index 82eb110..5a5413e 100644 --- a/AM2RLauncher/AM2RLauncherLib/Profile.cs +++ b/AM2RLauncher/AM2RLauncherLib/Profile.cs @@ -666,7 +666,7 @@ public static class Profile stream.WriteLine($"AM2RLauncher {Core.Version} log generated at {date}"); - if (Core.IsThisRunningFromWine) + if (OS.IsThisRunningFromWine) stream.WriteLine("Using WINE!"); stream.Flush();