private void toolStripMenuItemLang_Click(object sender, EventArgs e) { ToolStripMenuItem i = sender as ToolStripMenuItem; if (i != null && i.Tag != null) { LanguageFileInfoCollection col = new LanguageFileInfoCollection(); LanguageFileInfo n = i.Tag as LanguageFileInfo; if (n != null) { if (col.CurrentLanguage.ID == n.ID) { i.Checked = true; return; } col.CurrentLanguage = n; Translator.Instance.Update(this); foreach (ToolStripMenuItem m in this.toolStripMenuItemSelectLang.DropDownItems) { if (m.Checked == true) { m.Checked = false; } } i.Checked = true; } } }
private static LanguageFileInfo GetLanguageFileInfo(XElement languageFile) { var languageFiles = new LanguageFileInfo(); if (languageFile.HasAttributes) { SetLanguageFileAttributes(languageFile, languageFiles); } foreach (var fileVersions in languageFile.Elements()) { if (string.Compare(fileVersions.Name.LocalName, "FileVersions", StringComparison.InvariantCultureIgnoreCase) == 0) { foreach (var fileVersion in fileVersions.Elements()) { if (string.Compare(fileVersion.Name.LocalName, "fileVersion", StringComparison.InvariantCultureIgnoreCase) == 0) { if (!fileVersion.HasAttributes) { continue; } var fileVersionInfo = GetFileVersionInfo(fileVersion); languageFiles.FileVersionInfos.Add(fileVersionInfo); } } } } return(languageFiles); }
public void checkLanguage() { //This is the case when we start menu for the first time in a game if (ActualLanguage.actualLanguage == null) { //This condition makes sure the player starts the game for the first time. LanguageFileInfo languageSave = SaveSystem.LoadLanguage(); if (languageSave == null) { if (subject) { //If no actual save is stored, it means the game is starting spawnLanguage(); inOption = true; passCinematic = timeline.gameObject.GetComponent <passCinematicScript>(); passCinematic.disable(); } } else //We go there if the player starts the game after the first time { //In this case a language is already selected, we just have to put it in ActualLanguage ActualLanguage.actualLanguage = languageSave.Clone(); //In this case, we need to update all texts now RefreshAllText(); checkSave(); } } else { //If ActualLanguage is filled, then there is no need to do anything checkSave(); } }
private static void AddLanguageFileAssignmentInfo(XElement settingsBundle, LanguageFileInfo languageFile) { foreach (var settingBundle in settingsBundle.Elements()) { if (string.Compare(settingBundle.Name.LocalName, "SettingsBundle", StringComparison.InvariantCultureIgnoreCase) == 0) { var fileStateInfo = GetFileStateInfo(settingBundle); if (fileStateInfo == null) { break; } foreach (var settingsGroup in settingBundle.Elements()) { if (string.Compare(settingsGroup.Name.LocalName, "SettingsGroup", StringComparison.InvariantCultureIgnoreCase) == 0) { if (!settingsGroup.HasAttributes) { continue; } var fileAssignmentInfo = GetFileAssignmentInfo(settingsGroup, fileStateInfo); if (fileAssignmentInfo != null) { languageFile.FileAssignmentInfos.Add(fileAssignmentInfo); } } } } } }
public static void SaveLanguage(LanguageFileInfo _chosenLanguage) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/language.slime"; FileStream stream = new FileStream(path, FileMode.Create); formatter.Serialize(stream, _chosenLanguage); stream.Close(); }
public LanguageFileInfo Clone() { LanguageFileInfo clone = new LanguageFileInfo(); clone.chosenLanguage = new LanguageSaveFormat(); if (chosenLanguage != null) { clone.chosenLanguage.name = chosenLanguage.name; } return(clone); }
private void Awake() { persistantHandler = GameObject.FindGameObjectsWithTag("PersistentObject")[0]; //persistantHandler.GetComponent<InputHandler>().addObserver(this); this.gameObject.GetComponent <UIFader>().FadeIn(0.3f); Invoke("StopTime", 0.4f); //RefreshBubbles(); LanguageFileInfo languageSave = SaveSystem.LoadLanguage(); if (languageSave == null) { languageSave = new LanguageFileInfo(); } Debug.Log("language chargé : " + languageSave.chosenLanguage.name); //We load all the possible languages string loadedJsonFile = Resources.Load <TextAsset>("languages").text; allLanguages = JsonUtility.FromJson <LanguageContainer>(loadedJsonFile); //When we get to the one with te right code, we keep the index to be able to access the info easily for (int i = 0; i < allLanguages.languages.Length; i++) { Debug.Log(allLanguages.languages[i].code); if (allLanguages.languages[i].code == languageSave.chosenLanguage.name) { Debug.Log("This is the right language"); language = i; //We store in an environment variable the adress of the right dialogues languageSave.chosenLanguage.name = allLanguages.languages[i].adress; ActualLanguage.actualLanguage = languageSave.Clone(); } } //We then fill our dropdown with every language dropDown.options.Clear(); for (int i = 0; i < allLanguages.languages.Length; i++) { dropDown.options.Add(allLanguages.languages[i].name); } HandleSelect(); }
public static LanguageFileInfo LoadLanguage() { string path = Application.persistentDataPath + "/language.slime"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); LanguageFileInfo language = formatter.Deserialize(stream) as LanguageFileInfo; stream.Close(); return(language); } else { Debug.LogWarning("Save File not found in : " + path); return(null); } }
private static void SetLanguageFileAttributes(XElement languageFile, LanguageFileInfo languageFileInfo) { foreach (var attribute in languageFile.Attributes()) { if (string.Compare(attribute.Name.LocalName, "Guid", StringComparison.InvariantCultureIgnoreCase) == 0) { languageFileInfo.Guid = attribute.Value; } if (string.Compare(attribute.Name.LocalName, "SettingsBundleGuid", StringComparison.InvariantCultureIgnoreCase) == 0) { languageFileInfo.SettingsBundleGuid = attribute.Value; } if (string.Compare(attribute.Name.LocalName, "LanguageCode", StringComparison.InvariantCultureIgnoreCase) == 0) { languageFileInfo.LanguageCode = attribute.Value; } } }
private static LanguageFileInfo GetLanguageFileInfo(IEnumerable <ProjectFileInfo> projectFilesInfo, string settingsBundleGuid) { LanguageFileInfo languageFile = null; foreach (var projectFileInfo in projectFilesInfo) { foreach (var langugageFileInfo in projectFileInfo.LanguageFileInfos) { if (string.Compare(langugageFileInfo.SettingsBundleGuid, settingsBundleGuid, StringComparison.InvariantCultureIgnoreCase) == 0) { languageFile = langugageFileInfo; break; } } if (languageFile != null) { break; } } return(languageFile); }
public static void SaveLanguage(string _chosenLanguage) { LanguageFileInfo language = new LanguageFileInfo(_chosenLanguage); SaveLanguage(language); }