Exemplo n.º 1
0
    void OnGUI()
    {
        #region Buttons
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Previous"))
        {
            Debug.Log("Previous Text");
            selectedDialog = ((selectedDialog - 1) + totalDialog - 2) % (totalDialog - 2);
            Debug.Log(selectedDialog);
        }
        if (GUILayout.Button("Next"))
        {
            Debug.Log("Next Text");
            selectedDialog = (selectedDialog + 1) % (totalDialog - 2);
        }
        if (GUILayout.Button("Add Lang"))
        {
            Debug.Log("Added Language");
            AddLanguageWizard.Create();
        }
        EditorGUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Load Text"))
        {
            Debug.Log("Loading All Text...");
        }
        if (GUILayout.Button("Save Changes"))
        {
            Debug.Log("Saving Changes");
            SaveTextDebug(translatedText);
        }
        EditorGUILayout.EndHorizontal();
        #endregion

        #region Popup
        Rect popup = new Rect(new Vector2(0, 2 * EditorGUIUtility.singleLineHeight), new Vector2(EditorWindow.GetWindow <LocalizeWindow>().position.width, EditorGUIUtility.singleLineHeight));

        selectedLanguage = EditorGUI.Popup(popup, selectedLanguage, options.ToArray());
        #endregion

        #region OriginalText
        GUILayout.BeginArea(new Rect(0, 3 * EditorGUIUtility.singleLineHeight, EditorWindow.GetWindow <LocalizeWindow>().position.width, EditorGUIUtility.singleLineHeight * 6));
        EditorGUILayout.BeginHorizontal();
        GUILayout.TextArea(GetTextDebug(0, selectedDialog), GUILayout.Height(position.height - 30));
        EditorGUILayout.EndHorizontal();
        GUILayout.EndArea();
        #endregion

        #region LocalizedText
        GUILayout.BeginArea(new Rect(0, 10 * EditorGUIUtility.singleLineHeight, EditorWindow.GetWindow <LocalizeWindow>().position.width, EditorGUIUtility.singleLineHeight * 6));
        EditorGUILayout.BeginHorizontal();
        translatedText = GUILayout.TextArea(translatedText, GUILayout.Height(position.height - 30));
        EditorGUILayout.EndHorizontal();
        GUILayout.EndArea();
        #endregion
    }
