Exemple #1
0
        void OnGUI_References()
        {
            if (mLocalize.mGUI_ShowReferences = GUITools.DrawHeader("References", mLocalize.mGUI_ShowReferences))
            {
                GUITools.BeginContents();

                bool canTest = Event.current.type == EventType.Repaint;

                var testAddObj      = (canTest && LocalizationEditor.mTestAction == LocalizationEditor.eTest_ActionType.Button_Assets_Add) ? (Object)LocalizationEditor.mTestActionArg : null;
                var testReplaceIndx = (canTest && LocalizationEditor.mTestAction == LocalizationEditor.eTest_ActionType.Button_Assets_Replace) ? (int)LocalizationEditor.mTestActionArg : -1;
                var testReplaceObj  = (canTest && LocalizationEditor.mTestAction == LocalizationEditor.eTest_ActionType.Button_Assets_Replace) ? (Object)LocalizationEditor.mTestActionArg2 : null;
                var testDeleteIndx  = (canTest && LocalizationEditor.mTestAction == LocalizationEditor.eTest_ActionType.Button_Assets_Delete) ? (int)LocalizationEditor.mTestActionArg : -1;

                bool changed = GUITools.DrawObjectsArray(mProp_TranslatedObjects, false, false, true, testAddObj, testReplaceObj, testReplaceIndx, testDeleteIndx);
                if (changed)
                {
                    serializedObject.ApplyModifiedProperties();
                    foreach (var obj in serializedObject.targetObjects)
                    {
                        (obj as Localize).UpdateAssetDictionary();
                    }
                }

                GUITools.EndContents();
            }
        }
Exemple #2
0
 void OnGUI_References()
 {
     if (mLocalize.mGUI_ShowReferences = GUITools.DrawHeader("References", mLocalize.mGUI_ShowReferences))
     {
         GUITools.BeginContents();
         GUITools.DrawObjectsArray(mProp_TranslatedObjects);
         GUITools.EndContents();
     }
 }
        void OnGUI_Terms()
        {
            if (mGUI_ShowTems = GUITools.DrawHeader("Terms", mGUI_ShowTems))
            {
                //--[ tabs: Main and Secondary Terms ]----------------
                int oldTab = GUI_SelectedTerm;
                if (mLocalize.CanUseSecondaryTerm)
                {
                    GUI_SelectedTerm = GUITools.DrawTabs(GUI_SelectedTerm, new string[] { "Main", "Secondary" });
                }
                else
                {
                    GUI_SelectedTerm = 0;
                    GUITools.DrawTabs(GUI_SelectedTerm, new string[] { "Main", "" });
                }

                GUITools.BeginContents();

                if (GUI_SelectedTerm == 0)
                {
                    OnGUI_PrimaryTerm(oldTab != GUI_SelectedTerm);
                }
                else
                {
                    OnGUI_SecondaryTerm(oldTab != GUI_SelectedTerm);
                }

                GUITools.EndContents();

                //--[ Modifier ]-------------
                GUI.changed = false;
                int val = EditorGUILayout.Popup("Modifier", GUI_SelectedTerm == 0 ? (int)mLocalize.PrimaryTermModifier : (int)mLocalize.SecondaryTermModifier, System.Enum.GetNames(typeof(Localize.TermModification)));
                if (GUI.changed)
                {
                    serializedObject.FindProperty(GUI_SelectedTerm == 0 ? "PrimaryTermModifier" : "SecondaryTermModifier").enumValueIndex = val;
                    GUI.changed = false;
                }

                //--[ OnAwake vs OnEnable ]-------------
                mProp_LocalizeOnAwake.boolValue = GUILayout.Toggle(mProp_LocalizeOnAwake.boolValue, new GUIContent(" Pre-Localize on Awake", "Localizing on Awake could result in a lag when the level is loaded but faster later when objects are enabled. If false, it will Localize OnEnable, so will yield faster level load but could have a lag when screens are enabled"));

                //--[ Right To Left ]-------------
                GUILayout.BeginVertical("Box");
                mProp_IgnoreRTL.boolValue = GUILayout.Toggle(mProp_IgnoreRTL.boolValue, " Ignore Right To Left Languages");
                if (!mLocalize.IgnoreRTL)
                {
                    mProp_MaxCharactersInRTL.intValue      = EditorGUILayout.IntField(new GUIContent("Max line length", "If the language is Right To Left, long lines will be split at this length and the RTL fix will be applied to each line, this should be set to the maximum number of characters that fit in this text width. 0 disables the per line fix"), mProp_MaxCharactersInRTL.intValue);
                    mProp_CorrectAlignmentForRTL.boolValue = GUILayout.Toggle(mProp_CorrectAlignmentForRTL.boolValue, new GUIContent(" Adjust Alignment", "Right-align when Right-To-Left Language, and Left-Align otherwise"));
                }

                GUILayout.EndHorizontal();


                //GUILayout.EndHorizontal();
            }
        }
        public override void OnInspectorGUI()
        {
            GUILayout.Space(5);
            GUITools.DrawHeader("Assets:", true);
            GUITools.BeginContents();
            ///GUILayout.Label ("Assets:");
            GUITools.DrawObjectsArray(mAssets, false, false, false);
            GUITools.EndContents();

            serializedObject.ApplyModifiedProperties();
        }
        void OnGUI_ImportExport()
        {
            eSpreadsheetMode OldMode = mSpreadsheetMode;

            mSpreadsheetMode = (eSpreadsheetMode)GUITools.DrawShadowedTabs((int)mSpreadsheetMode, new string[] { "Local", "Google" });
            if (mSpreadsheetMode != OldMode)
            {
                ClearErrors();
            }

            GUITools.BeginContents();
            switch (mSpreadsheetMode)
            {
            case eSpreadsheetMode.Local: OnGUI_Spreadsheet_Local();  break;

            case eSpreadsheetMode.Google: OnGUI_Spreadsheet_Google(); break;
            }
            GUITools.EndContents(false);
        }
Exemple #6
0
        void OnGUI_Terms()
        {
            if ((mLocalize.mGUI_ShowTems = GUITools.DrawHeader("Terms", mLocalize.mGUI_ShowTems)) == true)
            {
                //--[ tabs: Main and Secondary Terms ]----------------
                int oldTab = GUI_SelectedTerm;
                if (mLocalize.mLocalizeTarget != null && mLocalize.mLocalizeTarget.CanUseSecondaryTerm())
                {
                    GUI_SelectedTerm = GUITools.DrawTabs(GUI_SelectedTerm, new string[] { "Main", "Secondary" });
                }
                else
                {
                    GUI_SelectedTerm = 0;
                    GUITools.DrawTabs(GUI_SelectedTerm, new string[] { "Main", "" });
                }

                GUITools.BeginContents();

                TermData termData = null;

                if (GUI_SelectedTerm == 0)
                {
                    termData = OnGUI_PrimaryTerm(oldTab != GUI_SelectedTerm);
                }
                else
                {
                    termData = OnGUI_SecondaryTerm(oldTab != GUI_SelectedTerm);
                }

                GUITools.EndContents();

                //--[ Modifier ]-------------
                if (mLocalize.Term != "-" && termData != null && termData.TermType == eTermType.Text)
                {
                    EditorGUI.BeginChangeCheck();
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Prefix:");
                    EditorGUILayout.PropertyField(mProp_TermPrefix, GUITools.EmptyContent);
                    GUILayout.Label("Suffix:");
                    EditorGUILayout.PropertyField(mProp_TermSuffix, GUITools.EmptyContent);
                    GUILayout.EndHorizontal();
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorApplication.delayCall += () =>
                        {
                            if (targets != null)
                            {
                                foreach (var t in targets)
                                {
                                    if ((t as Localize) != null)
                                    {
                                        (t as Localize).OnLocalize(true);
                                    }
                                }
                            }
                        };
                    }
                    EditorGUI.BeginChangeCheck();
                    int val = EditorGUILayout.Popup("Modifier", GUI_SelectedTerm == 0 ? (int)mLocalize.PrimaryTermModifier : (int)mLocalize.SecondaryTermModifier, System.Enum.GetNames(typeof(Localize.TermModification)));
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.FindProperty(GUI_SelectedTerm == 0 ? "PrimaryTermModifier" : "SecondaryTermModifier").enumValueIndex = val;
                        GUI.changed = false;
                    }
                }

                OnGUI_Options();
                //--[ OnAwake vs OnEnable ]-------------
                //GUILayout.BeginHorizontal();
                //mProp_LocalizeOnAwake.boolValue = GUILayout.Toggle(mProp_LocalizeOnAwake.boolValue, new GUIContent(" Pre-Localize on Awake", "Localizing on Awake could result in a lag when the level is loaded but faster later when objects are enabled. If false, it will Localize OnEnable, so will yield faster level load but could have a lag when screens are enabled"));
                //GUILayout.FlexibleSpace();
                //if (mLocalize.HasCallback())
                //{
                //    GUI.enabled = false;
                //    GUILayout.Toggle(true, new GUIContent(" Force Localize", "Enable this when the translations have parameters (e.g. Thew winner is {[WINNER}]) to prevent any optimization that could prevent updating the translation when the object is enabled"));
                //    GUI.enabled = true;
                //}
                //else
                //{
                //    mProp_AlwaysForceLocalize.boolValue = GUILayout.Toggle(mProp_AlwaysForceLocalize.boolValue, new GUIContent(" Force Localize", "Enable this when the translations have parameters (e.g. Thew winner is {[WINNER}]) to prevent any optimization that could prevent updating the translation when the object is enabled"));
                //}
                //GUILayout.EndHorizontal();

                //--[ Right To Left ]-------------
                if (!mLocalize.IgnoreRTL && mLocalize.Term != "-" && termData != null && termData.TermType == eTermType.Text)
                {
                    GUILayout.BeginVertical("Box");
                    //GUILayout.BeginHorizontal();
                    //    mProp_IgnoreRTL.boolValue = GUILayout.Toggle(mProp_IgnoreRTL.boolValue, new GUIContent(" Ignore Right To Left", "Arabic and other RTL languages require processing them so they render correctly, this toogle allows ignoring that processing (in case you are doing it manually during a callback)"));
                    //    GUILayout.FlexibleSpace();
                    //    mProp_SeparateWords.boolValue = GUILayout.Toggle(mProp_SeparateWords.boolValue, new GUIContent(" Separate Words", " Some languages (e.g. Chinese, Japanese and Thai) don't add spaces to their words (all characters are placed toguether), enabling this checkbox, will add spaces to all characters to allow wrapping long texts into multiple lines."));
                    //GUILayout.EndHorizontal();
                    {
                        mProp_MaxCharactersInRTL.intValue = EditorGUILayout.IntField(new GUIContent("Max line length", "If the language is Right To Left, long lines will be split at this length and the RTL fix will be applied to each line, this should be set to the maximum number of characters that fit in this text width. 0 disables the per line fix"), mProp_MaxCharactersInRTL.intValue);
                        GUILayout.BeginHorizontal();
                        mProp_CorrectAlignmentForRTL.boolValue = GUILayout.Toggle(mProp_CorrectAlignmentForRTL.boolValue, new GUIContent(" Adjust Alignment", "Right-align when Right-To-Left Language, and Left-Align otherwise"));
                        GUILayout.FlexibleSpace();
                        mProp_IgnoreNumbersInRTL.boolValue = GUILayout.Toggle(mProp_IgnoreNumbersInRTL.boolValue, new GUIContent(" Ignore Numbers", "Preserve numbers as latin characters instead of converting them"));
                        GUILayout.EndHorizontal();
                    }

                    GUILayout.EndVertical();
                }


                ////GUILayout.EndHorizontal();
            }
        }
Exemple #7
0
        public override void OnInspectorGUI()
        {
            Undo.RecordObject(target, "Localize");

            GUI.backgroundColor = Color.Lerp(Color.black, Color.gray, 1);
            GUILayout.BeginVertical(GUIStyle_Background, GUILayout.Height(1));
            GUI.backgroundColor = Color.white;

            if (GUILayout.Button("Localize", GUIStyle_Header))
            {
                //Application.OpenURL(HelpURL_Documentation);
            }
            GUILayout.Space(-10);

            LocalizationManager.UpdateSources();

            if (LocalizationManager.Sources.Count == 0)
            {
                EditorGUILayout.HelpBox("Unable to find a Language Source.", MessageType.Warning);
            }
            else
            {
                GUILayout.Space(10);
                OnGUI_Target();
                GUILayout.Space(10);
                OnGUI_Terms();

                //if (mGUI_ShowTems || mGUI_ShowReferences) GUILayout.Space(5);

                OnGUI_References();

                if (mLocalize.mGUI_ShowReferences || mLocalize.mGUI_ShowCallback)
                {
                    GUILayout.Space(10);
                }

                Localize loc = target as Localize;

                //--[ Localize Callback ]----------------------
                string HeaderTitle = "On Localize Call:";
                if (!mLocalize.mGUI_ShowCallback && loc.LocalizeCallBack.Target != null && !string.IsNullOrEmpty(loc.LocalizeCallBack.MethodName))
                {
                    HeaderTitle = string.Concat(HeaderTitle, " <b>", loc.LocalizeCallBack.Target.name, ".</b><i>", loc.LocalizeCallBack.MethodName, "</i>");
                }
                mLocalize.mGUI_ShowCallback = GUITools.DrawHeader(HeaderTitle, mLocalize.mGUI_ShowCallback);
                if (mLocalize.mGUI_ShowCallback)
                {
                    GUITools.BeginContents();
                    DrawEventCallBack(loc.LocalizeCallBack, loc);
                    GUITools.EndContents();
                }
            }
            OnGUI_Source();

            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(HelpURL_Tutorials);
            }

            GUILayout.Space(10);

            if (GUILayout.Button("Ask a Question", EditorStyles.miniLabel))
            {
                Application.OpenURL(HelpURL_forum);
            }

            GUILayout.Space(10);

            if (GUILayout.Button("Documentation", EditorStyles.miniLabel))
            {
                Application.OpenURL(HelpURL_Documentation);
            }
            GUILayout.EndHorizontal();
            EditorGUIUtility.labelWidth = 0;

            GUILayout.EndVertical();

            serializedObject.ApplyModifiedProperties();
        }
Exemple #8
0
        void OnGUI_Terms()
        {
            if (mLocalize.mGUI_ShowTems = GUITools.DrawHeader("Terms", mLocalize.mGUI_ShowTems))
            {
                //--[ tabs: Main and Secondary Terms ]----------------
                int oldTab = GUI_SelectedTerm;
                if (mLocalize.CanUseSecondaryTerm)
                {
                    GUI_SelectedTerm = GUITools.DrawTabs(GUI_SelectedTerm, new string[] { "Main", "Secondary" });
                }
                else
                {
                    GUI_SelectedTerm = 0;
                    GUITools.DrawTabs(GUI_SelectedTerm, new string[] { "Main", "" });
                }

                GUITools.BeginContents();

                if (GUI_SelectedTerm == 0)
                {
                    OnGUI_PrimaryTerm(oldTab != GUI_SelectedTerm);
                }
                else
                {
                    OnGUI_SecondaryTerm(oldTab != GUI_SelectedTerm);
                }

                GUITools.EndContents();

                //--[ Modifier ]-------------
                if (mLocalize.Term != "-")
                {
                    EditorGUI.BeginChangeCheck();
                    int val = EditorGUILayout.Popup("Modifier", GUI_SelectedTerm == 0 ? (int)mLocalize.PrimaryTermModifier : (int)mLocalize.SecondaryTermModifier, System.Enum.GetNames(typeof(Localize.TermModification)));
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.FindProperty(GUI_SelectedTerm == 0 ? "PrimaryTermModifier" : "SecondaryTermModifier").enumValueIndex = val;
                        GUI.changed = false;
                    }

                    EditorGUI.BeginChangeCheck();
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Prefix:");
                    EditorGUILayout.PropertyField(mProp_TermPrefix, GUITools.EmptyContent);
                    GUILayout.Label("Suffix:");
                    EditorGUILayout.PropertyField(mProp_TermSuffix, GUITools.EmptyContent);
                    GUILayout.EndHorizontal();
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorApplication.delayCall += () =>
                        {
                            if (targets != null)
                            {
                                foreach (var t in targets)
                                {
                                    if ((t as Localize) != null)
                                    {
                                        (t as Localize).OnLocalize(true);
                                    }
                                }
                            }
                        };
                    }
                }


                //--[ OnAwake vs OnEnable ]-------------
                GUILayout.BeginHorizontal();
                mProp_LocalizeOnAwake.boolValue = GUILayout.Toggle(mProp_LocalizeOnAwake.boolValue, new GUIContent(" Pre-Localize on Awake", "Localizing on Awake could result in a lag when the level is loaded but faster later when objects are enabled. If false, it will Localize OnEnable, so will yield faster level load but could have a lag when screens are enabled"));
                GUILayout.FlexibleSpace();
                if (mLocalize.LocalizeCallBack.HasCallback())
                {
                    GUI.enabled = false;
                    GUILayout.Toggle(true, new GUIContent(" Force Localize", "Enable this when the translations have parameters (e.g. Thew winner is {[WINNER}]) to prevent any optimization that could prevent updating the translation when the object is enabled"));
                    GUI.enabled = true;
                }
                else
                {
                    mProp_AlwaysForceLocalize.boolValue = GUILayout.Toggle(mProp_AlwaysForceLocalize.boolValue, new GUIContent(" Force Localize", "Enable this when the translations have parameters (e.g. Thew winner is {[WINNER}]) to prevent any optimization that could prevent updating the translation when the object is enabled"));
                }
                GUILayout.EndHorizontal();

                //--[ Right To Left ]-------------
                if (mLocalize.Term != "-")
                {
                    GUILayout.BeginVertical("Box");
                    mProp_IgnoreRTL.boolValue = GUILayout.Toggle(mProp_IgnoreRTL.boolValue, " Ignore Right To Left Languages");
                    if (!mLocalize.IgnoreRTL)
                    {
                        mProp_MaxCharactersInRTL.intValue = EditorGUILayout.IntField(new GUIContent("Max line length", "If the language is Right To Left, long lines will be split at this length and the RTL fix will be applied to each line, this should be set to the maximum number of characters that fit in this text width. 0 disables the per line fix"), mProp_MaxCharactersInRTL.intValue);
                        GUILayout.BeginHorizontal();
                        mProp_CorrectAlignmentForRTL.boolValue = GUILayout.Toggle(mProp_CorrectAlignmentForRTL.boolValue, new GUIContent(" Adjust Alignment", "Right-align when Right-To-Left Language, and Left-Align otherwise"));
                        GUILayout.FlexibleSpace();
                        mProp_IgnoreNumbersInRTL.boolValue = GUILayout.Toggle(mProp_IgnoreNumbersInRTL.boolValue, new GUIContent(" Ignore Numbers", "Preserve numbers as latin characters instead of converting them"));
                        GUILayout.EndHorizontal();
                    }

                    GUILayout.EndHorizontal();
                }


                //GUILayout.EndHorizontal();
            }
        }
