From 3b64befcd8b2ab5abef1a33c5c8f73a6b245aff0 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期四, 16 十月 2025 19:59:09 +0800
Subject: [PATCH] 136 子 【挑战】战锤秘境 / 【挑战】战锤秘境-客户端 修改战场名

---
 Main/Utility/UIHelper.cs |  168 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 123 insertions(+), 45 deletions(-)

diff --git a/Main/Utility/UIHelper.cs b/Main/Utility/UIHelper.cs
index f28674e..6757b45 100644
--- a/Main/Utility/UIHelper.cs
+++ b/Main/Utility/UIHelper.cs
@@ -69,20 +69,29 @@
     public static void SetIconWithMoneyType(this Image _image, int moneyType)
     {
         if (_image == null) return;
-        string iconKey = StringUtility.Contact("Money_Type_", moneyType);
-        _image.SetSprite(iconKey);
-    }
-
-    public static void SetSmallIconWithMoneyType(this Image _image, int moneyType)
-    {
-        if (_image == null) return;
-        string iconKey = StringUtility.Contact("SmallMoney", moneyType);
-        _image.SetSprite(iconKey);
+        if (GeneralDefine.MoneyDisplayModel.ContainsKey(moneyType))
+        {
+            _image.SetOrgSprite(ItemConfig.Get(GeneralDefine.MoneyDisplayModel[moneyType]).IconKey);
+        }
+        else
+        {
+            // 涓嶉渶瑕佺墿鍝佺殑鎯呭喌琛ュ厖
+            // string iconKey = StringUtility.Contact("Money_Type_", moneyType);
+            Debug.LogError("MoneyDisplayModel 鏈厤缃揣甯佺被鍨嬶細" + moneyType);
+        }
     }
 
     public static string GetIconNameWithMoneyType(int moneyType)
     {
-        return StringUtility.Contact("Money_Type_", moneyType);
+        if (GeneralDefine.MoneyDisplayModel.ContainsKey(moneyType))
+        {
+            return ItemConfig.Get(GeneralDefine.MoneyDisplayModel[moneyType]).IconKey;
+        }
+        else
+        {
+            Debug.LogError("MoneyDisplayModel 鏈厤缃揣甯佺被鍨嬶細" + moneyType);
+            return "";
+        }
     }
 
     /// <summary>
@@ -364,7 +373,7 @@
     public static readonly Color s_NavyYellow = new Color32(242, 238, 2, 255); //f2ee02
     public static readonly Color s_LightGreen = new Color32(42, 227, 55, 255);//2ae337
     public static readonly Color s_LightWhite = new Color32(245, 246, 230, 255); //f5f6e6
-    public static readonly Color s_Gray = new Color32(132, 121, 123, 255);  //84797b
+    public static readonly Color s_Gray = new Color32(187, 187, 187, 255); //bbbbbb
     public static readonly Color s_Gold = new Color32(255, 239, 71, 255);//ffef47
     public static readonly Color s_EarthYellow = new Color32(248, 152, 59, 255);//f8983b
 
@@ -535,6 +544,8 @@
                 return s_LightWhite;
             case TextColType.Gray:
                 return s_Gray;
+            case TextColType.NavyGray:
+                return new Color32(121, 121, 121, 255);
             case TextColType.itemjingliang:
                 // 729de4 绮捐壇
                 return new Color32(114, 157, 228, 255);
@@ -666,7 +677,7 @@
                 // 5d1d52 姘告亽
                 return new Color32(93, 29, 82, 128);
             case QualityTextColType.red:
-                return s_BrightRedColor;
+                return s_DarkRedColor;
         }
         return new Color32(0, 0, 0, 128);
     }
@@ -707,7 +718,9 @@
             case TextColType.LightGreen:
                 return StringUtility.Contact("<color=#8ddc11>", msg, "</color>");
             case TextColType.Gray:
-                return StringUtility.Contact("<color=#84797b>", msg, "</color>");
+                return StringUtility.Contact("<color=#bbbbbb>", msg, "</color>");
+            case TextColType.NavyGray:
+                return StringUtility.Contact("<color=#797979>", msg, "</color>");
             case TextColType.lightYellow:
                 return StringUtility.Contact("<color=#fcedb9>", msg, "</color>");
             case TextColType.NavyYellow:
@@ -741,13 +754,37 @@
                 return StringUtility.Contact("<color=#dfbbed>", msg, "</color>");
             case TextColType.itembuxiu:
                 // 5eeff2 涓嶆溄
-                return  StringUtility.Contact("<color=#5eeff2>", msg, "</color>");
+                return StringUtility.Contact("<color=#5eeff2>", msg, "</color>");
             case TextColType.itemyonghen:
                 // f5b4ea 姘告亽
                 return StringUtility.Contact("<color=#f5b4ea>", msg, "</color>");
         }
         return msg;
     }
+
+    public static string AppendColor(Color color, string msg)
+    {
+        return StringUtility.Contact("<color=#", ColorToHexWithHash(color), ">", msg, "</color>");
+    }
+
+
+    public static string ColorToHexWithHash(Color color, bool includeAlpha = false)
+    {
+        int r = Mathf.RoundToInt(color.r * 255);
+        int g = Mathf.RoundToInt(color.g * 255);
+        int b = Mathf.RoundToInt(color.b * 255);
+        if (includeAlpha)
+        {
+            int a = Mathf.RoundToInt(color.a * 255);
+            return string.Format("{0:X2}{1:X2}{2:X2}{3:X2}", r, g, b, a);
+        }
+        else
+        {
+            return string.Format("{0:X2}{1:X2}{2:X2}", r, g, b);
+        }
+    }
+
+
 
     //needName 鎸囧畼鑱�0鏄惁闇�瑕佸悕绉�
     public static string GetRealmName(int realmLv, bool bright = true, bool needName = false)
