diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs index bc400c2..1a8b7b4 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs @@ -1,5 +1,6 @@ using AM2RLauncher.Core; using AM2RLauncher.Core.XML; +using AM2RLauncher.Language; using Eto.Forms; using LibGit2Sharp; using System; @@ -53,7 +54,7 @@ namespace AM2RLauncher log.Error("Druid PatchData corruption occurred!"); await Application.Instance.InvokeAsync(() => { - MessageBox.Show(Language.Text.CorruptPatchData, Language.Text.ErrorWindowTitle, MessageBoxType.Error); + MessageBox.Show(Text.CorruptPatchData, Text.ErrorWindowTitle, MessageBoxType.Error); }); HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/PatchData"); return; @@ -62,7 +63,7 @@ namespace AM2RLauncher catch (UserCancelledException ex) { log.Info(ex.Message); - MessageBox.Show(Language.Text.CorruptPatchData, Language.Text.ErrorWindowTitle, MessageBoxType.Error); + MessageBox.Show(Text.CorruptPatchData, Text.ErrorWindowTitle, MessageBoxType.Error); HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/PatchData"); } catch (LibGit2SharpException ex) // This is for any exceptions from libgit @@ -74,19 +75,19 @@ namespace AM2RLauncher 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); + MessageBox.Show(Text.InternetConnectionDrop, 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); + MessageBox.Show(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Text.ErrorWindowTitle, MessageBoxType.Error); } } 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); + MessageBox.Show(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Text.ErrorWindowTitle, MessageBoxType.Error); } finally { @@ -170,12 +171,12 @@ namespace AM2RLauncher ex.Message.ToLower().Contains("failed to resolve address")) { log.Error("Internet connection dropped while attempting to clone repository" + currentMirror + "!"); - MessageBox.Show(Language.Text.InternetConnectionDrop, Language.Text.WarningWindowTitle, MessageBoxType.Warning); + MessageBox.Show(Text.InternetConnectionDrop, Text.WarningWindowTitle, MessageBoxType.Warning); } else { log.Error("LibGit2SharpException: " + 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); + MessageBox.Show(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Text.ErrorWindowTitle, MessageBoxType.Error); if (Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/PatchData")) HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/PatchData"); } @@ -184,7 +185,7 @@ namespace AM2RLauncher 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); + MessageBox.Show(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Text.ErrorWindowTitle, MessageBoxType.Error); if (Directory.Exists(CrossPlatformOperations.CURRENTPATH + " / PatchData")) HelperMethods.DeleteDirectory(CrossPlatformOperations.CURRENTPATH + "/PatchData"); @@ -216,7 +217,7 @@ namespace AM2RLauncher #region Downloading case UpdateState.Downloading: - var result = MessageBox.Show(Language.Text.CloseOnCloningText, Language.Text.WarningWindowTitle, MessageBoxButtons.YesNo, MessageBoxType.Warning, MessageBoxDefaultButton.No); + var result = MessageBox.Show(Text.CloseOnCloningText, Text.WarningWindowTitle, MessageBoxButtons.YesNo, MessageBoxType.Warning, MessageBoxDefaultButton.No); if (result == DialogResult.No) return; else @@ -241,10 +242,10 @@ namespace AM2RLauncher { Directory = new Uri(CrossPlatformOperations.CURRENTPATH), MultiSelect = false, - Title = Language.Text.Select11FileDialog + Title = Text.Select11FileDialog }; - fileFinder.Filters.Add(new FileFilter(Language.Text.ZipArchiveText, ".zip")); + fileFinder.Filters.Add(new FileFilter(Text.ZipArchiveText, ".zip")); if (fileFinder.ShowDialog(this) != DialogResult.Ok) { @@ -265,7 +266,7 @@ namespace AM2RLauncher if (errorCode != IsZipAM2R11ReturnCodes.Successful) { log.Error("User tried to input invalid AM2R_11.zip file (" + errorCode + "). Cancelling import."); - MessageBox.Show(Language.Text.ZipIsNotAM2R11 + "\n\nError Code: " + errorCode, Language.Text.ErrorWindowTitle, MessageBoxType.Error); + MessageBox.Show(Text.ZipIsNotAM2R11 + "\n\nError Code: " + errorCode, Text.ErrorWindowTitle, MessageBoxType.Error); return; } @@ -307,7 +308,7 @@ namespace AM2RLauncher // Check if xdelta is installed on linux´and exit if not if ((OS.IsUnix) && !CrossPlatformOperations.CheckIfXdeltaIsInstalled()) { - MessageBox.Show(Language.Text.XdeltaNotFound, Language.Text.WarningWindowTitle, MessageBoxButtons.OK); + MessageBox.Show(Text.XdeltaNotFound, Text.WarningWindowTitle, MessageBoxButtons.OK); SetPlayButtonState(UpdateState.Install); UpdateStateMachine(); @@ -324,7 +325,7 @@ namespace AM2RLauncher catch (Exception ex) { 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); + MessageBox.Show(ex.Message + "\n*****Stack Trace*****\n\n" + ex.StackTrace, Text.ErrorWindowTitle, MessageBoxType.Error); } progressBar.Visible = false; progressBar.Value = 0; @@ -403,7 +404,7 @@ namespace AM2RLauncher progressBar.MaxValue = transferProgress.TotalObjects; if (currentGitObject >= transferProgress.ReceivedObjects) return; - progressLabel.Text = Language.Text.ProgressbarProgress + " " + transferProgress.ReceivedObjects + " (" + ((int)transferProgress.ReceivedBytes / 1000000) + "MB) / " + transferProgress.TotalObjects + " objects"; + progressLabel.Text = Text.ProgressbarProgress + " " + transferProgress.ReceivedObjects + " (" + ((int)transferProgress.ReceivedBytes / 1000000) + "MB) / " + transferProgress.TotalObjects + " objects"; currentGitObject = transferProgress.ReceivedObjects; progressBar.Value = transferProgress.ReceivedObjects; }); @@ -419,7 +420,7 @@ namespace AM2RLauncher // Check for java, exit safely with a warning if not found! if (!CrossPlatformOperations.IsJavaInstalled()) { - MessageBox.Show(Language.Text.JavaNotFound, Language.Text.WarningWindowTitle, MessageBoxButtons.OK); + MessageBox.Show(Text.JavaNotFound, Text.WarningWindowTitle, MessageBoxButtons.OK); SetApkButtonState(ApkButtonState.Create); UpdateStateMachine(); log.Error("Java not found! Aborting Android APK creation."); @@ -428,7 +429,7 @@ namespace AM2RLauncher // Check if xdelta is installed on linux if (OS.IsUnix && !CrossPlatformOperations.CheckIfXdeltaIsInstalled()) { - MessageBox.Show(Language.Text.XdeltaNotFound, Language.Text.WarningWindowTitle, MessageBoxButtons.OK); + MessageBox.Show(Text.XdeltaNotFound, Text.WarningWindowTitle, MessageBoxButtons.OK); SetApkButtonState(ApkButtonState.Create); UpdateStateMachine(); log.Error("Xdelta not found. Aborting Android APK creation..."); @@ -506,10 +507,10 @@ namespace AM2RLauncher { Directory = new Uri(CrossPlatformOperations.CURRENTPATH), MultiSelect = false, - Title = Language.Text.SelectModFileDialog + Title = Text.SelectModFileDialog }; - fileFinder.Filters.Add(new FileFilter(Language.Text.ZipArchiveText, ".zip")); + fileFinder.Filters.Add(new FileFilter(Text.ZipArchiveText, ".zip")); if (fileFinder.ShowDialog(this) != DialogResult.Ok) { @@ -546,7 +547,7 @@ namespace AM2RLauncher ProfileXML profile2 = Serializer.Deserialize(File.ReadAllText(modsDir + "/" + extractedName + "/profile.xml")); log.Error("Mod is already imported as " + extractedName + "! Cancelling mod import."); - MessageBox.Show(Language.Text.ModIsAlreadyInstalledMessage.Replace("$NAME", profile2.Name), Language.Text.WarningWindowTitle, MessageBoxType.Warning); + MessageBox.Show(HelperMethods.GetText(Text.ModIsAlreadyInstalledMessage, profile2.Name), Text.WarningWindowTitle, MessageBoxType.Warning); return; } // Directory doesn't exist -> extract! @@ -558,7 +559,7 @@ namespace AM2RLauncher { log.Error(fileFinder.FileName + " does not contain profile.xml! Cancelling mod import."); - MessageBox.Show(Language.Text.ModIsInvalidMessage.Replace("$NAME", extractedName), Language.Text.ErrorWindowTitle, MessageBoxType.Error); + MessageBox.Show(HelperMethods.GetText(Text.ModIsInvalidMessage, extractedName), Text.ErrorWindowTitle, MessageBoxType.Error); Directory.Delete(modsDir + "/" + extractedName, true); File.Delete(CrossPlatformOperations.CURRENTPATH + "/Mods/" + modFile.Name); return; @@ -571,8 +572,8 @@ namespace AM2RLauncher { log.Error("Mod is for " + profile.OperatingSystem + " while current OS is " + OS.Name + ". Cancelling mod import."); - MessageBox.Show(Language.Text.ModIsForWrongOS.Replace("$NAME", profile.Name).Replace("$OS", profile.OperatingSystem).Replace("$CURRENTOS", OS.Name), - Language.Text.ErrorWindowTitle, MessageBoxType.Error); + MessageBox.Show(HelperMethods.GetText(Text.ModIsForWrongOS, profile.Name).Replace("$OS", profile.OperatingSystem).Replace("$CURRENTOS", OS.Name), + Text.ErrorWindowTitle, MessageBoxType.Error); HelperMethods.DeleteDirectory(modsDir + "/" + extractedName); return; } @@ -581,13 +582,13 @@ namespace AM2RLauncher if (profileList.FirstOrDefault(p => p.Name == profile.Name) != null || Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/Profiles/" + profile.Name)) { log.Error(profile.Name + " is already installed."); - MessageBox.Show(Language.Text.ModIsAlreadyInstalledMessage.Replace("$NAME", profile.Name), Language.Text.WarningWindowTitle, MessageBoxType.Warning); + MessageBox.Show(HelperMethods.GetText(Text.ModIsAlreadyInstalledMessage, profile.Name), Text.WarningWindowTitle, MessageBoxType.Warning); HelperMethods.DeleteDirectory(modsDir + "/" + extractedName); return; } log.Info(profile.Name + " successfully installed."); - MessageBox.Show(Language.Text.ModSuccessfullyInstalledMessage.Replace("$NAME", profile.Name), Language.Text.SuccessWindowTitle); + MessageBox.Show(HelperMethods.GetText(Text.ModSuccessfullyInstalledMessage, profile.Name), Text.SuccessWindowTitle); LoadProfilesAndAdjustLists(); // Adjust profileIndex to point to newly added mod. if its not found for whatever reason, we default to first community updates @@ -626,6 +627,8 @@ namespace AM2RLauncher { if (settingsProfileDropDown.SelectedIndex == -1 && settingsProfileDropDown.Items.Count == 0) return; + string profileName = settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text; + log.Info("SettingsProfileDropDown.SelectedIndex has been changed to " + settingsProfileDropDown.SelectedIndex + "."); if (settingsProfileDropDown.SelectedIndex <= 0 || settingsProfileDropDown.Items.Count == 0) { @@ -638,21 +641,21 @@ namespace AM2RLauncher else { deleteModButton.Enabled = true; - deleteModButton.ToolTip = Language.Text.DeleteModButtonToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text); + deleteModButton.ToolTip = HelperMethods.GetText(Text.DeleteModButtonToolTip, profileName); // On non-installable profiles we want to disable updating updateModButton.Enabled = profileList[settingsProfileDropDown.SelectedIndex].Installable; - updateModButton.ToolTip = Language.Text.UpdateModButtonToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text); + updateModButton.ToolTip = HelperMethods.GetText(Text.UpdateModButtonToolTip, profileName); } - profileButton.Enabled = Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/Profiles/" + profileList[settingsProfileDropDown.SelectedIndex].Name); - profileButton.ToolTip = Language.Text.OpenProfileFolderToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text); + profileButton.Enabled = Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/Profiles/" + profileName); + profileButton.ToolTip = HelperMethods.GetText(Text.OpenProfileFolderToolTip, profileName); saveButton.Enabled = true; - saveButton.ToolTip = Language.Text.OpenSaveFolderToolTip.Replace("$NAME", settingsProfileDropDown.Items[settingsProfileDropDown.SelectedIndex].Text); + saveButton.ToolTip = HelperMethods.GetText(Text.OpenSaveFolderToolTip, profileName); if (settingsProfileDropDown.SelectedIndex < 0 || settingsProfileDropDown.Items.Count == 0) return; profileNotesTextArea.TextColor = colGreen; - profileNotesTextArea.Text = Language.Text.ProfileNotes + "\n" + profileList[settingsProfileDropDown.SelectedIndex].ProfileNotes; + profileNotesTextArea.Text = Text.ProfileNotes + "\n" + profileList[settingsProfileDropDown.SelectedIndex].ProfileNotes; } @@ -738,8 +741,8 @@ namespace AM2RLauncher profileIndex = profileDropDown.SelectedIndex; log.Debug("profileDropDown.SelectedIndex has been changed to " + profileIndex + "."); - profileAuthorLabel.Text = Language.Text.Author + " " + profileList[profileDropDown.SelectedIndex].Author; - profileVersionLabel.Text = Language.Text.VersionLabel + " " + profileList[profileDropDown.SelectedIndex].Version; + profileAuthorLabel.Text = Text.Author + " " + profileList[profileDropDown.SelectedIndex].Author; + profileVersionLabel.Text = Text.VersionLabel + " " + profileList[profileDropDown.SelectedIndex].Version; if (profileDropDown.SelectedIndex != 0 && (profileList[profileDropDown.SelectedIndex].SaveLocation == "%localappdata%/AM2R" || profileList[profileDropDown.SelectedIndex].SaveLocation == "default")) @@ -789,7 +792,7 @@ namespace AM2RLauncher // Create warning dialog when enabling if (enabled) { - MessageBox.Show(Language.Text.WarningWindowText, Language.Text.WarningWindowTitle, MessageBoxType.Warning); + MessageBox.Show(Text.WarningWindowText, Text.WarningWindowTitle, MessageBoxType.Warning); currentMirror = customMirrorTextBox.Text; } else @@ -845,7 +848,7 @@ namespace AM2RLauncher if (!gitURLRegex.IsMatch(mirrorText)) { log.Info("User used " + mirrorText + " as a custom Mirror, didn't pass git validation test."); - MessageBox.Show(Language.Text.InvalidGitURL.Replace("$NAME", mirrorText), Language.Text.ErrorWindowTitle, MessageBoxType.Error); + MessageBox.Show(HelperMethods.GetText(Text.InvalidGitURL, mirrorText), Text.ErrorWindowTitle, MessageBoxType.Error); return; } @@ -893,7 +896,7 @@ namespace AM2RLauncher ProfileXML profile = profileList[settingsProfileDropDown.SelectedIndex]; log.Info("User is attempting to delete profile " + profile.Name + "."); - DialogResult result = MessageBox.Show(Language.Text.DeleteModWarning.Replace("$NAME", profile.Name), Language.Text.WarningWindowTitle, + DialogResult result = MessageBox.Show(HelperMethods.GetText(Text.DeleteModWarning, profile.Name), Text.WarningWindowTitle, MessageBoxButtons.OKCancel, MessageBoxType.Warning, MessageBoxDefaultButton.Cancel); if (result == DialogResult.Ok) @@ -901,7 +904,7 @@ namespace AM2RLauncher log.Info("User did not cancel. Proceeding to delete " + profile); DeleteProfileAndAdjustLists(profile); log.Info(profile + " has been deleted"); - MessageBox.Show(Language.Text.DeleteModButtonSuccess.Replace("$NAME", profile.Name), Language.Text.SuccessWindowTitle); + MessageBox.Show(HelperMethods.GetText(Text.DeleteModButtonSuccess, profile.Name), Text.SuccessWindowTitle); } else { @@ -925,10 +928,10 @@ namespace AM2RLauncher { Directory = new Uri(CrossPlatformOperations.CURRENTPATH), MultiSelect = false, - Title = Language.Text.SelectModFileDialog + Title = Text.SelectModFileDialog }; - fileFinder.Filters.Add(new FileFilter(Language.Text.ZipArchiveText, ".zip")); + fileFinder.Filters.Add(new FileFilter(Text.ZipArchiveText, ".zip")); if (fileFinder.ShowDialog(this) != DialogResult.Ok) { @@ -972,7 +975,7 @@ namespace AM2RLauncher if (!File.Exists(extractedFolder + "/profile.xml")) { log.Error(fileFinder.FileName + " does not contain profile.xml! Cancelling mod update."); - MessageBox.Show(Language.Text.ModIsInvalidMessage.Replace("$NAME", extractedName), Language.Text.ErrorWindowTitle, MessageBoxType.Error); + MessageBox.Show(HelperMethods.GetText(Text.ModIsInvalidMessage, extractedName), Text.ErrorWindowTitle, MessageBoxType.Error); Directory.Delete(extractedFolder, true); File.Delete(CrossPlatformOperations.CURRENTPATH + "/Mods/" + modFile.Name); return; @@ -984,7 +987,7 @@ namespace AM2RLauncher if (profileList.FirstOrDefault(p => p.Name == profile.Name) != null || Directory.Exists(CrossPlatformOperations.CURRENTPATH + "/Profiles/" + profile.Name)) { // Mod is already installed, so we can update! - DialogResult updateResult = MessageBox.Show(Language.Text.UpdateModWarning.Replace("$NAME", currentProfile.Name), Language.Text.WarningWindowTitle, + DialogResult updateResult = MessageBox.Show(HelperMethods.GetText(Text.UpdateModWarning, currentProfile.Name), Text.WarningWindowTitle, MessageBoxButtons.OKCancel, MessageBoxType.Warning, MessageBoxDefaultButton.Cancel); if (updateResult == DialogResult.Ok) @@ -993,7 +996,7 @@ namespace AM2RLauncher if (Profile.IsProfileInstalled(currentProfile)) { //TODO: localize - DialogResult archiveResult = MessageBox.Show(Language.Text.ArchiveMod.Replace("$NAME", currentProfile.Name + " " + Language.Text.VersionLabel + currentProfile.Version), Language.Text.WarningWindowTitle, MessageBoxButtons.YesNo, MessageBoxType.Warning, MessageBoxDefaultButton.No); + DialogResult archiveResult = MessageBox.Show(HelperMethods.GetText(Text.ArchiveMod, currentProfile.Name + " " + Text.VersionLabel + currentProfile.Version), Text.WarningWindowTitle, MessageBoxButtons.YesNo, MessageBoxType.Warning, MessageBoxDefaultButton.No); // User wants to archive profile if (archiveResult == DialogResult.Yes) @@ -1017,8 +1020,8 @@ namespace AM2RLauncher // Cancel the operation! // Show message to tell user that mod could not be found, install this separately log.Error("Mod is not installed! Cancelling mod update."); - MessageBox.Show(Language.Text.UpdateModButtonWrongMod.Replace("$NAME", currentProfile.Name).Replace("$SELECT", profile.Name), - Language.Text.WarningWindowTitle, MessageBoxButtons.OK); + MessageBox.Show(HelperMethods.GetText(Text.UpdateModButtonWrongMod, currentProfile.Name).Replace("$SELECT", profile.Name), + Text.WarningWindowTitle, MessageBoxButtons.OK); abort = true; } @@ -1031,7 +1034,7 @@ namespace AM2RLauncher } log.Info("Successfully updated mod profile " + profile.Name + "."); - MessageBox.Show(Language.Text.ModSuccessfullyInstalledMessage.Replace("$NAME", currentProfile.Name), Language.Text.SuccessWindowTitle); + MessageBox.Show(HelperMethods.GetText(Text.ModSuccessfullyInstalledMessage, currentProfile.Name), Text.SuccessWindowTitle); UpdateStateMachine(); LoadProfilesAndAdjustLists(); @@ -1059,7 +1062,7 @@ namespace AM2RLauncher { case UpdateState.Downloading: { - var result = MessageBox.Show(Language.Text.CloseOnCloningText, Language.Text.WarningWindowTitle, MessageBoxButtons.YesNo, + var result = MessageBox.Show(Text.CloseOnCloningText, Text.WarningWindowTitle, MessageBoxButtons.YesNo, MessageBoxType.Warning, MessageBoxDefaultButton.No); if (result == DialogResult.No) { @@ -1071,7 +1074,7 @@ namespace AM2RLauncher break; } case UpdateState.Installing: - MessageBox.Show(Language.Text.CloseOnInstallingText, Language.Text.WarningWindowTitle, MessageBoxButtons.OK, MessageBoxType.Warning); + MessageBox.Show(Text.CloseOnInstallingText, Text.WarningWindowTitle, MessageBoxButtons.OK, MessageBoxType.Warning); e.Cancel = true; break; } diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs index e1cb7fb..e0acccc 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs @@ -2,6 +2,7 @@ using System; using AM2RLauncher.Core; using AM2RLauncher.Core.XML; +using AM2RLauncher.Language; namespace AM2RLauncher { @@ -81,7 +82,7 @@ namespace AM2RLauncher // Our default values apkButton.Enabled = false; - apkButton.ToolTip = Language.Text.ApkButtonDisabledToolTip; + apkButton.ToolTip = Text.ApkButtonDisabledToolTip; // If profile supports Android and if we are NOT already creating an APK... if (!IsProfileIndexValid()) @@ -101,7 +102,7 @@ namespace AM2RLauncher case UpdateState.Playing: return; case UpdateState.Install: - case UpdateState.Play: apkButton.Enabled = true; apkButton.ToolTip = Language.Text.ApkButtonEnabledToolTip.Replace("$NAME", profileDropDown?.Items[profileDropDown.SelectedIndex]?.Text ?? ""); break; + case UpdateState.Play: apkButton.Enabled = true; apkButton.ToolTip = HelperMethods.GetText(Text.ApkButtonEnabledToolTip, profileDropDown?.Items[profileDropDown.SelectedIndex]?.Text ?? ""); break; } } @@ -167,19 +168,19 @@ namespace AM2RLauncher settingsProfileDropDown.Enabled = enabled; profileButton.Enabled = enabled; //TODO: these .replace($NAME) are in a lot of places, replace them with some fuction. - profileButton.ToolTip = Language.Text.OpenProfileFolderToolTip.Replace("$NAME", selectedProfileName); + profileButton.ToolTip = HelperMethods.GetText(Text.OpenProfileFolderToolTip, selectedProfileName); saveButton.Enabled = enabled; - saveButton.ToolTip = Language.Text.OpenSaveFolderToolTip.Replace("$NAME", selectedProfileName); + saveButton.ToolTip = HelperMethods.GetText(Text.OpenSaveFolderToolTip, selectedProfileName); addModButton.Enabled = enabled; - addModButton.ToolTip = Language.Text.AddNewModToolTip; + addModButton.ToolTip = Text.AddNewModToolTip; // Only enable these, when we're not on the community updates if (settingsProfileDropDown.SelectedIndex > 0) { updateModButton.Enabled = profileList[settingsProfileDropDown.SelectedIndex].Installable; - updateModButton.ToolTip = Language.Text.UpdateModButtonToolTip.Replace("$NAME", selectedProfileName); + updateModButton.ToolTip = HelperMethods.GetText(Text.UpdateModButtonToolTip, selectedProfileName); deleteModButton.Enabled = enabled; - deleteModButton.ToolTip = Language.Text.DeleteModButtonToolTip.Replace("$NAME", selectedProfileName); + deleteModButton.ToolTip = HelperMethods.GetText(Text.DeleteModButtonToolTip, selectedProfileName); } Color col = enabled ? colGreen : colInactive; @@ -203,13 +204,13 @@ namespace AM2RLauncher string profileName = ((profileDropDown != null) && (profileDropDown.Items.Count > 0)) ? profileDropDown.Items[profileDropDown.SelectedIndex].Text : ""; switch (updateState) { - case UpdateState.Download: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonDownloadToolTip; 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.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.Play: playButton.Enabled = true; playButton.ToolTip = Language.Text.PlayButtonPlayToolTip.Replace("$NAME", profileName); break; - case UpdateState.Playing: playButton.Enabled = false; playButton.ToolTip = Language.Text.PlayButtonPlayingToolTip; break; + case UpdateState.Download: playButton.Enabled = true; playButton.ToolTip = Text.PlayButtonDownloadToolTip; break; + case UpdateState.Downloading: playButton.Enabled = true; playButton.ToolTip = ""; playButton.ToolTip = Text.PlayButtonDownladingToolTip; break; + case UpdateState.Select11: playButton.Enabled = true; playButton.ToolTip = Text.PlayButtonSelect11ToolTip; break; + case UpdateState.Install: playButton.Enabled = true; playButton.ToolTip = HelperMethods.GetText(Text.PlayButtonInstallToolTip, profileName); break; + case UpdateState.Installing: playButton.Enabled = false; playButton.ToolTip = Text.PlayButtonInstallingToolTip; break; + case UpdateState.Play: playButton.Enabled = true; playButton.ToolTip = HelperMethods.GetText(Text.PlayButtonPlayToolTip, profileName); break; + case UpdateState.Playing: playButton.Enabled = false; playButton.ToolTip = Text.PlayButtonPlayingToolTip; break; } playButton.Text = GetPlayButtonText(); @@ -241,13 +242,13 @@ namespace AM2RLauncher { switch (updateState) { - case UpdateState.Download: return Language.Text.Download; - case UpdateState.Downloading: return Language.Text.Abort; - case UpdateState.Select11: return Language.Text.Select11; - case UpdateState.Install: return Language.Text.Install; - case UpdateState.Installing: return Language.Text.Installing; - case UpdateState.Play: return Language.Text.Play; - case UpdateState.Playing: return Language.Text.Playing; + case UpdateState.Download: return Text.Download; + case UpdateState.Downloading: return Text.Abort; + case UpdateState.Select11: return Text.Select11; + case UpdateState.Install: return Text.Install; + case UpdateState.Installing: return Text.Installing; + case UpdateState.Play: return Text.Play; + case UpdateState.Playing: return Text.Playing; default: return null; } } @@ -260,8 +261,8 @@ namespace AM2RLauncher { switch (apkButtonState) { - case ApkButtonState.Create: return Language.Text.CreateAPK; - case ApkButtonState.Creating: return Language.Text.CreatingAPK; + case ApkButtonState.Create: return Text.CreateAPK; + case ApkButtonState.Creating: return Text.CreatingAPK; default: return null; } } @@ -287,9 +288,9 @@ namespace AM2RLauncher { //TODO: localizations if (profile.Name.Contains("Community Updates")) - profile.ProfileNotes = Language.Text.ArchiveNotesCommunityUpdates; + profile.ProfileNotes = Text.ArchiveNotesCommunityUpdates; else - profile.ProfileNotes = Language.Text.ArchiveNotesMods + "\n\n" + profile.ProfileNotes; + profile.ProfileNotes = Text.ArchiveNotesMods + "\n\n" + profile.ProfileNotes; } profileDropDown.Items.Add(profile.Name); @@ -323,8 +324,8 @@ namespace AM2RLauncher // Refresh the author and version label on the main tab if (profileList.Count > 0) { - profileAuthorLabel.Text = Language.Text.Author + " " + profileList[profileDropDown.SelectedIndex].Author; - profileVersionLabel.Text = Language.Text.VersionLabel + " " + profileList[profileDropDown.SelectedIndex].Version; + profileAuthorLabel.Text = Text.Author + " " + profileList[profileDropDown.SelectedIndex].Author; + profileVersionLabel.Text = Text.VersionLabel + " " + profileList[profileDropDown.SelectedIndex].Version; } log.Info("Reloading UI components after loading successful."); diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs index c51f2d0..b3d2f98 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs @@ -1,5 +1,6 @@ using AM2RLauncher.Core; using AM2RLauncher.Core.XML; +using AM2RLauncher.Language; using Eto.Drawing; using Eto.Forms; using log4net; @@ -134,7 +135,7 @@ namespace AM2RLauncher log.Info("Beginning UI initialization..."); // System tray indicator - showButton = new ButtonMenuItem { Text = Language.Text.TrayButtonShow }; + showButton = new ButtonMenuItem { Text = Text.TrayButtonShow }; trayIndicator = new TrayIndicator { Menu = new ContextMenu(showButton), @@ -189,8 +190,8 @@ namespace AM2RLauncher foreach (var mirror in mirrorList) { string text = mirror; - if (text.Contains("github.com")) text = Language.Text.MirrorGithubText; - else if (text.Contains("gitlab.com")) text = Language.Text.MirrorGitlabText; + if (text.Contains("github.com")) text = Text.MirrorGithubText; + else if (text.Contains("gitlab.com")) text = Text.MirrorGitlabText; mirrorDescriptionList.Add(new ListItem() { Key = mirror, Text = text }); } #endregion @@ -246,7 +247,7 @@ namespace AM2RLauncher // APK button apkButton = new ColorButton { - Text = Language.Text.CreateAPK, + Text = Text.CreateAPK, Height = 40, Width = 250, TextColor = colGreen, @@ -286,7 +287,7 @@ namespace AM2RLauncher { BackgroundColor = colBG, Height = 15, - Text = Language.Text.CurrentProfile, + Text = Text.CurrentProfile, TextColor = colGreen }; @@ -315,7 +316,7 @@ namespace AM2RLauncher { BackgroundColor = colBG, Height = 16, - Text = Language.Text.Author + " ", + Text = Text.Author + " ", TextColor = colGreen }; @@ -325,7 +326,7 @@ namespace AM2RLauncher { BackgroundColor = colBG, Height = 16, - Text = Language.Text.VersionLabel + " ", + Text = Text.VersionLabel + " ", TextColor = colGreen }; @@ -337,7 +338,7 @@ namespace AM2RLauncher BackgroundColor = colBG, Width = 20, Height = 55, - Text = Language.Text.SaveLocationWarning, + Text = Text.SaveLocationWarning, TextColor = colRed }; @@ -345,16 +346,16 @@ namespace AM2RLauncher // Social buttons - var redditButton = new ImageButton { ToolTip = Language.Text.RedditToolTip, Image = redditIcon }; + var redditButton = new ImageButton { ToolTip = Text.RedditToolTip, Image = redditIcon }; redditButton.Click += RedditIconOnClick; - var githubButton = new ImageButton { ToolTip = Language.Text.GithubToolTip, Image = githubIcon }; + var githubButton = new ImageButton { ToolTip = Text.GithubToolTip, Image = githubIcon }; githubButton.Click += GithubIconOnClick; - var youtubeButton = new ImageButton { ToolTip = Language.Text.YoutubeToolTip, Image = youtubeIcon }; + var youtubeButton = new ImageButton { ToolTip = Text.YoutubeToolTip, Image = youtubeIcon }; youtubeButton.Click += YoutubeIconOnClick; - var discordButton = new ImageButton { ToolTip = Language.Text.DiscordToolTip, Image = discordIcon }; + var discordButton = new ImageButton { ToolTip = Text.DiscordToolTip, Image = discordIcon }; discordButton.Click += DiscordIconOnClick; @@ -395,7 +396,7 @@ namespace AM2RLauncher mainPage = new TabPage { BackgroundColor = colBGNoAlpha, - Text = Language.Text.PlayTab, + Text = Text.PlayTab, Content = drawable }; #endregion @@ -411,14 +412,14 @@ namespace AM2RLauncher changelogNoConnectionLabel = new Label { - Text = Language.Text.NoInternetConnection, + Text = Text.NoInternetConnection, TextColor = colGreen }; changelogPage = new TabPage { BackgroundColor = colBGNoAlpha, - Text = Language.Text.ChangelogTab, + Text = Text.ChangelogTab, Content = new TableLayout { @@ -442,13 +443,13 @@ namespace AM2RLauncher newsNoConnectionLabel = new Label { - Text = Language.Text.NoInternetConnection, + Text = Text.NoInternetConnection, TextColor = colGreen }; newsPage = new TabPage { - Text = Language.Text.NewsTab, + Text = Text.NewsTab, BackgroundColor = colBGNoAlpha, Content = new TableLayout @@ -492,7 +493,7 @@ namespace AM2RLauncher // LanguageLabel languageLabel = new Label { - Text = Language.Text.LanguageNotice, + Text = Text.LanguageNotice, TextColor = colGreen }; @@ -500,7 +501,7 @@ namespace AM2RLauncher List languageList = new List { - Language.Text.SystemLanguage, + Text.SystemLanguage, "Deutsch", "English", "Español", @@ -535,7 +536,7 @@ namespace AM2RLauncher autoUpdateAM2RCheck = new CheckBox { Checked = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("AutoUpdateAM2R")), - Text = Language.Text.AutoUpdateAM2R, + Text = Text.AutoUpdateAM2R, TextColor = colGreen }; @@ -544,7 +545,7 @@ namespace AM2RLauncher autoUpdateLauncherCheck = new CheckBox { Checked = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("AutoUpdateLauncher")), - Text = Language.Text.AutoUpdateLauncher, + Text = Text.AutoUpdateLauncher, TextColor = colGreen }; @@ -552,7 +553,7 @@ namespace AM2RLauncher hqMusicPCCheck = new CheckBox { Checked = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("MusicHQPC")), - Text = Language.Text.HighQualityPC, + Text = Text.HighQualityPC, TextColor = colGreen }; @@ -560,7 +561,7 @@ namespace AM2RLauncher hqMusicAndroidCheck = new CheckBox { Checked = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("MusicHQAndroid")), - Text = Language.Text.HighQualityAndroid, + Text = Text.HighQualityAndroid, TextColor = colGreen }; @@ -568,7 +569,7 @@ namespace AM2RLauncher profileDebugLogCheck = new CheckBox { Checked = bool.Parse(CrossPlatformOperations.ReadFromConfig("ProfileDebugLog")), - Text = Language.Text.ProfileDebugCheckBox, + Text = Text.ProfileDebugCheckBox, TextColor = colGreen }; @@ -578,7 +579,7 @@ namespace AM2RLauncher { customEnvVarLabel = new Label { - Text = Language.Text.CustomEnvVarLabel, + Text = Text.CustomEnvVarLabel, TextColor = colGreen }; } @@ -598,7 +599,7 @@ namespace AM2RLauncher // Mirror list mirrorLabel = new Label { - Text = Language.Text.DownloadSource, + Text = Text.DownloadSource, TextColor = colGreen }; @@ -621,7 +622,7 @@ namespace AM2RLauncher customMirrorCheck = new CheckBox { Checked = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("CustomMirrorEnabled")), - Text = Language.Text.CustomMirrorCheck, + Text = Text.CustomMirrorCheck, TextColor = colGreen }; @@ -641,7 +642,7 @@ namespace AM2RLauncher { BackgroundColor = colBGNoAlpha, Content = settingsLayout, - Text = Language.Text.LauncherSettingsTab + Text = Text.LauncherSettingsTab }; #endregion @@ -655,7 +656,7 @@ namespace AM2RLauncher addModButton = new ColorButton { ToolTip = null, - Text = Language.Text.AddNewMod, + Text = Text.AddNewMod, Font = smallButtonFont, Height = 30, Width = 275, @@ -672,7 +673,7 @@ namespace AM2RLauncher settingsProfileLabel = new Label { - Text = Language.Text.CurrentProfile, + Text = Text.CurrentProfile, TextColor = colGreen, Width = 275 }; @@ -692,7 +693,7 @@ namespace AM2RLauncher profileButton = new ColorButton { ToolTip = null, - Text = Language.Text.OpenProfileFolder, + Text = Text.OpenProfileFolder, Font = smallButtonFont, Height = 30, Width = 275, @@ -705,7 +706,7 @@ namespace AM2RLauncher saveButton = new ColorButton { ToolTip = null, - Text = Language.Text.OpenSaveFolder, + Text = Text.OpenSaveFolder, Font = smallButtonFont, Height = 30, Width = 275, @@ -718,7 +719,7 @@ namespace AM2RLauncher updateModButton = new ColorButton { ToolTip = null, - Text = Language.Text.UpdateModButtonText, + Text = Text.UpdateModButtonText, Font = smallButtonFont, Height = 30, Width = 275, @@ -731,7 +732,7 @@ namespace AM2RLauncher deleteModButton = new ColorButton { ToolTip = null, - Text = Language.Text.DeleteModButtonText, + Text = Text.DeleteModButtonText, Font = smallButtonFont, Height = 30, Width = 275, @@ -749,7 +750,7 @@ namespace AM2RLauncher SpellCheck = false, Width = 275, Height = 150, - Text = Language.Text.ProfileNotes + Text = Text.ProfileNotes }; profileLayout.BeginHorizontal(); @@ -761,7 +762,7 @@ namespace AM2RLauncher { BackgroundColor = colBGNoAlpha, Content = profileLayout, - Text = Language.Text.ProfileSettingsTab + Text = Text.ProfileSettingsTab }; #endregion diff --git a/AM2RLauncher/AM2RLauncherCore/HelperMethods.cs b/AM2RLauncher/AM2RLauncherCore/HelperMethods.cs index 0ca586b..9ed21e9 100644 --- a/AM2RLauncher/AM2RLauncherCore/HelperMethods.cs +++ b/AM2RLauncher/AM2RLauncherCore/HelperMethods.cs @@ -161,4 +161,15 @@ public static class HelperMethods log.Info("Internet connection established!"); return true; } + + /// + /// Gets and replaces "$NAME" with . + /// + /// The text to get + /// The text to replace "$NAME" with. + /// + public static string GetText(string languageText, string replacementText = "") + { + return languageText.Replace("$NAME", replacementText); + } } \ No newline at end of file