Esempio n. 1
0
        void SaveRootLanguageFile()
        {
            var changeNewRootKeys   = new Dictionary <string, string>();
            var changeNewRootValues = new Dictionary <string, string>();

            for (int i = 0; i < changedRootKeys.Count; i++)
            {
                SerializableStringPair             rootKey   = changedRootKeys[i];
                SerializableLocalizationObjectPair rootValue = changedRootValues[i];
                //Check for possible duplicates and rename them
                string newKeyValue = LanguageDictionaryHelper.AddNewKeyPersistent(changeNewRootKeys,
                                                                                  rootKey.originalValue,
                                                                                  rootValue.changedValue.GetFullKey(rootKey.changedValue));

                //Check for possible duplicates and rename them(same as above)
                LanguageDictionaryHelper.AddNewKeyPersistent(changeNewRootValues, newKeyValue, rootValue.changedValue.TextValue);
            }

            //Add the full values before saving
            var changeNewRootKeysToSave   = new Dictionary <string, string>();
            var changeNewRootValuesToSave = new Dictionary <string, string>();

            foreach (var rootKey in changeNewRootKeys)
            {
                LocalizedObject thisLocalizedObject = parsedRootValues[rootKey.Key];
                changeNewRootKeysToSave.Add(thisLocalizedObject.GetFullKey(rootKey.Key), rootKey.Value);
                changeNewRootValuesToSave.Add(thisLocalizedObject.GetFullKey(rootKey.Key), changeNewRootValues[rootKey.Key]);
            }



            SmartCultureInfoCollection allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());

            LanguageHandlerEditor.SaveRootLanguageFile(changeNewRootKeysToSave, changeNewRootValuesToSave, LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures));

            //Fire the root language changed event
            if (OnRootFileChanged != null)
            {
                OnRootFileChanged();
            }

            //Reload the window(in case of duplicate keys)
            SetRootValues(LanguageHandlerEditor.LoadParsedLanguageFile(null, true));
        }
Esempio n. 2
0
        SerializableLocalizationObjectPair DrawRootPair(Rect position, SerializableLocalizationObjectPair item)
        {
            LocalizedObjectType newChangedType = (LocalizedObjectType)EditorGUI.Popup(
                listColumns.GetColumnPosition(position, "Type"),
                (int)item.changedValue.ObjectType,
                keyTypes);

            int index = changedRootValues.IndexOf(item);
            SerializableStringPair rootValue = changedRootKeys[index];
            string newChangedValue           = EditorGUI.TextField(listColumns.GetColumnPosition(position, "Key"), rootValue.changedValue);
            string newTextValue = EditorGUI.TextArea(listColumns.GetColumnPosition(position, "Comment"), item.changedValue.TextValue);

            if (newChangedType != changedRootValues[index].changedValue.ObjectType ||
                newChangedValue != rootValue.changedValue ||
                newTextValue != changedRootValues[index].changedValue.TextValue)
            {
                undoManager.ForceDirty();
                changedRootValues[index].changedValue.ObjectType = newChangedType;
                rootValue.changedValue = newChangedValue;
                changedRootValues[index].changedValue.TextValue = newTextValue;
            }

            return(item);
        }