Exemplo n.º 2
0
    public void OnGUI()
    {
        EditorGUILayout.BeginVertical();
        {
            //#region ObjectField
            //Object dataObj = null;
            //dataObj = EditorGUILayout.ObjectField(dataObj, typeof(DataManager), false);
            //data = dataObj as DataManager;
            //#endregion

            #region Top Bar (Add Language)
            EditorGUILayout.BeginHorizontal("box");
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Add Language", GUILayout.Width(120), GUILayout.Height(standardButtonHeight)))
                {
                    //wizard = AddLanguageWizard.CreateInstance<AddLanguageWizard>();
                    AddLanguageWizard.Create(this);
                    //wizard.titleContent = GUIContent;
                    //wizard.Show();
                    Debug.Log("Opening new language window");
                    //wizard = AddLanguageWizard.CreateInstance<AddLanguageWizard>();
                    //AddLanguageWizard.Create("Add Language");
                }
            }
            EditorGUILayout.EndHorizontal();

            #endregion

            #region Popup/Dropdown Languages
            EditorGUILayout.BeginHorizontal();
            {
                Rect popup = new Rect(new Vector2(this.position.size.x - (2 * standardButtonWidth), 3.2f * EditorGUIUtility.singleLineHeight), new Vector2(2 * standardButtonWidth, EditorGUIUtility.singleLineHeight));

                if (!LocalizationManager.isEmpty)
                {
                    //List<string> options = new List<string>(data.languages.Keys);
                    //List<string> popupLang = data.languages.Keys.ToList();

                    //selectedPopupLanguage = EditorGUI.Popup(popup, selectedPopupLanguage, LocalizationManager.GetAvailableLanguages().ToArray());
                    //selectedLanguage = LocalizationManager.GetAvailableLanguages()[selectedPopupLanguage];
                    EditorGUI.BeginChangeCheck();
                    SelectedLanguage.index = EditorGUI.Popup(popup, SelectedLanguage.index, LocalizationManager.GetAvailableLanguages().ToArray());
                    SelectedLanguage.text  = LocalizationManager.GetAvailableLanguages()[SelectedLanguage.index];
                    if (EditorGUI.EndChangeCheck())
                    {
                        LocalizationManager.translatedText = LocalizationManager.GetDialog();
                    }
                }
                else
                {
                    List <string> empty = new List <string>()
                    {
                        "<list is empty>"
                    };
                    EditorGUI.Popup(popup, SelectedLanguage.index, empty.ToArray());
                    SelectedDialog.text = "";
                }
            }
            EditorGUILayout.EndHorizontal();
            #endregion

            EditorGUILayout.Space(); EditorGUILayout.Space();

            #region TextBoxes (Original Text, Translation)
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.BeginVertical();
                {
                    EditorGUILayout.LabelField("Original text", EditorStyles.boldLabel);
                    EditorGUILayout.BeginHorizontal("box");
                    {
                        GUI.skin.label.wordWrap = true;
                        GUILayout.Label(LocalizationManager.GetDialog(0),
                                        //GUIStyle.none,
                                        GUILayout.MinHeight(minTextFieldHeight),
                                        GUILayout.MaxHeight(maxTextFieldHeight),
                                        GUILayout.MinWidth(minTextFieldWidth),
                                        GUILayout.MaxWidth(maxTextFieldWidth)
                                        );
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical();
                {
                    EditorGUILayout.LabelField("Translation", EditorStyles.boldLabel);
                    LocalizationManager.translatedText = EditorGUILayout.TextField(LocalizationManager.translatedText,
                                                                                   GUILayout.MinHeight(minTextFieldHeight),
                                                                                   GUILayout.MaxHeight(maxTextFieldHeight),
                                                                                   GUILayout.MinWidth(minTextFieldWidth),
                                                                                   GUILayout.MaxWidth(maxTextFieldWidth)
                                                                                   );
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();
            #endregion

            GUILayout.FlexibleSpace();

            #region Bottom Bar (Previous, Next, Save, Load)
            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Previous\ntext", GUILayout.Width(prevNextButtonWidth), GUILayout.Height(standardButtonHeight)))
                {
                    // Debug.Log("Previous Text");
                    LocalizationManager.PreviousDialog();
                    //selectedDialog = popDialog[(selectPopDialog - 1 + totalDialog - 2) % (totalDialog - 2)];
                    //Debug.Log(selectedDialog);
                }

                if (GUILayout.Button("Next\ntext", GUILayout.Width(prevNextButtonWidth), GUILayout.Height(standardButtonHeight)))
                {
                    //Debug.Log("Next Text");
                    LocalizationManager.NextDialog();
                    //selectedDialog = popDialog[(selectPopDialog + 1) % (totalDialog - 2)];
                }

                GUILayout.FlexibleSpace();

                /*
                 * if (GUILayout.Button("Load Text", GUILayout.Height(standardButtonHeight), GUILayout.Width(standardButtonWidth))) {
                 *  Debug.Log("Loading All Text...");
                 *  LocalizationManager.LoadText();
                 * }
                 */
                if (GUILayout.Button("Save Changes", GUILayout.Height(standardButtonHeight), GUILayout.Width(standardButtonWidth)))
                {
                    //Debug.Log("Saving Changes");
                    LocalizationManager.SaveText();
                }
            }
            EditorGUILayout.EndHorizontal();
            #endregion
        }
        EditorGUILayout.EndVertical();
    }
Exemplo n.º 3
0
    void OnGUI()
    {
        //#region ObjectField
        //Object dataObj = null;
        //dataObj = EditorGUILayout.ObjectField(dataObj, typeof(DataManager), false);
        //data = dataObj as DataManager;
        //#endregion

        #region Buttons
        EditorGUILayout.BeginHorizontal();
        Dictionary <string, string> outLang;
        List <string> popDialog = null;
        if (selectedLanguage != null && data.languages.TryGetValue(selectedLanguage, out outLang))
        {
            //selectedDialog = outLang.Keys.FirstOrDefault();
            popDialog = outLang.Keys.ToList();
        }
        //List<string> popLang = data.languages.Keys.ToList();
        if (GUILayout.Button("Previous"))
        {
            Debug.Log("Previous Text");
            selectedDialog = popDialog[(selectPopDialog - 1 + totalDialog - 2) % (totalDialog - 2)];
            Debug.Log(selectedDialog);
        }
        if (GUILayout.Button("Next"))
        {
            Debug.Log("Next Text");
            selectedDialog = popDialog[(selectPopDialog + 1) % (totalDialog - 2)];
        }
        if (GUILayout.Button("Add Lang"))
        {
            Debug.Log("Added Language");
            wizard = AddLanguageWizard.CreateInstance <AddLanguageWizard>();
            wizard.Show();
        }

        EditorGUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Load Text"))
        {
            Debug.Log("Loading All Text...");
        }
        if (GUILayout.Button("Save Changes"))
        {
            Debug.Log("Saving Changes");
            //SaveTextDebug(translatedText);
        }
        EditorGUILayout.EndHorizontal();
        #endregion

        #region Popup
        Rect popup = new Rect(new Vector2(0, 2 * EditorGUIUtility.singleLineHeight), new Vector2(this.position.width, EditorGUIUtility.singleLineHeight));

        if (localizedLanguages.Count > 0)
        {
            List <string> popLang = data.languages.Keys.ToList();
            selectedLanguage = popLang[EditorGUI.Popup(popup, selectPopLanguage, options.ToArray())];
        }
        #endregion

        #region OriginalText
        GUILayout.BeginArea(new Rect(0, 3 * EditorGUIUtility.singleLineHeight, this.position.width, EditorGUIUtility.singleLineHeight * 6));
        EditorGUILayout.BeginHorizontal();
        GUILayout.TextArea(GetTextDebug(data.languages.Keys.FirstOrDefault(), selectedDialog), GUILayout.Height(position.height - 30));
        EditorGUILayout.EndHorizontal();
        GUILayout.EndArea();
        #endregion

        #region LocalizedText
        GUILayout.BeginArea(new Rect(0, 10 * EditorGUIUtility.singleLineHeight, this.position.width, EditorGUIUtility.singleLineHeight * 6));
        EditorGUILayout.BeginHorizontal();
        translatedText = GUILayout.TextArea(translatedText, GUILayout.Height(position.height - 30));
        EditorGUILayout.EndHorizontal();
        GUILayout.EndArea();
        #endregion
    }