void Initialize() { if (undoManager == null) { // Instantiate Undo Manager undoManager = new HOEditorUndoManager(this, "Smart Localization - Edit Root Language Window"); } if (keyTypes == null) { //Get the different key types List <string> enumNames = new List <string>(Enum.GetNames(typeof(LocalizedObjectType))); if (enumNames.Contains("INVALID")) { enumNames.Remove("INVALID"); } keyTypes = enumNames.ToArray(); } if (changedRootKeys == null) { changedRootKeys = new List <SerializableStringPair>(); } if (changedRootValues == null) { changedRootValues = new List <SerializableLocalizationObjectPair>(); } if (parsedRootValues == null) { parsedRootValues = new Dictionary <string, LocalizedObject>(); } if (parsedRootValues.Count < 1) { SetRootValues(LanguageHandlerEditor.LoadParsedLanguageFile(null, true)); } settingsList.Clear(); settingsList.Add("CONVERTLINEBREAK"); settingsList.Add("GENERAL"); settingsList.Add("SEARCH"); settingsList.Add("IMPORT"); settingsAdaptor = new SettingsListAdaptor(settingsList, DrawSettingsItem, 20); settingsContextMenu = new SettingsMenuControl(); localizedObjectAdaptor = new LocalizedObjectListAdaptor(changedRootValues, changedRootKeys, DrawRootPair, 17); if (localizedObjectContextMenu != null) { localizedObjectContextMenu.ClearEvents(); } localizedObjectContextMenu = new LocalizedObjectMenuControl(OnKeyDeleted, OnKeyAdded); listColumns = new EditorColumns(0.1f); listColumns.AddColumn("Type", 0.1f); listColumns.AddColumn("Key", 0.45f); listColumns.AddColumn("Comment", 0.45f); listColumns.RecalculateColumnWidths(); if (EditorPrefs.HasKey(CollapseMultilineSaveKey)) { collapseMultilineFields = EditorPrefs.GetBool(CollapseMultilineSaveKey); } GUIUtility.keyboardControl = 0; }
public void Initialize(SmartCultureInfo thisCultureInfo, bool forceNewLanguage = false) { if (thisCultureInfo != null) { if (undoManager == null) { // Instantiate Undo Manager undoManager = new HOEditorUndoManager(this, "Smart Localization - Translate Language Window"); } if (thisCultureInfo != null) { bool newLanguage = thisCultureInfo != this.currentCultureInfo ? true : false; if (Application.isPlaying || forceNewLanguage) { newLanguage = true; } this.currentCultureInfo = thisCultureInfo; if (loadedLanguageValues == null || loadedLanguageValues.Count < 1 || newLanguage) { InitializeLanguage(thisCultureInfo, LanguageHandlerEditor.LoadParsedLanguageFile(null, true), LanguageHandlerEditor.LoadParsedLanguageFile(thisCultureInfo.languageCode, false)); } } settingsList.Clear(); settingsList.Add("SETTINGS"); settingsList.Add("CONVERTLINEBREAK"); settingsList.Add("WATCHFILE"); settingsList.Add("AUTOTRANSLATE"); settingsList.Add("GENERAL"); #if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.WebPlayer && EditorUserBuildSettings.activeBuildTarget != BuildTarget.WebPlayerStreamed) #endif { settingsList.Add("SORT"); } settingsList.Add("SEARCH"); settingsAdaptor = new SettingsListAdaptor(settingsList, DrawSettingsItem, 20); settingsContextMenu = new SettingsMenuControl(); listColumns = new EditorColumns(0.02f, true); listColumns.AddColumn("Copy", 0.1f); listColumns.AddColumn("Translate", 0.1f); listColumns.AddColumn("Key", 0.21f); listColumns.AddColumn("Comment", 0.21f); listColumns.AddColumn("Override", 0.07f); listColumns.AddColumn("Value", 0.25f); listColumns.RecalculateColumnWidths(); if (EditorPrefs.HasKey(CollapseMultilineSaveKey)) { collapseMultilineFields = EditorPrefs.GetBool(CollapseMultilineSaveKey); } GUIUtility.keyboardControl = 0; SmartCultureInfoCollection allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath()); SmartCultureInfoCollection availableCultures = LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures); otherAvailableLanguageCodes.Clear(); otherAvailableLanguageCodesArray = null; foreach (SmartCultureInfo otherCulture in availableCultures.cultureInfos) { if (otherCulture.languageCode != thisCultureInfo.languageCode) { otherAvailableLanguageCodes.Add(otherCulture.languageCode); } } if (otherAvailableLanguageCodes.Count > 0) { otherAvailableLanguageCodesArray = otherAvailableLanguageCodes.ToArray(); } } }