@@ -761,7 +798,7 @@
         {
             return string.Empty;
         }
-        return GetRealmColorByLv(realmLv, config.Name, bright);
+        return AppendColor(realmLv, config.Name, bright);
     }
 
     //strFormat闄勫姞 澧冪晫鍚嶄互澶栫殑鏂囧瓧
@@ -780,31 +817,31 @@
     //     return GetRealmColorByLv(realmLv, string.Format(strFormat, config.Name), bright);
     // }
 
-    public static string GetRealmColorByLv(int realmLv, string msg, bool bright = true)
-    {
-        var config = RealmConfig.Get(realmLv);
-        if (config == null)
-        {
-            return string.Empty;
-        }
-        switch (config.Quality)
-        {
-            case 1:
-                return StringUtility.Contact("<color=#", bright ? "666666" : "dddddd", ">", msg, "</color>");
-            case 2:
-                return StringUtility.Contact("<color=#", bright ? "00b337" : "66ff00", ">", msg, "</color>");
-            case 3:
-                return StringUtility.Contact("<color=#", bright ? "0066ff" : "00c6ff", ">", msg, "</color>");
-            case 4:
-                return StringUtility.Contact("<color=#", bright ? "ff00f6" : "f000ff", ">", msg, "</color>");
-            case 5:
-                return StringUtility.Contact("<color=#", bright ? "ff6600" : "ff9000", ">", msg, "</color>");
-            case 6:
-                return StringUtility.Contact("<color=#", bright ? "ff0000" : "ff0000", ">", msg, "</color>");
-            default:
-                return msg;
-        }
-    }
+    // public static string GetRealmColorByLv(int realmLv, string msg, bool bright = true)
+    // {
+    //     var config = RealmConfig.Get(realmLv);
+    //     if (config == null)
+    //     {
+    //         return string.Empty;
+    //     }
+    //     switch (config.Quality)
+    //     {
+    //         case 1:
+    //             return StringUtility.Contact("<color=#", bright ? "666666" : "dddddd", ">", msg, "</color>");
+    //         case 2:
+    //             return StringUtility.Contact("<color=#", bright ? "00b337" : "66ff00", ">", msg, "</color>");
+    //         case 3:
+    //             return StringUtility.Contact("<color=#", bright ? "0066ff" : "00c6ff", ">", msg, "</color>");
+    //         case 4:
+    //             return StringUtility.Contact("<color=#", bright ? "ff00f6" : "f000ff", ">", msg, "</color>");
+    //         case 5:
+    //             return StringUtility.Contact("<color=#", bright ? "ff6600" : "ff9000", ">", msg, "</color>");
+    //         case 6:
+    //             return StringUtility.Contact("<color=#", bright ? "ff0000" : "ff0000", ">", msg, "</color>");
+    //         default:
+    //             return msg;
+    //     }
+    // }
 
     //鐗╁搧 鍚勫姛鑳藉搧璐�  浠庣簿鑹�1鍝佽川 瀵瑰簲 3寮�濮�
     /// <summary>
@@ -813,7 +850,7 @@
     /// <param name="itemColor"></param>
     /// <param name="msg"></param>
     /// <param name="bright"></param>
-    /// <param name="colorGroupType"></param>
+    /// <param name="colorGroupType">0 閫氱敤鍔熻兘鍝佽川鍒嗙粍绮捐壇鍒扮璇�</param>
     /// <returns></returns>
     public static string AppendColor(int itemColor, string msg, bool bright = true, int colorGroupType = 0)
     {
@@ -891,7 +928,7 @@
     }
     #endregion
 
-    
+
 
     #region 寰楀埌閲戦挶鏁伴噺鏍规嵁閲戦挶绫诲瀷
 
@@ -1069,6 +1106,11 @@
                     //姝﹀皢鎷涘嫙绉垎
                     return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default44);
                 }
+            case 52:
+                {
+                    //娣橀噾浠�
+                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.GoldRush);
+                }
             case 98:
                 {
                     //杩囨湡鍨嬩唬閲戝埜
@@ -1093,19 +1135,48 @@
     public static string ShowUseMoney(int moneyType, long useCnt, TextColType engoughColor = TextColType.Green)
     {
         long cnt = GetMoneyCnt(moneyType);
-        return AppendColor(useCnt <= cnt ? engoughColor : TextColType.Red, $"{ReplaceLargeNum(useCnt)}/{ReplaceLargeNum(cnt)}");
+        return AppendColor(useCnt <= cnt ? engoughColor : TextColType.Red, $"{ReplaceLargeNum(cnt)}/{ReplaceLargeNum(useCnt)}");
     }
 
     public static string ShowUseItem(PackType type, int itemId, long useCnt, TextColType engoughColor = TextColType.Green)
     {
         long cnt = PackManager.Instance.GetItemCountByID(type, itemId);
-        return AppendColor(useCnt <= cnt ? engoughColor : TextColType.Red, $"{ReplaceLargeNum(useCnt)}/{ReplaceLargeNum(cnt)}");
+        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
 
     #region 寰楀埌瑁呭浣嶆垨鑰呯绂忔爲鍝佽川鍚嶇О 甯﹂鑹�
-    public static string GetQualityNameWithColor(int quality, string format="{0}")
+    public static string GetQualityNameWithColor(int quality, string format = "{0}")
     {
         return AppendColor(quality, string.Format(format, Language.Get("equipQuality" + quality)), true, 1);
     }
@@ -1289,4 +1360,11 @@
         return money / scale;
     }
 
+
+    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;
+    }
 }

--
Gitblit v1.8.0