From c0261fd05c930cf2d2d8ca2a40f2d31fecef3999 Mon Sep 17 00:00:00 2001 From: Miepee Date: Wed, 29 Dec 2021 12:41:36 +0100 Subject: [PATCH 1/3] Make Linux not crash on boot, add todos + small cleanup --- .gitignore | 3 +++ AM2RLauncher/AM2RLauncher.Gtk/Program.cs | 3 ++- AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs | 12 ++++++------ .../AM2RLauncher/MainForm/MainForm.Events.cs | 3 +-- .../AM2RLauncher/MainForm/MainForm.StateMachine.cs | 1 - AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs | 4 +++- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 3614817..fb2c22e 100644 --- a/.gitignore +++ b/.gitignore @@ -349,3 +349,6 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ + +# Visual Studio Code folder +.vscode/ diff --git a/AM2RLauncher/AM2RLauncher.Gtk/Program.cs b/AM2RLauncher/AM2RLauncher.Gtk/Program.cs index 2d36bb3..c3652c7 100644 --- a/AM2RLauncher/AM2RLauncher.Gtk/Program.cs +++ b/AM2RLauncher/AM2RLauncher.Gtk/Program.cs @@ -46,6 +46,7 @@ namespace AM2RLauncher.Gtk { log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace.ToString()); Console.WriteLine(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace.ToString()); + Console.WriteLine("Check the logs at " + launcherDataPath + " for more info!"); } } @@ -95,7 +96,7 @@ namespace AM2RLauncher.Gtk } catch { } - return Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + return Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); } } } diff --git a/AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs b/AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs index 35e5a1b..a6ccc7d 100644 --- a/AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs +++ b/AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs @@ -25,11 +25,6 @@ namespace AM2RLauncher /// private static readonly Platform currentPlatform = Platform.Instance; - /// - /// Current Path where the Launcher is located. For more info, check . - /// - public static readonly string CURRENTPATH = GenerateCurrentPath(); - /// /// Name of the Launcher executable. /// @@ -45,6 +40,11 @@ namespace AM2RLauncher /// public static readonly string NIXXDGCONFIG = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME"); + /// + /// Current Path where the Launcher is located. For more info, check . + /// + public static readonly string CURRENTPATH = GenerateCurrentPath(); + /// /// Generates the mirror list, depending on the current Platform. /// @@ -464,7 +464,7 @@ namespace AM2RLauncher } log.Info("Something went wrong, falling back to the default CurrentPath."); - return Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + return Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); } } } diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs index 7a20913..61ac52a 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs @@ -746,7 +746,7 @@ namespace AM2RLauncher profileAuthorLabel.Text = Language.Text.Author + " " + profileList[profileDropDown.SelectedIndex].Author; profileVersionLabel.Text = Language.Text.VersionLabel + " " + profileList[profileDropDown.SelectedIndex].Version; - CrossPlatformOperations.WriteToConfig("ProfileIndex", profileIndex + ""); // Loj, tell me a better way to do this + CrossPlatformOperations.WriteToConfig("ProfileIndex", profileIndex.ToString()); if (profileDropDown.SelectedIndex != 0 && (profileList[profileDropDown.SelectedIndex].SaveLocation == "%localappdata%/AM2R" || profileList[profileDropDown.SelectedIndex].SaveLocation == "default")) @@ -754,7 +754,6 @@ namespace AM2RLauncher else saveWarningLabel.Visible = false; UpdateStateMachine(); - Console.WriteLine("end profile drop down changed"); } /// Gets called when user selects a different item from and writes that to the config. diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs index c4cd763..975835c 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs @@ -212,7 +212,6 @@ namespace AM2RLauncher if (enabled) { settingsProfileDropDown.SelectedIndex = profileDropDown.SelectedIndex; - SettingsProfileDropDownSelectedIndexChanged(null, null); } } } diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs index cafe4a3..dc9de28 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs @@ -140,7 +140,8 @@ namespace AM2RLauncher log.Info("Set Launcher CWD to " + Environment.CurrentDirectory); // But log actual folder location nonetheless - log.Info("Actual Launcher location: " + Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)); + // TODO: test if this logs correctly on windows now + log.Info("Actual Launcher location: " + Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory)); // Set the language to what User wanted or choose local language string userLanguage = CrossPlatformOperations.ReadFromConfig("Language").ToLower(); @@ -211,6 +212,7 @@ namespace AM2RLauncher Icon = new Icon(1f, am2rIcon); Title = "AM2RLauncher " + VERSION + ": " + splash; MinimumSize = new Size(500, 400); + // TODO: for some reason, this sometimes doesn't work on Linux. Eto bug maybe? ClientSize = new Size(int.Parse(CrossPlatformOperations.ReadFromConfig("Width")), int.Parse(CrossPlatformOperations.ReadFromConfig("Height"))); if (ClientSize.Width < 500) ClientSize = new Size(500, ClientSize.Height); From d2139677f4bd26777e3fcf8023c6e764c9c97591 Mon Sep 17 00:00:00 2001 From: Miepee <38186597+Miepee@users.noreply.github.com> Date: Wed, 29 Dec 2021 12:43:49 +0100 Subject: [PATCH 2/3] update linux build instructions to how we use it --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 921f03e..41264a2 100644 --- a/README.md +++ b/README.md @@ -49,5 +49,5 @@ Open the solution with Visual Studio 2019. Alternatively, build via `dotnet build` / the `buildAll` batch file. ## Linux Instructions -In order to build for linux, use `dotnet publish AM2RLauncher.Gtk -p:PublishSingleFile=true -c release -r ubuntu.18.04-x64`, MonoDevelop sadly doesn't work. +In order to build for linux, use `dotnet publish AM2RLauncher.Gtk -p:PublishSingleFile=true -p:DebugType=embedded -c release -r ubuntu.18.04-x64 --no-self-contained`, MonoDevelop sadly doesn't work. You *have* to specify it to build for Ubuntu, even on non-Ubuntu distros, because one of our Dependencies, libgit2sharp fails on the `linux-x64` RID. From 54aeb6a444db9d7e2c3023e22a0169b1eae0353d Mon Sep 17 00:00:00 2001 From: Miepee <38186597+Miepee@users.noreply.github.com> Date: Wed, 29 Dec 2021 12:44:35 +0100 Subject: [PATCH 3/3] readme: Fix broken list --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 41264a2..fed4d2a 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,9 @@ Alternatively, for Arch Linux users an [AUR Package](https://aur.archlinux.org/p ## Configuration and Data Files The AM2RLauncher stores its files in the following places: - - On Windows, it stores the config file to the `AM2RLauncher.exe.config` next to the binary, and its data files in the same folder as the binary. - - On Linux, it stores the config file to `$XDG_CONFIG_HOME/AM2RLauncher` and its data files to `$XDG_DATA_HOME/AM2RLauncher` (which are defaulting back to `~/.config` and `~/.local/share` respectively). +- On Windows, it stores the config file to the `AM2RLauncher.exe.config` next to the binary, and its data files in the same folder as the binary. +- On Linux, it stores the config file to `$XDG_CONFIG_HOME/AM2RLauncher` and its data files to `$XDG_DATA_HOME/AM2RLauncher` (which are defaulting back to `~/.config` and `~/.local/share` respectively). + The AM2RLauncher data can get quite big, so if you wish to change where it stores it, you can do so with the `AM2RLAUNCHERDATA` environment variable (i.e `AM2RLAUNCHERDATA="D:\MyLauncherData"` or `AM2RLAUNCHERDATA="/mnt/bigDrive/launcherData"`). # Compiling Instructions: