diff --git a/AM2RLauncher/AM2RLauncher.Gtk/AM2RLauncher.Gtk.csproj b/AM2RLauncher/AM2RLauncher.Gtk/AM2RLauncher.Gtk.csproj
index 80293d9..e368dc1 100644
--- a/AM2RLauncher/AM2RLauncher.Gtk/AM2RLauncher.Gtk.csproj
+++ b/AM2RLauncher/AM2RLauncher.Gtk/AM2RLauncher.Gtk.csproj
@@ -5,6 +5,7 @@
net5.0
icon64.ico
LatestMajor
+ latest
diff --git a/AM2RLauncher/AM2RLauncher.Gtk/Program.cs b/AM2RLauncher/AM2RLauncher.Gtk/Program.cs
index ebb9b1b..95ca7f2 100644
--- a/AM2RLauncher/AM2RLauncher.Gtk/Program.cs
+++ b/AM2RLauncher/AM2RLauncher.Gtk/Program.cs
@@ -4,101 +4,101 @@ using log4net.Config;
using System;
using System.IO;
-namespace AM2RLauncher.Gtk
+namespace AM2RLauncher.Gtk;
+
+///
+/// The main class for the GTK project.
+///
+static class MainClass
{
///
- /// The main class for the GTK project.
+ /// The logger for , used to write any caught exceptions.
+ ///
+ private static readonly ILog Log = LogManager.GetLogger(typeof(MainForm));
+ ///
+ /// The main method for the GTK project.
///
- static class MainClass
+ [STAThread]
+ public static void Main()
{
- ///
- /// The logger for , used to write any caught exceptions.
- ///
- private static readonly ILog Log = LogManager.GetLogger(typeof(MainForm));
- ///
- /// The main method for the GTK project.
- ///
- [STAThread]
- public static void Main(string[] args)
- {
- string launcherDataPath = GenerateCurrentPath();
+ string launcherDataPath = GenerateCurrentPath();
- // Make sure first, ~/.local/share/AM2RLauncher exists
- if (!Directory.Exists(launcherDataPath))
- Directory.CreateDirectory(launcherDataPath);
+ // Make sure first, ~/.local/share/AM2RLauncher exists
+ if (!Directory.Exists(launcherDataPath))
+ Directory.CreateDirectory(launcherDataPath);
- // Now, see if log4netConfig exists, if not write it again.
- if (!File.Exists(launcherDataPath + "/log4net.config"))
- File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath));
+ // Now, see if log4netConfig exists, if not write it again.
+ if (!File.Exists(launcherDataPath + "/log4net.config"))
+ File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath));
- // Configure logger
- XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));
+ // Configure logger
+ XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));
- try
- {
- Application GTKLauncher = new Application(Eto.Platforms.Gtk);
- LauncherUpdater.Main();
- GTKLauncher.UnhandledException += GTKLauncher_UnhandledException;
- GTKLauncher.Run(new MainForm());
- }
- catch (Exception e)
- {
- Log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace);
- Console.WriteLine(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace);
- Console.WriteLine("Check the logs at " + launcherDataPath + " for more info!");
- }
+ try
+ {
+ Application GTKLauncher = new Application(Eto.Platforms.Gtk);
+ LauncherUpdater.Main();
+ GTKLauncher.UnhandledException += GTKLauncher_UnhandledException;
+ GTKLauncher.Run(new MainForm());
}
-
- ///
- /// This method gets fired when an unhandled excpetion occurs in .
- ///
- private static void GTKLauncher_UnhandledException(object sender, Eto.UnhandledExceptionEventArgs e)
+ catch (Exception e)
{
- Log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.ExceptionObject);
- Application.Instance.Invoke(() =>
- {
- MessageBox.Show(Language.Text.UnhandledException + "\n*****Stack Trace*****\n\n" + e.ExceptionObject, "GTK", MessageBoxType.Error);
- });
+ Log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace);
+ Console.WriteLine(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace);
+ Console.WriteLine("Check the logs at " + launcherDataPath + " for more info!");
}
+ }
- // This is a duplicate of CrossPlatformOperations.GenerateCurrentPath, because trying to invoke that would cause a crash due to currentPlatform not being initialized.
- private static string GenerateCurrentPath()
+ ///
+ /// This method gets fired when an unhandled excpetion occurs in .
+ ///
+ private static void GTKLauncher_UnhandledException(object sender, Eto.UnhandledExceptionEventArgs e)
+ {
+ Log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.ExceptionObject);
+ Application.Instance.Invoke(() =>
{
- string nixHome = Environment.GetEnvironmentVariable("HOME");
- // First, we check if the user has a custom AM2RLAUNCHERDATA env var
- string am2rLauncherDataEnvVar = Environment.GetEnvironmentVariable("AM2RLAUNCHERDATA");
- if (!String.IsNullOrWhiteSpace(am2rLauncherDataEnvVar))
- {
- try
- {
- // This will create the directories recursively if they don't exist
- Directory.CreateDirectory(am2rLauncherDataEnvVar);
-
- // Our env var is now set and directories exist
- return am2rLauncherDataEnvVar;
- }
- catch { }
- }
-
- // First check if XDG_DATA_HOME is set, if not we'll use ~/.local/share
- string xdgDataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
- if (string.IsNullOrWhiteSpace(xdgDataHome))
- xdgDataHome = nixHome + "/.local/share";
-
- // Add AM2RLauncher to the end of the dataPath
- xdgDataHome += "/AM2RLauncher";
+ MessageBox.Show(Language.Text.UnhandledException + "\n*****Stack Trace*****\n\n" + e.ExceptionObject, "GTK", MessageBoxType.Error);
+ });
+ }
+ // This is a duplicate of CrossPlatformOperations.GenerateCurrentPath, because trying to invoke that would cause a crash due to currentPlatform not being initialized.
+ private static string GenerateCurrentPath()
+ {
+ string nixHome = Environment.GetEnvironmentVariable("HOME");
+ // First, we check if the user has a custom AM2RLAUNCHERDATA env var
+ string am2rLauncherDataEnvVar = Environment.GetEnvironmentVariable("AM2RLAUNCHERDATA");
+ if (!String.IsNullOrWhiteSpace(am2rLauncherDataEnvVar))
+ {
try
{
// This will create the directories recursively if they don't exist
- Directory.CreateDirectory(xdgDataHome);
+ Directory.CreateDirectory(am2rLauncherDataEnvVar);
// Our env var is now set and directories exist
- return xdgDataHome;
+ return am2rLauncherDataEnvVar;
}
catch { }
+ }
+
+ // First check if XDG_DATA_HOME is set, if not we'll use ~/.local/share
+ string xdgDataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
+ if (String.IsNullOrWhiteSpace(xdgDataHome))
+ xdgDataHome = nixHome + "/.local/share";
- return Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
+ // Add AM2RLauncher to the end of the dataPath
+ xdgDataHome += "/AM2RLauncher";
+
+ try
+ {
+ // This will create the directories recursively if they don't exist
+ Directory.CreateDirectory(xdgDataHome);
+
+ // Our env var is now set and directories exist
+ return xdgDataHome;
}
+ catch { }
+
+ return Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
}
}
+
diff --git a/AM2RLauncher/AM2RLauncher.Mac/Program.cs b/AM2RLauncher/AM2RLauncher.Mac/Program.cs
index 02280ce..9042367 100644
--- a/AM2RLauncher/AM2RLauncher.Mac/Program.cs
+++ b/AM2RLauncher/AM2RLauncher.Mac/Program.cs
@@ -4,79 +4,77 @@ using log4net.Config;
using System;
using System.IO;
-namespace AM2RLauncher.Mac
+namespace AM2RLauncher.Mac;
+
+///
+/// The main class for the Mac project.
+///
+static class MainClass
{
///
- /// The main class for the Mac project.
+ /// The logger for , used to write any caught exceptions.
///
- static class MainClass
- {
- ///
- /// The logger for , used to write any caught exceptions.
- ///
- private static readonly ILog Log = LogManager.GetLogger(typeof(MainForm));
+ private static readonly ILog Log = LogManager.GetLogger(typeof(MainForm));
- ///
- /// The main method for the Mac project.
- ///
- [STAThread]
- public static void Main(string[] args)
- {
- string launcherDataPath = GenerateCurrentPath();
+ ///
+ /// The main method for the Mac project.
+ ///
+ [STAThread]
+ public static void Main()
+ {
+ string launcherDataPath = GenerateCurrentPath();
- // Make sure first, ~/.local/share/AM2RLauncher exists
- if (!Directory.Exists(launcherDataPath))
- Directory.CreateDirectory(launcherDataPath);
+ // Make sure first, ~/.local/share/AM2RLauncher exists
+ if (!Directory.Exists(launcherDataPath))
+ Directory.CreateDirectory(launcherDataPath);
- // Now, see if log4netConfig exists, if not write it again.
- if (!File.Exists(launcherDataPath + "/log4net.config"))
- File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath));
+ // Now, see if log4netConfig exists, if not write it again.
+ if (!File.Exists(launcherDataPath + "/log4net.config"))
+ File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath));
- // Configure logger
- XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));
+ // Configure logger
+ XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));
- try
- {
- Application MacLauncher = new Application(Eto.Platforms.Mac64);
- LauncherUpdater.Main();
- MacLauncher.UnhandledException += MacLauncher_UnhandledException;
- MacLauncher.Run(new MainForm());
- }
- catch (Exception e)
- {
- Log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace);
- Console.WriteLine(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace);
- Console.WriteLine("Check the logs at " + launcherDataPath + " for more info!");
- }
- //new Application(Eto.Platforms.Mac64).Run(new MainForm());
+ try
+ {
+ Application macLauncher = new Application(Eto.Platforms.Mac64);
+ LauncherUpdater.Main();
+ macLauncher.UnhandledException += MacLauncher_UnhandledException;
+ macLauncher.Run(new MainForm());
}
-
- ///
- /// This method gets fired when an unhandled excpetion occurs in .
- ///
- private static void MacLauncher_UnhandledException(object sender, Eto.UnhandledExceptionEventArgs e)
+ catch (Exception e)
{
- Log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.ExceptionObject);
- Application.Instance.Invoke(() =>
- {
- MessageBox.Show(Language.Text.UnhandledException + "\n*****Stack Trace*****\n\n" + e.ExceptionObject, "Mac", MessageBoxType.Error);
- });
+ Log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace);
+ Console.WriteLine(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace);
+ Console.WriteLine("Check the logs at " + launcherDataPath + " for more info!");
}
+ }
- // This is a duplicate of CrossPlatformOperations.GenerateCurrentPath, because trying to invoke that would cause a crash due to currentPlatform not being initialized.
- private static string GenerateCurrentPath()
+ ///
+ /// This method gets fired when an unhandled excpetion occurs in .
+ ///
+ private static void MacLauncher_UnhandledException(object sender, Eto.UnhandledExceptionEventArgs e)
+ {
+ Log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.ExceptionObject);
+ Application.Instance.Invoke(() =>
{
- string nixHome = Environment.GetEnvironmentVariable("HOME");
- //Mac has the Path at HOME/Library/AM2RLauncher
- string macPath = nixHome + "/Library/AM2RLauncher";
- try
- {
- Directory.CreateDirectory(macPath);
- return macPath;
- }
- catch { }
+ MessageBox.Show(Language.Text.UnhandledException + "\n*****Stack Trace*****\n\n" + e.ExceptionObject, "Mac", MessageBoxType.Error);
+ });
+ }
- return Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
+ // This is a duplicate of CrossPlatformOperations.GenerateCurrentPath, because trying to invoke that would cause a crash due to currentPlatform not being initialized.
+ private static string GenerateCurrentPath()
+ {
+ string nixHome = Environment.GetEnvironmentVariable("HOME");
+ //Mac has the Path at HOME/Library/AM2RLauncher
+ string macPath = nixHome + "/Library/AM2RLauncher";
+ try
+ {
+ Directory.CreateDirectory(macPath);
+ return macPath;
}
+ catch { }
+
+ return Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
}
-}
+}
\ No newline at end of file
diff --git a/AM2RLauncher/AM2RLauncher.Wpf/AM2RLauncher.Wpf.csproj b/AM2RLauncher/AM2RLauncher.Wpf/AM2RLauncher.Wpf.csproj
index 9621af8..987c6d2 100644
--- a/AM2RLauncher/AM2RLauncher.Wpf/AM2RLauncher.Wpf.csproj
+++ b/AM2RLauncher/AM2RLauncher.Wpf/AM2RLauncher.Wpf.csproj
@@ -17,6 +17,7 @@
https://github.com/AM2R-Community-Developers/AM2RLauncherRewrite/
GNU General Public License v3.0
A Launcher for AM2R that with mod capabilities.
+ latest
diff --git a/AM2RLauncher/AM2RLauncher.Wpf/Program.cs b/AM2RLauncher/AM2RLauncher.Wpf/Program.cs
index 78e8d69..77ed605 100644
--- a/AM2RLauncher/AM2RLauncher.Wpf/Program.cs
+++ b/AM2RLauncher/AM2RLauncher.Wpf/Program.cs
@@ -5,80 +5,80 @@ using System;
using System.IO;
using System.Reflection;
-namespace AM2RLauncher.Wpf
+namespace AM2RLauncher.Wpf;
+
+///
+/// The main class for the WinForms project.
+///
+static class MainClass
{
///
- /// The main class for the WinForms project.
+ /// The logger for , used to write any caught exceptions.
+ ///
+ private static readonly ILog Log = LogManager.GetLogger(typeof(MainForm));
+ ///
+ /// The main method for the WinForms project.
///
- static class MainClass
+ [STAThread]
+ public static void Main()
{
- ///
- /// The logger for , used to write any caught exceptions.
- ///
- private static readonly ILog Log = LogManager.GetLogger(typeof(MainForm));
- ///
- /// The main method for the WinForms project.
- ///
- [STAThread]
- public static void Main(string[] args)
- {
- string launcherDataPath = GenerateCurrentPath();
+ string launcherDataPath = GenerateCurrentPath();
- // Make sure first, that the path exists
- if (!Directory.Exists(launcherDataPath))
- Directory.CreateDirectory(launcherDataPath);
+ // Make sure first, that the path exists
+ if (!Directory.Exists(launcherDataPath))
+ Directory.CreateDirectory(launcherDataPath);
- // Now, see if log4netConfig exists, if not write it again.
- if (!File.Exists(launcherDataPath + "/log4net.config"))
- File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath));
+ // Now, see if log4netConfig exists, if not write it again.
+ if (!File.Exists(launcherDataPath + "/log4net.config"))
+ File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath));
- // Configure logger
- XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));
+ // Configure logger
+ XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config"));
- // Try catch in case it ever crashes before actually getting to the Eto application
- try
- {
- Application winLauncher = new Application(Eto.Platforms.WinForms);
- LauncherUpdater.Main();
- winLauncher.UnhandledException += WinLauncher_UnhandledException;
- winLauncher.Run(new MainForm());
- }
- catch (Exception e)
- {
- Log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace);
- System.Windows.Forms.MessageBox.Show(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace, "Microsoft .NET Framework",
- System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
- }
+ // Try catch in case it ever crashes before actually getting to the Eto application
+ try
+ {
+ Application winLauncher = new Application(Eto.Platforms.WinForms);
+ LauncherUpdater.Main();
+ winLauncher.UnhandledException += WinLauncher_UnhandledException;
+ winLauncher.Run(new MainForm());
}
-
- ///
- /// This method gets fired when an unhandled excpetion occurs in .
- ///
- private static void WinLauncher_UnhandledException(object sender, Eto.UnhandledExceptionEventArgs e)
+ catch (Exception e)
{
- Log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.ExceptionObject);
- MessageBox.Show(Language.Text.UnhandledException + "\n*****Stack Trace*****\n\n" + e.ExceptionObject, "Microsoft .NET Framework", MessageBoxType.Error);
+ Log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace);
+ System.Windows.Forms.MessageBox.Show(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace, "Microsoft .NET Framework",
+ System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
}
+ }
+
+ ///
+ /// This method gets fired when an unhandled excpetion occurs in .
+ ///
+ private static void WinLauncher_UnhandledException(object sender, Eto.UnhandledExceptionEventArgs e)
+ {
+ Log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.ExceptionObject);
+ MessageBox.Show(Language.Text.UnhandledException + "\n*****Stack Trace*****\n\n" + e.ExceptionObject, "Microsoft .NET Framework", MessageBoxType.Error);
+ }
- // This is a duplicate of CrossPlatformOperations.GenerateCurrentPath, because trying to invoke that would cause a crash due to currentPlatform not being initialized.
- private static string GenerateCurrentPath()
+ // This is a duplicate of CrossPlatformOperations.GenerateCurrentPath, because trying to invoke that would cause a crash due to currentPlatform not being initialized.
+ private static string GenerateCurrentPath()
+ {
+ // First, we check if the user has a custom AM2RLAUNCHERDATA env var
+ string am2rLauncherDataEnvVar = Environment.GetEnvironmentVariable("AM2RLAUNCHERDATA");
+ if (!String.IsNullOrWhiteSpace(am2rLauncherDataEnvVar))
{
- // First, we check if the user has a custom AM2RLAUNCHERDATA env var
- string am2rLauncherDataEnvVar = Environment.GetEnvironmentVariable("AM2RLAUNCHERDATA");
- if (!String.IsNullOrWhiteSpace(am2rLauncherDataEnvVar))
+ try
{
- try
- {
- // This will create the directories recursively if they don't exist
- Directory.CreateDirectory(am2rLauncherDataEnvVar);
+ // This will create the directories recursively if they don't exist
+ Directory.CreateDirectory(am2rLauncherDataEnvVar);
- // Our env var is now set and directories exist
- return am2rLauncherDataEnvVar;
- }
- catch { }
+ // Our env var is now set and directories exist
+ return am2rLauncherDataEnvVar;
}
- // Windows has the path where the exe is located as default
- return Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
+ catch { }
}
+ // Windows has the path where the exe is located as default
+ return Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
}
}
+
diff --git a/AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs b/AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs
index e9a996a..5f89725 100644
--- a/AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs
+++ b/AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs
@@ -45,9 +45,9 @@ namespace AM2RLauncher
/// Linux: Will point to XDG_CONFIG_HOME/AM2RLauncher
/// Mac: Will point to ~/Library/Preferences/AM2RLauncher
///
- private static readonly string NIXLAUNCHERCONFIGPATH = CurrentPlatform.IsGtk ? ((String.IsNullOrWhiteSpace(LINUXXDGCONFIG) ? (NIXHOME + "/.config")
- : LINUXXDGCONFIG) + "/AM2RLauncher")
- : NIXHOME + "/Library/Preferences/AM2RLauncher";
+ private static readonly string NIXLAUNCHERCONFIGPATH = CurrentPlatform.IsGtk ? (String.IsNullOrWhiteSpace(LINUXXDGCONFIG) ? NIXHOME + "/.config"
+ : LINUXXDGCONFIG) + "/AM2RLauncher"
+ : NIXHOME + "/Library/Preferences/AM2RLauncher";
///
/// Config file path for *nix based systems. Will be + "/config.xml".
@@ -154,7 +154,7 @@ namespace AM2RLauncher
if (appConfig == null)
throw new NullReferenceException("Could not find the Config file! Please make sure it exists!");
ConnectionStringsSection connectionStringsSection = (ConnectionStringsSection)appConfig.GetSection("connectionStrings");
- if (connectionStringsSection == null || connectionStringsSection.ConnectionStrings[property]?.ConnectionString == null)
+ if (connectionStringsSection?.ConnectionStrings[property]?.ConnectionString == null)
throw new ArgumentException("The property " + property + " could not be found.");
connectionStringsSection.ConnectionStrings[property].ConnectionString = value.ToString();
appConfig.Save();
@@ -512,7 +512,7 @@ namespace AM2RLauncher
{
// First check if XDG_DATA_HOME is set, if not we'll use ~/.local/share
string xdgDataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
- if (string.IsNullOrWhiteSpace(xdgDataHome))
+ if (String.IsNullOrWhiteSpace(xdgDataHome))
{
Log.Info("Using default Linux CurrentPath.");
xdgDataHome = NIXHOME + "/.local/share";
diff --git a/AM2RLauncher/AM2RLauncher/LauncherUpdater.cs b/AM2RLauncher/AM2RLauncher/LauncherUpdater.cs
index 00b02fe..a32a836 100644
--- a/AM2RLauncher/AM2RLauncher/LauncherUpdater.cs
+++ b/AM2RLauncher/AM2RLauncher/LauncherUpdater.cs
@@ -18,18 +18,18 @@ namespace AM2RLauncher
// Auto updating is fun!
/// The Version that identifies this current release.
- public static readonly string VERSION = "2.2.0";
+ public const string VERSION = "2.2.0";
/// The current Running platform.
- private static readonly Platform currentPlatform = Platform.Instance; // Needs to be declared here as well, because I can't access the one from eto,
+ private static readonly Platform CurrentPlatform = Platform.Instance; // Needs to be declared here as well, because I can't access the one from eto,
// Since isn't loaded at this point
/// The Path of the oldConfig. Only gets used Windows-only
- private static readonly string oldConfigPath = CrossPlatformOperations.CURRENTPATH + "/" + CrossPlatformOperations.LAUNCHERNAME + ".oldCfg";
+ private static readonly string OldConfigPath = CrossPlatformOperations.CURRENTPATH + "/" + CrossPlatformOperations.LAUNCHERNAME + ".oldCfg";
/// The actual Path where the executable is stored, only used for updating.
//TODO: for mac, this reports the path of the mac runner, not the actual .app
- private static readonly string updatePath = currentPlatform.IsWinForms ? CrossPlatformOperations.CURRENTPATH : Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
+ private static readonly string UpdatePath = CurrentPlatform.IsWinForms ? CrossPlatformOperations.CURRENTPATH : Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
///
/// Our log object, that handles logging the current execution to a file.
@@ -51,19 +51,19 @@ namespace AM2RLauncher
Log.Info("AM2RLauncher.bak detected. Removing file.");
File.Delete(CrossPlatformOperations.CURRENTPATH + "/AM2RLauncher.bak");
}
- if (currentPlatform.IsWinForms && File.Exists(oldConfigPath))
+ if (CurrentPlatform.IsWinForms && File.Exists(OldConfigPath))
{
Log.Info(CrossPlatformOperations.LAUNCHERNAME + ".oldCfg detected. Removing file.");
- File.Delete(oldConfigPath);
+ File.Delete(OldConfigPath);
}
- if (currentPlatform.IsWinForms && Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/oldLib"))
+ if (CurrentPlatform.IsWinForms && Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/oldLib"))
{
Log.Info("Old lib folder detected, removing folder.");
Directory.Delete(CrossPlatformOperations.CURRENTPATH + "/oldLib", true);
}
// Clean up old update libs
- if (currentPlatform.IsWinForms && Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/lib"))
+ if (CurrentPlatform.IsWinForms && Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/lib"))
{
foreach (FileInfo file in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetFiles())
{
@@ -91,7 +91,7 @@ namespace AM2RLauncher
// This is supposed to fix the updater throwing an exception on windows 7 and earlier(?)
// See this for information: https://stackoverflow.com/q/2859790 and https://stackoverflow.com/a/50977774
- if (currentPlatform.IsWinForms)
+ if (CurrentPlatform.IsWinForms)
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
@@ -132,89 +132,90 @@ namespace AM2RLauncher
Log.Info((isCurrentVersionOutdated ? "Updating" : "Not Updating") + " from " + VERSION + " to " + onlineVersion);
- if (isCurrentVersionOutdated)
- {
- Log.Info("Current version (" + VERSION + ") is outdated! Initiating update for version " + onlineVersion + ".");
+ // No new update, exiting
+ if (!isCurrentVersionOutdated)
+ return;
+
+ Log.Info("Current version (" + VERSION + ") is outdated! Initiating update for version " + onlineVersion + ".");
- string tmpUpdatePath = CrossPlatformOperations.CURRENTPATH + "/tmpupdate/";
- string zipPath = CrossPlatformOperations.CURRENTPATH + "/launcher.zip";
+ string tmpUpdatePath = CrossPlatformOperations.CURRENTPATH + "/tmpupdate/";
+ string zipPath = CrossPlatformOperations.CURRENTPATH + "/launcher.zip";
- // Clean tmpupdate
- if (Directory.Exists(tmpUpdatePath))
- Directory.Delete(tmpUpdatePath, true);
- if (!Directory.Exists(tmpUpdatePath))
- Directory.CreateDirectory(tmpUpdatePath);
+ // Clean tmpupdate
+ if (Directory.Exists(tmpUpdatePath))
+ Directory.Delete(tmpUpdatePath, true);
+ if (!Directory.Exists(tmpUpdatePath))
+ Directory.CreateDirectory(tmpUpdatePath);
- try
+ try
+ {
+ using (var client = new WebClient())
{
- using (var client = new WebClient())
- {
- string platformSuffix = "";
- if (currentPlatform.IsWinForms) platformSuffix = "_win";
- else if (currentPlatform.IsGtk) platformSuffix = "_lin";
+ string platformSuffix = "";
+ if (CurrentPlatform.IsWinForms) platformSuffix = "_win";
+ else if (CurrentPlatform.IsGtk) platformSuffix = "_lin";
- Log.Info("Downloading https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest/download/AM2RLauncher_" + onlineVersion + platformSuffix + ".zip to " + zipPath + ".");
+ Log.Info("Downloading https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest/download/AM2RLauncher_" + onlineVersion + platformSuffix + ".zip to " + zipPath + ".");
- client.DownloadFile("https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest/download/AM2RLauncher_" + onlineVersion + platformSuffix + ".zip", zipPath);
+ client.DownloadFile("https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest/download/AM2RLauncher_" + onlineVersion + platformSuffix + ".zip", zipPath);
- Log.Info("File successfully downloaded.");
- }
- }
- catch (UnauthorizedAccessException)
- {
- Log.Error("UnauthorizedAccessException caught! Displaying MessageBox.");
- MessageBox.Show(Language.Text.UnauthorizedAccessMessage);
- return;
+ Log.Info("File successfully downloaded.");
}
+ }
+ catch (UnauthorizedAccessException)
+ {
+ Log.Error("UnauthorizedAccessException caught! Displaying MessageBox.");
+ MessageBox.Show(Language.Text.UnauthorizedAccessMessage);
+ return;
+ }
- ZipFile.ExtractToDirectory(zipPath, tmpUpdatePath);
- Log.Info("Updates successfully extracted to " + tmpUpdatePath);
+ ZipFile.ExtractToDirectory(zipPath, tmpUpdatePath);
+ Log.Info("Updates successfully extracted to " + tmpUpdatePath);
- File.Delete(zipPath);
- File.Move(updatePath + "/" + CrossPlatformOperations.LAUNCHERNAME, CrossPlatformOperations.CURRENTPATH + "/AM2RLauncher.bak");
- if (currentPlatform.IsWinForms) File.Move(CrossPlatformOperations.LAUNCHERNAME + ".config", CrossPlatformOperations.LAUNCHERNAME + ".oldCfg");
+ File.Delete(zipPath);
+ File.Move(UpdatePath + "/" + CrossPlatformOperations.LAUNCHERNAME, CrossPlatformOperations.CURRENTPATH + "/AM2RLauncher.bak");
+ if (CurrentPlatform.IsWinForms) File.Move(CrossPlatformOperations.LAUNCHERNAME + ".config", CrossPlatformOperations.LAUNCHERNAME + ".oldCfg");
- foreach (var file in new DirectoryInfo(tmpUpdatePath).GetFiles())
+ foreach (var file in new DirectoryInfo(tmpUpdatePath).GetFiles())
+ {
+ Log.Info("Moving " + file.FullName + " to " + CrossPlatformOperations.CURRENTPATH + "/" + file.Name);
+ File.Copy(file.FullName, UpdatePath + "/" + file.Name, true);
+ }
+ // For windows, the actual application is in "AM2RLauncher.dll". Which means, we need to update the lib folder as well.
+ if (CurrentPlatform.IsWinForms && Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/lib"))
+ {
+ // So, because Windows behavior is dumb...
+
+ // Rename all files in lib to *.bak
+ foreach (FileInfo file in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetFiles())
{
- Log.Info("Moving " + file.FullName + " to " + CrossPlatformOperations.CURRENTPATH + "/" + file.Name);
- File.Copy(file.FullName, updatePath + "/" + file.Name, true);
+ file.CopyTo(file.Directory + "/" + file.Name + ".bak");
}
- // For windows, the actual application is in "AM2RLauncher.dll". Which means, we need to update the lib folder as well.
- if (currentPlatform.IsWinForms && Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/lib"))
- {
- // So, because Windows behavior is dumb...
-
- // Rename all files in lib to *.bak
- foreach (FileInfo file in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetFiles())
- {
- file.CopyTo(file.Directory + "/" + file.Name + ".bak");
- }
- // Do the same for each subdir
- foreach (DirectoryInfo dir in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetDirectories())
+ // Do the same for each subdir
+ foreach (DirectoryInfo dir in new DirectoryInfo(CrossPlatformOperations.CURRENTPATH + "/lib").GetDirectories())
+ {
+ foreach (FileInfo file in dir.GetFiles())
{
- foreach (FileInfo file in dir.GetFiles())
- {
- file.CopyTo(file.Directory + "/" + file.Name + ".bak");
- }
+ file.CopyTo(file.Directory + "/" + file.Name + ".bak");
}
-
- // Yes, the above calls could be recursive. No, I can't be bothered to make them as such.
- if (Directory.Exists(tmpUpdatePath + "lib"))
- HelperMethods.DirectoryCopy(tmpUpdatePath + "lib", CrossPlatformOperations.CURRENTPATH + "/lib");
}
- Directory.Delete(tmpUpdatePath, true);
+ // Yes, the above calls could be recursive. No, I can't be bothered to make them as such.
+ if (Directory.Exists(tmpUpdatePath + "lib"))
+ HelperMethods.DirectoryCopy(tmpUpdatePath + "lib", CrossPlatformOperations.CURRENTPATH + "/lib");
+ }
- CrossPlatformOperations.CopyOldConfigToNewConfig();
+ Directory.Delete(tmpUpdatePath, true);
- Log.Info("Files extracted. Preparing to restart executable...");
+ CrossPlatformOperations.CopyOldConfigToNewConfig();
- if (currentPlatform.IsGtk) System.Diagnostics.Process.Start("chmod", "+x ./AM2RLauncher.Gtk");
+ Log.Info("Files extracted. Preparing to restart executable...");
- System.Diagnostics.Process.Start(updatePath + "/" + CrossPlatformOperations.LAUNCHERNAME);
- Environment.Exit(0);
- }
+ if (CurrentPlatform.IsGtk) System.Diagnostics.Process.Start("chmod", "+x ./AM2RLauncher.Gtk");
+
+ System.Diagnostics.Process.Start(UpdatePath + "/" + CrossPlatformOperations.LAUNCHERNAME);
+ Environment.Exit(0);
}
else
{
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/HelperMethods.cs b/AM2RLauncher/AM2RLauncher/MainForm/HelperMethods.cs
index a2ef13c..aa3d802 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/HelperMethods.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/HelperMethods.cs
@@ -67,14 +67,15 @@ namespace AM2RLauncher.Helpers
}
// If copying subdirectories, copy them and their contents to new location.
- if (copySubDirs)
+ if (!copySubDirs)
+ return;
+
+ foreach (DirectoryInfo subDir in dirs)
{
- foreach (DirectoryInfo subdir in dirs)
- {
- string tempPath = Path.Combine(destDirName, subdir.Name);
- DirectoryCopy(subdir.FullName, tempPath, overwriteFiles, copySubDirs);
- }
+ string tempPath = Path.Combine(destDirName, subDir.Name);
+ DirectoryCopy(subDir.FullName, tempPath, overwriteFiles);
}
+
}
@@ -170,10 +171,9 @@ namespace AM2RLauncher.Helpers
{
Log.Info("Checking internet connection...");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://github.com");
- HttpWebResponse response = null;
try
{
- response = (HttpWebResponse)request.GetResponse();
+ HttpWebResponse response = (HttpWebResponse)request.GetResponse();
}
catch (WebException)
{
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
index 964483a..3e37f6a 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
@@ -30,7 +30,7 @@ namespace AM2RLauncher
/// Pointer to the process you want to have in the foreground.
///
[DllImport("user32.dll")]
- static extern bool SetForegroundWindow(IntPtr hWnd);
+ private static extern bool SetForegroundWindow(IntPtr hWnd);
///
/// After the has bee loaded, git pull if a repo has been cloned already.
@@ -38,120 +38,120 @@ namespace AM2RLauncher
private async void PlayButtonLoadComplete(object sender, EventArgs e)
{
LoadProfiles();
- if (HelperMethods.IsPatchDataCloned() && (bool)autoUpdateAM2RCheck.Checked)
- {
- SetPlayButtonState(UpdateState.Downloading);
+ if (!HelperMethods.IsPatchDataCloned() || !(bool)autoUpdateAM2RCheck.Checked)
+ return;
+
+ SetPlayButtonState(UpdateState.Downloading);
- progressBar.Visible = true;
- progressLabel.Visible = true;
- progressBar.Value = 0;
+ progressBar.Visible = true;
+ progressLabel.Visible = true;
+ progressBar.Value = 0;
- // Try to pull first.
- try
- {
- await Task.Run(PullPatchData);
+ // Try to pull first.
+ try
+ {
+ await Task.Run(PullPatchData);
- // Thank you druid, for this case that should never happen
- if (!File.Exists(CrossPlatformOperations.CURRENTPATH + "/PatchData/profile.xml"))
+ // Thank you druid, for this case that should never happen
+ if (!File.Exists(CrossPlatformOperations.CURRENTPATH + "/PatchData/profile.xml"))
+ {
+ Log.Error("Druid PatchData corruption occurred!");
+ await Application.Instance.InvokeAsync(() =>
{
- Log.Error("Druid PatchData corruption occurred!");
- await Application.Instance.InvokeAsync(() =>
- {
- MessageBox.Show(Language.Text.CorruptPatchData, Language.Text.ErrorWindowTitle, MessageBoxType.Error);
- });
- HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/PatchData");
- return;
- }
+ MessageBox.Show(Language.Text.CorruptPatchData, Language.Text.ErrorWindowTitle, MessageBoxType.Error);
+ });
+ HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/PatchData");
+ return;
}
- catch (UserCancelledException) { } // We deliberately cancelled this!
- catch (LibGit2SharpException ex) // This is for any exceptions from libgit
+ }
+ catch (UserCancelledException) { } // We deliberately cancelled this!
+ catch (LibGit2SharpException ex) // This is for any exceptions from libgit
+ {
+ // Libgit2sharp error messages are always in english!
+ if (ex.Message.ToLower().Contains("failed to send request") || ex.Message.ToLower().Contains("connection with the server was terminated") ||
+ ex.Message.ToLower().Contains("failed to resolve address"))
{
- // Libgit2sharp error messages are always in english!
- if (ex.Message.ToLower().Contains("failed to send request") || ex.Message.ToLower().Contains("connection with the server was terminated") ||
- ex.Message.ToLower().Contains("failed to resolve address"))
+ if (!(bool)autoUpdateAM2RCheck.Checked)
{
- if (!(bool)autoUpdateAM2RCheck.Checked)
- {
- Log.Error("Internet connection failed while attempting to pull repository" + currentMirror + "!");
- MessageBox.Show(Language.Text.InternetConnectionDrop, Language.Text.WarningWindowTitle, MessageBoxType.Warning);
- }
- }
- else
- {
- Log.Error(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace);
- MessageBox.Show(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Language.Text.ErrorWindowTitle, MessageBoxType.Error);
+ Log.Error("Internet connection failed while attempting to pull repository" + currentMirror + "!");
+ MessageBox.Show(Language.Text.InternetConnectionDrop, Language.Text.WarningWindowTitle, MessageBoxType.Warning);
}
}
- catch (Exception ex) // This is if somehow any other exception might get thrown as well.
+ else
{
Log.Error(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace);
MessageBox.Show(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Language.Text.ErrorWindowTitle, MessageBoxType.Error);
}
- finally
- {
- progressBar.Visible = false;
- progressLabel.Visible = false;
- LoadProfiles();
- }
-
- // Handling for updates - if current version does not match PatchData version, rename folder so that we attempt to install!
- // Also, add a non-installable profile for it so people can access the older version or delete it from the mod manager.
- if (profileList.Count > 0 && IsProfileInstalled(profileList[0]))
- {
- ProfileXML currentXML = Serializer.Deserialize(File.ReadAllText(CrossPlatformOperations.CURRENTPATH + "/Profiles/Community Updates (Latest)/profile.xml"));
-
- if (currentXML.Version != profileList[0].Version)
- {
- Log.Info("New game version (" + profileList[0].Version + ") detected! Beginning archival of version " + currentXML.Version + "...");
+ }
+ catch (Exception ex) // This is if somehow any other exception might get thrown as well.
+ {
+ Log.Error(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace);
+ MessageBox.Show(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Language.Text.ErrorWindowTitle, MessageBoxType.Error);
+ }
+ finally
+ {
+ progressBar.Visible = false;
+ progressLabel.Visible = false;
+ LoadProfiles();
+ }
- string profileArchivePath = CrossPlatformOperations.CURRENTPATH + "/Profiles/Community Updates (" + currentXML.Version + ")";
+ // Handling for updates - if current version does not match PatchData version, rename folder so that we attempt to install!
+ // Also, add a non-installable profile for it so people can access the older version or delete it from the mod manager.
+ if (profileList.Count > 0 && IsProfileInstalled(profileList[0]))
+ {
+ ProfileXML currentXML = Serializer.Deserialize(File.ReadAllText(CrossPlatformOperations.CURRENTPATH + "/Profiles/Community Updates (Latest)/profile.xml"));
- // Do NOT overwrite if a path with this name already exists! It is likely an existing user archive.
- if (!Directory.Exists(profileArchivePath))
- {
- // Rename current Community Updates
- Directory.Move(CrossPlatformOperations.CURRENTPATH + "/Profiles/Community Updates (Latest)", profileArchivePath);
+ if (currentXML.Version != profileList[0].Version)
+ {
+ Log.Info("New game version (" + profileList[0].Version + ") detected! Beginning archival of version " + currentXML.Version + "...");
- currentXML.Name = "Community Updates (" + currentXML.Version + ")";
+ string profileArchivePath = CrossPlatformOperations.CURRENTPATH + "/Profiles/Community Updates (" + currentXML.Version + ")";
- // Set as non-installable so that it's just treated as a launching reference
- currentXML.Installable = false;
- currentXML.SupportsAndroid = false;
+ // Do NOT overwrite if a path with this name already exists! It is likely an existing user archive.
+ if (!Directory.Exists(profileArchivePath))
+ {
+ // Rename current Community Updates
+ Directory.Move(CrossPlatformOperations.CURRENTPATH + "/Profiles/Community Updates (Latest)", profileArchivePath);
- string modArchivePath = CrossPlatformOperations.CURRENTPATH + "/Mods/" + currentXML.Name;
+ currentXML.Name = "Community Updates (" + currentXML.Version + ")";
- // Do NOT overwrite if a path with this name already exists! It is likely an existing user archive.
- if (!Directory.Exists(modArchivePath))
- {
- Directory.CreateDirectory(modArchivePath);
- File.WriteAllText(modArchivePath + "/profile.xml", Serializer.Serialize(currentXML));
- Log.Info("Finished archival.");
- }
- else
- {
- HelperMethods.DeleteDirectory(profileArchivePath);
- Log.Info("Cancelling archival! User-defined archive in Mods already exists.");
- }
+ // Set as non-installable so that it's just treated as a launching reference
+ currentXML.Installable = false;
+ currentXML.SupportsAndroid = false;
+ string modArchivePath = CrossPlatformOperations.CURRENTPATH + "/Mods/" + currentXML.Name;
+ // Do NOT overwrite if a path with this name already exists! It is likely an existing user archive.
+ if (!Directory.Exists(modArchivePath))
+ {
+ Directory.CreateDirectory(modArchivePath);
+ File.WriteAllText(modArchivePath + "/profile.xml", Serializer.Serialize(currentXML));
+ Log.Info("Finished archival.");
}
- else // If our desired rename already exists, it's probably a user archive... so we just delete the folder and move on with installation of the new version.
+ else
{
- HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/Profiles/Community Updates (Latest)");
- Log.Info("Cancelling archival! User-defined archive in Profiles already exists.");
+ HelperMethods.DeleteDirectory(profileArchivePath);
+ Log.Info("Cancelling archival! User-defined archive in Mods already exists.");
}
- profileDropDown.SelectedIndex = 0;
- LoadProfiles();
+ }
+ else // If our desired rename already exists, it's probably a user archive... so we just delete the folder and move on with installation of the new version.
+ {
+ HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/Profiles/Community Updates (Latest)");
+ Log.Info("Cancelling archival! User-defined archive in Profiles already exists.");
+ }
+ profileDropDown.SelectedIndex = 0;
- }
- }
+ LoadProfiles();
- SetPlayButtonState(UpdateState.Install);
- UpdateStateMachine();
+
+ }
}
+
+ SetPlayButtonState(UpdateState.Install);
+ UpdateStateMachine();
}
///
@@ -282,7 +282,7 @@ namespace AM2RLauncher
Title = Language.Text.Select11FileDialog
};
- fileFinder.Filters.Add(new FileFilter(Language.Text.ZipArchiveText, new[] { ".zip" }));
+ fileFinder.Filters.Add(new FileFilter(Language.Text.ZipArchiveText, ".zip"));
if (fileFinder.ShowDialog(this) != DialogResult.Ok)
{
@@ -290,7 +290,7 @@ namespace AM2RLauncher
return;
}
- if (!string.IsNullOrWhiteSpace(fileFinder.FileName)) // This is default
+ if (!String.IsNullOrWhiteSpace(fileFinder.FileName)) // This is default
{
if (Directory.Exists(fileFinder.FileName))
{
@@ -416,13 +416,11 @@ namespace AM2RLauncher
{
progressBar.MinValue = 0;
progressBar.MaxValue = transferProgress.TotalObjects;
- if (currentGitObject < transferProgress.ReceivedObjects)
- {
- progressLabel.Text = Language.Text.ProgressbarProgress + " " + transferProgress.ReceivedObjects + " (" + (int)transferProgress.ReceivedBytes / 1000000 + "MB) / " + transferProgress.TotalObjects + " objects";
- currentGitObject = transferProgress.ReceivedObjects;
- progressBar.Value = transferProgress.ReceivedObjects;
-
- }
+ if (currentGitObject >= transferProgress.ReceivedObjects)
+ return;
+ progressLabel.Text = Language.Text.ProgressbarProgress + " " + transferProgress.ReceivedObjects + " (" + (int)transferProgress.ReceivedBytes / 1000000 + "MB) / " + transferProgress.TotalObjects + " objects";
+ currentGitObject = transferProgress.ReceivedObjects;
+ progressBar.Value = transferProgress.ReceivedObjects;
});
return true;
@@ -507,7 +505,7 @@ namespace AM2RLauncher
Title = Language.Text.SelectModFileDialog
};
- fileFinder.Filters.Add(new FileFilter(Language.Text.ZipArchiveText, new[] { ".zip" }));
+ fileFinder.Filters.Add(new FileFilter(Language.Text.ZipArchiveText, ".zip"));
if (fileFinder.ShowDialog(this) != DialogResult.Ok)
{
@@ -515,7 +513,7 @@ namespace AM2RLauncher
return;
}
- if (!string.IsNullOrWhiteSpace(fileFinder.FileName)) // This is default
+ if (!String.IsNullOrWhiteSpace(fileFinder.FileName)) // This is default
{
Log.Info("User selected \"" + fileFinder.FileName + "\"");
@@ -607,12 +605,11 @@ namespace AM2RLauncher
///
private void ProfilesButtonClickEvent(object sender, EventArgs e)
{
- if (IsProfileIndexValid())
- {
- Log.Info("User opened the profile directory for profile " + profileList[settingsProfileDropDown.SelectedIndex].Name +
- ", which is " + profileList[settingsProfileDropDown.SelectedIndex].SaveLocation);
- CrossPlatformOperations.OpenFolder(CrossPlatformOperations.CURRENTPATH + "/Profiles/" + profileList[settingsProfileDropDown.SelectedIndex].Name);
- }
+ if (!IsProfileIndexValid())
+ return;
+ Log.Info("User opened the profile directory for profile " + profileList[settingsProfileDropDown.SelectedIndex].Name +
+ ", which is " + profileList[settingsProfileDropDown.SelectedIndex].SaveLocation);
+ CrossPlatformOperations.OpenFolder(CrossPlatformOperations.CURRENTPATH + "/Profiles/" + profileList[settingsProfileDropDown.SelectedIndex].Name);
}
///
@@ -657,12 +654,11 @@ namespace AM2RLauncher
saveButton.Enabled = true;
saveButton.ToolTip = Language.Text.OpenSaveFolderToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text);
- if (!(settingsProfileDropDown.SelectedIndex < 0 || settingsProfileDropDown.Items.Count == 0))
- {
- profileNotesTextArea.TextColor = colGreen;
- profileNotesTextArea.Text = Language.Text.ProfileNotes + "\n" + profileList[settingsProfileDropDown.SelectedIndex].ProfileNotes;
- }
-
+ if (settingsProfileDropDown.SelectedIndex < 0 || settingsProfileDropDown.Items.Count == 0)
+ return;
+ profileNotesTextArea.TextColor = colGreen;
+ profileNotesTextArea.Text = Language.Text.ProfileNotes + "\n" + profileList[settingsProfileDropDown.SelectedIndex].ProfileNotes;
+
}
///
@@ -673,17 +669,16 @@ namespace AM2RLauncher
{
// Safety check
if (settingsProfileDropDown == null) return;
- if (settingsProfileDropDown.Items.Count == 0)
- {
- addModButton.Enabled = false;
- settingsProfileLabel.TextColor = colInactive;
- settingsProfileDropDown.Enabled = false;
- profileButton.Enabled = false;
- saveButton.Enabled = false;
- updateModButton.Enabled = false;
- deleteModButton.Enabled = false;
- profileNotesTextArea.TextColor = colInactive;
- }
+ if (settingsProfileDropDown.Items.Count != 0)
+ return;
+ addModButton.Enabled = false;
+ settingsProfileLabel.TextColor = colInactive;
+ settingsProfileDropDown.Enabled = false;
+ profileButton.Enabled = false;
+ saveButton.Enabled = false;
+ updateModButton.Enabled = false;
+ deleteModButton.Enabled = false;
+ profileNotesTextArea.TextColor = colInactive;
}
///
@@ -942,7 +937,7 @@ namespace AM2RLauncher
Title = Language.Text.SelectModFileDialog
};
- fileFinder.Filters.Add(new FileFilter(Language.Text.ZipArchiveText, new[] { ".zip" }));
+ fileFinder.Filters.Add(new FileFilter(Language.Text.ZipArchiveText, ".zip"));
if (fileFinder.ShowDialog(this) != DialogResult.Ok)
{
@@ -950,7 +945,7 @@ namespace AM2RLauncher
return;
}
- if (!string.IsNullOrWhiteSpace(fileFinder.FileName)) // This is default
+ if (!String.IsNullOrWhiteSpace(fileFinder.FileName)) // This is default
{
Log.Info("User selected \"" + fileFinder.FileName + "\"");
@@ -1047,32 +1042,34 @@ namespace AM2RLauncher
CrossPlatformOperations.WriteToConfig("Width", ClientSize.Width);
CrossPlatformOperations.WriteToConfig("Height", ClientSize.Height);
- CrossPlatformOperations.WriteToConfig("IsMaximized", (this.WindowState == WindowState.Maximized));
+ CrossPlatformOperations.WriteToConfig("IsMaximized", this.WindowState == WindowState.Maximized);
- if (updateState == UpdateState.Downloading)
+ switch (updateState)
{
- var result = MessageBox.Show(Language.Text.CloseOnCloningText, Language.Text.WarningWindowTitle, MessageBoxButtons.YesNo,
- MessageBoxType.Warning, MessageBoxDefaultButton.No);
- if (result == DialogResult.No)
+ case UpdateState.Downloading:
{
- e.Cancel = true;
+ var result = MessageBox.Show(Language.Text.CloseOnCloningText, Language.Text.WarningWindowTitle, MessageBoxButtons.YesNo,
+ MessageBoxType.Warning, MessageBoxDefaultButton.No);
+ if (result == DialogResult.No)
+ {
+ e.Cancel = true;
+ }
+ else
+ isGitProcessGettingCancelled = true;
+ // We don't need to delete any folders here, the cancelled gitClone will do that automatically for us :)
+ break;
}
- else
- isGitProcessGettingCancelled = true;
- // We don't need to delete any folders here, the cancelled gitClone will do that automatically for us :)
-
- }
- else if (updateState == UpdateState.Installing)
- {
- MessageBox.Show(Language.Text.CloseOnInstallingText, Language.Text.WarningWindowTitle, MessageBoxButtons.OK, MessageBoxType.Warning);
- e.Cancel = true;
+ case UpdateState.Installing:
+ MessageBox.Show(Language.Text.CloseOnInstallingText, Language.Text.WarningWindowTitle, MessageBoxButtons.OK, MessageBoxType.Warning);
+ e.Cancel = true;
+ break;
}
// This needs to be made invisible, otherwise a tray indicator will be visible (on linux?) that clicking crashes the application
trayIndicator.Visible = false;
if (e.Cancel)
- Log.Info("Cancelled MainForm closing event during UpdateState." + updateState.ToString() + ".");
+ Log.Info("Cancelled MainForm closing event during UpdateState." + updateState + ".");
else
Log.Info("Successfully closed MainForm. Exiting main thread.");
}
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs
index 7f76ca8..92229fe 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs
@@ -131,7 +131,7 @@ namespace AM2RLauncher
if (reloadProfileList)
LoadProfiles();
- Log.Info("Succesfully deleted profile " + profile.Name + ".");
+ Log.Info("Successfully deleted profile " + profile.Name + ".");
}
///
@@ -165,19 +165,18 @@ namespace AM2RLauncher
{
foreach (FileInfo file in dir.GetFiles())
{
- if (file.Name == "profile.xml")
+ if (file.Name != "profile.xml")
+ continue;
+ ProfileXML prof = Serializer.Deserialize(File.ReadAllText(dir.FullName + "/profile.xml"));
+ if (prof.Installable || IsProfileInstalled(prof)) // Safety check for non-installable profiles
{
- ProfileXML prof = Serializer.Deserialize(File.ReadAllText(dir.FullName + "/profile.xml"));
- if (prof.Installable || IsProfileInstalled(prof)) // Safety check for non-installable profiles
- {
- prof.DataPath = "/Mods/" + dir.Name;
- profileList.Add(prof);
- }
- else if (!IsProfileInstalled(prof)) // If not installable and isn't installed, remove it
- {
- prof.DataPath = "/Mods/" + dir.Name;
- DeleteProfile(prof, false);
- }
+ prof.DataPath = "/Mods/" + dir.Name;
+ profileList.Add(prof);
+ }
+ else if (!IsProfileInstalled(prof)) // If not installable and isn't installed, remove it
+ {
+ prof.DataPath = "/Mods/" + dir.Name;
+ DeleteProfile(prof, false);
}
}
}
@@ -284,7 +283,7 @@ namespace AM2RLauncher
Directory.CreateDirectory(profilePath + "/Resources");
profilePath += "/Resources";
- Log.Info("ProfileInstallstion: Created folder structure.");
+ Log.Info("ProfileInstallation: Created folder structure.");
}
// Extract 1.1
@@ -345,7 +344,7 @@ namespace AM2RLauncher
CrossPlatformOperations.ApplyXdeltaPatch(profilePath + "/data.win", dataPath + "/game.xdelta", profilePath + "/" + datawin);
CrossPlatformOperations.ApplyXdeltaPatch(profilePath + "/AM2R.exe", dataPath + "/AM2R.xdelta", profilePath + "/" + exe);
// Just in case the resulting file isn't chmoddded...
- Process.Start("chmod", "+x \"" + profilePath + "/" + exe + "\"").WaitForExit();
+ Process.Start("chmod", "+x \"" + profilePath + "/" + exe + "\"")?.WaitForExit();
// These are not needed by linux or Mac at all, so we delete them
File.Delete(profilePath + "/data.win");
@@ -409,7 +408,7 @@ namespace AM2RLauncher
Directory.SetCurrentDirectory(profilePath);
Console.SetError(new StreamWriter(Stream.Null));
Environment.SetEnvironmentVariable("ARCH", "x86_64");
- Process.Start(CrossPlatformOperations.CURRENTPATH + "/PatchData/utilities/appimagetool-x86_64.AppImage", "-n AM2R.AppDir").WaitForExit();
+ Process.Start(CrossPlatformOperations.CURRENTPATH + "/PatchData/utilities/appimagetool-x86_64.AppImage", "-n AM2R.AppDir")?.WaitForExit();
Directory.SetCurrentDirectory(workingDir);
Console.SetError(cliError);
@@ -439,7 +438,7 @@ namespace AM2RLauncher
// Copy profile.xml so we can grab data to compare for updates later!
// tldr; check if we're in PatchData or not
- if (new DirectoryInfo(dataPath).Parent.Name == "PatchData")
+ if (new DirectoryInfo(dataPath)?.Parent?.Name == "PatchData")
File.Copy(dataPath + "/../profile.xml", profilePath + "/profile.xml");
else File.Copy(dataPath + "/profile.xml", profilePath + "/profile.xml");
@@ -567,217 +566,217 @@ namespace AM2RLauncher
///
private void RunGame()
{
- if (IsProfileIndexValid())
- {
- ProfileXML profile = profileList[profileIndex.Value];
+ if (!IsProfileIndexValid())
+ return;
+
+ ProfileXML profile = profileList[profileIndex.Value];
- // These are used on both windows and linux for game logging
- string savePath = Platform.IsWinForms ? profile.SaveLocation.Replace("%localappdata%", Environment.GetEnvironmentVariable("LOCALAPPDATA"))
- : profile.SaveLocation.Replace("~", CrossPlatformOperations.NIXHOME);
- DirectoryInfo logDir = new DirectoryInfo(savePath + "/logs");
- string date = string.Join("-", DateTime.Now.ToString().Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries));
+ // These are used on both windows and linux for game logging
+ string savePath = Platform.IsWinForms ? profile.SaveLocation.Replace("%localappdata%", Environment.GetEnvironmentVariable("LOCALAPPDATA"))
+ : profile.SaveLocation.Replace("~", CrossPlatformOperations.NIXHOME);
+ DirectoryInfo logDir = new DirectoryInfo(savePath + "/logs");
+ string date = String.Join("-", DateTime.Now.ToString().Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries));
- Log.Info("Launching game profile " + profile.Name + ".");
+ Log.Info("Launching game profile " + profile.Name + ".");
- bool isLoggingEnabled = false;
- Application.Instance.Invoke(new Action(() => isLoggingEnabled = (bool)profileDebugLogCheck.Checked));
+ bool isLoggingEnabled = false;
+ Application.Instance.Invoke(new Action(() => isLoggingEnabled = (bool)profileDebugLogCheck.Checked));
- if (Platform.IsWinForms)
- {
- // Sets the arguments to empty, or to the profiles save path/logs and create time based logs. Creates the folder if necessary.
- string arguments = "";
+ if (Platform.IsWinForms)
+ {
+ // Sets the arguments to empty, or to the profiles save path/logs and create time based logs. Creates the folder if necessary.
+ string arguments = "";
- // Game logging
+ // Game logging
- if (isLoggingEnabled)
- {
- Log.Info("Performing logging setup for profile " + profile.Name + ".");
+ if (isLoggingEnabled)
+ {
+ Log.Info("Performing logging setup for profile " + profile.Name + ".");
- if (!Directory.Exists(logDir.FullName))
- Directory.CreateDirectory(logDir.FullName);
+ if (!Directory.Exists(logDir.FullName))
+ Directory.CreateDirectory(logDir.FullName);
- if (File.Exists(logDir.FullName + "/" + profile.Name + ".txt"))
- HelperMethods.RecursiveRollover(logDir.FullName + "/" + profile.Name + ".txt", 5);
+ if (File.Exists(logDir.FullName + "/" + profile.Name + ".txt"))
+ HelperMethods.RecursiveRollover(logDir.FullName + "/" + profile.Name + ".txt", 5);
- StreamWriter stream = File.AppendText(logDir.FullName + "/" + profile.Name + ".txt");
+ StreamWriter stream = File.AppendText(logDir.FullName + "/" + profile.Name + ".txt");
- stream.WriteLine("AM2RLauncher " + VERSION + " log generated at " + date);
+ stream.WriteLine("AM2RLauncher " + VERSION + " log generated at " + date);
- if (isThisRunningFromWine)
- stream.WriteLine("Using WINE!");
+ if (isThisRunningFromWine)
+ stream.WriteLine("Using WINE!");
- stream.Flush();
+ stream.Flush();
- stream.Close();
+ stream.Close();
- arguments = "-debugoutput \"" + logDir.FullName + "/" + profile.Name + ".txt\" -output \"" + logDir.FullName + "/" + profile.Name + ".txt\"";
- }
+ arguments = "-debugoutput \"" + logDir.FullName + "/" + profile.Name + ".txt\" -output \"" + logDir.FullName + "/" + profile.Name + ".txt\"";
+ }
- ProcessStartInfo proc = new ProcessStartInfo();
+ ProcessStartInfo proc = new ProcessStartInfo();
- proc.WorkingDirectory = CrossPlatformOperations.CURRENTPATH + "/Profiles/" + profile.Name;
- proc.FileName = proc.WorkingDirectory + "/AM2R.exe";
- proc.Arguments = arguments;
+ proc.WorkingDirectory = CrossPlatformOperations.CURRENTPATH + "/Profiles/" + profile.Name;
+ proc.FileName = proc.WorkingDirectory + "/AM2R.exe";
+ proc.Arguments = arguments;
- Log.Info("CWD of Profile is " + proc.WorkingDirectory);
+ Log.Info("CWD of Profile is " + proc.WorkingDirectory);
- using (var p = Process.Start(proc))
- {
- SetForegroundWindow(p.MainWindowHandle);
- p.WaitForExit();
- }
- }
- else if (Platform.IsGtk)
+ using (var p = Process.Start(proc))
{
+ SetForegroundWindow(p.MainWindowHandle);
+ p.WaitForExit();
+ }
+ }
+ else if (Platform.IsGtk)
+ {
- ProcessStartInfo startInfo = new ProcessStartInfo();
+ ProcessStartInfo startInfo = new ProcessStartInfo();
- string envVars = "";
- Application.Instance.Invoke(new Action(() => envVars = customEnvVarTextBox.Text));
- Log.Info("Is the environment textbox null or whitespace = " + string.IsNullOrWhiteSpace(envVars));
+ string envVars = "";
+ Application.Instance.Invoke(new Action(() => envVars = customEnvVarTextBox.Text));
+ Log.Info("Is the environment textbox null or whitespace = " + String.IsNullOrWhiteSpace(envVars));
- if (!string.IsNullOrWhiteSpace(envVars))
+ if (!String.IsNullOrWhiteSpace(envVars))
+ {
+ for (int i = 0; i < envVars.Count(f => f == '='); i++)
{
- for (int i = 0; i < envVars.Count(f => f == '='); i++)
+ // Env var variable
+ string variable = envVars.Substring(0, envVars.IndexOf('='));
+ envVars = envVars.Replace(variable + "=", "");
+
+ // This thing here is the value parser. Since values are sometimes in quotes, i need to compensate for them.
+ int valueSubstringLength = 0;
+ if (envVars[0] != '"') // If value is not embedded in "", check if there are spaces left. If yes, get the index of the space, if not that was the last
+ {
+ if (envVars.IndexOf(' ') >= 0)
+ valueSubstringLength = envVars.IndexOf(' ') + 1;
+ else
+ valueSubstringLength = envVars.Length;
+ }
+ else // If value is embedded in "", check if there are spaces after the "". if yes, get index of that, if not that was the last
{
- // Env var variable
- string variable = envVars.Substring(0, envVars.IndexOf('='));
- envVars = envVars.Replace(variable + "=", "");
-
- // This thing here is the value parser. Since values are sometimes in quotes, i need to compensate for them.
- int valueSubstringLength = 0;
- if (envVars[0] != '"') // If value is not embedded in "", check if there are spaces left. If yes, get the index of the space, if not that was the last
- {
- if (envVars.IndexOf(' ') >= 0)
- valueSubstringLength = envVars.IndexOf(' ') + 1;
- else
- valueSubstringLength = envVars.Length;
- }
- else // If value is embedded in "", check if there are spaces after the "". if yes, get index of that, if not that was the last
- {
- int secondQuoteIndex = envVars.IndexOf('"', envVars.IndexOf('"') + 1);
- if (envVars.IndexOf(' ', secondQuoteIndex) >= 0)
- valueSubstringLength = envVars.IndexOf(' ', secondQuoteIndex) + 1;
- else
- valueSubstringLength = envVars.Length;
- }
- // Env var value
- string value = envVars.Substring(0, valueSubstringLength);
- envVars = envVars.Substring(value.Length);
-
- Log.Info("Adding variable \"" + variable + "\" with value \"" + value + "\"");
- startInfo.EnvironmentVariables[variable] = value;
+ int secondQuoteIndex = envVars.IndexOf('"', envVars.IndexOf('"') + 1);
+ if (envVars.IndexOf(' ', secondQuoteIndex) >= 0)
+ valueSubstringLength = envVars.IndexOf(' ', secondQuoteIndex) + 1;
+ else
+ valueSubstringLength = envVars.Length;
}
+ // Env var value
+ string value = envVars.Substring(0, valueSubstringLength);
+ envVars = envVars.Substring(value.Length);
+
+ Log.Info("Adding variable \"" + variable + "\" with value \"" + value + "\"");
+ startInfo.EnvironmentVariables[variable] = value;
}
+ }
- // If we're supposed to log profiles, add events that track those and append them to this var. otherwise keep it null
- string terminalOutput = null;
+ // If we're supposed to log profiles, add events that track those and append them to this var. otherwise keep it null
+ string terminalOutput = null;
- startInfo.UseShellExecute = false;
- startInfo.WorkingDirectory = CrossPlatformOperations.CURRENTPATH + "/Profiles/" + profile.Name;
- startInfo.FileName = startInfo.WorkingDirectory + "/AM2R.AppImage";
+ startInfo.UseShellExecute = false;
+ startInfo.WorkingDirectory = CrossPlatformOperations.CURRENTPATH + "/Profiles/" + profile.Name;
+ startInfo.FileName = startInfo.WorkingDirectory + "/AM2R.AppImage";
- Log.Info("CWD of Profile is " + startInfo.WorkingDirectory);
+ Log.Info("CWD of Profile is " + startInfo.WorkingDirectory);
- Log.Info("Launching game with following variables: ");
- foreach (System.Collections.DictionaryEntry item in startInfo.EnvironmentVariables)
- {
- Log.Info("Key: \"" + item.Key + "\" Value: \"" + item.Value + "\"");
- }
+ Log.Info("Launching game with following variables: ");
+ foreach (System.Collections.DictionaryEntry item in startInfo.EnvironmentVariables)
+ {
+ Log.Info("Key: \"" + item.Key + "\" Value: \"" + item.Value + "\"");
+ }
- using (Process p = new Process())
+ using (Process p = new Process())
+ {
+ p.StartInfo = startInfo;
+ if (isLoggingEnabled)
{
- p.StartInfo = startInfo;
- if (isLoggingEnabled)
- {
- p.StartInfo.RedirectStandardOutput = true;
- p.OutputDataReceived += (sender, e) => { terminalOutput += e.Data + "\n"; };
+ p.StartInfo.RedirectStandardOutput = true;
+ p.OutputDataReceived += (sender, e) => { terminalOutput += e.Data + "\n"; };
- p.StartInfo.RedirectStandardError = true;
- p.ErrorDataReceived += (sender, e) => { terminalOutput += e.Data + "\n"; };
- }
-
- p.Start();
+ p.StartInfo.RedirectStandardError = true;
+ p.ErrorDataReceived += (sender, e) => { terminalOutput += e.Data + "\n"; };
+ }
- if (isLoggingEnabled)
- {
- p.BeginOutputReadLine();
- p.BeginErrorReadLine();
- }
+ p.Start();
- p.WaitForExit();
+ if (isLoggingEnabled)
+ {
+ p.BeginOutputReadLine();
+ p.BeginErrorReadLine();
}
- if (terminalOutput != null)
- {
- Log.Info("Performed logging setup for profile " + profile.Name + ".");
+ p.WaitForExit();
+ }
- if (!Directory.Exists(logDir.FullName))
- Directory.CreateDirectory(logDir.FullName);
+ if (terminalOutput != null)
+ {
+ Log.Info("Performed logging setup for profile " + profile.Name + ".");
- if (File.Exists(logDir.FullName + "/" + profile.Name + ".txt"))
- HelperMethods.RecursiveRollover(logDir.FullName + "/" + profile.Name + ".txt", 5);
+ if (!Directory.Exists(logDir.FullName))
+ Directory.CreateDirectory(logDir.FullName);
- StreamWriter stream = File.AppendText(logDir.FullName + "/" + profile.Name + ".txt");
+ if (File.Exists(logDir.FullName + "/" + profile.Name + ".txt"))
+ HelperMethods.RecursiveRollover(logDir.FullName + "/" + profile.Name + ".txt", 5);
- // Write general info
- stream.WriteLine("AM2RLauncher " + VERSION + " log generated at " + date);
+ StreamWriter stream = File.AppendText(logDir.FullName + "/" + profile.Name + ".txt");
- // Write what was in the terminal
- stream.WriteLine(terminalOutput);
+ // Write general info
+ stream.WriteLine("AM2RLauncher " + VERSION + " log generated at " + date);
- stream.Flush();
+ // Write what was in the terminal
+ stream.WriteLine(terminalOutput);
- stream.Close();
- }
+ stream.Flush();
+ stream.Close();
}
- else if (Platform.IsMac)
- {
- // Sets the arguments to only open the game, or append the profiles save path/logs and create time based logs. Creates the folder if necessary.
- string arguments = "AM2R.app -W";
- // Game logging
- if (isLoggingEnabled)
- {
- Log.Info("Performing logging setup for profile " + profile.Name + ".");
+ }
+ else if (Platform.IsMac)
+ {
+ // Sets the arguments to only open the game, or append the profiles save path/logs and create time based logs. Creates the folder if necessary.
+ string arguments = "AM2R.app -W";
+
+ // Game logging
+ if (isLoggingEnabled)
+ {
+ Log.Info("Performing logging setup for profile " + profile.Name + ".");
- if (!Directory.Exists(logDir.FullName))
- Directory.CreateDirectory(logDir.FullName);
+ if (!Directory.Exists(logDir.FullName))
+ Directory.CreateDirectory(logDir.FullName);
- if (File.Exists(logDir.FullName + "/" + profile.Name + ".txt"))
- HelperMethods.RecursiveRollover(logDir.FullName + "/" + profile.Name + ".txt", 5);
+ if (File.Exists(logDir.FullName + "/" + profile.Name + ".txt"))
+ HelperMethods.RecursiveRollover(logDir.FullName + "/" + profile.Name + ".txt", 5);
- StreamWriter stream = File.AppendText(logDir.FullName + "/" + profile.Name + ".txt");
+ StreamWriter stream = File.AppendText(logDir.FullName + "/" + profile.Name + ".txt");
- stream.WriteLine("AM2RLauncher " + VERSION + " log generated at " + date);
+ stream.WriteLine("AM2RLauncher " + VERSION + " log generated at " + date);
- stream.Flush();
+ stream.Flush();
- stream.Close();
+ stream.Close();
- arguments += " --stdout \"" + logDir.FullName + "/" + profile.Name + ".txt\" --stderr \"" + logDir.FullName + "/" + profile.Name + ".txt\"";
- }
+ arguments += " --stdout \"" + logDir.FullName + "/" + profile.Name + ".txt\" --stderr \"" + logDir.FullName + "/" + profile.Name + ".txt\"";
+ }
- ProcessStartInfo proc = new ProcessStartInfo();
+ ProcessStartInfo proc = new ProcessStartInfo();
- proc.WorkingDirectory = CrossPlatformOperations.CURRENTPATH + "/Profiles/" + profile.Name;
- proc.FileName = "open";
- proc.Arguments = arguments;
+ proc.WorkingDirectory = CrossPlatformOperations.CURRENTPATH + "/Profiles/" + profile.Name;
+ proc.FileName = "open";
+ proc.Arguments = arguments;
- Log.Info("CWD of Profile is " + proc.WorkingDirectory);
+ Log.Info("CWD of Profile is " + proc.WorkingDirectory);
- using (var p = Process.Start(proc))
- {
- p?.WaitForExit();
- }
+ using (var p = Process.Start(proc))
+ {
+ p?.WaitForExit();
}
- else
- Log.Error(Platform.ID + " cannot run games!");
-
- Log.Info("Profile " + profile.Name + " process exited.");
}
+ else
+ Log.Error(Platform.ID + " cannot run games!");
+
+ Log.Info("Profile " + profile.Name + " process exited.");
}
}
}
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs
index 8076b3b..a56dbc8 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs
@@ -79,30 +79,24 @@ namespace AM2RLauncher
private void UpdateApkState()
{
// Safety check
- if (apkButton != null)
+ if (apkButton == null)
+ return;
+ // If profile supports Android...
+ if (IsProfileIndexValid() && profileList[profileIndex.Value].SupportsAndroid && profileList[profileIndex.Value].Installable)
{
- // If profile supports Android...
- if (IsProfileIndexValid() && profileList[profileIndex.Value].SupportsAndroid && profileList[profileIndex.Value].Installable)
+ // If we are NOT already creating an APK...
+ if (apkButtonState == ApkButtonState.Create)
{
- // If we are NOT already creating an APK...
- if (apkButtonState == ApkButtonState.Create)
- {
- // Switch status based on main button's state
- switch (updateState)
- {
- case UpdateState.Download: apkButton.Enabled = false; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; break;
- case UpdateState.Downloading: apkButton.Enabled = false; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; break;
- case UpdateState.Select11: apkButton.Enabled = false; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; break;
- case UpdateState.Install: apkButton.Enabled = true; apkButton.ToolTip = Language.Text.ApkButtonEnabledToolTip.Replace("$NAME", profileDropDown?.Items[profileDropDown.SelectedIndex]?.Text ?? ""); break;
- case UpdateState.Installing: apkButton.Enabled = false; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; break;
- case UpdateState.Play: apkButton.Enabled = true; apkButton.ToolTip = Language.Text.ApkButtonEnabledToolTip.Replace("$NAME", profileDropDown?.Items[profileDropDown.SelectedIndex]?.Text ?? ""); break;
- case UpdateState.Playing: apkButton.Enabled = false; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; break;
- }
- }
- else // Otherwise, disable.
+ // Switch status based on main button's state
+ switch (updateState)
{
- apkButton.Enabled = false;
- apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip;
+ case UpdateState.Download: apkButton.Enabled = false; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; break;
+ case UpdateState.Downloading: apkButton.Enabled = false; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; break;
+ case UpdateState.Select11: apkButton.Enabled = false; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; break;
+ case UpdateState.Install: apkButton.Enabled = true; apkButton.ToolTip = Language.Text.ApkButtonEnabledToolTip.Replace("$NAME", profileDropDown?.Items[profileDropDown.SelectedIndex]?.Text ?? ""); break;
+ case UpdateState.Installing: apkButton.Enabled = false; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; break;
+ case UpdateState.Play: apkButton.Enabled = true; apkButton.ToolTip = Language.Text.ApkButtonEnabledToolTip.Replace("$NAME", profileDropDown?.Items[profileDropDown.SelectedIndex]?.Text ?? ""); break;
+ case UpdateState.Playing: apkButton.Enabled = false; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; break;
}
}
else // Otherwise, disable.
@@ -111,6 +105,11 @@ namespace AM2RLauncher
apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip;
}
}
+ else // Otherwise, disable.
+ {
+ apkButton.Enabled = false;
+ apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip;
+ }
}
///
@@ -119,31 +118,30 @@ namespace AM2RLauncher
private void UpdateProfileState()
{
// Safety check
- if (profileDropDown != null)
+ if (profileDropDown == null)
+ return;
+ switch (updateState)
{
- switch (updateState)
- {
- case UpdateState.Download: profileDropDown.Enabled = false; break;
- case UpdateState.Downloading: profileDropDown.Enabled = false; break;
- case UpdateState.Select11: profileDropDown.Enabled = true; break;
- case UpdateState.Install: profileDropDown.Enabled = true; break;
- case UpdateState.Installing: profileDropDown.Enabled = false; break;
- case UpdateState.Play: profileDropDown.Enabled = true; break;
- case UpdateState.Playing: profileDropDown.Enabled = false; break;
- }
- switch (apkButtonState)
- {
- case ApkButtonState.Creating: profileDropDown.Enabled = false; break;
- }
+ case UpdateState.Download: profileDropDown.Enabled = false; break;
+ case UpdateState.Downloading: profileDropDown.Enabled = false; break;
+ case UpdateState.Select11: profileDropDown.Enabled = true; break;
+ case UpdateState.Install: profileDropDown.Enabled = true; break;
+ case UpdateState.Installing: profileDropDown.Enabled = false; break;
+ case UpdateState.Play: profileDropDown.Enabled = true; break;
+ case UpdateState.Playing: profileDropDown.Enabled = false; break;
+ }
+ switch (apkButtonState)
+ {
+ case ApkButtonState.Creating: profileDropDown.Enabled = false; break;
+ }
- Color col = profileDropDown.Enabled ? colGreen : colInactive;
+ Color col = profileDropDown.Enabled ? colGreen : colInactive;
- if (Platform.IsWinForms)
- profileDropDown.TextColor = col;
- profileAuthorLabel.TextColor = col;
- profileVersionLabel.TextColor = col;
- profileLabel.TextColor = col;
- }
+ if (Platform.IsWinForms)
+ profileDropDown.TextColor = col;
+ profileAuthorLabel.TextColor = col;
+ profileVersionLabel.TextColor = col;
+ profileLabel.TextColor = col;
}
///
@@ -152,51 +150,49 @@ namespace AM2RLauncher
private void UpdateProfileSettingsState()
{
// Safety check
- if (settingsProfileDropDown == null) return;
- if (settingsProfileDropDown.Items.Count > 0)
+ if (settingsProfileDropDown == null || settingsProfileDropDown.Items.Count <= 0) return;
+
+ bool enabled = false;
+ switch (updateState)
{
- bool enabled = false;
- switch (updateState)
- {
- case UpdateState.Download: enabled = false; break;
- case UpdateState.Downloading: enabled = false; break;
- case UpdateState.Select11: enabled = false; break;
- case UpdateState.Install: enabled = true; break;
- case UpdateState.Installing: enabled = false; break;
- case UpdateState.Play: enabled = true; break;
- case UpdateState.Playing: enabled = false; break;
- }
- if (apkButtonState == ApkButtonState.Creating) enabled = false;
+ case UpdateState.Download: enabled = false; break;
+ case UpdateState.Downloading: enabled = false; break;
+ case UpdateState.Select11: enabled = false; break;
+ case UpdateState.Install: enabled = true; break;
+ case UpdateState.Installing: enabled = false; break;
+ case UpdateState.Play: enabled = true; break;
+ case UpdateState.Playing: enabled = false; break;
+ }
+ if (apkButtonState == ApkButtonState.Creating) enabled = false;
- settingsProfileLabel.TextColor = colGreen;
- settingsProfileDropDown.Enabled = enabled;
- profileButton.Enabled = enabled;
- profileButton.ToolTip = Language.Text.OpenProfileFolderToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text);
- saveButton.Enabled = enabled;
- saveButton.ToolTip = Language.Text.OpenSaveFolderToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text);
- addModButton.Enabled = enabled;
- addModButton.ToolTip = Language.Text.AddNewModToolTip;
+ settingsProfileLabel.TextColor = colGreen;
+ settingsProfileDropDown.Enabled = enabled;
+ profileButton.Enabled = enabled;
+ profileButton.ToolTip = Language.Text.OpenProfileFolderToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text);
+ saveButton.Enabled = enabled;
+ saveButton.ToolTip = Language.Text.OpenSaveFolderToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text);
+ addModButton.Enabled = enabled;
+ addModButton.ToolTip = Language.Text.AddNewModToolTip;
- // Only enable these, when we're not on the community updates
- if (settingsProfileDropDown.SelectedIndex > 0)
- {
- updateModButton.Enabled = enabled;
- updateModButton.ToolTip = Language.Text.UpdateModButtonToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text);
- deleteModButton.Enabled = enabled;
- deleteModButton.ToolTip = Language.Text.DeleteModButtonToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text);
- }
+ // Only enable these, when we're not on the community updates
+ if (settingsProfileDropDown.SelectedIndex > 0)
+ {
+ updateModButton.Enabled = enabled;
+ updateModButton.ToolTip = Language.Text.UpdateModButtonToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text);
+ deleteModButton.Enabled = enabled;
+ deleteModButton.ToolTip = Language.Text.DeleteModButtonToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text);
+ }
- Color col = enabled ? colGreen : colInactive;
+ Color col = enabled ? colGreen : colInactive;
- if (Platform.IsWinForms)
- settingsProfileDropDown.TextColor = col;
+ if (Platform.IsWinForms)
+ settingsProfileDropDown.TextColor = col;
- settingsProfileLabel.TextColor = col;
+ settingsProfileLabel.TextColor = col;
- if (enabled)
- {
- settingsProfileDropDown.SelectedIndex = profileDropDown.SelectedIndex;
- }
+ if (enabled)
+ {
+ settingsProfileDropDown.SelectedIndex = profileDropDown.SelectedIndex;
}
}
@@ -255,8 +251,8 @@ namespace AM2RLauncher
case UpdateState.Installing: return Language.Text.Installing;
case UpdateState.Play: return Language.Text.Play;
case UpdateState.Playing: return Language.Text.Playing;
+ default: return null;
}
- return null;
}
///
@@ -269,8 +265,8 @@ namespace AM2RLauncher
{
case ApkButtonState.Create: return Language.Text.CreateAPK;
case ApkButtonState.Creating: return Language.Text.CreatingAPK;
+ default: return null;
}
- return null;
}
///
/// Checks if AM2R 1.1 has been installed already, aka if a valid AM2R 1.1 Zip exists.
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
index 5ed9ba1..82d784b 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
@@ -28,7 +28,7 @@ namespace AM2RLauncher
///
/// An enum, that has possible states for our Launcher.
///
- enum UpdateState
+ private enum UpdateState
{
Download,
Downloading,
@@ -42,7 +42,7 @@ namespace AM2RLauncher
///
/// An enum, that has different states for .
///
- enum ApkButtonState
+ private enum ApkButtonState
{
Create,
Creating
@@ -52,11 +52,10 @@ namespace AM2RLauncher
///
/// A - of custom splashes.
///
-
///
/// The current Launcher version.
///
- private static readonly string VERSION = LauncherUpdater.VERSION;
+ private const string VERSION = LauncherUpdater.VERSION;
///
/// A of the AM2R icon.
@@ -124,11 +123,10 @@ namespace AM2RLauncher
Process current = Process.GetCurrentProcess();
foreach (Process process in Process.GetProcessesByName(current.ProcessName))
{
- if (process.Id != current.Id)
- {
- SetForegroundWindow(process.MainWindowHandle);
- break;
- }
+ if (process.Id == current.Id)
+ continue;
+ SetForegroundWindow(process.MainWindowHandle);
+ break;
}
}
Environment.Exit(0);
@@ -173,7 +171,7 @@ namespace AM2RLauncher
// Set the language to what User wanted or choose local language
string userLanguage = CrossPlatformOperations.ReadFromConfig("Language").ToLower();
if (!userLanguage.Equals("default"))
- Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultures(CultureTypes.AllCultures).Where(c => c.NativeName.ToLower().Contains(userLanguage)).First();
+ Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultures(CultureTypes.AllCultures).First(c => c.NativeName.ToLower().Contains(userLanguage));
Log.Info("Language has been set to: " + Thread.CurrentThread.CurrentUICulture.EnglishName);
@@ -181,8 +179,8 @@ namespace AM2RLauncher
Log.Info("Beginning UI initialization...");
// System tray indicator
- showButton = new ButtonMenuItem() { Text = Language.Text.TrayButtonShow };
- trayIndicator = new TrayIndicator()
+ showButton = new ButtonMenuItem { Text = Language.Text.TrayButtonShow };
+ trayIndicator = new TrayIndicator
{
Menu = new ContextMenu(showButton),
Title = "AM2RLauncher",
@@ -198,9 +196,9 @@ namespace AM2RLauncher
profileList = new List();
profileNames = new List();
- for (int i = 0; i < profileList.Count; i++)
+ foreach (var profile in profileList)
{
- profileNames.Add(profileList[i].Name);
+ profileNames.Add(profile.Name);
}
// Custom splash texts
@@ -243,15 +241,15 @@ namespace AM2RLauncher
Title = "AM2RLauncher " + VERSION + ": " + splash;
MinimumSize = new Size(500, 400);
// TODO: for some reason, this sometimes doesn't work on Linux. Was reported at eto, stays here until its fixed
- ClientSize = new Size(int.Parse(CrossPlatformOperations.ReadFromConfig("Width")), int.Parse(CrossPlatformOperations.ReadFromConfig("Height")));
+ ClientSize = new Size(Int32.Parse(CrossPlatformOperations.ReadFromConfig("Width")), Int32.Parse(CrossPlatformOperations.ReadFromConfig("Height")));
if (ClientSize.Width < 500)
ClientSize = new Size(500, ClientSize.Height);
if (ClientSize.Height < 400)
ClientSize = new Size(ClientSize.Width, 400);
Log.Info("Start the launcher with Size: " + ClientSize.Width + ", " + ClientSize.Height);
- if (bool.Parse(CrossPlatformOperations.ReadFromConfig("IsMaximized"))) Maximize();
+ if (Boolean.Parse(CrossPlatformOperations.ReadFromConfig("IsMaximized"))) Maximize();
- drawable = new Drawable() { BackgroundColor = colBGNoAlpha };
+ drawable = new Drawable { BackgroundColor = colBGNoAlpha };
// Drawable paint event
drawable.Paint += DrawablePaintEvent;
@@ -318,7 +316,7 @@ namespace AM2RLauncher
Height = 15,
Text = "",
TextColor = colGreen,
- Visible = false,
+ Visible = false
};
centerInterface.AddRow(progressLabel);
@@ -331,7 +329,7 @@ namespace AM2RLauncher
BackgroundColor = colBG,
Height = 15,
Text = Language.Text.CurrentProfile,
- TextColor = colGreen,
+ TextColor = colGreen
};
centerInterface.AddRow(profileLabel);
@@ -344,7 +342,7 @@ namespace AM2RLauncher
profileDropDown = new DropDown
{
TextColor = colGreen,
- BackgroundColor = Platform.IsWinForms ? colBGNoAlpha : new Color(),
+ BackgroundColor = Platform.IsWinForms ? colBGNoAlpha : new Color()
};
// In order to not have conflicting theming, we just always respect the users theme for dropdown on GTK.
if (Platform.IsGtk)
@@ -382,23 +380,23 @@ namespace AM2RLauncher
Width = 20,
Height = 55,
Text = Language.Text.SaveLocationWarning,
- TextColor = colRed,
+ TextColor = colRed
};
centerInterface.AddRow(saveWarningLabel);
// Social buttons
- var redditButton = new ImageButton() { ToolTip = Language.Text.RedditToolTip, Image = redditIcon };
+ var redditButton = new ImageButton { ToolTip = Language.Text.RedditToolTip, Image = redditIcon };
redditButton.Click += RedditIconOnClick;
- var githubButton = new ImageButton() { ToolTip = Language.Text.GithubToolTip, Image = githubIcon };
+ var githubButton = new ImageButton { ToolTip = Language.Text.GithubToolTip, Image = githubIcon };
githubButton.Click += GithubIconOnClick;
- var youtubeButton = new ImageButton() { ToolTip = Language.Text.YoutubeToolTip, Image = youtubeIcon };
+ var youtubeButton = new ImageButton { ToolTip = Language.Text.YoutubeToolTip, Image = youtubeIcon };
youtubeButton.Click += YoutubeIconOnClick;
- var discordButton = new ImageButton() { ToolTip = Language.Text.DiscordToolTip, Image = discordIcon };
+ var discordButton = new ImageButton { ToolTip = Language.Text.DiscordToolTip, Image = discordIcon };
discordButton.Click += DiscordIconOnClick;
@@ -534,7 +532,7 @@ namespace AM2RLauncher
// Language DropDown menu
- List languageList = new List()
+ List languageList = new List
{
Language.Text.SystemLanguage,
"Deutsch",
@@ -551,7 +549,7 @@ namespace AM2RLauncher
languageDropDown = new DropDown
{
TextColor = colGreen,
- BackgroundColor = Platform.IsWinForms ? colBGNoAlpha : new Color(),
+ BackgroundColor = Platform.IsWinForms ? colBGNoAlpha : new Color()
};
if (Platform.IsGtk)
languageDropDown = new DropDown();
@@ -559,7 +557,7 @@ namespace AM2RLauncher
languageDropDown.Items.AddRange(languageList);
var tmpLanguage = CrossPlatformOperations.ReadFromConfig("Language");
- languageDropDown.SelectedIndex = tmpLanguage == "Default" ? 0 : languageDropDown.Items.IndexOf(languageDropDown.Items.Where(x => x.Text.Equals(tmpLanguage)).FirstOrDefault());
+ languageDropDown.SelectedIndex = tmpLanguage == "Default" ? 0 : languageDropDown.Items.IndexOf(languageDropDown.Items.FirstOrDefault(x => x.Text.Equals(tmpLanguage)));
if (languageDropDown.SelectedIndex == -1)
{
@@ -570,7 +568,7 @@ namespace AM2RLauncher
// autoUpdateAM2R checkbox
autoUpdateAM2RCheck = new CheckBox
{
- Checked = bool.Parse(CrossPlatformOperations.ReadFromConfig("AutoUpdateAM2R")),
+ Checked = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("AutoUpdateAM2R")),
Text = Language.Text.AutoUpdateAM2R,
TextColor = colGreen
};
@@ -579,7 +577,7 @@ namespace AM2RLauncher
// autoUpdateLauncher checkbox
autoUpdateLauncherCheck = new CheckBox
{
- Checked = bool.Parse(CrossPlatformOperations.ReadFromConfig("AutoUpdateLauncher")),
+ Checked = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("AutoUpdateLauncher")),
Text = Language.Text.AutoUpdateLauncher,
TextColor = colGreen
};
@@ -587,7 +585,7 @@ namespace AM2RLauncher
// HQ music, PC
hqMusicPCCheck = new CheckBox
{
- Checked = bool.Parse(CrossPlatformOperations.ReadFromConfig("MusicHQPC")),
+ Checked = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("MusicHQPC")),
Text = Language.Text.HighQualityPC,
TextColor = colGreen
};
@@ -595,7 +593,7 @@ namespace AM2RLauncher
// HQ music, Android
hqMusicAndroidCheck = new CheckBox
{
- Checked = bool.Parse(CrossPlatformOperations.ReadFromConfig("MusicHQAndroid")),
+ Checked = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("MusicHQAndroid")),
Text = Language.Text.HighQualityAndroid,
TextColor = colGreen
};
@@ -641,13 +639,14 @@ namespace AM2RLauncher
mirrorDropDown = new DropDown
{
TextColor = colGreen,
- BackgroundColor = Platform.IsWinForms ? colBGNoAlpha : new Color(),
+ BackgroundColor = Platform.IsWinForms ? colBGNoAlpha : new Color()
};
if (Platform.IsGtk)
mirrorDropDown = new DropDown();
mirrorDropDown.Items.AddRange(mirrorDescriptionList); // As above, find a way to get this inside the dropDown definition
- mirrorIndex = (int.Parse(CrossPlatformOperations.ReadFromConfig("MirrorIndex")) < mirrorDropDown.Items.Count) ? int.Parse(CrossPlatformOperations.ReadFromConfig("MirrorIndex")) : 0;
+ mirrorIndex = (Int32.Parse(CrossPlatformOperations.ReadFromConfig("MirrorIndex")) < mirrorDropDown.Items.Count) ? Int32.Parse(CrossPlatformOperations.ReadFromConfig("MirrorIndex"))
+ : 0;
mirrorDropDown.SelectedIndex = mirrorIndex;
currentMirror = mirrorList[mirrorDropDown.SelectedIndex];
@@ -655,7 +654,7 @@ namespace AM2RLauncher
// Custom mirror
customMirrorCheck = new CheckBox
{
- Checked = bool.Parse(CrossPlatformOperations.ReadFromConfig("CustomMirrorEnabled")),
+ Checked = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("CustomMirrorEnabled")),
Text = Language.Text.CustomMirrorCheck,
TextColor = colGreen
};
@@ -712,7 +711,7 @@ namespace AM2RLauncher
settingsProfileDropDown = new DropDown
{
TextColor = colGreen,
- BackgroundColor = Platform.IsWinForms ? colBGNoAlpha : new Color(),
+ BackgroundColor = Platform.IsWinForms ? colBGNoAlpha : new Color()
};
// In order to not have conflicting theming, we just always respect the users theme for dropdown on GTK.
@@ -815,7 +814,7 @@ namespace AM2RLauncher
};
#region EVENTS
- Log.Info("All UI objects have been initalized, UI has been set up.");
+ Log.Info("All UI objects have been initialized, UI has been set up.");
Log.Info("Beginning event linkage...");
Closing += MainformClosing;
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/Splash.cs b/AM2RLauncher/AM2RLauncher/MainForm/Splash.cs
index 0f1130d..4e7a00f 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/Splash.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/Splash.cs
@@ -12,7 +12,7 @@ namespace AM2RLauncher
///
/// Cross-Platform splash strings
///
- static readonly string[] GeneralSplash =
+ private static readonly string[] GeneralSplash =
{
"The real Ridley is the friends we made along the way.",
"Now with 100% more Septoggs!",
@@ -48,7 +48,7 @@ namespace AM2RLauncher
///
/// Linux only splash strings
///
- static readonly string[] LinuxSplash =
+ private static readonly string[] LinuxSplash =
{
"Sorry this is ugly, but at least it works.",
"GTK + QT = 💣",
@@ -75,7 +75,7 @@ namespace AM2RLauncher
/// Get a random splash string, according to the current OS.
///
/// The randomly chosen splash as a .
- static public string GetSplash()
+ public static string GetSplash()
{
string[] combinedSplash;
Random rng = new Random();
diff --git a/AM2RLauncher/AM2RLauncher/XML/Serializer.cs b/AM2RLauncher/AM2RLauncher/XML/Serializer.cs
index 869995b..0096011 100644
--- a/AM2RLauncher/AM2RLauncher/XML/Serializer.cs
+++ b/AM2RLauncher/AM2RLauncher/XML/Serializer.cs
@@ -7,7 +7,7 @@ namespace AM2RLauncher.XML
///
/// The Serializer class, that serializes to and deserializes from XML files.
///
- public class Serializer
+ public static class Serializer
{
///
/// Serializes as a to XML.