void OnGUI_CategorizedTerm(string Term) { GUILayout.BeginHorizontal(); string sKey, sCategory; LanguageSourceData.DeserializeFullTerm(Term, out sKey, out sCategory); if (!string.IsNullOrEmpty(sCategory)) { GUI.color = Color.gray; GUILayout.Label(sCategory + "/"); GUI.color = Color.white; } GUILayout.Label(sKey); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }
static ParsedTerm AddParsedTerm(string FullTerm, string TermKey, string Category, int Usage) { if (TermKey == null) { LanguageSourceData.DeserializeFullTerm(FullTerm, out TermKey, out Category); } var data = new ParsedTerm(); data.Usage = Usage; data.FullTerm = FullTerm; data.Term = TermKey; data.Category = Category; mParsedTerms[FullTerm] = data; return(data); }
void AssignCategoryToSelectedTerms() { mIsParsing = true; EditorApplication.update -= AssignCategoryToSelectedTerms; mNewCategory = mNewCategory.Trim(LanguageSourceData.CategorySeparators); if (mNewCategory == LanguageSourceData.EmptyCategory) { mNewCategory = string.Empty; } TermReplacements = new Dictionary <string, string>(System.StringComparer.Ordinal); for (int i = mSelectedKeys.Count - 1; i >= 0; --i) { string sKey, sCategory; string OldTerm = mSelectedKeys[i]; LanguageSourceData.DeserializeFullTerm(OldTerm, out sKey, out sCategory); if (!string.IsNullOrEmpty(mNewCategory)) { sKey = string.Concat(mNewCategory, "/", sKey); } if (OldTerm == sKey) { continue; } TermReplacements[OldTerm] = sKey; if (!mLanguageSource.ContainsTerm(sKey)) { TermData termData = mLanguageSource.GetTermData(OldTerm); if (termData != null) { termData.Term = sKey; } else { TermReplacements.Remove(OldTerm); } EditorUtility.SetDirty(mLanguageSource.owner); } } if (TermReplacements.Count <= 0) { ShowError("Unable to assign category: Terms were not found in the selected LanguageSource"); } else { mLanguageSource.UpdateDictionary(true); ExecuteActionOnSelectedScenes(ReplaceTermsInCurrentScene); ParseTerms(true, false, true); if (string.IsNullOrEmpty(mNewCategory)) { mNewCategory = LanguageSourceData.EmptyCategory; } if (!mSelectedCategories.Contains(mNewCategory)) { mSelectedCategories.Add(mNewCategory); } //RemoveUnusedCategoriesFromSelected(); ScheduleUpdateTermsToShowInList(); } TermReplacements = null; mIsParsing = false; }