yyl
9 天以前 3bd7f56906e31e8fe0072108c9d4652707b51de8
Main/Utility/UIHelper.cs
@@ -69,14 +69,15 @@
    public static void SetIconWithMoneyType(this Image _image, int moneyType)
    {
        if (_image == null) return;
        // string iconKey = StringUtility.Contact("Money_Type_", moneyType);
        if (GeneralDefine.MoneyDisplayModel.ContainsKey(moneyType))
        {
            _image.SetOrgSprite(ItemConfig.Get(GeneralDefine.MoneyDisplayModel[moneyType]).IconKey);
        }
        else
        {
            Debug.LogError("MoneyDisplayModel 为配置货币类型:" + moneyType);
            // 不需要物品的情况补充
            // string iconKey = StringUtility.Contact("Money_Type_", moneyType);
            Debug.LogError("MoneyDisplayModel 未配置货币类型:" + moneyType);
        }
    }
@@ -88,7 +89,7 @@
        }
        else
        {
            Debug.LogError("MoneyDisplayModel 为配置货币类型:" + moneyType);
            Debug.LogError("MoneyDisplayModel 未配置货币类型:" + moneyType);
            return "";
        }
    }
@@ -323,6 +324,13 @@
        }
        return false;
    }
    // 检查字符串是不是纯整数
    public static bool IsNumeric(string input)
    {
        return int.TryParse(input, out _);
    }
    public static string GetColorNameByItemColor(int itemColor)
    {
@@ -968,7 +976,7 @@
        {3, PlayerDataType.Silver},
        {41, PlayerDataType.default26},
        {42, PlayerDataType.default33},
        {53, PlayerDataType.ChallengeVoucher},
    };
    public static long GetMoneyCnt(int moneyType)
@@ -1105,6 +1113,16 @@
                    //武将招募积分
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default44);
                }
            case 52:
                {
                    //淘金令
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.GoldRush);
                }
            case 53:
                {
                    //挑战凭证
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ChallengeVoucher);
                }
            case 98:
                {
                    //过期型代金券
@@ -1137,6 +1155,35 @@
        long cnt = PackManager.Instance.GetItemCountByID(type, itemId);
        return AppendColor(useCnt <= cnt ? engoughColor : TextColType.Red, $"{ReplaceLargeNum(cnt)}/{ReplaceLargeNum(useCnt)}");
    }
    /// <param name="needTips">0 不响应 1 弹提示 2 弹获取途径tips</param>
    public static bool CheckMoneyCount(int moneyType, long needCount, int needTips = 0)
    {
        if (needCount <= 0)
        {
            return true;
        }
        long haveCount = GetMoneyCnt(moneyType);
        bool isEnough = haveCount >= needCount;
        if (!isEnough)
        {
            if (needTips == 1)
            {
                SysNotifyMgr.Instance.ShowTip("LackMoney", moneyType);
            }
            else if (needTips == 2)
            {
                ItemTipUtility.ShowMoneyTip(moneyType);
            }
        }
        return isEnough;
    }
    #endregion
@@ -1221,13 +1268,15 @@
        return content;
    }
    //检查名字长度,玩家名和公会名
    //不同国家长度不同,排版不同
    public static bool SatisfyNameLength(string name, out int error)
    {
        error = 0;
        //bool pureChinese = Regex.IsMatch(name, "^[\u4e00-\u9fa5]+$");
        //var chsCount = GetChsCount(name);
        int length = Encoding.Default.GetBytes(name).Length;
        var maxlength = 20;
        var maxlength = 14;  //纯中文不建议超过7个字
        var minlength = 3;
        if (length > maxlength)
        {
@@ -1327,9 +1376,24 @@
    public static string RemoveColor(string content)
    {
    {
        content = WordAnalysis.Color_Start_Regex.Replace(content, string.Empty);
        content = WordAnalysis.Color_End_Regex.Replace(content, string.Empty);
        return content;
    }
    //复制到剪贴板
    // TODO 暂不支持web后续补充
    public static void CopyToClipboard(string text)
    {
        GUIUtility.systemCopyBuffer = text;
        Debug.Log("文字已复制到剪贴板: " + text);
    }
    //获取剪切板内容
    public static string GetClipboardText()
    {
        return GUIUtility.systemCopyBuffer;
    }
}