public void InitializeCultureCollections(bool reloadAllCultures = false)
        {
            if (reloadAllCultures)
            {
                allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
            }

            availableCultures    = LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);
            nonAvailableCultures = LanguageHandlerEditor.GetNonAvailableLanguages(allCultures);

            availableCultures.cultureInfos.Sort((a, b) =>
            {
                return(a.englishName.CompareTo(b.englishName));
            });
            nonAvailableCultures.cultureInfos.Sort((a, b) =>
            {
                return(a.englishName.CompareTo(b.englishName));
            });

            availableCultures.cultureInfos.Insert(0, new SmartCultureInfo(string.Empty, "ROOT", "ROOT", false));

            languageListAdaptor     = new SmartCultureInfoListAdaptor(availableCultures.cultureInfos, DrawAvailableLanguageItem, 28);
            languageListContextMenu = new SmartCultureInfoMenuControl();

            createListAdaptor     = new CreateLanguageListAdaptor(nonAvailableCultures.cultureInfos, DrawCreateLanguageItem, 15);
            createListContextMenu = new CreateLanguageMenuControl();

            settingsAdaptor     = new SettingsListAdaptor(settingsList, DrawSettingsItem, 110);
            settingsContextMenu = new SettingsMenuControl();
        }
        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;
        }
Пример #3
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();
                }
            }
        }