Exemple #1
0
    public void NextLanguage()
    {
        int index = languageFileMap.Languages.IndexOf(CurrentSelection);

        if (index >= languageFileMap.Languages.Count() - 1)
        {
            CurrentSelection = languageFileMap.Languages.FirstOrDefault();
        }
        else
        {
            CurrentSelection = languageFileMap.Languages.ElementAt(index + 1);
        }
        SetFlagIcon(CurrentSelection.icon);
    }
Exemple #2
0
    public void PreviousLanguage()
    {
        int index = languageFileMap.Languages.IndexOf(CurrentSelection);

        if (index == 0)
        {
            CurrentSelection = languageFileMap.Languages.LastOrDefault();
        }
        else
        {
            CurrentSelection = languageFileMap.Languages.ElementAt(index - 1);
        }
        SetFlagIcon(CurrentSelection.icon);
    }
    public LanguageFileEntry GetEntry(string tag)
    {
        if (string.IsNullOrEmpty(tag))
        {
            return(new LanguageFileEntry(tag, ""));
        }
        if (!this.Exists(tag))
        {
            return(new LanguageFileEntry(tag, ""));
        }

        LanguageFileEntry entry = entries[entries.FindIndex(e => e.textTag == tag)];

        return(entry);
    }
 public void SetEntry(string tag, LanguageFileEntry entry)
 {
     if (string.IsNullOrEmpty(tag))
     {
         return;
     }
     if (!this.Exists(tag))
     {
         AddEntry(tag, entry.textContent);
     }
     else
     {
         entries[entries.FindIndex(e => string.Equals(e.textTag, tag, StringComparison.CurrentCultureIgnoreCase))] = entry;
     }
 }
Exemple #5
0
    void Start()
    {
        languageFileMap = GetComponent <LanguageFileMap>();

        flagIcon = GetComponent <Image>();

        var lang = PlayerPrefsManager.GetLanguage();

        if (lang != null)
        {
            CurrentSelection = languageFileMap.Languages.FirstOrDefault(l => l.FileName == lang);
        }
        else
        {
            CurrentSelection = languageFileMap.Languages.First();
        }

        if (CurrentSelection.icon)
        {
            SetFlagIcon(CurrentSelection.icon);
        }
    }
    private void DrawLanguageContent()
    {
        if (m_canRemoveTagsFromDict)
        {
            m_deleteTagList.ForEach(tag =>
            {
                if (m_categorysAndTagsList.ContainsKey(GetUntilOrEmpty(tag)))
                {
                    if (m_categorysAndTagsList[GetUntilOrEmpty(tag)].Count == 1)
                    {
                        m_categorysAndTagsList.Remove(GetUntilOrEmpty(tag));
                    }
                    else
                    {
                        m_categorysAndTagsList[GetUntilOrEmpty(tag)].Remove(tag);
                    }
                }
            });
            m_canRemoveTagsFromDict        = false;
            m_selectedIndexCategoryForTags = 0;
        }

        if (m_categorysAndTagsList.Count == 0)
        {
            return;
        }

        m_selectedIndexCategoryForTags = EditorGUILayout.Popup("Category", m_selectedIndexCategoryForTags,
                                                               m_categorysAndTagsList.Keys.ToArray(),
                                                               GUILayout.Width(TAG_HEADER_TAG_WIDTH - 20));
        if (m_selectedIndexCategoryForTags >= m_categorysAndTagsList.Count)
        {
            m_selectedIndexCategoryForTags = 0;
        }

        if (m_categorysAndTagsList.Count == 0)
        {
            return;
        }

        EditorGUI.indentLevel++;
        float contentTextSize = Mathf.Clamp(((position.width - TAG_HEADER_TAG_WIDTH) / 2), 100f, 9999f);

        m_categorysAndTagsList.ElementAt(m_selectedIndexCategoryForTags).Value.ForEach(tag =>
        {
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("-", GUILayout.MaxWidth(20)))
            {
                m_deleteTagList.Add(tag);
                m_newTagList.Remove(tag);
                m_englishFile.RemoveEntry(tag);
                m_canRemoveTagsFromDict = true;
                isDirtyTags             = true;
                return;
            }

            if (!m_canRemoveTagsFromDict && m_englishFile.Exists(tag))
            {
                EditorGUILayout.SelectableLabel(tag, GUILayout.Height(15),
                                                GUILayout.Width(TAG_HEADER_TAG_WIDTH - 50));

                LanguageFileEntry englishEntry = m_englishFile.GetEntry(tag);

                string areaText = EditorGUILayout.TextArea(m_englishFile.GetEntryText(tag),
                                                           GUILayout.Width(contentTextSize));

                if (!englishEntry.textContent.Equals(areaText))
                {
                    isDirtyEng = true;
                }

                englishEntry.textContent = areaText;
                m_englishFile.SetEntry(tag, englishEntry);


                if (m_secondLanguageFile.fileLanguage != Languages.English && m_secondLanguageFile.Exists(tag))
                {
                    LanguageFileEntry secondEntry = m_secondLanguageFile.GetEntry(tag);

                    string areaText2 = EditorGUILayout.TextArea(m_secondLanguageFile.GetEntryText(tag),
                                                                GUILayout.Width(contentTextSize));

                    if (!secondEntry.textContent.Equals(areaText2))
                    {
                        isDirtySecond = true;
                    }

                    secondEntry.textContent = areaText2;
                    m_secondLanguageFile.SetEntry(tag, secondEntry);
                }
            }

            EditorGUILayout.EndHorizontal();
        });
        EditorGUI.indentLevel--;
    }