Cleanup commit nr 3

pull/32/head
Miepee 5 years ago
parent 8e34b55398
commit 6a129a3dd0

@ -668,9 +668,7 @@ namespace AM2RLauncher
private void ProfileLayoutLoadComplete(object sender, EventArgs e) private void ProfileLayoutLoadComplete(object sender, EventArgs e)
{ {
// Safety check // Safety check
if (settingsProfileDropDown == null) return; if ((settingsProfileDropDown == null) || (settingsProfileDropDown.Items.Count != 0)) return;
if (settingsProfileDropDown.Items.Count != 0)
return;
addModButton.Enabled = false; addModButton.Enabled = false;
settingsProfileLabel.TextColor = colInactive; settingsProfileLabel.TextColor = colInactive;
settingsProfileDropDown.Enabled = false; settingsProfileDropDown.Enabled = false;
@ -1075,4 +1073,4 @@ namespace AM2RLauncher
} }
} }
} }

@ -573,7 +573,7 @@ namespace AM2RLauncher
// These are used on both windows and linux for game logging // These are used on both windows and linux for game logging
string savePath = Platform.IsWinForms ? profile.SaveLocation.Replace("%localappdata%", Environment.GetEnvironmentVariable("LOCALAPPDATA")) string savePath = Platform.IsWinForms ? profile.SaveLocation.Replace("%localappdata%", Environment.GetEnvironmentVariable("LOCALAPPDATA"))
: profile.SaveLocation.Replace("~", CrossPlatformOperations.NIXHOME); : profile.SaveLocation.Replace("~", CrossPlatformOperations.NIXHOME);
DirectoryInfo logDir = new DirectoryInfo(savePath + "/logs"); DirectoryInfo logDir = new DirectoryInfo(savePath + "/logs");
string date = String.Join("-", DateTime.Now.ToString().Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries)); string date = String.Join("-", DateTime.Now.ToString().Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries));

@ -27,50 +27,52 @@ namespace AM2RLauncher
private void UpdatePlayState() private void UpdatePlayState()
{ {
// If not downloading or installing... // If not downloading or installing...
if (updateState != UpdateState.Downloading && updateState != UpdateState.Installing) if ((updateState == UpdateState.Downloading) || (updateState == UpdateState.Installing))
return;
// If we're currently creating an APK...
if (apkButtonState != ApkButtonState.Creating)
{ {
if (apkButtonState != ApkButtonState.Creating) playButton.Enabled = true;
// If PatchData is cloned...
if (HelperMethods.IsPatchDataCloned())
{ {
playButton.Enabled = true; // If 1.1 is installed or if the current profile is invalid...
// If PatchData is cloned... if (Is11Installed())
if (HelperMethods.IsPatchDataCloned())
{ {
// If 1.1 is installed... var isProfileValid = IsProfileIndexValid();
if (Is11Installed()) // If current profile is installed...
if (isProfileValid && IsProfileInstalled(profileList[profileIndex.Value]))
{ {
// If current profile is installed... // We're ready to play!
if (IsProfileIndexValid() && IsProfileInstalled(profileList[profileIndex.Value])) SetPlayButtonState(UpdateState.Play);
{
// We're ready to play!
SetPlayButtonState(UpdateState.Play);
}
// Otherwise, if profile is NOT installable...
else if (IsProfileIndexValid() && profileList[profileIndex.Value].Installable == false)
{
// We delete the profile, because we can't install it and it therefor holds no value!
DeleteProfile(profileList[profileIndex.Value]);
}
// Otherwise, we still need to install.
else
{
SetPlayButtonState(UpdateState.Install);
}
} }
else // We still need to select 1.1. // Otherwise, if profile is NOT installable...
else if (isProfileValid && profileList[profileIndex.Value].Installable == false)
{ {
SetPlayButtonState(UpdateState.Select11); // We delete the profile, because we can't install it and it therefore holds no value!
DeleteProfile(profileList[profileIndex.Value]);
}
// Otherwise, we still need to install.
else
{
SetPlayButtonState(UpdateState.Install);
} }
} }
else // We still need to download. else // We still need to select 1.1.
{ {
SetPlayButtonState(UpdateState.Download); SetPlayButtonState(UpdateState.Select11);
} }
} }
else else // We still need to download.
{ {
playButton.Enabled = false; SetPlayButtonState(UpdateState.Download);
} }
} }
else // We disable the Play button.
{
playButton.Enabled = false;
}
} }
/// <summary> /// <summary>
@ -81,28 +83,20 @@ namespace AM2RLauncher
// Safety check // Safety check
if (apkButton == null) if (apkButton == null)
return; return;
// If profile supports Android... var profile = profileList[profileIndex.Value];
if (IsProfileIndexValid() && profileList[profileIndex.Value].SupportsAndroid && profileList[profileIndex.Value].Installable) // If profile supports Android and if we are NOT already creating an APK...
if (IsProfileIndexValid() && profile.SupportsAndroid && profile.Installable && (apkButtonState == ApkButtonState.Create))
{ {
// If we are NOT already creating an APK... // Switch status based on main button's state
if (apkButtonState == ApkButtonState.Create) switch (updateState)
{
// 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.
{ {
apkButton.Enabled = false; case UpdateState.Download: apkButton.Enabled = false; apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; break;
apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; 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. else // Otherwise, disable.
@ -203,11 +197,11 @@ namespace AM2RLauncher
private void SetPlayButtonState(UpdateState state) private void SetPlayButtonState(UpdateState state)
{ {
updateState = state; updateState = state;
string profileName = (profileDropDown != null && profileDropDown.Items.Count > 0) ? profileDropDown.Items[profileDropDown.SelectedIndex].Text : ""; string profileName = ((profileDropDown != null) && (profileDropDown.Items.Count > 0)) ? profileDropDown.Items[profileDropDown.SelectedIndex].Text : "";
switch (updateState) switch (updateState)
{ {
case UpdateState.Download: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonDownloadToolTip; break; case UpdateState.Download: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonDownloadToolTip; break;
case UpdateState.Downloading: playButton.Enabled = true; playButton.ToolTip = ""; break; // ; playButton.ToolTip = Language.Text.PlayButtonDownladingToolTip; break; case UpdateState.Downloading: playButton.Enabled = true; playButton.ToolTip = ""; playButton.ToolTip = Language.Text.PlayButtonDownladingToolTip; break;
case UpdateState.Select11: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonSelect11ToolTip; break; case UpdateState.Select11: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonSelect11ToolTip; break;
case UpdateState.Install: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonInstallToolTip.Replace("$NAME", profileName); break; case UpdateState.Install: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonInstallToolTip.Replace("$NAME", profileName); break;
case UpdateState.Installing: playButton.Enabled = false; playButton.ToolTip = Language.Text.PlayButtonInstallingToolTip; break; case UpdateState.Installing: playButton.Enabled = false; playButton.ToolTip = Language.Text.PlayButtonInstallingToolTip; break;
@ -308,4 +302,4 @@ namespace AM2RLauncher
} }
} }
} }
Loading…
Cancel
Save