Fix more invalid UI Access

pull/30/head
Miepee 5 years ago
parent 11e5c07fce
commit 2f2ee99ac0

@ -57,7 +57,10 @@ namespace AM2RLauncher
if (!File.Exists(CrossPlatformOperations.CURRENTPATH + "/PatchData/profile.xml")) if (!File.Exists(CrossPlatformOperations.CURRENTPATH + "/PatchData/profile.xml"))
{ {
log.Error("Druid PatchData corruption occurred!"); log.Error("Druid PatchData corruption occurred!");
MessageBox.Show(Language.Text.CorruptPatchData, Language.Text.ErrorWindowTitle, MessageBoxType.Error); Application.Instance.Invoke(new Action(() =>
{
MessageBox.Show(Language.Text.CorruptPatchData, Language.Text.ErrorWindowTitle, MessageBoxType.Error);
}));
HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/PatchData"); HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/PatchData");
return; return;
} }
@ -341,11 +344,7 @@ namespace AM2RLauncher
// If the file cannot be launched due to anti-virus shenanigans or any other reason, we try catch here // If the file cannot be launched due to anti-virus shenanigans or any other reason, we try catch here
try try
{ {
await Task.Run(() => InstallProfile(profileList[profileIndex.Value]));
await Task.Run(() =>
{
InstallProfile(profileList[profileIndex.Value]);
});
} }
catch (Exception ex) catch (Exception ex)
{ {

@ -514,7 +514,9 @@ namespace AM2RLauncher
string workingDir = tempDir + "/AM2RWrapper/assets"; string workingDir = tempDir + "/AM2RWrapper/assets";
ZipFile.ExtractToDirectory(CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip", workingDir); ZipFile.ExtractToDirectory(CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip", workingDir);
HelperMethods.DirectoryCopy(dataPath + "/files_to_copy", workingDir); HelperMethods.DirectoryCopy(dataPath + "/files_to_copy", workingDir);
if (hqMusicAndroidCheck.Checked == true) bool isHqMusicChecked = false;
Application.Instance.Invoke(new Action(() => isHqMusicChecked = (bool)hqMusicAndroidCheck.Checked));
if (isHqMusicChecked)
HelperMethods.DirectoryCopy(CrossPlatformOperations.CURRENTPATH + "/PatchData/data/HDR_HQ_in-game_music", workingDir); HelperMethods.DirectoryCopy(CrossPlatformOperations.CURRENTPATH + "/PatchData/data/HDR_HQ_in-game_music", workingDir);
// Yes, I'm aware this is dumb. If you've got any better ideas for how to copy a seemingly randomly named .ini from this folder to the APK, please let me know. // Yes, I'm aware this is dumb. If you've got any better ideas for how to copy a seemingly randomly named .ini from this folder to the APK, please let me know.
foreach (FileInfo file in new DirectoryInfo(dataPath).GetFiles().Where(f => f.Name.EndsWith("ini"))) foreach (FileInfo file in new DirectoryInfo(dataPath).GetFiles().Where(f => f.Name.EndsWith("ini")))
@ -581,14 +583,16 @@ namespace AM2RLauncher
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));
if (Platform.IsWinForms) 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. // Sets the arguments to empty, or to the profiles save path/logs and create time based logs. Creates the folder if necessary.
string arguments = ""; string arguments = "";
// Game logging // Game logging
bool isLoggingEnabled = false;
Application.Instance.Invoke(new Action(() => isLoggingEnabled = (bool)profileDebugLogCheck.Checked));
if (isLoggingEnabled) if (isLoggingEnabled)
{ {
@ -635,11 +639,12 @@ namespace AM2RLauncher
log.Info("Is the environment textbox null or whitespace = " + string.IsNullOrWhiteSpace(customEnvVarTextBox.Text)); log.Info("Is the environment textbox null or whitespace = " + string.IsNullOrWhiteSpace(customEnvVarTextBox.Text));
if (!string.IsNullOrWhiteSpace(customEnvVarTextBox.Text)) string envVars = "";
{ Application.Instance.Invoke(new Action(() => envVars = customEnvVarTextBox.Text));
string envVars = customEnvVarTextBox.Text;
for (int i = 0; i < customEnvVarTextBox.Text.Count(f => f == '='); i++) if (!string.IsNullOrWhiteSpace(envVars))
{
for (int i = 0; i < envVars.Count(f => f == '='); i++)
{ {
// Env var variable // Env var variable
string variable = envVars.Substring(0, envVars.IndexOf('=')); string variable = envVars.Substring(0, envVars.IndexOf('='));
@ -689,7 +694,7 @@ namespace AM2RLauncher
using (Process p = new Process()) using (Process p = new Process())
{ {
p.StartInfo = startInfo; p.StartInfo = startInfo;
if ((bool)profileDebugLogCheck.Checked) if (isLoggingEnabled)
{ {
p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardOutput = true;
p.OutputDataReceived += new DataReceivedEventHandler((sender, e) => { terminalOutput += e.Data + "\n"; }); p.OutputDataReceived += new DataReceivedEventHandler((sender, e) => { terminalOutput += e.Data + "\n"; });
@ -736,7 +741,7 @@ namespace AM2RLauncher
string arguments = "AM2R.app -W"; string arguments = "AM2R.app -W";
// Game logging // Game logging
if ((bool)profileDebugLogCheck.Checked) if (isLoggingEnabled)
{ {
log.Info("Performing logging setup for profile " + profile.Name + "."); log.Info("Performing logging setup for profile " + profile.Name + ".");

Loading…
Cancel
Save