Skip to content

Commit

Permalink
Update TooltipHelper.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
HikariCalyx committed Apr 6, 2024
1 parent e1ec108 commit 4a03724
Showing 1 changed file with 68 additions and 31 deletions.
99 changes: 68 additions & 31 deletions WzComparerR2.MapRender/UI/TooltipHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,43 @@

namespace WzComparerR2.MapRender.UI
{

public static class TooltipHelper
{
private static string ToCJKNumberExpr(long value)
{
var sb = new StringBuilder(16);
bool firstPart = true;
if (value >= 1_0000_0000_0000)
{
long part = value / 1_0000_0000;
sb.AppendFormat("{0}兆", part); // Korean: 조, Chinese+Japanese: 兆
value -= part * 1_0000_0000;
firstPart = false;
}
if (value >= 1_0000_0000)
{
long part = value / 1_0000_0000;
sb.AppendFormat("{0}億", part); // Korean: 억, TradChinese+Japanese: 億, SimpChinese: 亿
value -= part * 1_0000_0000;
firstPart = false;
}
if (value >= 1_0000)
{
long part = value / 1_0000;
sb.Append(firstPart ? null : " ");
sb.AppendFormat("{0}万", part); // Korean: 만, TradChinese: 萬, SimpChinese+Japanese: 万
value -= part * 1_0000;
firstPart = false;
}
if (value > 0)
{
sb.Append(firstPart ? null : " ");
sb.AppendFormat("{0}", value);
}

return sb.Length > 0 ? sb.ToString() : "0";
}
public static TextBlock PrepareTextBlock(IWcR2Font font, string text, ref Vector2 pos, Color color)
{
Vector2 size = font.MeasureString(text);
Expand Down Expand Up @@ -68,35 +103,35 @@ public static TextBlock[] Prepare(LifeInfo info, MapRenderFonts fonts, out Vecto
var current = Vector2.Zero;
size = Vector2.Zero;

blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "Lv: " + info.level + (info.boss ? " (Boss)" : null), ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "レベル: " + info.level + (info.boss ? " (ボス)" : null), ref current, Color.White, ref size.X));


blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "HP: " + info.maxHP.ToString("N0"), ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "MP: " + info.maxMP.ToString("N0"), ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "Physical Damage: " + info.PADamage.ToString("N0"), ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "Magic Damage: " + info.MADamage.ToString("N0"), ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "PDRate: " + info.PDRate + "%", ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "MDRate: " + info.MDRate + "%", ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "EXP: " + info.exp.ToString("N0"), ref current, Color.White, ref size.X));
if (info.undead) blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "Undead: Yes", ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "HP: " + ToCJKNumberExpr(info.maxHP), ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "MP: " + ToCJKNumberExpr(info.maxMP), ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "物理ダメージ: " + ToCJKNumberExpr(info.PADamage), ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "魔法ダメージ: " + ToCJKNumberExpr(info.MADamage), ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "物理防御率: " + info.PDRate + "%", ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "魔法防御率: " + info.MDRate + "%", ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "経験値: " + ToCJKNumberExpr(info.exp), ref current, Color.White, ref size.X));
if (info.undead) blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "不死型", ref current, Color.White, ref size.X));
StringBuilder sb;
if ((sb = GetLifeElemAttrString(ref info.elemAttr)).Length > 0)
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "Element: " + sb.ToString().TrimEnd().TrimEnd(','), ref current, Color.White, ref size.X));
blocks.Add(PrepareTextLine(fonts.TooltipContentFont, "エレメント: " + sb.ToString(), ref current, Color.White, ref size.X));
size.Y = current.Y;

return blocks.ToArray();
}

public static StringBuilder GetLifeElemAttrString(ref LifeInfo.ElemAttr elemAttr)
{
StringBuilder sb = new StringBuilder();//original value: 14
sb.Append(GetElemResistanceString("Physical", elemAttr.P));
sb.Append(GetElemResistanceString("Holy", elemAttr.H));
sb.Append(GetElemResistanceString("Fire", elemAttr.F));
sb.Append(GetElemResistanceString("Ice", elemAttr.I));
sb.Append(GetElemResistanceString("Poison", elemAttr.S));
sb.Append(GetElemResistanceString("Lightning", elemAttr.L));
sb.Append(GetElemResistanceString("Dark", elemAttr.D));
StringBuilder sb = new StringBuilder(14);
sb.Append(GetElemResistanceString("", elemAttr.I));
sb.Append(GetElemResistanceString("", elemAttr.L));
sb.Append(GetElemResistanceString("", elemAttr.F));
sb.Append(GetElemResistanceString("", elemAttr.S));
sb.Append(GetElemResistanceString("", elemAttr.H));
sb.Append(GetElemResistanceString("", elemAttr.D));
sb.Append(GetElemResistanceString("", elemAttr.P));
return sb;
}

Expand All @@ -105,10 +140,10 @@ public static string GetElemResistanceString(string elemName, LifeInfo.ElemResis
string e = null;
switch (resist)
{
case LifeInfo.ElemResistance.Immune: e = " immune, "; break;
case LifeInfo.ElemResistance.Resist: e = " strong, "; break;
case LifeInfo.ElemResistance.Immune: e = "× "; break;
case LifeInfo.ElemResistance.Resist: e = " "; break;
case LifeInfo.ElemResistance.Normal: e = null; break;
case LifeInfo.ElemResistance.Weak: e = " weak, "; break;
case LifeInfo.ElemResistance.Weak: e = " "; break;
}
return e != null ? (elemName + e) : null;
}
Expand All @@ -117,16 +152,16 @@ public static string GetPortalTypeString(int pType)
{
switch (pType)
{
case 0: return "Starting Point";
case 1: return "Normal (Hidden)";
case 2: return "Normal";
case 3: return "Normal (Collision)";
case 6: return "Mystic Door (Warp)";
case 7: return "Script";
case 8: return "Script Hidden";
case 9: return "Script (Collision)";
case 10: return "Invisible Portal";
case 12: return "Collision Vertical Jump Portal";
case 0: return "地図の誕生点";
case 1: return "一般ポータル (非表示)";
case 2: return "一般ポータル";
case 3: return "一般ポータル (タッチ)";
case 6: return "時空ゲートポイント";
case 7: return "スクリプトポータル";
case 8: return "スクリプトポータル (非表示)";
case 9: return "スクリプトポータル (タッチ)";
case 10: return "マップ内のポータル";
case 12: return "弾性デバイス";
default: return null;
}
}
Expand Down Expand Up @@ -211,6 +246,8 @@ public virtual Color GetColor(string colorID)
return Color.White;
}
}


}
}
}

0 comments on commit 4a03724

Please sign in to comment.