Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 0 additions & 84 deletions index.html

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public static class CoreParam
OfficialMatchDurationMilliseconds + GameTimeGuardSlackMilliseconds;
private const int MaximumSingleLiveTimeJumpMilliseconds = MaximumDisplayGameMilliseconds;
private static bool hasStableLiveGameTime;
private const int MaxTeamDisplayNameLength = 18;
private static readonly Dictionary<long, string> teamDisplayNames = new Dictionary<long, string>();

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

public static void ClearTeamDisplayNames()
{
teamDisplayNames.Clear();
}

public static void SetTeamDisplayName(long teamId, string displayName)
{
if (teamId <= 0)
{
return;
}

string normalized = NormalizeTeamDisplayName(displayName);
if (string.IsNullOrEmpty(normalized))
{
teamDisplayNames.Remove(teamId);
return;
}

teamDisplayNames[teamId] = normalized;
}

public static string GetTeamDisplayLabel(long teamId)
{
string fallback = $"队伍 {teamId}";
return teamDisplayNames.TryGetValue(teamId, out string displayName) && !string.IsNullOrWhiteSpace(displayName)
? $"{fallback}:{displayName}"
: fallback;
}

private static string NormalizeTeamDisplayName(string displayName)
{
if (string.IsNullOrWhiteSpace(displayName))
{
return string.Empty;
}

string normalized = displayName
.Replace('\r', ' ')
.Replace('\n', ' ')
.Replace('\t', ' ')
.Replace('<', '<')
.Replace('>', '>')
.Trim();

while (normalized.IndexOf(" ", StringComparison.Ordinal) >= 0)
{
normalized = normalized.Replace(" ", " ");
}

return normalized.Length > MaxTeamDisplayNameLength
? normalized.Substring(0, MaxTeamDisplayNameLength) + "…"
: normalized;
}

private static void DestroyAll<TKey>(Dictionary<TKey, GameObject> objects)
{
foreach (var kvp in objects)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,9 @@ private static string BuildTeamStatusText(
string memberStatus)
{
string accent = ColorUtility.ToHtmlStringRGB(GetTeamAccentColor(teamIndex - 1));
string teamLabel = CoreParam.GetTeamDisplayLabel(teamIndex);
return
$"<size=15><b><color=#{accent}>队伍 {teamIndex}</color>{WideGap(1)}得分:{score}</b></size>\n" +
$"<size=15><b><color=#{accent}>{teamLabel}</color>{WideGap(1)}得分:{score}</b></size>\n" +
$"原料:{material}{WideGap(1)}算力:{computePower}\n" +
$"工厂血量:{factoryHp}\n" +
$"科技等级:{techSummary}\n" +
Expand Down
Loading
Loading