Clean helper methods + move wine property to OS.

pull/32/head
Miepee 4 years ago
parent c3e60ee18c
commit f1cf1ce14f

@ -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

@ -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;

@ -42,25 +42,6 @@ public static class Core
/// </summary>
public static readonly string ModsPath = CrossPlatformOperations.CurrentPath + "/Mods";
/// <summary>
/// Checks if this is run via WINE.
/// </summary>
public static readonly bool IsThisRunningFromWine = CheckIfRunFromWINE();
/// <summary>
/// Checks if the Launcher is ran from WINE.
/// </summary>
/// <returns><see langword="true"/> if run from WINE, <see langword="false"/> if not.</returns>
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;
}
/// <summary>
/// This is used on Windows only. This sets a window to be in foreground, is used i.e. to fix am2r just being hidden.
/// </summary>

@ -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
/// </summary>
/// <param name="filename">Full Path to the file whose MD5 hash is supposed to be calculated.</param>
/// <returns>The MD5 hash as a <see cref="string"/>, empty string if file does not exist.</returns>
/*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)
{

@ -46,4 +46,23 @@ public static class OS
return "Unknown OS";
}
/// <summary>
/// Checks if this is run via WINE.
/// </summary>
public static readonly bool IsThisRunningFromWine = CheckIfRunFromWINE();
/// <summary>
/// Checks if the Launcher is ran from WINE.
/// </summary>
/// <returns><see langword="true"/> if run from WINE, <see langword="false"/> if not.</returns>
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;
}
}

@ -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();

Loading…
Cancel
Save