public static bool ShowGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginChangeCheck(); var Terms = LocalizationManager.GetTermsList(); Terms.Sort(System.StringComparer.OrdinalIgnoreCase); Terms.Add(""); Terms.Add("<inferred from text>"); Terms.Add("<none>"); var index = (property.stringValue == "-" || property.stringValue == "" ? Terms.Count - 1 : (property.stringValue == " " ? Terms.Count - 2 : Terms.IndexOf(property.stringValue))); var newIndex = EditorGUI.Popup(position, label.text, index, Terms.ToArray()); if (EditorGUI.EndChangeCheck()) { property.stringValue = (newIndex < 0 || newIndex == Terms.Count - 1) ? string.Empty : Terms[newIndex]; if (newIndex == Terms.Count - 1) { property.stringValue = "-"; } else if (newIndex < 0 || newIndex == Terms.Count - 2) { property.stringValue = string.Empty; } else { property.stringValue = Terms[newIndex]; } return(true); } return(false); }
void UpdateTermsList(string currentTerm) { List <string> Terms = mLocalize.Source == null?LocalizationManager.GetTermsList() : mLocalize.Source.SourceData.GetTermsList(); // If there is a filter, remove all terms not matching that filter if (mAllowEditKeyName && !string.IsNullOrEmpty(mNewKeyName)) { string Filter = mNewKeyName.ToUpper(); for (int i = Terms.Count - 1; i >= 0; --i) { if (!Terms[i].ToUpper().Contains(Filter) && Terms[i] != currentTerm) { Terms.RemoveAt(i); } } } if (!string.IsNullOrEmpty(currentTerm) && currentTerm != "-" && !Terms.Contains(currentTerm)) { Terms.Add(currentTerm); } Terms.Sort(System.StringComparer.OrdinalIgnoreCase); Terms.Add(""); if (mLocalize.Source != null) { Terms.Add("< Show Terms from all sources >"); Terms.Add(""); } Terms.Add("<inferred from text>"); Terms.Add("<none>"); mTermsArray = Terms.ToArray(); }
void UpdateTermsList(string currentTerm) { List <string> Terms = LocalizationManager.GetTermsList(); // If there is a filter, remove all terms not matching that filter if (mAllowEditKeyName && !string.IsNullOrEmpty(mNewKeyName)) { string Filter = mNewKeyName.ToUpper(); for (int i = Terms.Count - 1; i >= 0; --i) { if (!Terms[i].ToUpper().Contains(Filter) && Terms[i] != currentTerm) { Terms.RemoveAt(i); } } } if (!Terms.Contains(currentTerm)) { Terms.Add(currentTerm); } Terms.Sort(System.StringComparer.OrdinalIgnoreCase); Terms.Add("<none>"); mTermsArray = Terms.ToArray(); }
public override void OnInspectorGUI() { #if UNITY_5_6_OR_NEWER serializedObject.UpdateIfRequiredOrScript(); #else serializedObject.UpdateIfDirtyOrScript(); #endif terms = LocalizationManager.GetTermsList (); terms.Sort(System.StringComparer.OrdinalIgnoreCase); terms.Add(""); terms.Add("<inferred from text>"); terms.Add("<none>"); GUI.backgroundColor = Color.Lerp (Color.black, Color.gray, 1); GUILayout.BeginVertical(LocalizeInspector.GUIStyle_Background); GUI.backgroundColor = Color.white; if (GUILayout.Button("Localize DropDown", LocalizeInspector.GUIStyle_Header)) { Application.OpenURL(LocalizeInspector.HelpURL_Documentation); } GUILayout.Space(5); mList.DoLayoutList(); GUILayout.Space (10); GUITools.OnGUI_Footer("I2 Localization", LocalizationManager.GetVersion(), LocalizeInspector.HelpURL_forum, LocalizeInspector.HelpURL_Documentation, LocalizeInspector.HelpURL_AssetStore); EditorGUIUtility.labelWidth = 0; GUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); terms = null; }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); terms = LocalizationManager.GetTermsList(); terms.Sort(System.StringComparer.OrdinalIgnoreCase); terms.Add("<inferred from text>"); GUI.backgroundColor = Color.Lerp(Color.black, Color.gray, 1); GUILayout.BeginVertical(LocalizeInspector.GUIStyle_Background); GUI.backgroundColor = Color.white; if (GUILayout.Button("Localize DropDown", LocalizeInspector.GUIStyle_Header)) { Application.OpenURL(LocalizeInspector.HelpURL_Documentation); } GUILayout.Space(5); mList.DoLayoutList(); GUILayout.Space(10); GUILayout.BeginHorizontal(); if (GUILayout.Button("v" + LocalizationManager.GetVersion(), EditorStyles.miniLabel)) { Application.OpenURL(LocalizeInspector.HelpURL_ReleaseNotes); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Tutorials", EditorStyles.miniLabel)) { Application.OpenURL(LocalizeInspector.HelpURL_Tutorials); } GUILayout.Space(10); if (GUILayout.Button("Ask a Question", EditorStyles.miniLabel)) { Application.OpenURL(LocalizeInspector.HelpURL_forum); } GUILayout.Space(10); if (GUILayout.Button("Documentation", EditorStyles.miniLabel)) { Application.OpenURL(LocalizeInspector.HelpURL_Documentation); } GUILayout.EndHorizontal(); EditorGUIUtility.labelWidth = 0; GUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); terms = null; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginChangeCheck(); var Terms = LocalizationManager.GetTermsList(); Terms.Sort(System.StringComparer.OrdinalIgnoreCase); Terms.Add("<none>"); var newIndex = EditorGUI.Popup(position, label.text, Terms.IndexOf(property.stringValue), Terms.ToArray()); if (EditorGUI.EndChangeCheck()) { property.stringValue = (newIndex < 0 || newIndex == Terms.Count - 1) ? string.Empty : Terms [newIndex]; } }
public static bool ShowGUI(Rect position, SerializedProperty property, GUIContent label, LanguageSource source, string filter = "") { label = EditorGUI.BeginProperty(position, label, property); EditorGUI.BeginChangeCheck(); var Terms = (source == null ? LocalizationManager.GetTermsList() : source.GetTermsList()); if (string.IsNullOrEmpty(filter) == false) { Terms = Filter(Terms, filter); } Terms.Sort(System.StringComparer.OrdinalIgnoreCase); Terms.Add(""); Terms.Add("<inferred from text>"); Terms.Add("<none>"); var index = (property.stringValue == "-" || property.stringValue == "" ? Terms.Count - 1 : (property.stringValue == " " ? Terms.Count - 2 : Terms.IndexOf(property.stringValue))); var newIndex = EditorGUI.Popup(position, label, index, DisplayOptions(Terms)); if (EditorGUI.EndChangeCheck()) { property.stringValue = (newIndex < 0 || newIndex == Terms.Count - 1) ? string.Empty : Terms[newIndex]; if (newIndex == Terms.Count - 1) { property.stringValue = "-"; } else if (newIndex < 0 || newIndex == Terms.Count - 2) { property.stringValue = string.Empty; } else { property.stringValue = Terms[newIndex]; } EditorGUI.EndProperty(); return(true); } EditorGUI.EndProperty(); return(false); }
bool EditTermSelection() { if (_target.term == null || _target.term.IsNone) { return(false); } // make sure our FsmString is not pointing to a variable. _target.term.UseVariable = false; var terms = (_target.mSource != null) ? _target.mSource.GetTermsList() : LocalizationManager.GetTermsList(); terms.Sort(System.StringComparer.OrdinalIgnoreCase); terms.Add(""); terms.Add("<inferred from text>"); terms.Add("<none>"); var aTerms = terms.ToArray(); var index = (_target.term.Value == "-" || _target.term.Value == "" ? aTerms.Length - 1: (_target.term.Value == " " ? aTerms.Length - 2 : System.Array.IndexOf(aTerms, _target.term.Value))); var newIndex = EditorGUILayout.Popup("Term", index, aTerms); if (index == newIndex) { return(false); } _target.term.Value = (newIndex < 0 || newIndex == aTerms.Length - 1) ? string.Empty : aTerms[newIndex]; if (newIndex == aTerms.Length - 1) { _target.term.Value = "-"; } else if (newIndex < 0 || newIndex == aTerms.Length - 2) { _target.term.Value = string.Empty; } else { _target.term.Value = aTerms[newIndex]; } return(true); }
public static void SetRandomTerm(this Localize localize, string prefix) { var allTerms = LocalizationManager.GetTermsList(); var matchedTerms = new List <string>(); foreach (var term in allTerms) { if (term.StartsWith(prefix)) { matchedTerms.Add(term); } } if (matchedTerms.Count > 0) { localize.SetTerm(matchedTerms[Random.Range(0, matchedTerms.Count)]); } }
static void UpdateTermsCache(LanguageSourceData source, string filter, ref GUIContent[] terms_Contexts, ref int framesBeforeUpdating, ref string prevFilter) { framesBeforeUpdating--; if (terms_Contexts != null && framesBeforeUpdating > 0 && filter == prevFilter) { return; } framesBeforeUpdating = 60; prevFilter = filter; var Terms = (source == null ? LocalizationManager.GetTermsList() : source.GetTermsList()); if (string.IsNullOrEmpty(filter) == false) { Terms = Filter(Terms, filter); } Terms.Sort(System.StringComparer.OrdinalIgnoreCase); Terms.Add(""); Terms.Add("<inferred from text>"); Terms.Add("<none>"); terms_Contexts = DisplayOptions(Terms); }
bool EditTerms() { var changed = false; if (mTarget.PrimaryTerm == null) { return(false); } // make sure our FsmString is not pointing to a variable. mTarget.PrimaryTerm.UseVariable = false; mTarget.SecondaryTerm.UseVariable = false; var go = mTarget.Fsm.GetOwnerDefaultTarget(mTarget.GameObject); if (go != null) { mLocalize = go.GetComponent <Localize> (); } var terms = (mLocalize != null && mLocalize.Source != null) ? mLocalize.Source.GetTermsList() : LocalizationManager.GetTermsList(); terms.Sort(System.StringComparer.OrdinalIgnoreCase); terms.Add(""); terms.Add("<inferred from text>"); terms.Add("<none>"); var aTerms = terms.ToArray(); changed |= DoTermPopup("Primary Term", mTarget.PrimaryTerm, aTerms); changed |= DoTermPopup("Secondary Term", mTarget.SecondaryTerm, aTerms); return(GUI.changed || changed); }