Beispiel #1
0
    private void OnEnable()
    {
        LangsList                 = MultiLang.GetAllLanguages();
        infoText.fontSize         = 12;
        infoText.normal.textColor = new Color(0.8f, 0.8f, 0.8f);

        headerText.fontSize         = 20;
        headerText.normal.textColor = new Color(0.8f, 0.8f, 0.8f);
        headerText.richText         = true;
        headerText.alignment        = TextAnchor.UpperCenter;
    }
Beispiel #2
0
 public static string GetUserName(int userId)
 {
     CacheUser();
     if (_userNameHash.ContainsKey(userId))
     {
         return(_userNameHash[userId]);
     }
     else
     {
         return(MultiLang.GetText("Unkown User"));
     }
 }
Beispiel #3
0
 private void CreateButtons()
 {
     GUILayout.BeginHorizontal();
     for (int i = 0; i < LangsList.Count; i++)
     {
         string lang = LangsList[i];
         if (GUILayout.Button(lang.ToUpper()))
         {
             MultiLang.ChangeLanguage(lang);
         }
     }
     GUILayout.EndHorizontal();
 }
Beispiel #4
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }

        LoadLanguage();
    }
Beispiel #5
0
    public static void InitializeEnumText()
    {
        if (!_isInit)
        {
            MultiLang.Clear();

            InitializeEnumText <Boolean>(true, "是");
            InitializeEnumText <Boolean>(false, "否");
            InitializeEnumText <OrgType>(OrgType.Own, "内部用户");
            InitializeEnumText <UserGroupType>(UserGroupType.Administrative, "系统管理员");
            InitializeEnumText <UserGroupType>(UserGroupType.System, "系统");
            InitializeEnumText <UserGroupType>(UserGroupType.Users, "用户");
            InitializeEnumText <UserStatus>(UserStatus.Disabled, "禁用");
            InitializeEnumText <UserStatus>(UserStatus.Enabled, "启用");

            InitializeEnumText <Magic.Sys.MessageAccessibility>(MessageAccessibility.Public, "公共");
            InitializeEnumText <MessageAccessibility>(MessageAccessibility.Subscriber, "仅订阅者");
            InitializeEnumText <MessageStatus>(MessageStatus.New, "新消息");
            InitializeEnumText <MessageStatus>(MessageStatus.Sent, "已发送");
            InitializeEnumText <MessageStatus>(MessageStatus.Elite, "置顶");
            InitializeEnumText <MessageStatus>(MessageStatus.Expired, "过期");

            InitializeEnumText <DayOfWeek>(DayOfWeek.Sunday, "星期天");
            InitializeEnumText <DayOfWeek>(DayOfWeek.Monday, "星期一");
            InitializeEnumText <DayOfWeek>(DayOfWeek.Tuesday, "星期二");
            InitializeEnumText <DayOfWeek>(DayOfWeek.Wednesday, "星期三");
            InitializeEnumText <DayOfWeek>(DayOfWeek.Thursday, "星期四");
            InitializeEnumText <DayOfWeek>(DayOfWeek.Friday, "星期五");
            InitializeEnumText <DayOfWeek>(DayOfWeek.Saturday, "星期六");

            InitializeEnumText <DictionaryItemType>(DictionaryItemType.Boolean, "布尔型");
            InitializeEnumText <DictionaryItemType>(DictionaryItemType.Numric, "数值型");
            InitializeEnumText <DictionaryItemType>(DictionaryItemType.String, "字符型");
            InitializeEnumText <DictionaryItemType>(DictionaryItemType.Group, "组/集合");
        }
        _isInit = true;
    }
Beispiel #6
0
 public static string GetStr(string srcStr, CoreLanguageClass lang)
 {
     return(MultiLang.ProcStr(srcStr, lang));
 }
Beispiel #7
0
    public static void Redirect(Page page, string url, bool endSession)
    {
        MultiLang ml = new MultiLang(page, true);

        ml.Redirect(url, true);
    }
Beispiel #8
0
	public static void Redirect(Page page, string url, bool endSession)
	{
		MultiLang ml = new MultiLang(page, true);

		ml.Redirect(url, true);
	}
Beispiel #9
0
    override public void OnInspectorGUI()
    {
        gameEditor = target as GameEditor;
        #region PlayerPrefs
        GUILayout.Label("PlayerPrefs", headerText);
        #region PlayerPrefs Edit
        EditorGUILayout.LabelField("PlayerPrefs Edit", EditorStyles.boldLabel);
        gameEditor.playerPrefsState = (PlayerPrefsState)EditorGUILayout.EnumPopup("Mode", gameEditor.playerPrefsState);
        gameEditor.editKey          = EditorGUILayout.TextField("Key Name", gameEditor.editKey);
        GUILayout.BeginHorizontal();
        if (gameEditor.playerPrefsState == PlayerPrefsState.Int)
        {
            gameEditor.intValue = EditorGUILayout.IntField("Value", gameEditor.intValue);
            if (GUILayout.Button($"Set '{gameEditor.editKey}' Key"))
            {
                PlayerPrefs.SetInt(gameEditor.editKey, gameEditor.intValue);
                Debug.Log($"{gameEditor.editKey} is {(PlayerPrefs.GetInt(gameEditor.editKey)).ToString()} now");
            }
        }
        else if (gameEditor.playerPrefsState == PlayerPrefsState.String)
        {
            gameEditor.stringValue = EditorGUILayout.TextField("Value", gameEditor.stringValue);

            if (GUILayout.Button($"Set '{gameEditor.editKey}' Key"))
            {
                PlayerPrefs.SetString(gameEditor.editKey, gameEditor.stringValue);
                Debug.Log($"{gameEditor.editKey} is {(PlayerPrefs.GetString(gameEditor.editKey)).ToString()} now");
            }
        }
        else if (gameEditor.playerPrefsState == PlayerPrefsState.Float)
        {
            gameEditor.floatValue = EditorGUILayout.FloatField("Value", gameEditor.floatValue);

            if (GUILayout.Button($"Set '{gameEditor.editKey}' Key"))
            {
                PlayerPrefs.SetFloat(gameEditor.editKey, gameEditor.floatValue);
                Debug.Log($"{gameEditor.editKey} is {(PlayerPrefs.GetFloat(gameEditor.editKey)).ToString()} now");
            }
        }
        GUILayout.EndHorizontal();
        #endregion
        GUILayout.Space(15);
        #region PlayerPrefs Learn
        EditorGUILayout.LabelField("PlayerPrefs Learn", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();

        gameEditor.learnKey = EditorGUILayout.TextField("Key Name", gameEditor.learnKey);

        GUILayout.Space(10);
        if (gameEditor.playerPrefsState == PlayerPrefsState.Int)
        {
            if (GUILayout.Button($"Learn '{gameEditor.learnKey}' Key"))
            {
                Debug.Log($"'{gameEditor.learnKey}' Key's value is '{(PlayerPrefs.GetInt(gameEditor.learnKey))}'");
            }
        }
        else if (gameEditor.playerPrefsState == PlayerPrefsState.String)
        {
            if (GUILayout.Button($"Learn '{gameEditor.learnKey}' Key"))
            {
                Debug.Log($"'{gameEditor.learnKey}' Key's value is '{(PlayerPrefs.GetString(gameEditor.learnKey))}'");
            }
        }
        else if (gameEditor.playerPrefsState == PlayerPrefsState.Float)
        {
            if (GUILayout.Button($"Learn '{gameEditor.learnKey}' Key"))
            {
                Debug.Log($"'{gameEditor.learnKey}' Key's value is '{(PlayerPrefs.GetFloat(gameEditor.learnKey))}'");
            }
        }
        GUILayout.EndHorizontal();
        #endregion
        GUILayout.Space(15);
        #region PlayerPrefs Delete
        EditorGUILayout.LabelField("PlayerPrefs Delete", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();
        gameEditor.deleteKey = EditorGUILayout.TextField("Key Name", gameEditor.deleteKey);

        if (GUILayout.Button("Delete Key"))
        {
            Debug.Log($"{gameEditor.deleteKey} Key Deleted");
            PlayerPrefs.DeleteKey(gameEditor.deleteKey);
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(15);

        if (GUILayout.Button("Delete All Keys"))
        {
            Debug.Log("All Keys Deleted");
            PlayerPrefs.DeleteAll();
        }
        EditorGUILayout.HelpBox("Please be careful when pressing this button. It is an irreversible action.", MessageType.Warning);
        #endregion
        #endregion
        GUILayout.Space(20);
        #region Language
        GUILayout.Label("Language", headerText);
        #region Language Change
        GUILayout.Space(5);
        GUILayout.Label("Language Change", EditorStyles.boldLabel);
        CreateButtons();
        GUILayout.Label("Current Language: " + PlayerPrefs.GetString("language").ToUpper(), infoText);
        #endregion
        GUILayout.Space(15);
        #region Language Add
        GUILayout.Label("Language Add", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();
        gameEditor.addLanguage = EditorGUILayout.TextField("Language Add", gameEditor.addLanguage);
        if (GUILayout.Button("Add"))
        {
            MultiLang.AddLanguage(gameEditor.addLanguage);
        }
        GUILayout.EndHorizontal();
        #endregion
        GUILayout.Space(15);
        #region Language Delete
        GUILayout.Label("Language Delete", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();
        gameEditor.deleteLanguage = EditorGUILayout.TextField("Language Delete", gameEditor.deleteLanguage);
        if (GUILayout.Button("Delete"))
        {
            MultiLang.DeleteLanguage(gameEditor.deleteLanguage);
        }
        GUILayout.EndHorizontal();
        #endregion
        #endregion
        serializedObject.ApplyModifiedProperties();
    }
Beispiel #10
0
 private void Awake()
 {
     LangsList = MultiLang.GetAllLanguages();
 }
Beispiel #11
0
    public IEnumerator Write()
    {
        yield return(new WaitForSeconds(waitAtTheStart));

        foreach (var key in sentenceKeys)
        {
            wobblyText.ResetIndexs();
            shakeText.ResetIndexs();
            jellyText.ResetIndexs();
            writerText.text = "";
            if (!playSoundEachLetter && playSound)
            {
                AudioManager.Instance.PlayClip(soundName);
            }
            string sentence = "";
            if (MultiLang.GetTranslation(key) != null)
            {
                sentence = MultiLang.GetTranslation(key);
            }
            else
            {
                sentence = key;
            }
            List <string> tags             = new List <string>();
            string        tagName          = "";
            bool          tag              = false;
            int           wobblyStartIndex = 0;
            int           shakeStartIndex  = 0;
            int           jellyStartIndex  = 0;
            for (int i = 0; i < sentence.Length; i++)
            {
                char letter = sentence[i];

                string letterStr = letter.ToString();
                if (tag)
                {
                    tagName += letter;
                    if (letter == '>')
                    {
                        tag = false;
                        tags.Add(tagName);
                        if (tagName.Contains("wobbly"))
                        {
                            int sumLen = 0;
                            foreach (var item in tags)
                            {
                                sumLen += item.Length;
                            }
                            int lenOffset = i - sumLen + 1;
                            if (!tagName.Contains("/"))
                            {
                                wobblyText.AddStartIndex(lenOffset);
                                wobblyStartIndex = lenOffset;
                            }
                            else
                            {
                                wobblyText.AddEndIndex(wobblyStartIndex, lenOffset);
                                wobblyStartIndex = 0;
                            }
                        }
                        else if (tagName.Contains("shake"))
                        {
                            int sumLen = 0;
                            foreach (var item in tags)
                            {
                                sumLen += item.Length;
                            }
                            int lenOffset = i - sumLen + 1;
                            if (!tagName.Contains("/"))
                            {
                                shakeText.AddStartIndex(lenOffset);
                                shakeStartIndex = lenOffset;
                            }
                            else
                            {
                                shakeText.AddEndIndex(shakeStartIndex, lenOffset);
                                shakeStartIndex = 0;
                            }
                        }
                        else if (tagName.Contains("jelly"))
                        {
                            int sumLen = 0;
                            foreach (var item in tags)
                            {
                                sumLen += item.Length;
                            }
                            int lenOffset = i - sumLen + 1;
                            if (!tagName.Contains("/"))
                            {
                                jellyText.AddStartIndex(lenOffset);
                                jellyStartIndex = lenOffset;
                            }
                            else
                            {
                                jellyText.AddEndIndex(jellyStartIndex, lenOffset);
                                jellyStartIndex = 0;
                            }
                        }
                        else
                        {
                            writerText.text += tagName;
                        }
                        tagName = "";
                    }
                }
                else
                {
                    if (letter == '<')
                    {
                        tag      = true;
                        tagName += letter;
                    }
                    else
                    {
                        if (playSoundEachLetter && playSound)
                        {
                            AudioManager.Instance.PlayClipWithRandomPitch(soundName, minPitch, maxPitch);
                        }
                        writerText.text += letter;
                        if (letter.ToString().IndexOfAny(stopperChars) != -1)
                        {
                            yield return(new WaitForSeconds(waitBetweenLetters * 3));
                        }
                        yield return(new WaitForSeconds(waitBetweenLetters));
                    }
                }
            }
            resume.SetActive(true);
            yield return(new WaitUntil(() => Input.GetKeyDown(KeyCode.Space)));

            resume.SetActive(false);
        }
        resume.SetActive(true);
        yield return(new WaitUntil(() => Input.GetKeyDown(KeyCode.Space)));

        resume.SetActive(false);
        if (playEvent)
        {
            AfterEvent.Invoke();
        }
    }
 public TabDesc(int index, MultiLang.ID name, ItemData.Type[] itemTypes, YGUISystem.GUIButton tab)
 {
     m_index = index;
     m_tab = tab;
     m_checked = tab.Button.transform.Find("Checked").gameObject;
     m_tab.Lable.Text.text = RefData.Instance.RefTexts(name);
     m_itemTypes = itemTypes;
     m_tabImage = tab.Button.gameObject.GetComponent<Image>();
 }
Beispiel #13
0
 public static string GetString(string name)
 {
     return(MultiLang.GetLang(name));
 }
Beispiel #14
0
 private void Start()
 {
     GetComponent <Text>().text = MultiLang.GetTranslation(key);
 }
Beispiel #15
0
 /// <summary>
 /// 获取EnumType的文本信息
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static string GetEnumTypeText <enumT>(object value)
 {
     return(MultiLang.GetText <enumT>(value));
 }
Beispiel #16
0
 public static void InitializeEnumText <enumT>(object value, string text)
 {
     MultiLang.AddText(value, text);
 }