private void AddKey()
 {
     LocalizationEditor.AddKey(LocalizationEditor.ActiveLanguage.Pages[ActivePageIndex].PageName, newKey);
     if (LocalizationEditor.ActiveLanguage.Pages[ActivePageIndex].Data.ContainsKey(newKey))
     {
         newKey = StringNumber(newKey);
     }
 }
 private void AddPage()
 {
     LocalizationEditor.AddPage(newPage.ReplaceStringHaveInvalidChars());
     if (LocalizationEditor.ActiveLanguage.FindPage(newPage) != null)
     {
         newPage = StringNumber(newPage);
     }
 }
        public override void DrawTab(Window <LocalizationWindow> owner)
        {
            using (new GUILayout.HorizontalScope(EditorStyles.toolbarButton))
                DrawHeaderGUI();

            using (new GUILayout.HorizontalScope())
            {
                using (var scroll = new GUILayout.ScrollViewScope(pageScroll,
                                                                  false,
                                                                  false,
                                                                  //GUI.skin.horizontalScrollbar,
                                                                  //GUI.skin.verticalScrollbar,
                                                                  //EditorStyles.textArea,
                                                                  GUILayout.Width(PAGE_WIDTH),
                                                                  GUILayout.ExpandHeight(true))
                {
                    handleScrollWheel = true
                })
                {
                    pageScroll = scroll.scrollPosition;
                    DrawPagesGUI();
                }

                using (var scroll = new GUILayout.ScrollViewScope(entryScroll,
                                                                  false,
                                                                  false,
                                                                  //GUI.skin.horizontalScrollbar,
                                                                  //GUI.skin.verticalScrollbar,
                                                                  //EditorStyles.textArea,
                                                                  GUILayout.Width(KEYS_WIDTH),
                                                                  GUILayout.ExpandHeight(true))
                {
                    handleScrollWheel = true
                })
                {
                    entryScroll = scroll.scrollPosition;

                    DrawKeysGUI();
                }

                using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
                {
                    DrawDetailsGUI();
                    if (changeCheckScope.changed)
                    {
                        LocalizationEditor.Save();
                    }
                }
            }
            using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
                DrawFooter();
        }
Exemplo n.º 4
0
 private void DrawAddLangGUI()
 {
     using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
     {
         newLang = EditorGUILayout.TextArea(newLang, EditorStyles.toolbarTextField, GUILayout.Width(Owner.position.width * 0.5f), GUILayout.ExpandWidth(true));
         if (GUILayout.Button("Add New Luanguage", EditorStyles.toolbarButton, GUILayout.Width(Owner.position.width * 0.5f)))
         {
             if (!LocalizationEditor.Languages.Contains(newLang))
             {
                 LocalizationEditor.CreateNewLanguage(newLang);
             }
         }
     }
 }
 private void DeleteKey(string key, bool showWarning = true)
 {
     if (showWarning)
     {
         var yes = EditorUtility.DisplayDialog("Delete Key?", String.Format("Are you sure you want to delete the Entry: {0}", key), "Yes", "No, why would I!");
         if (yes)
         {
             LocalizationEditor.RemoveKey(LocalizationEditor.ActiveLanguage.Pages[ActivePageIndex].PageName, key);
         }
     }
     else
     {
         LocalizationEditor.RemoveKey(LocalizationEditor.ActiveLanguage.Pages[ActivePageIndex].PageName, key);
     }
 }
        public override void DrawTab(Window <LocalizationWindow> owner)
        {
            EditorGUILayout.LabelField("Help");
            var e = JMilesGUILayoutEvents.Button("Reload files (Warning, does not save data!)", EditorStyles.toolbarButton);

            if (e.EventIsMouse0InRect)
            {
                var yes = EditorUtility.DisplayDialog("Reload all files",
                                                      "Are you sure you want to reload all the files, this will delete any non-saved changes!",
                                                      "Yes (possable loss of data)",
                                                      "No");
                if (yes)
                {
                    LocalizationEditor.LoadAll();
                }
            }
        }
 private void DrawDetailsFooterGUI()
 {
     EditorGUILayout.LabelField("Details");
     if (GUILayout.Button("Reload files (Warning, does not save data!)", EditorStyles.toolbarButton))
     {
         var yes = EditorUtility.DisplayDialog("Reload all files",
                                               "Are you sure you want to reload all the files, this will delete any non-saved changes!",
                                               "Yes (possable loss of data)",
                                               "No");
         if (yes)
         {
             ActivePageIndex = 0;
             activeKeyKey    = "";
             LocalizationEditor.LoadAll();
         }
     }
 }
 private void DeletePage(int index, bool showWarning = true)
 {
     if (showWarning)
     {
         var yes = EditorUtility.DisplayDialog("Delete Page?",
                                               String.Format("Are you sure you want to delete the Page: {0}\n\nThis will delete the Page file in the Lang Directory, and all that it contains.",
                                                             LocalizationEditor.ActiveLanguage.Pages[index].PageName),
                                               "Yes",
                                               "No, why would I!");
         if (yes)
         {
             LocalizationEditor.DeletePage(LocalizationEditor.ActiveLanguage.Pages[index].PageName);
         }
     }
     else
     {
         LocalizationEditor.DeletePage(LocalizationEditor.ActiveLanguage.Pages[index].PageName);
     }
 }
