Skip to content

Commit 8bd0739

Browse files
authored
show name
show name
2 parents 1c466aa + 9339f38 commit 8bd0739

13 files changed

Lines changed: 688 additions & 147 deletions

File tree

index.html

Lines changed: 0 additions & 84 deletions
This file was deleted.

interface/Unity/Unity-Live/Packages/com.eesast.interface.shared/Runtime/Scripts/Core/CoreParam.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public static class CoreParam
7575
OfficialMatchDurationMilliseconds + GameTimeGuardSlackMilliseconds;
7676
private const int MaximumSingleLiveTimeJumpMilliseconds = MaximumDisplayGameMilliseconds;
7777
private static bool hasStableLiveGameTime;
78+
private const int MaxTeamDisplayNameLength = 18;
79+
private static readonly Dictionary<long, string> teamDisplayNames = new Dictionary<long, string>();
7880

7981
public static Dictionary<long, MessageOfCharacter> characters = new Dictionary<long, MessageOfCharacter>();
8082
public static Dictionary<long, MessageOfTeam> teams = new Dictionary<long, MessageOfTeam>();
@@ -181,6 +183,61 @@ public static int ClampDisplayGameMilliseconds(int totalMilliseconds)
181183
return Math.Max(0, Math.Min(totalMilliseconds, MaximumDisplayGameMilliseconds));
182184
}
183185

186+
public static void ClearTeamDisplayNames()
187+
{
188+
teamDisplayNames.Clear();
189+
}
190+
191+
public static void SetTeamDisplayName(long teamId, string displayName)
192+
{
193+
if (teamId <= 0)
194+
{
195+
return;
196+
}
197+
198+
string normalized = NormalizeTeamDisplayName(displayName);
199+
if (string.IsNullOrEmpty(normalized))
200+
{
201+
teamDisplayNames.Remove(teamId);
202+
return;
203+
}
204+
205+
teamDisplayNames[teamId] = normalized;
206+
}
207+
208+
public static string GetTeamDisplayLabel(long teamId)
209+
{
210+
string fallback = $"队伍 {teamId}";
211+
return teamDisplayNames.TryGetValue(teamId, out string displayName) && !string.IsNullOrWhiteSpace(displayName)
212+
? $"{fallback}{displayName}"
213+
: fallback;
214+
}
215+
216+
private static string NormalizeTeamDisplayName(string displayName)
217+
{
218+
if (string.IsNullOrWhiteSpace(displayName))
219+
{
220+
return string.Empty;
221+
}
222+
223+
string normalized = displayName
224+
.Replace('\r', ' ')
225+
.Replace('\n', ' ')
226+
.Replace('\t', ' ')
227+
.Replace('<', '<')
228+
.Replace('>', '>')
229+
.Trim();
230+
231+
while (normalized.IndexOf(" ", StringComparison.Ordinal) >= 0)
232+
{
233+
normalized = normalized.Replace(" ", " ");
234+
}
235+
236+
return normalized.Length > MaxTeamDisplayNameLength
237+
? normalized.Substring(0, MaxTeamDisplayNameLength) + "…"
238+
: normalized;
239+
}
240+
184241
private static void DestroyAll<TKey>(Dictionary<TKey, GameObject> objects)
185242
{
186243
foreach (var kvp in objects)

interface/Unity/Unity-Live/Packages/com.eesast.interface.shared/Runtime/Scripts/UI/SimpleHud.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,9 @@ private static string BuildTeamStatusText(
445445
string memberStatus)
446446
{
447447
string accent = ColorUtility.ToHtmlStringRGB(GetTeamAccentColor(teamIndex - 1));
448+
string teamLabel = CoreParam.GetTeamDisplayLabel(teamIndex);
448449
return
449-
$"<size=15><b><color=#{accent}>队伍 {teamIndex}</color>{WideGap(1)}得分:{score}</b></size>\n" +
450+
$"<size=15><b><color=#{accent}>{teamLabel}</color>{WideGap(1)}得分:{score}</b></size>\n" +
450451
$"原料:{material}{WideGap(1)}算力:{computePower}\n" +
451452
$"工厂血量:{factoryHp}\n" +
452453
$"科技等级:{techSummary}\n" +

0 commit comments

Comments
 (0)