From 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 11 五月 2026 16:20:37 +0800
Subject: [PATCH] Merge branch 'master' into h5version
---
Main/Utility/UIHelper.cs | 428 ++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 338 insertions(+), 90 deletions(-)
diff --git a/Main/Utility/UIHelper.cs b/Main/Utility/UIHelper.cs
index 724730b..43a23f7 100644
--- a/Main/Utility/UIHelper.cs
+++ b/Main/Utility/UIHelper.cs
@@ -8,6 +8,7 @@
using System.Text.RegularExpressions;
using System.IO;
using LitJson;
+using Cysharp.Threading.Tasks;
/// <summary>
/// UI杈呭姪绫�
@@ -22,10 +23,16 @@
//涓嶉渶瑕佹彁鍙栫炕璇戠殑鏂囨湰
private static readonly string[] numbers = new string[] { "闆�", "涓�", "浜�", "涓�", "鍥�", "浜�", "鍏�", "涓�", "鍏�", "涔�" };
private static readonly string[] units = new string[] { "鍗�", "鐧�", "鍗�", "涓�" };
-
+ private static readonly string[] unitFTs = new string[] { "鍗�", "鐧�", "鍗�", "钀�" };
//鏁板瓧杞腑鏂�(鍙仛灏忔暟瀛�)锛屾捣澶栫増鏈皟鐢ㄦ敼鍑芥暟鍒囨崲鐗堟湰璇风洿鎺ヨ繑鍥炴暟瀛�
public static string ChineseNumber(int number)
{
+ string langId = Language.Id;
+ if (!string.IsNullOrEmpty(langId) && langId != "zh" && langId != "ft")
+ return number.ToString();
+
+ string[] curUnits = (langId == "ft") ? unitFTs : units;
+
if (number == 0)
return numbers[0];
@@ -39,9 +46,9 @@
if (part != 0)
{
if (needZero)
- result = StringUtility.Contact(numbers[0] + result);
+ result = StringUtility.Concat(numbers[0] + result);
- result = numbers[part] + (unitPlace == 1 ? "" : units[unitPlace - 2]) + result; // 鍗曚綅鍙湪鍗併�佺櫨銆佸崈銆佷竾鍐呴儴浣跨敤
+ result = numbers[part] + (unitPlace == 1 ? "" : curUnits[unitPlace - 2]) + result; // 鍗曚綅鍙湪鍗併�佺櫨銆佸崈銆佷竾鍐呴儴浣跨敤
needZero = false;
}
else
@@ -66,6 +73,8 @@
#region UI閫氱敤
+
+ //榛樿璐у竵鍥剧墖鐢ㄩ珮娓呯殑锛屽瘜鏂囨湰鐨勫彲浠ョ敤灏忓浘鏍囧埄浜庢帓鐗堟樉绀�
public static void SetIconWithMoneyType(this Image _image, int moneyType)
{
if (_image == null) return;
@@ -75,8 +84,9 @@
}
else
{
+ // 鏆備笉鑰冭檻瀵屾枃鏈殑鎯呭喌
// 涓嶉渶瑕佺墿鍝佺殑鎯呭喌琛ュ厖
- // string iconKey = StringUtility.Contact("Money_Type_", moneyType);
+ // string iconKey = StringUtility.Concat("Money_Type_", moneyType);
Debug.LogError("MoneyDisplayModel 鏈厤缃揣甯佺被鍨嬶細" + moneyType);
}
}
@@ -85,6 +95,7 @@
{
if (IconConfig.HasKey("MoneyType_" + moneyType))
{
+ //瀵屾枃鏈樉绀虹殑鎯呭喌
return IconConfig.Get("MoneyType_" + moneyType).sprite;
}
else if (GeneralDefine.MoneyDisplayModel.ContainsKey(moneyType))
@@ -95,6 +106,20 @@
{
Debug.LogError("MoneyDisplayModel 鏈厤缃揣甯佺被鍨嬶細" + moneyType);
return "";
+ }
+ }
+
+ // 閫氳繃璐у竵绫诲瀷鑾峰彇鐗╁搧ID
+ public static int GetItemIDWithMoneyType(int moneyType)
+ {
+ if (GeneralDefine.MoneyDisplayModel.ContainsKey(moneyType))
+ {
+ return GeneralDefine.MoneyDisplayModel[moneyType];
+ }
+ else
+ {
+ Debug.LogError("MoneyDisplayModel 鏈厤缃揣甯佺被鍨嬶細" + moneyType);
+ return 0;
}
}
@@ -110,20 +135,20 @@
{
if (attrName.Length == 2)
{
- suitStr = StringUtility.Contact(suitStr, attrName[i], " ");
+ suitStr = StringUtility.Concat(suitStr, attrName[i].ToString(), " ");
}
else if (attrName.Length == 3)
{
- suitStr = StringUtility.Contact(suitStr, attrName[i], " ");
+ suitStr = StringUtility.Concat(suitStr, attrName[i].ToString(), " ");
}
else
{
- suitStr = StringUtility.Contact(suitStr, attrName[i]);
+ suitStr = StringUtility.Concat(suitStr, attrName[i].ToString());
}
}
else
{
- suitStr = StringUtility.Contact(suitStr, attrName[i]);
+ suitStr = StringUtility.Concat(suitStr, attrName[i].ToString());
}
}
return suitStr;
@@ -205,76 +230,92 @@
return val.Replace(@"</r>", "\n");
}
- public static double numto2Decimals(double value)
- {
- //涓轰粈涔堣value * 1000/10 杩欎箞鍐欙紝鐗规畩鐨勬暟瀛椾細鏈夐棶棰橈紝姣斿36.80000锛屼細(int)(value * 100)琚绠椾负3679
- //娴嬭瘯涓嬪彧鏈�30鍑犵偣8000鐨勬墠浼氳繖鏍�
- return (int)(value * 1000 / 10) / 100.00;
- }
/// <summary>
- /// 澶ф暟鍊艰浆鍖� 鏍煎紡 鏈�澶氫袱涓皬鏁�
+ /// 澶ф暟鍊艰浆鍖� 鏍煎紡 鏈�澶氫袱涓皬鏁� ,鍚戜笅鍙栨暣
/// K -鍗冿紝M -鐧捐惉锛孊-鍗佸剟锛孴 -钀剟
- /// 涓嶅洓鑸嶄簲鍏ワ紝涓嶇敤Math.Round锛屽洜涓哄綋鐜╁鍙湁23.3456,浣嗘槸Math.Round浼氭樉绀�23.35, 褰撹喘涔颁环鏍间负23.35鏃舵棤娉曡喘涔扮殑
/// </summary>
- public static string ReplaceLargeNum(double num)
+ public static string ReplaceLargeNum(double num, int decimalPlaces = 1)
{
- const long K = 10000; //鍥藉唴涓轰竾锛屾捣澶栦负鍗�
- const long M = K * 10000;
- const long B = M * 10000;
- const long T = B * 10000;
+ // 鑾峰彇褰撳墠璇█鐘舵��
+ string langId = Language.Id;
+ bool isChinese = langId == "zh" || langId == "ft";
+
+ // 绠�绻佷腑鏂囦竾杩涘埗 (10000)锛屽叾浠栧崈杩涘埗 (1000)
+ long baseUnit = isChinese ? 10000 : 1000;
+
+ long K = baseUnit;
+ long M = K * baseUnit;
+ long B = M * baseUnit;
+ long T = B * baseUnit;
if (num >= T)
{
- return StringUtility.Contact(numto2Decimals(num / T).ToString("0.##"), Language.Get("L1070_0"));
+ return StringUtility.Concat(FormatWithoutRounding(num / T, 2), Language.Get("L1070_0"));
}
else if (num >= B)
{
- return StringUtility.Contact(numto2Decimals(num / B).ToString("0.##"), Language.Get("L1070_1"));
+ return StringUtility.Concat(FormatWithoutRounding(num / B, 2), Language.Get("L1070_1"));
}
else if (num >= M)
{
- return StringUtility.Contact(numto2Decimals(num / M).ToString("0.#"), Language.Get("L1070"));
+ return StringUtility.Concat(FormatWithoutRounding(num / M, decimalPlaces), Language.Get("L1070"));
}
else if (num >= K)
{
- return StringUtility.Contact(numto2Decimals(num / K).ToString("0.#"), Language.Get("L1071"));
+ return StringUtility.Concat(FormatWithoutRounding(num / K, decimalPlaces), Language.Get("L1071"));
}
else
{
- return numto2Decimals(num).ToString("0.#");
+ return FormatWithoutRounding(num, decimalPlaces);
}
}
//鐢ㄤ簬缇庢湳瀛� 缁熶竴鐢ㄥ瓧姣岾MBT浠h〃浣跨敤锛屽皬鏁扮偣鐢�.
public static string ReplaceLargeArtNum(double num)
{
- const long K = 10000; //鍥藉唴涓轰竾锛屾捣澶栦负鍗�
- const long M = K * 10000;
- const long B = M * 10000;
- const long T = B * 10000;
+ // 鑾峰彇褰撳墠璇█鐘舵��
+ string langId = Language.Id;
+ bool isChinese = langId == "zh" || langId == "ft";
+
+ // 绠�绻佷腑鏂囦竾杩涘埗 (10000)锛屽叾浠栧崈杩涘埗 (1000)
+ long baseUnit = isChinese ? 10000 : 1000;
+
+ long K = baseUnit;
+ long M = K * baseUnit;
+ long B = M * baseUnit;
+ long T = B * baseUnit;
if (num >= T)
{
- return StringUtility.Contact(numto2Decimals(num / T).ToString("0.##"), "t");
+ return StringUtility.Concat(FormatWithoutRounding(num / T, 2), "t");
}
else if (num >= B)
{
- return StringUtility.Contact(numto2Decimals(num / B).ToString("0.##"), "b");
+ return StringUtility.Concat(FormatWithoutRounding(num / B, 2), "b");
}
else if (num >= M)
{
- return StringUtility.Contact(numto2Decimals(num / M).ToString("0.#"), "m");
+ return StringUtility.Concat(FormatWithoutRounding(num / M, 1), "m");
}
else if (num >= K)
{
- return StringUtility.Contact(numto2Decimals(num / K).ToString("0.#"), "k");
+ return StringUtility.Concat(FormatWithoutRounding(num / K, 1), "k");
}
else
{
- return numto2Decimals(num).ToString("0.#");
+ return FormatWithoutRounding(num, 1);
}
}
+
+ //鏍规嵁灏忔暟浣嶆暟鐩存帴鎴柇涓嶅仛鍥涜垗浜斿叆
+ public static string FormatWithoutRounding(double value, int decimalPlaces)
+ {
+ double factor = Math.Pow(10, decimalPlaces);
+ double truncated = Math.Truncate(value * factor) / factor;
+ return truncated.ToString($"0.{new string('#', decimalPlaces)}");
+ }
+
// 杞寲澶ф暟鍊煎甫鍗曚綅鐨勬樉绀猴紝濡傛灉灏忎簬200000鍒欐樉绀哄師鍊硷紝鍚﹀垯鏄剧ず澶ф暟鍊�
public static string ReplaceLargeNumEx(double num)
@@ -314,6 +355,8 @@
}
}
+
+ // 鍙栧悕楠岃瘉
static Regex s_SpecialCharacterRegex = new Regex("[()锛堬級@!#$%^&*[]|_]");
static Regex s_AsciiCharacterRegex = new Regex("[\x00-\x1F]|[\x21-\x2F]|[\x3A-\x40]|[\x5B-\x60]|[\x7B-\x7E]");
public static bool HasSpecialCharac(string str)
@@ -323,6 +366,17 @@
return true;
}
if (s_AsciiCharacterRegex.IsMatch(str))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ //鑱婂ぉ
+ static Regex s_AsciiCharacterRegexChat = new Regex("[\x00-\x1F]");
+ public static bool HasSpecCheckChat(string str)
+ {
+ if (s_AsciiCharacterRegexChat.IsMatch(str))
{
return true;
}
@@ -441,19 +495,19 @@
// switch (crossDanLVConfig.DanType)
// {
// case 0:
- // return StringUtility.Contact("<color=#", bright ? "666666" : "dddddd", ">", name, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "666666" : "dddddd", ">", name, "</color>");
// case 1:
- // return StringUtility.Contact("<color=#", bright ? "9460ff" : "7999ff", ">", name, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "9460ff" : "7999ff", ">", name, "</color>");
// case 2:
- // return StringUtility.Contact("<color=#", bright ? "0066ff" : "00c6ff", ">", name, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "0066ff" : "00c6ff", ">", name, "</color>");
// case 3:
- // return StringUtility.Contact("<color=#", bright ? "00b337" : "66ff00", ">", name, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "00b337" : "66ff00", ">", name, "</color>");
// case 4:
- // return StringUtility.Contact("<color=#", bright ? "ff6600" : "ff9000", ">", name, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "ff6600" : "ff9000", ">", name, "</color>");
// case 5:
- // return StringUtility.Contact("<color=#", bright ? "ff0000" : "ff0000", ">", name, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "ff0000" : "ff0000", ">", name, "</color>");
// case 6:
- // return StringUtility.Contact("<color=#", bright ? "ff00f6" : "f000ff", ">", name, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "ff00f6" : "f000ff", ">", name, "</color>");
// }
// return name;
// }
@@ -515,6 +569,25 @@
case 28:
case 29:
return GetUIColor(TextColType.itemyonghen, bright);
+ case 30:
+ case 31:
+ case 32:
+ case 33:
+ case 34:
+ return GetUIColor(TextColType.itemanjin, bright);
+ case 35:
+ case 36:
+ case 37:
+ case 38:
+ case 39:
+ return GetUIColor(TextColType.itemchuanqi, bright);
+ case 40:
+ case 41:
+ case 42:
+ case 43:
+ case 44:
+ return GetUIColor(TextColType.itemshenhua, bright);
+
}
@@ -633,6 +706,25 @@
case 28:
case 29:
return GetUIOutlineColor(QualityTextColType.itemyonghen);
+ case 30:
+ case 31:
+ case 32:
+ case 33:
+ case 34:
+ return GetUIOutlineColor(QualityTextColType.itemanjin);
+ case 35:
+ case 36:
+ case 37:
+ case 38:
+ case 39:
+ return GetUIOutlineColor(QualityTextColType.itemchuanqi);
+ case 40:
+ case 41:
+ case 42:
+ case 43:
+ case 44:
+ return GetUIOutlineColor(QualityTextColType.itemshenhua);
+
}
return GetUIOutlineColor(QualityTextColType.itemputong);
}
@@ -707,75 +799,75 @@
{
case TextColType.None:
case TextColType.White:
- return StringUtility.Contact("<color=#", bright ? "ffffff" : "ffffff", ">", msg, "</color>");
+ return StringUtility.Concat("<color=#", bright ? "ffffff" : "ffffff", ">", msg, "</color>");
case TextColType.titleSelectColor:
- return StringUtility.Contact("<color=#7F4139>", msg, "</color>");
+ return StringUtility.Concat("<color=#7F4139>", msg, "</color>");
case TextColType.titleUnSelectColor:
- return StringUtility.Contact("<color=#6E5C60>", msg, "</color>");
+ return StringUtility.Concat("<color=#6E5C60>", msg, "</color>");
case TextColType.Red:
- return StringUtility.Contact("<color=#", bright ? "ea261e" : "ea261e", ">", msg, "</color>");
+ return StringUtility.Concat("<color=#", bright ? "ea261e" : "ea261e", ">", msg, "</color>");
case TextColType.Pink:
- return StringUtility.Contact("<color=#", bright ? "f6408d" : "ff7c7c", ">", msg, "</color>");
+ return StringUtility.Concat("<color=#", bright ? "f6408d" : "ff7c7c", ">", msg, "</color>");
case TextColType.Green:
- return StringUtility.Contact("<color=#", bright ? "248B12" : "2ae337", ">", msg, "</color>");
+ return StringUtility.Concat("<color=#", bright ? "248B12" : "2ae337", ">", msg, "</color>");
case TextColType.NavyBrown:
- return StringUtility.Contact("<color=#6e4c31>", msg, "</color>");
+ return StringUtility.Concat("<color=#6e4c31>", msg, "</color>");
case TextColType.DarkGreen:
- return StringUtility.Contact("<color=#248B12>", msg, "</color>");
+ return StringUtility.Concat("<color=#248B12>", msg, "</color>");
case TextColType.Black:
- return StringUtility.Contact("<color=#000000>", msg, "</color>");
+ return StringUtility.Concat("<color=#000000>", msg, "</color>");
case TextColType.LightWhite:
- return StringUtility.Contact("<color=f5f646>", msg, "</color>");
+ return StringUtility.Concat("<color=f5f646>", msg, "</color>");
case TextColType.LightGreen:
- return StringUtility.Contact("<color=#8ddc11>", msg, "</color>");
+ return StringUtility.Concat("<color=#8ddc11>", msg, "</color>");
case TextColType.Gray:
- return StringUtility.Contact("<color=#bbbbbb>", msg, "</color>");
+ return StringUtility.Concat("<color=#bbbbbb>", msg, "</color>");
case TextColType.NavyGray:
- return StringUtility.Contact("<color=#797979>", msg, "</color>");
+ return StringUtility.Concat("<color=#797979>", msg, "</color>");
case TextColType.lightYellow:
- return StringUtility.Contact("<color=#fcedb9>", msg, "</color>");
+ return StringUtility.Concat("<color=#fcedb9>", msg, "</color>");
case TextColType.NavyYellow:
- return StringUtility.Contact("<color=#f2ee02>", msg, "</color>");
+ return StringUtility.Concat("<color=#f2ee02>", msg, "</color>");
case TextColType.itemjingliang:
// 729de4 绮捐壇
- return StringUtility.Contact("<color=#729de4>", msg, "</color>");
+ return StringUtility.Concat("<color=#729de4>", msg, "</color>");
case TextColType.itemxiyou:
// c87bfa绋�鏈�
- return StringUtility.Contact("<color=#c87bfa>", msg, "</color>");
+ return StringUtility.Concat("<color=#c87bfa>", msg, "</color>");
case TextColType.itemshishi:
// f6de56 鍙茶瘲
- return StringUtility.Contact("<color=#f6de56>", msg, "</color>");
+ return StringUtility.Concat("<color=#f6de56>", msg, "</color>");
case TextColType.itemchuanqi:
// fe8534 浼犲
- return StringUtility.Contact("<color=#fe8534>", msg, "</color>");
+ return StringUtility.Concat("<color=#fe8534>", msg, "</color>");
case TextColType.itemshenhua:
// fe4a47 绁炶瘽
- return StringUtility.Contact("<color=#fe4a47>", msg, "</color>");
+ return StringUtility.Concat("<color=#fe4a47>", msg, "</color>");
case TextColType.itemwuxia:
// eb5ce9 鏃犵憰
- return StringUtility.Contact("<color=#eb5ce9>", msg, "</color>");
+ return StringUtility.Concat("<color=#eb5ce9>", msg, "</color>");
case TextColType.itemanjin:
// f9e29f 鏆楅噾
- return StringUtility.Contact("<color=#f9e29f>", msg, "</color>");
+ return StringUtility.Concat("<color=#f9e29f>", msg, "</color>");
case TextColType.itemjueyi:
// cdfef2 缁濊壓
- return StringUtility.Contact("<color=#cdfef2>", msg, "</color>");
+ return StringUtility.Concat("<color=#cdfef2>", msg, "</color>");
case TextColType.itemyuanzu:
// dfbbed 鍏冪
- return StringUtility.Contact("<color=#dfbbed>", msg, "</color>");
+ return StringUtility.Concat("<color=#dfbbed>", msg, "</color>");
case TextColType.itembuxiu:
// 5eeff2 涓嶆溄
- return StringUtility.Contact("<color=#5eeff2>", msg, "</color>");
+ return StringUtility.Concat("<color=#5eeff2>", msg, "</color>");
case TextColType.itemyonghen:
// f5b4ea 姘告亽
- return StringUtility.Contact("<color=#f5b4ea>", msg, "</color>");
+ return StringUtility.Concat("<color=#f5b4ea>", msg, "</color>");
}
return msg;
}
public static string AppendColor(Color color, string msg)
{
- return StringUtility.Contact("<color=#", ColorToHexWithHash(color), ">", msg, "</color>");
+ return StringUtility.Concat("<color=#", ColorToHexWithHash(color), ">", msg, "</color>");
}
@@ -794,6 +886,33 @@
return string.Format("{0:X2}{1:X2}{2:X2}", r, g, b);
}
}
+
+
+ //鍔熻兘鍝佽川鏂囧瓧棰滆壊锛屽摢浜涘姛鑳界敱缇庢湳鍐冲畾锛岀洰鍓嶇敤浜庡彜瀹�
+ public static Color GetFuncQualityColor(int quality)
+ {
+
+ switch (quality)
+ {
+ case 1:
+ // bbd5ff
+ return new Color32(187, 213, 255, 255);
+ case 2:
+ // e4bbfe
+ return new Color32(228, 187, 254, 255);
+ case 3:
+ // f7eba4
+ return new Color32(247, 235, 164, 255);
+ case 4:
+ // ffc096
+ return new Color32(255, 192, 150, 255);
+ case 5:
+ // fe9896
+ return new Color32(254, 152, 150, 255);
+ }
+ return Color.white;
+ }
+
@@ -838,17 +957,17 @@
// switch (config.Quality)
// {
// case 1:
- // return StringUtility.Contact("<color=#", bright ? "666666" : "dddddd", ">", msg, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "666666" : "dddddd", ">", msg, "</color>");
// case 2:
- // return StringUtility.Contact("<color=#", bright ? "00b337" : "66ff00", ">", msg, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "00b337" : "66ff00", ">", msg, "</color>");
// case 3:
- // return StringUtility.Contact("<color=#", bright ? "0066ff" : "00c6ff", ">", msg, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "0066ff" : "00c6ff", ">", msg, "</color>");
// case 4:
- // return StringUtility.Contact("<color=#", bright ? "ff00f6" : "f000ff", ">", msg, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "ff00f6" : "f000ff", ">", msg, "</color>");
// case 5:
- // return StringUtility.Contact("<color=#", bright ? "ff6600" : "ff9000", ">", msg, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "ff6600" : "ff9000", ">", msg, "</color>");
// case 6:
- // return StringUtility.Contact("<color=#", bright ? "ff0000" : "ff0000", ">", msg, "</color>");
+ // return StringUtility.Concat("<color=#", bright ? "ff0000" : "ff0000", ">", msg, "</color>");
// default:
// return msg;
// }
@@ -856,18 +975,22 @@
//鐗╁搧 鍚勫姛鑳藉搧璐� 浠庣簿鑹�1鍝佽川 瀵瑰簲 3寮�濮�
/// <summary>
- /// 棰滆壊瀹氫箟鏍规嵁鍒嗙粍澶勭悊锛屽鏅�氱墿鍝佺殑棰滆壊绮捐壇鏄�1寮�濮嬶紝鏍戝拰瑁呭涔熸槸绮楃硻1寮�濮嬶紝闇�瑕佽皟鏁村尮閰�
+ /// 棰滆壊瀹氫箟鏍规嵁鍒嗙粍澶勭悊锛屽鏅�氱墿鍝佺殑棰滆壊绮捐壇鏄�1寮�濮嬶紝鏍戝拰瑁呭涔熸槸绮楃硻1寮�濮嬶紝鍛芥牸鏄粠棰滆壊2寮�濮嬮渶瑕佽皟鏁村尮閰�
/// </summary>
/// <param name="itemColor"></param>
/// <param name="msg"></param>
/// <param name="bright"></param>
- /// <param name="colorGroupType">0 閫氱敤鍔熻兘鍝佽川鍒嗙粍绮捐壇鍒扮璇�</param>
+ /// <param name="colorGroupType">0 閫氱敤鍔熻兘鍝佽川鍒嗙粍绮捐壇鍒扮璇� 1 绁濈鍜岃澶囩敤 2鍛芥牸鐢�</param>
/// <returns></returns>
public static string AppendColor(int itemColor, string msg, bool bright = true, int colorGroupType = 0)
{
if (colorGroupType == 0)
{
itemColor = itemColor + 2;
+ }
+ else if (colorGroupType == 2)
+ {
+ itemColor = itemColor + 1;
}
switch (itemColor)
@@ -915,6 +1038,24 @@
case 28:
case 29:
return AppendColor(TextColType.itemyonghen, msg, bright);
+ case 30:
+ case 31:
+ case 32:
+ case 33:
+ case 34:
+ return AppendColor(TextColType.itemanjin, msg, bright);
+ case 35:
+ case 36:
+ case 37:
+ case 38:
+ case 39:
+ return AppendColor(TextColType.itemchuanqi, msg, bright);
+ case 40:
+ case 41:
+ case 42:
+ case 43:
+ case 44:
+ return AppendColor(TextColType.itemshenhua, msg, bright);
}
return msg;
@@ -978,9 +1119,16 @@
{1, PlayerDataType.Gold},
{2, PlayerDataType.GoldPaper},
{3, PlayerDataType.Silver},
+ {15, PlayerDataType.UnionLiven},
{41, PlayerDataType.default26},
+ {43, PlayerDataType.default34},
{42, PlayerDataType.default33},
{53, PlayerDataType.ChallengeVoucher},
+ {54, PlayerDataType.DailySpecials},
+ {55, PlayerDataType.OSGalaScore},
+ {57, PlayerDataType.QYScore},
+ {58, PlayerDataType.heroSkin},
+ {99, PlayerDataType.ExAttr11},
};
public static long GetMoneyCnt(int moneyType)
@@ -1080,7 +1228,7 @@
}
case 43:
{
- //鍑瘉绉垎
+ //灏嗛瓊
return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default34);
}
case 44:
@@ -1128,6 +1276,31 @@
//鎸戞垬鍑瘉
return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ChallengeVoucher);
}
+ case 54:
+ {
+ //鐗规儬鍗扮欢
+ return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.DailySpecials);
+ }
+ case 55:
+ {
+ //寮�鏈嶅簡鍏哥Н鍒�
+ return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.OSGalaScore);
+ }
+ case 56:
+ {
+ //缇よ嫳鎸戞垬浠�
+ return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.QunyingWDL);
+ }
+ case 57:
+ {
+ //缇よ嫳绉垎
+ return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.QYScore);
+ }
+ case 58:
+ {
+ //鏃惰璐у竵
+ return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.heroSkin);
+ }
case 98:
{
//杩囨湡鍨嬩唬閲戝埜
@@ -1149,16 +1322,22 @@
}
//鏄剧ず鏁伴噺, 鏍煎紡n/m, 瓒冲缁胯壊涓嶈冻绾㈣壊
- public static string ShowUseMoney(int moneyType, long useCnt, TextColType engoughColor = TextColType.Green)
+ public static string ShowUseMoney(int moneyType, long useCnt, bool showLargeNum = false)
{
long cnt = GetMoneyCnt(moneyType);
- return AppendColor(useCnt <= cnt ? engoughColor : TextColType.Red, $"{ReplaceLargeNum(cnt)}/{ReplaceLargeNum(useCnt)}");
+ if (showLargeNum)
+ return AppendColor(useCnt <= cnt ? TextColType.Green : TextColType.Red, $"{ReplaceLargeNum(cnt)}/{useCnt}");
+ else
+ return AppendColor(useCnt <= cnt ? TextColType.Green : TextColType.Red, $"{cnt}/{useCnt}");
}
- public static string ShowUseItem(PackType type, int itemId, long useCnt, TextColType engoughColor = TextColType.Green)
+ public static string ShowUseItem(PackType type, int itemId, long useCnt, bool showLargeNum = false, bool bright = true)
{
long cnt = PackManager.Instance.GetItemCountByID(type, itemId);
- return AppendColor(useCnt <= cnt ? engoughColor : TextColType.Red, $"{ReplaceLargeNum(cnt)}/{ReplaceLargeNum(useCnt)}");
+ if (showLargeNum)
+ return AppendColor(useCnt <= cnt ? TextColType.Green : TextColType.Red, $"{ReplaceLargeNum(cnt)}/{useCnt}", bright);
+ else
+ return AppendColor(useCnt <= cnt ? TextColType.Green : TextColType.Red, $"{cnt}/{useCnt}", bright);
}
@@ -1189,6 +1368,34 @@
return isEnough;
}
+ /// <param name="needTips">0 涓嶅搷搴� 1 寮规彁绀� 2 寮硅幏鍙栭�斿緞tips</param>
+ public static bool CheckItemCount(int itemId, long needCount, int needTips = 0)
+ {
+ if (needCount <= 0)
+ {
+ return true;
+ }
+ long haveCount = PackManager.Instance.GetItemCountByID(PackType.Item, itemId);
+ bool isEnough = haveCount >= needCount;
+
+ if (!isEnough)
+ {
+ if (needTips == 1)
+ {
+ ItemConfig itemConfig = ItemConfig.Get(itemId);
+ if (itemConfig != null)
+ {
+ SysNotifyMgr.Instance.ShowTip("LackItem", itemConfig.ItemName);
+ }
+ }
+ else if (needTips == 2)
+ {
+ ItemTipUtility.Show(itemId, true);
+ }
+ }
+
+ return isEnough;
+ }
#endregion
@@ -1281,7 +1488,7 @@
//bool pureChinese = Regex.IsMatch(name, "^[\u4e00-\u9fa5]+$");
//var chsCount = GetChsCount(name);
int length = Encoding.Default.GetBytes(name).Length;
- var maxlength = 14; //绾腑鏂囦笉寤鸿瓒呰繃7涓瓧
+ var maxlength = 21; //绾腑鏂囦笉寤鸿瓒呰繃7涓瓧
var minlength = 3;
if (length > maxlength)
{
@@ -1324,7 +1531,7 @@
// {
// return string.Empty;
// }
- // return StringUtility.Contact(GetEquipSuitName(itmeId, bright), itemConfig.ItemName);
+ // return StringUtility.Concat(GetEquipSuitName(itmeId, bright), itemConfig.ItemName);
// }
public static string GetStar(int star)
@@ -1367,10 +1574,10 @@
serverList.Add(serverName);
//澶暱浼氬鑷寸晫闈㈤《鐐规暟瓒呰繃65000
if (serverList.Count > 1000)
- return string.Join(", ", serverList.ToArray());
+ return string.Join(", ", serverList);
}
}
- return string.Join(", ", serverList.ToArray());
+ return string.Join(", ", serverList);
}
//涓嶅悓鐗堟湰鐜伴噾鐨勫崟浣嶄笉涓�鏍凤紝姣斿瓒婂崡鐩炬槸鏁存暟锛屼笅鍙戞槸鍘熷�硷紱缇庡厓鍜孯MB鏄皬鏁帮紝涓嬪彂鏄師鍊肩殑100
@@ -1387,18 +1594,59 @@
return content;
}
- //澶嶅埗鍒板壀璐存澘
- // TODO 鏆備笉鏀寔web鍚庣画琛ュ厖
+
+
public static void CopyToClipboard(string text)
{
+#if UNITY_WEBGL && !UNITY_EDITOR
+ LaunchUtility.UIHelper_CopyToClipboard(text);
+#else
GUIUtility.systemCopyBuffer = text;
+#endif
Debug.Log("鏂囧瓧宸插鍒跺埌鍓创鏉�: " + text);
}
-
+
//鑾峰彇鍓垏鏉垮唴瀹�
public static string GetClipboardText()
{
+#if UNITY_WEBGL && !UNITY_EDITOR
+ // WebGL涓嬫祻瑙堝櫒瀹夊叏闄愬埗锛屾棤娉曞悓姝ヨ鍙栧壀璐存澘
+ return string.Empty;
+#else
return GUIUtility.systemCopyBuffer;
+#endif
}
-
+
+ /// <summary>
+ /// 寮哄埗鍒锋柊Layout锛岃В鍐冲祵濂桳ayout鍜孋ontentSizeFitter鐨勯噸鍙犻棶棰�
+ /// </summary>
+ public static async UniTask ForceRefreshLayout(Transform transform)
+ {
+ await UniTask.DelayFrame(2);
+ // 鍒锋柊鎵�鏈塋ayout缁勪欢
+ var layouts = transform.GetComponentsInChildren<LayoutGroup>(true);
+ foreach (var layout in layouts)
+ {
+ LayoutRebuilder.ForceRebuildLayoutImmediate(layout.GetComponent<RectTransform>());
+ }
+ await UniTask.DelayFrame(2);
+ // 鍒锋柊鎵�鏈塋ayout缁勪欢
+ foreach (var layout in layouts)
+ {
+ LayoutRebuilder.ForceRebuildLayoutImmediate(layout.GetComponent<RectTransform>());
+ }
+
+ }
+
+
+ public static void ShowServersPanel(List<int> serverIDList)
+ {
+ if (UIManager.Instance.IsOpened<ServersSmallTipWin>())
+ {
+ UIManager.Instance.CloseWindow<ServersSmallTipWin>();
+ }
+ ServersSmallTipWin.serverIDList = serverIDList;
+ UIManager.Instance.OpenWindowAsync<ServersSmallTipWin>().Forget();
+ }
+
}
--
Gitblit v1.8.0