Exemplo n.º 9
0
        private void DrawFooterGUI()
        {
            using (new GUILayout.HorizontalScope())
            {
                using (new GUILayout.HorizontalScope(EditorStyles.toolbarButton, GUILayout.Width(Owner.position.width * 0.5f)))
                {
                    var e1 = JMilesGUILayoutEvents.Button("Generate Pages, From Active Language Pages (non-destructive)", EditorStyles.toolbarButton);
                    if (e1.EventIsMouse0InRect)
                    {
                        LocalizationEditor.GenerateAllPagesFromActive();
                    }
                    //else if (e1.EventIsMouse1InRect)
                    //{
                    //	Debug.Log("e1 Right Click");
                    //}
                }

                using (new GUILayout.HorizontalScope(EditorStyles.toolbarButton, GUILayout.Width(Owner.position.width * 0.5f)))
                {
                    var e2 = JMilesGUILayoutEvents.Button("Generate Pages, From Active Language Pages and copy the data (non-destructive)", EditorStyles.toolbarButton);
                    if (e2.EventIsMouse0InRect)
                    {
                        LocalizationEditor.GenerateAllPagesFromActive(true);
                    }
                    //else if (e2.EventIsMouse1InRect)
                    //{
                    //	Debug.Log("e2 Right Click");
                    //}
                }

                //if (GUILayout.Button("Generate Pages, From Active Language Pages (non-destructive)", EditorStyles.toolbarButton))
                //{
                //	LocalizationEditor.GenerateAllPagesFromActive();
                //}
                //if (GUILayout.Button("Generate Pages, From Active Language Pages and copy the data (non-destructive)", EditorStyles.toolbarButton))
                //{
                //	LocalizationEditor.GenerateAllPagesFromActive(true);
                //}
            }
            DrawAddLangGUI();
        }
        private void DrawDetailsGUI()
        {
            var lastKey = activeKeyKey;

            #region Null&ErrorChecks
            if (LocalizationEditor.Languages == null)
            {
                DrawError();
                return;
            }
            if (LocalizationEditor.ActiveLanguage == null)
            {
                DrawError();
                return;
            }
            if (LocalizationEditor.ActiveLanguage.Pages == null)
            {
                DrawError();
                return;
            }
            if (LocalizationEditor.ActiveLanguage.Pages[ActivePageIndex] == null)
            {
                DrawError();
                return;
            }
            if (!LocalizationEditor.ActiveLanguage.Pages[ActivePageIndex].Loaded)
            {
                DrawError();
                return;
            }
            if (!LocalizationEditor.ActiveLanguage.Pages[ActivePageIndex].Data.ContainsKey(activeKeyKey))
            {
                DrawError();
                return;
            }
            #endregion

            if (newChangedKey == "")
            {
                newChangedKey = activeKeyKey;
            }
            using (new GUILayout.VerticalScope(GUI.skin.textArea))
            {
                using (var scope = new GUILayout.ScrollViewScope(entryDetailScroll, GUILayout.ExpandHeight(true)))
                {
                    entryDetailScroll = scope.scrollPosition;
                    newChangedKey     = EditorGUILayout.DelayedTextField(new GUIContent("Key: "), newChangedKey, GUILayout.ExpandWidth(true));

                    var pageName = LocalizationEditor.ActiveLanguage.Pages[ActivePageIndex].PageName;

                    foreach (var language in LocalizationEditor.Languages)
                    {
                        language.Loaded = true;
                        using (new GUILayout.VerticalScope(EditorStyles.helpBox))
                        {
                            if (language.DefualtPage.Data.ContainsKey("language_name"))
                            {
                                EditorGUILayout.SelectableLabel(string.Format("{0} | {1}", language.LanguageName, language.DefualtPage.Data["language_name"]), GUILayout.Height(18f));
                            }
                            else
                            {
                                EditorGUILayout.SelectableLabel(language.LanguageName, GUILayout.Height(18f));
                            }

                            bool pageFound = false;
                            Page foundPage = null;
                            foreach (var page in language.Pages)
                            {
                                if (page.PageName == pageName)
                                {
                                    pageFound        = true;
                                    foundPage        = page;
                                    foundPage.Loaded = true;
                                    break;
                                }
                            }
                            if (!pageFound || foundPage == null || !foundPage.Loaded)
                            {
                                using (new GUILayout.HorizontalScope())
                                {
                                    EditorGUILayout.HelpBox(string.Format("No Page found for :{0} in {1}", pageName, language.LanguageName), MessageType.Warning);
                                    if (GUILayout.Button("Generate Page", GUILayout.Width(128), GUILayout.Height((16 * 2.5f) - 1.1f)))
                                    {
                                        LocalizationEditor.GeneratePage(language, pageName);
                                    }
                                    if (GUILayout.Button("Generate Page\nAnd Copy Data", GUILayout.Width(128), GUILayout.Height((16 * 2.5f) - 1.1f)))
                                    {
                                        LocalizationEditor.GeneratePage(language, pageName, true);
                                    }
                                }
                            }
                            else
                            {
                                bool loaded = foundPage.Loaded;
                                foundPage.Loaded = true;
                                if (!foundPage.Data.ContainsKey(activeKeyKey))
                                {
                                    foundPage.Data.Add(activeKeyKey, "");
                                }

                                var str = EditorGUILayout.TextField(foundPage.Data[activeKeyKey], GUILayout.Height(18 * 3), GUILayout.ExpandWidth(true));
                                if (foundPage.Data.ContainsKey(activeKeyKey) && (foundPage.Data[activeKeyKey] != str))
                                {
                                    if (changedTab)
                                    {
                                        changedTab = false;
                                    }
                                    else
                                    {
                                        foundPage.Data[activeKeyKey] = str;
                                    }
                                }
                            }
                        }
                    }
                    if (newChangedKey != activeKeyKey)
                    {
                        foreach (var language in LocalizationEditor.Languages)
                        {
                            language.Pages[ActivePageIndex].Data.ChangeKey(activeKeyKey, newChangedKey);
                        }
                        activeKeyKey = newChangedKey;
                    }
                }
            }
        }