Exemple #9
0
        public override void OnInspectorGUI()
        {
            Undo.RecordObject(target, "Localize");

            GUI.backgroundColor = Color.Lerp(Color.black, Color.gray, 1);
            GUILayout.BeginVertical(GUIStyle_Background, GUILayout.Height(1));
            GUI.backgroundColor = Color.white;

            if (GUILayout.Button("Localize", GUIStyle_Header))
            {
                //Application.OpenURL(HelpURL_Documentation);
            }
            GUILayout.Space(-10);

            LocalizationManager.UpdateSources();

            if (LocalizationManager.Sources.Count == 0)
            {
                EditorGUILayout.HelpBox("Unable to find a Language Source.", MessageType.Warning);
            }
            else
            {
                GUILayout.Space(10);
                OnGUI_Target();
                GUILayout.Space(10);
                OnGUI_Terms();

                //if (mGUI_ShowTems || mGUI_ShowReferences) GUILayout.Space(5);

                OnGUI_References();

                if (mLocalize.mGUI_ShowReferences || mLocalize.mGUI_ShowCallback)
                {
                    GUILayout.Space(10);
                }

                Localize loc = target as Localize;

                //--[ Localize Callback ]----------------------
                string HeaderTitle = "On Localize Call:";
                if (!mLocalize.mGUI_ShowCallback && loc.LocalizeCallBack.Target != null && !string.IsNullOrEmpty(loc.LocalizeCallBack.MethodName))
                {
                    HeaderTitle = string.Concat(HeaderTitle, " <b>", loc.LocalizeCallBack.Target.name, ".</b><i>", loc.LocalizeCallBack.MethodName, "</i>");
                }
                mLocalize.mGUI_ShowCallback = GUITools.DrawHeader(HeaderTitle, mLocalize.mGUI_ShowCallback);
                if (mLocalize.mGUI_ShowCallback)
                {
                    GUITools.BeginContents();
                    DrawEventCallBack(loc.LocalizeCallBack, loc);
                    GUITools.EndContents();
                }
            }
            OnGUI_Source();

            GUILayout.Space(10);

            GUITools.OnGUI_Footer("I2 Localization", LocalizationManager.GetVersion(), HelpURL_forum, HelpURL_Documentation, LocalizeInspector.HelpURL_AssetStore);

            GUILayout.EndVertical();

            serializedObject.ApplyModifiedProperties();
            if (Event.current.type == EventType.Repaint)
            {
                LocalizationEditor.mTestAction     = LocalizationEditor.eTest_ActionType.None;
                LocalizationEditor.mTestActionArg  = null;
                LocalizationEditor.mTestActionArg2 = null;
            }
        }