少年修仙传客户端代码仓库
client_Hale
2018-10-09 0706d9139c58a7b5e399a31e3a96884e48920c75
Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
3个文件已修改
95 ■■■■■ 已修改文件
System/Login/CreateRoleWin.cs 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Role/RoleRenameWin.cs 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Utility/UIHelper.cs 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Login/CreateRoleWin.cs
@@ -187,7 +187,7 @@
                return;
            }
            int error = 0;
            if (!SatisfyNameLength(userNameInput.text, out error))
            if (!UIHelper.SatisfyNameLength(userNameInput.text, out error))
            {
                switch (error)
                {
@@ -270,35 +270,6 @@
        private void RemoveRoleModel()
        {
            m_CreateRoleShow.Dispose();
        }
        public bool SatisfyNameLength(string name, out int error)
        {
            error = 0;
            bool pureChinese = Regex.IsMatch(name, "^[\u4e00-\u9fa5]+$");
            if (pureChinese)
            {
                if (name.Length > 5)
                {
                    error = 1;
                }
                else if (name.Length < 2)
                {
                    error = 2;
                }
            }
            else
            {
                if (name.Length > 6)
                {
                    error = 1;
                }
                else if (name.Length < 3)
                {
                    error = 2;
                }
            }
            return error == 0;
        }
    }
System/Role/RoleRenameWin.cs
@@ -101,7 +101,7 @@
            }
            int error = 0;
            if (!SatisfyNameLength(renameInput.text, out error))
            if (!UIHelper.SatisfyNameLength(renameInput.text, out error))
            {
                switch (error)
                {
@@ -145,36 +145,5 @@
              });
              
        }
        public bool SatisfyNameLength(string name, out int error)
        {
            error = 0;
            bool pureChinese = Regex.IsMatch(name, "^[\u4e00-\u9fa5]+$");
            if (pureChinese)
            {
                if (name.Length > 5)
                {
                    error = 1;
                }
                else if (name.Length < 2)
                {
                    error = 2;
                }
            }
            else
            {
                if (name.Length > 6)
                {
                    error = 1;
                }
                else if (name.Length < 3)
                {
                    error = 2;
                }
            }
            return error == 0;
        }
    }
}
Utility/UIHelper.cs
@@ -775,4 +775,35 @@
        content = content.Replace(" ", string.Empty);
        return content;
    }
    public static bool SatisfyNameLength(string name, out int error)
    {
        error = 0;
        bool pureChinese = Regex.IsMatch(name, "^[\u4e00-\u9fa5]+$");
        var chsCount = GetChsCount(name);
        var maxlength = pureChinese ? 5 : chsCount > 0 ? 6 : 8;
        var minlength = pureChinese ? 2 : 3;
        if (name.Length > maxlength)
        {
            error = 1;
        }
        else if (name.Length < minlength)
        {
            error = 2;
        }
        return error == 0;
    }
    public static int GetChsCount(string name)
    {
        var count = 0;
        for (int i = 0; i < name.Length; i++)
        {
            if (Regex.IsMatch(name[i].ToString(), "[\u4e00-\u9fa5]"))
            {
                count++;
            }
        }
        return count;
    }
}