From a75662b073dfa57e6ea936d85e7dcc50e87888da Mon Sep 17 00:00:00 2001
From: Miepee <38186597+Miepee@users.noreply.github.com>
Date: Mon, 23 May 2022 19:32:54 +0200
Subject: [PATCH] Mark UI settings as readonly + trycatch running game
Also adds a few comments
---
.../AM2RLauncher/MainForm/MainForm.Events.cs | 9 ++-
.../AM2RLauncher/MainForm/MainForm.UI.cs | 64 +++++++++----------
.../CrossPlatformOperations.cs | 5 +-
AM2RLauncher/AM2RLauncherLib/Profile.cs | 1 +
4 files changed, 44 insertions(+), 35 deletions(-)
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
index 3d10463..6a207f3 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
@@ -435,7 +435,14 @@ public partial class MainForm : Form
string envVarText = customEnvVarTextBox?.Text;
bool createDebugLogs = profileDebugLogCheck.Checked.Value;
- await Task.Run(() => Profile.RunGame(profile, createDebugLogs, envVarText));
+ try
+ {
+ await Task.Run(() => Profile.RunGame(profile, createDebugLogs, envVarText));
+ }
+ catch
+ {
+ // ignore any errors that occur.
+ }
ShowInTaskbar = true;
trayIndicator.Visible = false;
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
index d018c46..82dd15f 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
@@ -825,13 +825,13 @@ public partial class MainForm : Form
// Visual studio does it like this for normal winforms projects, so I just used the same format.
/// The tray indicator
- private TrayIndicator trayIndicator;
+ private readonly TrayIndicator trayIndicator;
/// of s, used for actually working with profile data.
//TODO: this should be moved into AM2RLauncherLib
private List profileList;
/// of s so that Eto's annoying interface is appeased. Used for profile name display in DropDowns.
- private List profileNames;
+ private readonly List profileNames;
/// The planet Background.
private readonly Bitmap formBG = new Bitmap(Resources.bgCentered);
@@ -854,73 +854,73 @@ public partial class MainForm : Form
// Mirror lists
/// of mirror s, used for actually working with mirrors.
- private List mirrorList;
+ private readonly List mirrorList;
/// of so that Eto's annoying IListItem interface is appeased. Used for mirror name display in DropDowns.
- private List mirrorDescriptionList;
+ private readonly List mirrorDescriptionList;
/// A that acts as the main Button
- private ColorButton playButton;
+ private readonly ColorButton playButton;
/// A which is only used for creating APK's
- private ColorButton apkButton;
+ private readonly ColorButton apkButton;
/// A that is used to add mods.
- private ColorButton addModButton;
+ private readonly ColorButton addModButton;
/// A that will open the game files directory for the selected mod.
- private ColorButton profileButton;
+ private readonly ColorButton profileButton;
/// A that will open the save directory for the selected mod.
- private ColorButton saveButton;
+ private readonly ColorButton saveButton;
/// A that is used to update a mod
- private ColorButton updateModButton;
+ private readonly ColorButton updateModButton;
/// A that is used to delete a mod
- private ColorButton deleteModButton;
+ private readonly ColorButton deleteModButton;
/// The that entitles .
- private Label profileLabel;
+ private readonly Label profileLabel;
/// The that gives author information for .
- private Label profileAuthorLabel;
+ private readonly Label profileAuthorLabel;
/// The that gives version information for .
- private Label profileVersionLabel;
+ private readonly Label profileVersionLabel;
/// The that gives information for .
- private Label mirrorLabel;
+ private readonly Label mirrorLabel;
/// The that gives information for .
- private Label settingsProfileLabel;
+ private readonly Label settingsProfileLabel;
/// The that compliments .
- private Label progressLabel;
+ private readonly Label progressLabel;
/// The that gives a warning if the current selected shares the same save location has default AM2R.
- private Label saveWarningLabel;
+ private readonly Label saveWarningLabel;
/// A , that indicates whether to automatically update AM2R or not.
- private CheckBox autoUpdateAM2RCheck;
+ private readonly CheckBox autoUpdateAM2RCheck;
/// A , that indicates whether to automatically update the AM2RLauncher or not.
- private CheckBox autoUpdateLauncherCheck;
+ private readonly CheckBox autoUpdateLauncherCheck;
/// A , that indicates whether to use a custom mirror or not.
- private CheckBox customMirrorCheck;
+ private readonly CheckBox customMirrorCheck;
/// A , that indicates whether to use HQ Music when patching to PC or not.
- private CheckBox hqMusicPCCheck;
+ private readonly CheckBox hqMusicPCCheck;
/// A , that indicates whether to use HQ Music when patching to Android or not.
- private CheckBox hqMusicAndroidCheck;
+ private readonly CheckBox hqMusicAndroidCheck;
/// A , that indicates whether to create debug logs for profiles.
- private CheckBox profileDebugLogCheck;
+ private readonly CheckBox profileDebugLogCheck;
/// A where languages can be chosen.
- private DropDown languageDropDown;
+ private readonly DropDown languageDropDown;
/// A where mirrors can be chosen.
- private DropDown mirrorDropDown;
+ private readonly DropDown mirrorDropDown;
/// A where profiles can be chosen.
- private DropDown profileDropDown;
+ private readonly DropDown profileDropDown;
/// A where profiles can be chosen (located in Profile Settings).
//TODO: Use MVVM bindings: https://github.com/picoe/Eto/wiki/Data-Binding#mvvm-binding
- private DropDown modSettingsProfileDropDown;
+ private readonly DropDown modSettingsProfileDropDown;
/// A , where the user can input their custom mirror.
- private TextBox customMirrorTextBox;
+ private readonly TextBox customMirrorTextBox;
/// A , where the user can input their custom environment variables.
- private TextBox customEnvVarTextBox;
+ private readonly TextBox customEnvVarTextBox;
/// A , where the notes from the current selected profile in are displayed.
- private TextArea profileNotesTextArea;
+ private readonly TextArea profileNotesTextArea;
/// A that can be used to show progress for a specific task.
- private ProgressBar progressBar;
+ private readonly ProgressBar progressBar;
#endregion
}
\ No newline at end of file
diff --git a/AM2RLauncher/AM2RLauncherLib/CrossPlatformOperations.cs b/AM2RLauncher/AM2RLauncherLib/CrossPlatformOperations.cs
index c0728c1..236d670 100644
--- a/AM2RLauncher/AM2RLauncherLib/CrossPlatformOperations.cs
+++ b/AM2RLauncher/AM2RLauncherLib/CrossPlatformOperations.cs
@@ -259,10 +259,11 @@ public static class CrossPlatformOperations
if (originalFile == outputFile)
outputFile += "_";
- //TODO: why is currentPath taken out of all the paths? investigate!
+ // The reason why currentPath is taken out of all paths, is because xdelta (windows?) breaks if it has non-ascii characters
+ // So for users who have a russian username for example, this would just throw.
+ // By replacing the currentPath and setting the working directory to where we want it to be, we ensure to only have our ascii characters.
string arguments = $"-f -d -s \"{originalFile.Replace($"{CurrentPath}/", "")}\" \"{patchFile.Replace($"{CurrentPath}/", "")}\" \"{outputFile.Replace($"{CurrentPath}/", "")}\"";
-
ProcessStartInfo parameters = new ProcessStartInfo
{
FileName = OS.IsWindows ? $"{CurrentPath}/PatchData/utilities/xdelta/xdelta3.exe" : "xdelta3",
diff --git a/AM2RLauncher/AM2RLauncherLib/Profile.cs b/AM2RLauncher/AM2RLauncherLib/Profile.cs
index ee2c6ef..a7fa626 100644
--- a/AM2RLauncher/AM2RLauncherLib/Profile.cs
+++ b/AM2RLauncher/AM2RLauncherLib/Profile.cs
@@ -585,6 +585,7 @@ public static class Profile
progress.Report(14);
// Decompile AM2RWrapper.apk
+ //TODO: double check if this still works on machines with non-ascii characters. See explanation in CrossPlatformOperations.PatchXdelta
CrossPlatformOperations.RunJavaJar($"\"{apktoolPath}\" d \"{dataPath}/android/AM2RWrapper.apk\"", tempDir);
log.Info("AM2RWrapper decompiled.");
progress.Report(28);