- Replace hardcoded color values with HudTheme references across files - Update ActivityProse, Chronicle, ChronicleHud, and others for consistency - Increment version to 0.28.25 in mod.json
88 lines
2.7 KiB
C#
88 lines
2.7 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace IdleSpectator;
|
|
|
|
/// <summary>
|
|
/// Screen-space count badges over multi-entry grave stacks (pooled, on-screen only).
|
|
/// </summary>
|
|
public static class GraveCountBadges
|
|
{
|
|
private const int PoolSize = 64;
|
|
private static readonly List<GraveMarkers.GraveStack> Scratch = new List<GraveMarkers.GraveStack>(256);
|
|
private static readonly List<Badge> Pool = new List<Badge>(PoolSize);
|
|
private static Transform _root;
|
|
private static bool _built;
|
|
|
|
private sealed class Badge
|
|
{
|
|
public GameObject Go;
|
|
public RectTransform Rt;
|
|
public Text Label;
|
|
}
|
|
|
|
/// <summary>Badges retired - stack size lives in Lore title. Kept so old pools hide cleanly.</summary>
|
|
public static void Hide()
|
|
{
|
|
for (int i = 0; i < Pool.Count; i++)
|
|
{
|
|
if (Pool[i].Go != null)
|
|
{
|
|
Pool[i].Go.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void Update()
|
|
{
|
|
Hide();
|
|
}
|
|
|
|
private static void EnsureBuilt()
|
|
{
|
|
if (_built)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Canvas canvas = HudCanvas.Resolve();
|
|
if (canvas == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
GameObject rootGo = new GameObject("IdleGraveCountBadges", typeof(RectTransform));
|
|
rootGo.transform.SetParent(canvas.transform, false);
|
|
_root = rootGo.transform;
|
|
RectTransform rootRt = rootGo.GetComponent<RectTransform>();
|
|
rootRt.anchorMin = Vector2.zero;
|
|
rootRt.anchorMax = Vector2.one;
|
|
rootRt.offsetMin = Vector2.zero;
|
|
rootRt.offsetMax = Vector2.zero;
|
|
|
|
for (int i = 0; i < PoolSize; i++)
|
|
{
|
|
GameObject go = new GameObject("Badge" + i, typeof(RectTransform), typeof(Image));
|
|
go.transform.SetParent(_root, false);
|
|
RectTransform rt = go.GetComponent<RectTransform>();
|
|
rt.sizeDelta = new Vector2(14f, 10f);
|
|
Image img = go.GetComponent<Image>();
|
|
img.color = HudTheme.ToolFill;
|
|
img.raycastTarget = false;
|
|
Text label = HudCanvas.MakeText(go.transform, "N", "2", 8);
|
|
RectTransform lrt = label.GetComponent<RectTransform>();
|
|
lrt.anchorMin = Vector2.zero;
|
|
lrt.anchorMax = Vector2.one;
|
|
lrt.offsetMin = Vector2.zero;
|
|
lrt.offsetMax = Vector2.zero;
|
|
label.alignment = TextAnchor.MiddleCenter;
|
|
label.color = HudTheme.AccentGold;
|
|
label.raycastTarget = false;
|
|
go.SetActive(false);
|
|
Pool.Add(new Badge { Go = go, Rt = rt, Label = label });
|
|
}
|
|
|
|
_built = true;
|
|
}
|
|
}
|