Snapshot for release 2026.10.28.2 (internal 4a5e2d7)
This commit is contained in:
parent
8728446a27
commit
f9ae10d692
14 changed files with 1069 additions and 115 deletions
|
|
@ -396,6 +396,13 @@ internal static class BusyCountHooks
|
|||
public static void ResetSession()
|
||||
{
|
||||
_lastThisPtr = IntPtr.Zero;
|
||||
// The next session's ClientUISystem starts at 0, and so does our copy (2026-10-28). Kept,
|
||||
// a count left up by a logout mid-action stayed up for good: the watchdog can't clear it
|
||||
// without the pointer, switches itself off, and is armed again only by a 0 -> 1 step, so
|
||||
// GetBusyState answered "busy" until the client restarted (the item bar refused every use
|
||||
// after a relog; RynthAi's waiting-on-the-server test reads the same count).
|
||||
Interlocked.Exchange(ref _netBusyCount, 0);
|
||||
Volatile.Write(ref _busyBecamePositiveTickMs, 0);
|
||||
Volatile.Write(ref _realBusyPositiveTickMs, 0);
|
||||
_realBusyNegativeSince = 0;
|
||||
lock (_directLock)
|
||||
|
|
|
|||
|
|
@ -1231,16 +1231,17 @@ internal static class RynthCoreChatCommands
|
|||
/// <summary>
|
||||
/// /rv plates (alias /rc plates): the RynthVision nameplates and combat text
|
||||
/// (ImGui/MonsterHud). Alone it toggles the monster plates; on|off, all on|off,
|
||||
/// self|debuffs|others|numbers|gains [sub] [on|off], all|engaged, dist|max|scale|
|
||||
/// opacity|lift <n>, names|hp|level|weak|distance|fade|click [on|off], reset, status.
|
||||
/// Every change is saved.
|
||||
/// self|debuffs|others|numbers|gains [sub] [on|off], debuffs size / self debuffs size <50-200>,
|
||||
/// all|engaged, dist|max|scale|opacity|lift <n>, names|hp|level|weak|distance|fade|click [on|off],
|
||||
/// reset, status. Every change is saved.
|
||||
/// </summary>
|
||||
private static void HandlePlatesCommand(string args)
|
||||
{
|
||||
const string usage = "Usage: /rv plates [on|off] | all on|off | self [numbers|name|firstperson|lock] [on|off] | " +
|
||||
"self fixed|follow|unlock|reset | " +
|
||||
"debuffs [on|off] | others [on|off] | numbers [dealt|taken|heals|kills] [on|off] | " +
|
||||
"gains [xp|lum|radiance] [on|off] | npcs [on|off] | npcs dist <yd>|max <n> | players [on|off] | all|engaged |dist <yd>|max <n>|scale <x>|opacity <x>|lift <m> | " +
|
||||
const string usage = "Usage: /rv plates [on|off] | all on|off | self [numbers|name|firstperson|lock|debuffs] [on|off] | " +
|
||||
"self fixed|follow|unlock|reset | self debuffs size <50-200%> | " +
|
||||
"debuffs [on|off] | debuffs size <50-200%> | others [on|off] | numbers [dealt|taken|heals|kills] [on|off] | " +
|
||||
"gains [xp|lum|radiance] [on|off] | npcs [on|off] | npcs dist <yd>|max <n> | players [on|off] | portals [on|off] | portals dist <yd> | " +
|
||||
"all|engaged |dist <yd>|max <n>|scale <x>|opacity <x>|lift <m> | " +
|
||||
"names|hp|level|weak|distance|fade|click [on|off] | reset | status | test";
|
||||
if (!ImGuiBackend.Hud.HudFeed.VisionInstalled)
|
||||
{
|
||||
|
|
@ -1285,6 +1286,19 @@ internal static class RynthCoreChatCommands
|
|||
case "numbers": case "text": S.SelfNumbers = Flag(subValue, S.SelfNumbers); break;
|
||||
case "name": S.SelfName = Flag(subValue, S.SelfName); break;
|
||||
case "firstperson": case "fp": S.SelfHideFirstPerson = Flag(subValue, S.SelfHideFirstPerson); break;
|
||||
// "Debuffs on you": on|off, or its icon size ("self debuffs size 150").
|
||||
case "debuffs": case "debuff":
|
||||
if (subValue != null && subValue.Equals("size", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (!S.TryParseDebuffIconSize(parts.Length > 3 ? parts[3] : null, out int sdi))
|
||||
{
|
||||
Reply($"usage: /rv plates self debuffs size {S.MinDebuffIconSize}-{S.MaxDebuffIconSize} (percent; now {S.SelfDebuffIconSize}%)");
|
||||
return;
|
||||
}
|
||||
S.SelfDebuffIconSize = sdi;
|
||||
}
|
||||
else S.SelfDebuffs = Flag(subValue, S.SelfDebuffs);
|
||||
break;
|
||||
// Placement: fixed on screen (drag it while unlocked) or following the character.
|
||||
case "fixed": case "screen": S.SelfPlacement = ImGuiBackend.Hud.SelfPlacement.Fixed; break;
|
||||
case "follow": case "world": S.SelfPlacement = ImGuiBackend.Hud.SelfPlacement.Follow; break;
|
||||
|
|
@ -1318,7 +1332,18 @@ internal static class RynthCoreChatCommands
|
|||
S.KeepOnScreen = Flag(value, S.KeepOnScreen); break;
|
||||
case "debuffs":
|
||||
case "debuff":
|
||||
S.ShowDebuffs = Flag(value, S.ShowDebuffs); break;
|
||||
if (sub == "size")
|
||||
{
|
||||
// The monster plates' icon size ("debuffs size 150"); your own row's is "self debuffs size".
|
||||
if (!S.TryParseDebuffIconSize(subValue, out int mdi))
|
||||
{
|
||||
Reply($"usage: /rv plates debuffs size {S.MinDebuffIconSize}-{S.MaxDebuffIconSize} (percent; now {S.MonsterDebuffIconSize}%)");
|
||||
return;
|
||||
}
|
||||
S.MonsterDebuffIconSize = mdi;
|
||||
}
|
||||
else S.ShowDebuffs = Flag(value, S.ShowDebuffs);
|
||||
break;
|
||||
case "others":
|
||||
S.ShowOthersDebuff = Flag(value, S.ShowOthersDebuff); break;
|
||||
case "numbers":
|
||||
|
|
@ -1395,6 +1420,17 @@ internal static class RynthCoreChatCommands
|
|||
default: Reply(usage); return;
|
||||
}
|
||||
break;
|
||||
case "portals":
|
||||
case "portal":
|
||||
switch (sub)
|
||||
{
|
||||
case null: S.PortalNames = Flag(subValue, S.PortalNames); break;
|
||||
case "dist": case "range":
|
||||
if (!TryNum(subValue, out float pd)) { Reply("usage: /rv plates portals dist 5-120"); return; }
|
||||
S.PortalMaxDistance = Math.Clamp(pd, S.MinPortalDistance, S.MaxPortalDistanceLimit); break;
|
||||
default: Reply(usage); return;
|
||||
}
|
||||
break;
|
||||
case "players":
|
||||
S.PlayerNames = Flag(value, S.PlayerNames); break;
|
||||
case "playerbars": S.PlayerBars = Flag(value, S.PlayerBars); break;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@
|
|||
//
|
||||
// Moved out of MonsterHud.PaintIcons unchanged (2026-10-27) so the player
|
||||
// plate can draw the same row; the monster plates look exactly as before.
|
||||
// Sizes (2026-10-28): every length comes from DebuffRowMetrics (PlateMetrics.cs),
|
||||
// the plate's scale x its own "Debuff icon size" setting (monster plates and
|
||||
// your plate apart, neither tied to a text size); the stack digit and "+N"
|
||||
// scale the plate's small text by it. At 100 % the row is exactly as before.
|
||||
// Render thread only. Engine-owned statics.
|
||||
// ============================================================================
|
||||
|
||||
|
|
@ -59,35 +63,24 @@ internal static class DebuffIconRow
|
|||
/// The row centred on <paramref name="cx"/> with its top at <paramref name="top"/>:
|
||||
/// <paramref name="count"/> kinds (may exceed <paramref name="icons"/>' length: the rest
|
||||
/// show as "+N"), then the "debuffed by others" marker when <paramref name="others"/>.
|
||||
/// <paramref name="sz"/> is the icon square, <paramref name="smallFont"/>/<paramref name="smallSize"/>
|
||||
/// draw the stack digit and "+N"; <paramref name="overflowKey"/>/<paramref name="overflowText"/>
|
||||
/// <paramref name="row"/> holds every length (the plate's scale x its icon size setting);
|
||||
/// <paramref name="smallFont"/>/<paramref name="smallSize"/> are the plate's small text, which the
|
||||
/// stack digit and "+N" scale by the icon size; <paramref name="overflowKey"/>/<paramref name="overflowText"/>
|
||||
/// cache the "+N" string per row. <paramref name="now"/> is Stopwatch ticks.
|
||||
/// </summary>
|
||||
internal static void Paint(ImDrawListPtr dl, DebuffIcon[] icons, int count, bool others, float sz,
|
||||
internal static void Paint(ImDrawListPtr dl, DebuffIcon[] icons, int count, bool others, in DebuffRowMetrics row,
|
||||
ImFontPtr smallFont, float smallSize, ref int overflowKey, ref string overflowText,
|
||||
float cx, float top, float k, float a, long now)
|
||||
float cx, float top, float a, long now)
|
||||
{
|
||||
float gap = MathF.Max(2f, MathF.Round(2f * k));
|
||||
int shown = count > icons.Length ? icons.Length - 1 : count;
|
||||
int overflow = count - shown;
|
||||
string more = "";
|
||||
float moreW = 0f;
|
||||
if (overflow > 0)
|
||||
{
|
||||
if (overflow != overflowKey)
|
||||
{
|
||||
overflowKey = overflow;
|
||||
overflowText = "+" + overflow.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
more = overflowText;
|
||||
moreW = MonsterHud.TextWidth(smallFont, smallSize, more) + 4f * k;
|
||||
}
|
||||
int slots = shown + (others ? 1 : 0);
|
||||
float rowW = slots * sz + Math.Max(0, slots - 1) * gap + (overflow > 0 ? gap + moreW : 0f);
|
||||
float sz = row.Icon, gap = row.Gap;
|
||||
int shown = Prepare(icons.Length, count, in row, ref smallFont, ref smallSize, ref overflowKey, ref overflowText,
|
||||
out int overflow, out string more, out float moreTextW);
|
||||
float moreW = overflow > 0 ? row.MoreWidth(moreTextW) : 0f;
|
||||
float rowW = row.Width(shown + (others ? 1 : 0), overflow > 0, moreTextW);
|
||||
float x = MathF.Round(cx - rowW * 0.5f);
|
||||
float glyphPx = MathF.Round(sz * 0.8f);
|
||||
float glyphPx = row.Glyph;
|
||||
ImFontPtr iconFont = ImGuiFonts.Sharp(glyphPx, bold: false); // the icons are merged into every bake
|
||||
float lineH = MathF.Max(1f, MathF.Round(1.5f * k));
|
||||
float lineH = row.LineH;
|
||||
|
||||
for (int i = 0; i < shown; i++)
|
||||
{
|
||||
|
|
@ -100,20 +93,20 @@ internal static class DebuffIconRow
|
|||
|
||||
var i0 = new Vector2(x, top);
|
||||
var i1 = i0 + new Vector2(sz, sz);
|
||||
dl.AddRectFilled(i0, i1, MonsterHud.Mul(IconBack, a), 2f * k);
|
||||
dl.AddRect(i0, i1, MonsterHud.Mul(tint, a * 0.55f * blink), 2f * k, ImDrawFlags.None, 1f);
|
||||
dl.AddRectFilled(i0, i1, MonsterHud.Mul(IconBack, a), row.Round);
|
||||
dl.AddRect(i0, i1, MonsterHud.Mul(tint, a * 0.55f * blink), row.Round, ImDrawFlags.None, 1f);
|
||||
PhosphorIcons.DrawCentered(dl, iconFont, glyphPx, KindGlyph[kind < KindGlyph.Length ? kind : KindGlyph.Length - 1],
|
||||
i0, new Vector2(sz, sz), MonsterHud.Mul(tint, a * blink));
|
||||
if (ic.Stack > 1 && ic.Stack < StackDigits.Length)
|
||||
{
|
||||
string digit = StackDigits[ic.Stack];
|
||||
float ds = MathF.Round(smallSize * 0.85f);
|
||||
var dp = new Vector2(i1.X - MonsterHud.TextWidth(smallFont, ds, digit) + 1f, i0.Y - 2f);
|
||||
var dp = new Vector2(i1.X - MonsterHud.TextWidth(smallFont, ds, digit) + row.DigitDx, i0.Y - row.DigitDy);
|
||||
MonsterHud.OutlinedText(dl, smallFont, ds, dp, a, digit);
|
||||
dl.AddText(smallFont, ds, dp, MonsterHud.Mul(MonsterHud.HpText, a), digit);
|
||||
}
|
||||
// Countdown: a line under the icon that shrinks to nothing at expiry.
|
||||
float ly = i1.Y + 1f;
|
||||
float ly = i1.Y + row.LineGap;
|
||||
dl.AddRectFilled(new Vector2(i0.X, ly), new Vector2(i1.X, ly + lineH), MonsterHud.Mul(MonsterHud.Outline, a * 0.8f));
|
||||
if (frac > 0f)
|
||||
dl.AddRectFilled(new Vector2(i0.X, ly), new Vector2(i0.X + MathF.Max(1f, sz * frac), ly + lineH), MonsterHud.Mul(tint, a * blink));
|
||||
|
|
@ -131,8 +124,50 @@ internal static class DebuffIconRow
|
|||
if (others)
|
||||
{
|
||||
var i0 = new Vector2(x, top);
|
||||
dl.AddRectFilled(i0, i0 + new Vector2(sz, sz), MonsterHud.Mul(IconBack, a * 0.8f), 2f * k);
|
||||
dl.AddRectFilled(i0, i0 + new Vector2(sz, sz), MonsterHud.Mul(IconBack, a * 0.8f), row.Round);
|
||||
PhosphorIcons.DrawCentered(dl, iconFont, glyphPx, PhosphorIcons.UsersThree, i0, new Vector2(sz, sz), MonsterHud.Mul(OthersTint, a * 0.8f));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The row's width as <see cref="Paint"/> lays it out (same arguments): the plates' layout uses it so
|
||||
/// their box (crowding, clicks, the screen clamp) holds an enlarged row.
|
||||
/// </summary>
|
||||
internal static float Width(int capacity, int count, bool others, in DebuffRowMetrics row,
|
||||
ImFontPtr smallFont, float smallSize, ref int overflowKey, ref string overflowText)
|
||||
{
|
||||
int shown = Prepare(capacity, count, in row, ref smallFont, ref smallSize, ref overflowKey, ref overflowText,
|
||||
out int overflow, out _, out float moreTextW);
|
||||
return row.Width(shown + (others ? 1 : 0), overflow > 0, moreTextW);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// How many icons show (the last slot makes room for "+N" when more kinds than fit), the "+N" string and
|
||||
/// its width, and the row's text (stack digit, "+N"): the plate's small text scaled by the icon size, from
|
||||
/// the smallest bake at least that big (at 100 % the plate's own font and size, untouched).
|
||||
/// </summary>
|
||||
private static int Prepare(int capacity, int count, in DebuffRowMetrics row, ref ImFontPtr font, ref float size,
|
||||
ref int overflowKey, ref string overflowText, out int overflow, out string more, out float moreTextW)
|
||||
{
|
||||
if (row.Scale != 1f)
|
||||
{
|
||||
size = row.TextSize(size);
|
||||
font = ImGuiFonts.Sharp(size, bold: false);
|
||||
}
|
||||
int shown = count > capacity ? capacity - 1 : count;
|
||||
overflow = count - shown;
|
||||
more = "";
|
||||
moreTextW = 0f;
|
||||
if (overflow > 0)
|
||||
{
|
||||
if (overflow != overflowKey)
|
||||
{
|
||||
overflowKey = overflow;
|
||||
overflowText = "+" + overflow.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
more = overflowText;
|
||||
moreTextW = MonsterHud.TextWidth(font, size, more);
|
||||
}
|
||||
return shown;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,8 +33,10 @@
|
|||
// same scan picks the name-only labels: non-attackable creatures (NPCs,
|
||||
// vendors; summoned pets skipped) within NpcMaxDistance, nearest first,
|
||||
// capped at MaxNpcLabels apart from the plates (and players, if "Player
|
||||
// names" is on). Each object is classified once (Classes). The same tick
|
||||
// polls the player's XP / Luminance for the gain text.
|
||||
// names" is on), and portals' names ("Portal names", 2026-10-28) within
|
||||
// PortalMaxDistance, capped at MaxPortalLabels on their own. Each object
|
||||
// is classified once (Classes, PlateClass: ITEM_TYPE creature / portal).
|
||||
// The same tick polls the player's XP / Luminance for the gain text.
|
||||
// Draw (inside the ImGui frame): every frame each chosen monster's LIVE
|
||||
// position is read (main thread, a handful of objects) and projected with
|
||||
// the engine's camera capture (GameMatrixCapture), so plates stick to
|
||||
|
|
@ -72,7 +74,6 @@ internal static class MonsterHud
|
|||
private const int SnapshotPeriodMs = 250; // monster list refresh (4 Hz)
|
||||
private const double AttackerMemorySec = 20; // "hit you recently"
|
||||
private const double HurtMemorySec = 60; // "hurt recently" (engaged filter)
|
||||
private const uint TypeCreature = 0x10; // ITEM_TYPE TYPE_CREATURE
|
||||
private const uint BfPlayer = 0x8; // PublicWeenieDesc BF_PLAYER
|
||||
private const uint BfVendor = 0x200; // PublicWeenieDesc BF_VENDOR
|
||||
private const uint PetOwnerIid = 44; // PropertyInstanceId PetOwner (summoned pets)
|
||||
|
|
@ -143,7 +144,8 @@ internal static class MonsterHud
|
|||
public bool Others; // "debuffed by others" marker
|
||||
|
||||
// Layout (this frame)
|
||||
public float Width, Height, BarW, BarH, NameSize, SmallSize, BelowBar, IconSize;
|
||||
public float Width, Height, BarW, BarH, NameSize, SmallSize, BelowBar;
|
||||
public DebuffRowMetrics Row; // the debuff row's lengths (k x "Debuff icon size")
|
||||
public ImFontPtr NameFont, SmallFont;
|
||||
public float NameW, BadgeW;
|
||||
|
||||
|
|
@ -160,6 +162,9 @@ internal static class MonsterHud
|
|||
private sealed record WeakTag(string Label, uint Color, string Icon);
|
||||
|
||||
private const float DefaultHeadHeight = 2.0f;
|
||||
// Portals: the snapshot has no model height, so a fixed lift over the portal's origin (its foot)
|
||||
// that clears the top of a standard swirl. "Height lift" in the settings adds to it, as to every plate.
|
||||
private const float PortalLabelHeight = 3.5f;
|
||||
// A player's health is only known from what the game happened to tell us; a reading older than this is not drawn.
|
||||
private const long PlayerBarMemorySec = 90;
|
||||
// A size from the table is the top of the model: a hand's width above it for the plate, within sane bounds.
|
||||
|
|
@ -169,14 +174,16 @@ internal static class MonsterHud
|
|||
private static readonly List<Plate> Placed = new(64);
|
||||
private static readonly List<(uint Id, float D2)> Candidates = new(128);
|
||||
private static readonly List<(uint Id, float D2)> LabelCandidates = new(64);
|
||||
private static readonly List<(uint Id, float D2)> PortalCandidates = new(16);
|
||||
private static readonly List<uint> Evict = new(16);
|
||||
|
||||
// What each live object is, worked out once per id (item type, BF_PLAYER, BF_VENDOR and
|
||||
// PetOwner never change), so the 4 Hz scan skips non-creatures with one lookup and the
|
||||
// PetOwner never change), so the 4 Hz scan skips other objects with one lookup and the
|
||||
// monster pick no longer reads the bitfield live. Attackable is NOT cached: it is read
|
||||
// from the snapshot every scan, as before. Entries not seen for a while are pruned.
|
||||
private const byte ClsUnknown = 0, ClsOther = 1, ClsCreature = 2, ClsVendor = 3, ClsPlayer = 4, ClsPet = 5;
|
||||
private const byte ClsCreatureNoPwd = 6; // a creature whose PWD isn't in the snapshot yet: never cached
|
||||
private const byte ClsUnknown = PlateClass.Unknown, ClsOther = PlateClass.Other, ClsCreature = PlateClass.Creature,
|
||||
ClsVendor = PlateClass.Vendor, ClsPlayer = PlateClass.Player, ClsPet = PlateClass.Pet, ClsPortal = PlateClass.Portal;
|
||||
private const byte ClsCreatureNoPwd = PlateClass.CreatureNoPwd; // a creature whose PWD isn't in the snapshot yet: never cached
|
||||
private struct ObjClass { public byte Cls; public int Seen; }
|
||||
private static readonly Dictionary<uint, ObjClass> Classes = new(512);
|
||||
private static readonly List<uint> ClassEvict = new(64);
|
||||
|
|
@ -263,8 +270,9 @@ internal static class MonsterHud
|
|||
// "the Drudge you hit" among them) when the plates themselves are off.
|
||||
bool monsters = MonsterHudSettings.Enabled;
|
||||
bool trackMonsters = monsters || MonsterHudSettings.Numbers;
|
||||
// Name-only labels over NPCs (and, if asked, players): their own switches and cap.
|
||||
bool track = trackMonsters || MonsterHudSettings.NpcNames || MonsterHudSettings.PlayerNames || MonsterHudSettings.PlayerBars;
|
||||
// Name-only labels over NPCs (and, if asked, players) and over portals: their own switches and caps.
|
||||
bool track = trackMonsters || MonsterHudSettings.NpcNames || MonsterHudSettings.PlayerNames || MonsterHudSettings.PlayerBars ||
|
||||
MonsterHudSettings.PortalNames;
|
||||
if (!track) ClearPlates();
|
||||
SetDamageSubscription(monsters && MonsterHudSettings.ShowWeakness);
|
||||
if (monsters && MonsterHudSettings.ShowDebuffs) PortalSpellTable.EnsureLoadQueued();
|
||||
|
|
@ -369,10 +377,16 @@ internal static class MonsterHud
|
|||
float npcD2 = npcD * npcD;
|
||||
float npcTargetD2 = MathF.Max(npcD2, 100f * 100f); // a selected NPC keeps its name further out too
|
||||
bool targetIsLabel = false;
|
||||
bool portalNames = MonsterHudSettings.PortalNames;
|
||||
float portalD = MonsterHudSettings.PortalMaxDistance;
|
||||
float portalD2 = portalD * portalD;
|
||||
float portalTargetD2 = MathF.Max(portalD2, 100f * 100f); // and a selected portal
|
||||
bool targetIsPortal = false;
|
||||
|
||||
int pass = ++_classPass;
|
||||
Candidates.Clear();
|
||||
LabelCandidates.Clear();
|
||||
PortalCandidates.Clear();
|
||||
uint[] ids = ClientObjectHooks.LiveObjectIds;
|
||||
for (int i = 0; i < ids.Length; i++)
|
||||
{
|
||||
|
|
@ -390,9 +404,15 @@ internal static class MonsterHud
|
|||
}
|
||||
if (cls == ClsOther || cls == ClsUnknown) continue;
|
||||
|
||||
// Monster plate (attackable creature) or name label (NPC / vendor, player)?
|
||||
bool label;
|
||||
if (cls == ClsPlayer)
|
||||
// Monster plate (attackable creature), name label (NPC / vendor, player) or portal name?
|
||||
bool label, portal = false;
|
||||
if (cls == ClsPortal)
|
||||
{
|
||||
// A portal: its name only, from its own list and cap.
|
||||
if (!portalNames) continue;
|
||||
label = portal = true;
|
||||
}
|
||||
else if (cls == ClsPlayer)
|
||||
{
|
||||
// Players never get a monster plate (attackable in PK or not).
|
||||
if (!playerNames) continue;
|
||||
|
|
@ -419,7 +439,13 @@ internal static class MonsterHud
|
|||
if (!TryOffset(pCell, cell, out float ox, out float oy)) continue;
|
||||
float dx = x + ox - px, dy = y + oy - py, dz = z - pz;
|
||||
float d2 = dx * dx + dy * dy + dz * dz;
|
||||
if (label)
|
||||
if (portal)
|
||||
{
|
||||
if (d2 > (id == target ? portalTargetD2 : portalD2)) continue;
|
||||
PortalCandidates.Add((id, d2));
|
||||
if (id == target) targetIsPortal = true;
|
||||
}
|
||||
else if (label)
|
||||
{
|
||||
if (d2 > (id == target ? npcTargetD2 : npcD2)) continue;
|
||||
LabelCandidates.Add((id, d2));
|
||||
|
|
@ -433,6 +459,7 @@ internal static class MonsterHud
|
|||
}
|
||||
Candidates.Sort(ByD2);
|
||||
LabelCandidates.Sort(ByD2);
|
||||
PortalCandidates.Sort(ByD2);
|
||||
if ((pass & 63) == 0) PruneClasses(pass);
|
||||
|
||||
foreach (Plate p in Plates.Values) p.Chosen = false;
|
||||
|
|
@ -493,6 +520,28 @@ internal static class MonsterHud
|
|||
if (isTarget) targetIsLabel = false; // found: the cap applies again
|
||||
}
|
||||
|
||||
// ── Portal names: their own cap, so a town's NPCs never push them out ──
|
||||
int portalCap = MonsterHudSettings.MaxPortalLabels;
|
||||
int portals = 0;
|
||||
for (int i = 0; i < PortalCandidates.Count; i++)
|
||||
{
|
||||
uint id = PortalCandidates[i].Id;
|
||||
bool isTarget = id == target;
|
||||
if (portals >= portalCap && !isTarget)
|
||||
{
|
||||
if (!targetIsPortal) break;
|
||||
continue; // keep scanning only to find the target
|
||||
}
|
||||
if (!ClientObjectHooks.TryGetSnapshotName(id, out string name) || name.Length == 0) continue;
|
||||
|
||||
Plate plate = GetPlate(id, RadarKind.Portal);
|
||||
plate.WithBar = false;
|
||||
if (name != plate.Name) plate.Name = name;
|
||||
plate.HeadHeight = PortalLabelHeight;
|
||||
portals++;
|
||||
if (isTarget) targetIsPortal = false;
|
||||
}
|
||||
|
||||
// Plates no longer chosen fade out in Draw and are evicted at zero alpha.
|
||||
}
|
||||
|
||||
|
|
@ -511,14 +560,15 @@ internal static class MonsterHud
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// What an object is, from the main-thread snapshots only (no AC call): not a creature,
|
||||
/// a player, a summoned pet, a vendor or another creature. ClsUnknown / ClsCreatureNoPwd
|
||||
/// when the snapshots don't have it yet (asked again next scan).
|
||||
/// What an object is, from the main-thread snapshots only (no AC call): a portal, nothing
|
||||
/// labelled, a player, a summoned pet, a vendor or another creature. ClsUnknown /
|
||||
/// ClsCreatureNoPwd when the snapshots don't have it yet (asked again next scan).
|
||||
/// </summary>
|
||||
private static byte Classify(uint id)
|
||||
{
|
||||
if (!ClientObjectHooks.TryGetSnapshotItemType(id, out uint type)) return ClsUnknown;
|
||||
if ((type & TypeCreature) == 0) return ClsOther;
|
||||
byte byType = PlateClass.FromItemType(type);
|
||||
if (byType != ClsCreature) return byType; // a portal, or nothing that gets a plate or a name
|
||||
if (!ClientObjectHooks.TryGetSnapshotPwdInfo(id, out uint bf, out _, out _)) return ClsCreatureNoPwd;
|
||||
if ((bf & BfPlayer) != 0) return ClsPlayer;
|
||||
if (ClientObjectHooks.TryGetObjectInstanceIdProperty(id, PetOwnerIid, out uint owner) && owner != 0) return ClsPet;
|
||||
|
|
@ -835,6 +885,7 @@ internal static class MonsterHud
|
|||
{
|
||||
float monsterMaxD = MonsterHudSettings.MaxDistance;
|
||||
float labelMaxD = MonsterHudSettings.NpcMaxDistance;
|
||||
float portalMaxD = MonsterHudSettings.PortalMaxDistance;
|
||||
float opacity = MonsterHudSettings.Opacity;
|
||||
float userScale = MonsterHudSettings.Scale;
|
||||
float lift = MonsterHudSettings.HeightLift;
|
||||
|
|
@ -905,7 +956,7 @@ internal static class MonsterHud
|
|||
}
|
||||
|
||||
// ── Alpha / scale targets ──
|
||||
float maxD = label ? labelMaxD : monsterMaxD;
|
||||
float maxD = !label ? monsterMaxD : p.Kind == RadarKind.Portal ? portalMaxD : labelMaxD;
|
||||
float t = maxD > 1f ? Math.Clamp(p.Distance / maxD, 0f, 1f) : 0f;
|
||||
float distFade = fade ? 1f - 0.55f * SmoothStep(0.45f, 1f, t) : 1f;
|
||||
bool show = p.OnScreen && (p.Chosen || p.IsTarget) && !p.Gone;
|
||||
|
|
@ -1042,7 +1093,7 @@ internal static class MonsterHud
|
|||
p.NameFont = ImGuiFonts.Sharp(p.NameSize, bold: true);
|
||||
p.NameW = TextWidth(p.NameFont, p.NameSize, p.Name);
|
||||
p.BadgeW = 0f;
|
||||
p.IconSize = 0f;
|
||||
p.Row = default;
|
||||
if (p.HasBar)
|
||||
{
|
||||
// A thin bar under the name, at least the name's width.
|
||||
|
|
@ -1077,9 +1128,10 @@ internal static class MonsterHud
|
|||
p.BadgeW = MonsterHudSettings.ShowLevel && p.LevelText.Length > 0
|
||||
? TextWidth(p.SmallFont, p.SmallSize, p.LevelText) + 8f * k : 0f;
|
||||
|
||||
// Debuff row under the bar: icon + countdown line.
|
||||
p.IconSize = MathF.Round(13f * k);
|
||||
float iconRow = p.IconCount > 0 || p.Others ? p.IconSize + MathF.Round(3f * k) + 3f : 0f;
|
||||
// Debuff row under the bar: icon + countdown line, at its own size (not the text size).
|
||||
p.Row = new DebuffRowMetrics(k, MonsterHudSettings.MonsterDebuffIconSize);
|
||||
bool icons = p.IconCount > 0 || p.Others;
|
||||
float iconRow = icons ? p.Row.Height : 0f;
|
||||
p.BelowBar = iconRow + (p.IsTarget ? 9f * k : 3f * k);
|
||||
|
||||
float nameLine = p.NameW + (p.BadgeW > 0 ? p.BadgeW + 4f * k : 0f);
|
||||
|
|
@ -1088,10 +1140,14 @@ internal static class MonsterHud
|
|||
// inside the crowd-avoidance box, symmetric so the plate stays centred.
|
||||
float side = (p.Weak != null || MonsterHudSettings.ShowDistance) ? 2f * 30f * k * text : 0f;
|
||||
p.Width = MathF.Max(p.BarW + side, nameLine) + 8f * k;
|
||||
// Icons made bigger than the default can be wider than the bar: the box (crowding, clicks) holds them.
|
||||
if (icons && p.Row.Scale > 1f)
|
||||
p.Width = p.Row.CoverWidth(p.Width, DebuffIconRow.Width(p.Icons.Length, p.IconCount, p.Others, in p.Row,
|
||||
p.SmallFont, p.SmallSize, ref p.OverflowKey, ref p.OverflowString), 8f * k);
|
||||
p.Height = nameH + p.BarH + p.BelowBar;
|
||||
}
|
||||
|
||||
/// <summary>A name label's text size: players' or NPCs' (vendors count as NPCs).</summary>
|
||||
/// <summary>A name label's text size: players' or NPCs' (vendors and portals go with NPCs).</summary>
|
||||
private static float LabelTextSize(byte kind) =>
|
||||
kind == RadarKind.Player ? MonsterHudSettings.PlayerTextSize : MonsterHudSettings.NpcTextSize;
|
||||
|
||||
|
|
@ -1223,8 +1279,8 @@ internal static class MonsterHud
|
|||
var b1 = new Vector2(barR, barBottom);
|
||||
float round = MathF.Max(1f, 2f * k);
|
||||
bool icons = p.IconCount > 0 || p.Others;
|
||||
float iconTop = barBottom + MathF.Round(3f * k);
|
||||
float pointerTop = icons ? iconTop + p.IconSize + 3f + 2f * k : barBottom + 2f * k;
|
||||
float iconTop = barBottom + p.Row.Above;
|
||||
float pointerTop = icons ? iconTop + p.Row.Icon + p.Row.Below + 2f * k : barBottom + 2f * k;
|
||||
|
||||
// Crowd leader: a plate pushed up keeps a faint line down to its monster.
|
||||
if (p.Nudge > 10f * uiScale)
|
||||
|
|
@ -1290,8 +1346,8 @@ internal static class MonsterHud
|
|||
|
||||
// Under the bar: the debuff icons.
|
||||
if (icons)
|
||||
DebuffIconRow.Paint(dl, p.Icons, p.IconCount, p.Others, p.IconSize, p.SmallFont, p.SmallSize,
|
||||
ref p.OverflowKey, ref p.OverflowString, cx, iconTop, k, a, now);
|
||||
DebuffIconRow.Paint(dl, p.Icons, p.IconCount, p.Others, in p.Row, p.SmallFont, p.SmallSize,
|
||||
ref p.OverflowKey, ref p.OverflowString, cx, iconTop, a, now);
|
||||
|
||||
// ── Name line: [level badge] Name ──
|
||||
if (p.NameW > 0 || p.BadgeW > 0)
|
||||
|
|
@ -1621,12 +1677,13 @@ internal static class MonsterHud
|
|||
/// <summary>Chat lines for "/rv plates status": what the overlays see right now. AC's thread.</summary>
|
||||
public static string[] DescribeLines()
|
||||
{
|
||||
int onScreen = 0, known = 0, labels = 0, labelsOnScreen = 0;
|
||||
int onScreen = 0, known = 0, labels = 0, labelsOnScreen = 0, portals = 0;
|
||||
foreach (Plate p in Plates.Values)
|
||||
{
|
||||
if (p.IsLabel)
|
||||
{
|
||||
labels++;
|
||||
if (p.Kind == RadarKind.Portal) portals++;
|
||||
if (p.OnScreen && p.Alpha > 0.01f) labelsOnScreen++;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1636,7 +1693,7 @@ internal static class MonsterHud
|
|||
return new[]
|
||||
{
|
||||
$"Nameplates: {Plates.Count - labels} tracked, {onScreen} on screen, {known} with health seen; " +
|
||||
$"name labels {labels} ({labelsOnScreen} on screen), {Classes.Count} objects classified; " +
|
||||
$"name labels {labels} ({labelsOnScreen} on screen, {portals} portals), {Classes.Count} objects classified; " +
|
||||
$"camera {(GameMatrixCapture.HasCapturedFrame ? "captured" : "not captured")} " +
|
||||
$"(frame lb 0x{GameMatrixCapture.FrameLandblock:X4}, viewport {GameMatrixCapture.ViewportWidth}x{GameMatrixCapture.ViewportHeight}); " +
|
||||
$"weakness data {(_weakByWcid.Count + _weakByName.Count > 0 ? "loaded" : "none")}.",
|
||||
|
|
|
|||
|
|
@ -58,6 +58,15 @@ internal static class MonsterHudSettings
|
|||
public static bool PlayerNames = false;
|
||||
/// <summary>A health bar under other players' names, for those whose health the client has been told (selected, fellowship).</summary>
|
||||
public static bool PlayerBars = false;
|
||||
/// <summary>
|
||||
/// The name over portals (2026-10-28), in the radar's portal colour. On by default: portals are few and
|
||||
/// the label is only the name. Their own distance and count, so NPC names never crowd them out.
|
||||
/// </summary>
|
||||
public static bool PortalNames = true;
|
||||
public static float PortalMaxDistance = DefaultPortalDistance; // yards; portals are worth seeing from further than NPCs
|
||||
public const float DefaultPortalDistance = 60f;
|
||||
/// <summary>At most this many portal names (nearest first; a selected portal always keeps its own). Not a setting.</summary>
|
||||
public const int MaxPortalLabels = 12;
|
||||
|
||||
// Debuff icons on the monster plates (PlateDebuffs).
|
||||
public static bool ShowDebuffs = true;
|
||||
|
|
@ -121,7 +130,7 @@ internal static class MonsterHudSettings
|
|||
// NPC and player names are name-only labels (no bar), so they only have a text size.
|
||||
/// <summary>Monster plates: the health bar's width and height, and their text (name, level, HP, weak-to, distance).</summary>
|
||||
public static float MonsterBarWidth = 1.0f, MonsterBarHeight = 1.0f, MonsterTextSize = 1.0f;
|
||||
/// <summary>Name labels over NPCs and vendors.</summary>
|
||||
/// <summary>Name labels over NPCs and vendors, and over portals.</summary>
|
||||
public static float NpcTextSize = 1.0f;
|
||||
/// <summary>Name labels over other players.</summary>
|
||||
public static float PlayerTextSize = 1.0f;
|
||||
|
|
@ -130,12 +139,21 @@ internal static class MonsterHudSettings
|
|||
public const float MinBarWidth = 0.5f, MaxBarWidth = 2.5f;
|
||||
public const float MinBarHeight = 0.5f, MaxBarHeight = 3.0f;
|
||||
public const float MinTextSize = 0.5f, MaxTextSize = 2.0f;
|
||||
/// <summary>
|
||||
/// "Debuff icon size" (2026-10-28), in percent of the icons' size before it existed (100 = unchanged), on
|
||||
/// top of Look > Scale: the monster plates' row and your own plate's "Debuffs on you" row, each on its own
|
||||
/// and apart from every text size. The icon, its glyph, countdown line, stack digit, "+N" and spacing all
|
||||
/// follow it (DebuffRowMetrics).
|
||||
/// </summary>
|
||||
public static int MonsterDebuffIconSize = DefaultDebuffIconSize, SelfDebuffIconSize = DefaultDebuffIconSize;
|
||||
public const int DefaultDebuffIconSize = 100, MinDebuffIconSize = 50, MaxDebuffIconSize = 200;
|
||||
|
||||
// ── Ranges (shared by the Settings face, the command and Load) ──────
|
||||
public const float MinDistance = 5f, MaxDistanceLimit = 120f;
|
||||
public const int MinPlates = 1, MaxPlatesLimit = 60;
|
||||
public const float MinNpcDistance = 5f, MaxNpcDistanceLimit = 80f;
|
||||
public const int MinNpcLabels = 1, MaxNpcLabelsLimit = 40;
|
||||
public const float MinPortalDistance = 5f, MaxPortalDistanceLimit = 120f;
|
||||
public const float MinScale = 0.6f, MaxScale = 2.0f;
|
||||
public const float MinOpacity = 0.2f, MaxOpacity = 1.0f;
|
||||
public const float MinLift = -1.5f, MaxLift = 3.0f;
|
||||
|
|
@ -211,6 +229,8 @@ internal static class MonsterHudSettings
|
|||
break;
|
||||
case "playerNames": PlayerNames = val == "1"; break;
|
||||
case "playerBars": PlayerBars = val == "1"; break;
|
||||
case "portalNames": PortalNames = val == "1"; break;
|
||||
case "portalDistance": if (TryF(val, out float pd)) PortalMaxDistance = Math.Clamp(pd, MinPortalDistance, MaxPortalDistanceLimit); break;
|
||||
case "showDebuffs": ShowDebuffs = val == "1"; break;
|
||||
case "showOthersDebuff": ShowOthersDebuff = val == "1"; break;
|
||||
case "selfPlate": SelfPlate = val == "1"; break;
|
||||
|
|
@ -250,12 +270,38 @@ internal static class MonsterHudSettings
|
|||
case "selfBarWidth": if (TryF(val, out float sbw)) SelfBarWidth = Math.Clamp(sbw, MinBarWidth, MaxBarWidth); break;
|
||||
case "selfBarHeight": if (TryF(val, out float sbh)) SelfBarHeight = Math.Clamp(sbh, MinBarHeight, MaxBarHeight); break;
|
||||
case "selfTextSize": if (TryF(val, out float sts)) SelfTextSize = Math.Clamp(sts, MinTextSize, MaxTextSize); break;
|
||||
case "monsterDebuffIconSize":
|
||||
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out int mdi))
|
||||
MonsterDebuffIconSize = Math.Clamp(mdi, MinDebuffIconSize, MaxDebuffIconSize);
|
||||
break;
|
||||
case "selfDebuffIconSize":
|
||||
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out int sdi))
|
||||
SelfDebuffIconSize = Math.Clamp(sdi, MinDebuffIconSize, MaxDebuffIconSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryF(string s, out float v) => float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out v);
|
||||
|
||||
/// <summary>
|
||||
/// A typed debuff icon size (/rv plates debuffs size, /rv plates self debuffs size) as a percent in range:
|
||||
/// "150", "150%", or a factor "1.5" / "1.5x" (up to 3 reads as a factor). False for junk.
|
||||
/// </summary>
|
||||
internal static bool TryParseDebuffIconSize(string? text, out int percent)
|
||||
{
|
||||
percent = DefaultDebuffIconSize;
|
||||
if (string.IsNullOrWhiteSpace(text)) return false;
|
||||
string t = text.Trim();
|
||||
bool factor = false;
|
||||
if (t.EndsWith('%')) t = t[..^1].TrimEnd();
|
||||
else if (t.EndsWith('x') || t.EndsWith('X')) { t = t[..^1].TrimEnd(); factor = true; }
|
||||
if (!TryF(t, out float v) || !float.IsFinite(v)) return false;
|
||||
if (factor || v <= 3f) v *= 100f;
|
||||
percent = (int)MathF.Round(Math.Clamp(v, MinDebuffIconSize, MaxDebuffIconSize));
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Writes the settings in the background. Any thread.</summary>
|
||||
public static void Save() => UiBackgroundWriter.Enqueue("nameplate settings", SaveNow);
|
||||
|
||||
|
|
@ -298,6 +344,8 @@ internal static class MonsterHudSettings
|
|||
sw.WriteLine(FormattableString.Invariant($"npcMax={MaxNpcLabels}"));
|
||||
sw.WriteLine($"playerNames={B(PlayerNames)}");
|
||||
sw.WriteLine($"playerBars={B(PlayerBars)}");
|
||||
sw.WriteLine($"portalNames={B(PortalNames)}");
|
||||
sw.WriteLine(FormattableString.Invariant($"portalDistance={PortalMaxDistance:0.#}"));
|
||||
sw.WriteLine($"showDebuffs={B(ShowDebuffs)}");
|
||||
sw.WriteLine($"showOthersDebuff={B(ShowOthersDebuff)}");
|
||||
sw.WriteLine($"selfPlate={B(SelfPlate)}");
|
||||
|
|
@ -337,6 +385,8 @@ internal static class MonsterHudSettings
|
|||
sw.WriteLine(FormattableString.Invariant($"selfBarWidth={SelfBarWidth:0.##}"));
|
||||
sw.WriteLine(FormattableString.Invariant($"selfBarHeight={SelfBarHeight:0.##}"));
|
||||
sw.WriteLine(FormattableString.Invariant($"selfTextSize={SelfTextSize:0.##}"));
|
||||
sw.WriteLine(FormattableString.Invariant($"monsterDebuffIconSize={MonsterDebuffIconSize}"));
|
||||
sw.WriteLine(FormattableString.Invariant($"selfDebuffIconSize={SelfDebuffIconSize}"));
|
||||
}
|
||||
|
||||
private static string B(bool v) => v ? "1" : "0";
|
||||
|
|
@ -349,6 +399,7 @@ internal static class MonsterHudSettings
|
|||
FadeWithDistance = true; Scale = 1.0f; Opacity = 0.9f; HeightLift = 0f; ClickToSelect = true;
|
||||
ShowDebuffs = true; ShowOthersDebuff = true;
|
||||
NpcNames = true; NpcMaxDistance = 30f; MaxNpcLabels = 15; PlayerNames = false; PlayerBars = false;
|
||||
PortalNames = true; PortalMaxDistance = DefaultPortalDistance;
|
||||
SelfPlate = true; SelfNumbers = false; SelfName = false; SelfHideFirstPerson = true;
|
||||
SelfPlacement = SelfPlacement.Fixed; SelfLocked = true; SelfFixedX = DefaultSelfFixedX; SelfFixedY = DefaultSelfFixedY;
|
||||
SelfBarTrack = true; SelfBarChip = true; SelfTextOutline = true; SelfNumberBand = true; SelfDebuffs = true;
|
||||
|
|
@ -360,7 +411,7 @@ internal static class MonsterHudSettings
|
|||
Save();
|
||||
}
|
||||
|
||||
/// <summary>Every plate type's bar and text size back to 1 (and saved). Render / chat thread.</summary>
|
||||
/// <summary>Every plate type's bar and text size back to 1, the debuff icon sizes to 100 % (and saved). Render / chat thread.</summary>
|
||||
public static void ResetSizes()
|
||||
{
|
||||
ResetSizesNoSave();
|
||||
|
|
@ -372,6 +423,7 @@ internal static class MonsterHudSettings
|
|||
MonsterBarWidth = 1.0f; MonsterBarHeight = 1.0f; MonsterTextSize = 1.0f;
|
||||
NpcTextSize = 1.0f; PlayerTextSize = 1.0f;
|
||||
SelfBarWidth = 1.0f; SelfBarHeight = 1.0f; SelfTextSize = 1.0f;
|
||||
MonsterDebuffIconSize = DefaultDebuffIconSize; SelfDebuffIconSize = DefaultDebuffIconSize;
|
||||
}
|
||||
|
||||
/// <summary>The fixed plate back to its default spot (and saved). Render / chat thread.</summary>
|
||||
|
|
@ -401,7 +453,7 @@ internal static class MonsterHudSettings
|
|||
/// <summary>Every master switch at once ("/rv plates all on|off").</summary>
|
||||
public static void SetAll(bool on)
|
||||
{
|
||||
Enabled = on; ShowDebuffs = on; SelfPlate = on; Numbers = on; Gains = on; NpcNames = on;
|
||||
Enabled = on; ShowDebuffs = on; SelfPlate = on; Numbers = on; Gains = on; NpcNames = on; PortalNames = on;
|
||||
if (!on) { PlayerNames = false; PlayerBars = false; } // "all on" leaves player names and bars as chosen (off by default)
|
||||
}
|
||||
|
||||
|
|
@ -411,16 +463,17 @@ internal static class MonsterHudSettings
|
|||
$"{MaxDistance:0}yd, max {MaxPlates}, scale {Scale:0.##}, opacity {Opacity:0.##}, lift {HeightLift:0.#}m; " +
|
||||
$"names {OnOff(ShowNames)}, hp {OnOff(ShowHpNumbers)}, level {OnOff(ShowLevel)}, weak {OnOff(ShowWeakness)}, " +
|
||||
$"distance {OnOff(ShowDistance)}, fade {OnOff(FadeWithDistance)}, click to select {OnOff(ClickToSelect)}), debuffs {OnOff(ShowDebuffs)} (others {OnOff(ShowOthersDebuff)}); " +
|
||||
$"NPC names {OnOff(NpcNames)} ({NpcMaxDistance:0}yd, max {MaxNpcLabels}), player names {OnOff(PlayerNames)} (bars {OnOff(PlayerBars)}); " +
|
||||
$"NPC names {OnOff(NpcNames)} ({NpcMaxDistance:0}yd, max {MaxNpcLabels}), player names {OnOff(PlayerNames)} (bars {OnOff(PlayerBars)}), " +
|
||||
$"portal names {OnOff(PortalNames)} ({PortalMaxDistance:0}yd); " +
|
||||
$"self {OnOff(SelfPlate)} ({(SelfPlacement == SelfPlacement.Fixed ? "fixed on screen, " + (SelfLocked ? "locked" : "unlocked") : "follows you, " + SelfPosition.ToString().ToLowerInvariant())}, " +
|
||||
$"numbers {OnOff(SelfNumbers)}, name {OnOff(SelfName)}, hide in first person {OnOff(SelfHideFirstPerson)}, " +
|
||||
$"debuffs on you {OnOff(SelfDebuffs)}, track {OnOff(SelfBarTrack)}, damage trail {OnOff(SelfBarChip)}, " +
|
||||
$"text outline {OnOff(SelfTextOutline)}, number band {OnOff(SelfNumberBand)}); " +
|
||||
$"combat text {OnOff(Numbers)} (dealt {OnOff(NumDealt)}, taken {OnOff(NumTaken)}, heals {OnOff(NumHeals)}, kills {OnOff(NumKills)}); " +
|
||||
$"gains {OnOff(Gains)} (xp {OnOff(GainXp)}, lum {OnOff(GainLum)}, radiance {OnOff(GainRadiance)}); " +
|
||||
$"sizes: monster bar {MonsterBarWidth:0.##}x{MonsterBarHeight:0.##} text {MonsterTextSize:0.##}, " +
|
||||
$"NPC text {NpcTextSize:0.##}, player text {PlayerTextSize:0.##}, " +
|
||||
$"your bars {SelfBarWidth:0.##}x{SelfBarHeight:0.##} text {SelfTextSize:0.##}.");
|
||||
$"sizes: monster bar {MonsterBarWidth:0.##}x{MonsterBarHeight:0.##} text {MonsterTextSize:0.##} debuff icons {MonsterDebuffIconSize}%, " +
|
||||
$"NPC and portal text {NpcTextSize:0.##}, player text {PlayerTextSize:0.##}, " +
|
||||
$"your bars {SelfBarWidth:0.##}x{SelfBarHeight:0.##} text {SelfTextSize:0.##} debuff icons {SelfDebuffIconSize}%.");
|
||||
|
||||
private static string OnOff(bool v) => v ? "on" : "off";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/MonsterHud/MonsterHudSettingsUi.cs
|
||||
// The RynthVision overlay settings, drawn as two tabs of the Vision panel
|
||||
// (Panels/VisionFace.cs): "Nameplates" (monster plates, NPC / player names,
|
||||
// (Panels/VisionFace.cs): "Nameplates" (monster plates, NPC / player / portal names,
|
||||
// debuff icons, your plate, look) and "Combat text" (numbers, kill burst, gains). Square toggle
|
||||
// dots and amber section headers; sliders save when the drag ends. Values
|
||||
// live engine-side in MonsterHudSettings. AC's render thread, inside the
|
||||
|
|
@ -24,6 +24,11 @@ internal static class MonsterHudSettingsUi
|
|||
private static uint BtnFill => RynthTheme.Button;
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
|
||||
private static readonly string PortalNamesTip =
|
||||
"The portal's name above it, in the radar's portal colour (purple by default), at the NPC name size. " +
|
||||
$"The nearest {MonsterHudSettings.MaxPortalLabels}, counted on their own so NPC names never crowd them out; " +
|
||||
"click one to select the portal. Chat: /rv plates portals [on|off], /rv plates portals dist <yd>.";
|
||||
|
||||
private static bool Loading(float w)
|
||||
{
|
||||
if (MonsterHudSettings.Loaded) return false;
|
||||
|
|
@ -79,7 +84,7 @@ internal static class MonsterHudSettingsUi
|
|||
changed |= SizeSlider("Text size", ref MonsterHudSettings.MonsterTextSize, MonsterHudSettings.MinTextSize, MonsterHudSettings.MaxTextSize, w,
|
||||
"The monster plate's text: name, level badge, HP numbers, weak-to pill and distance (1.00x = the default).");
|
||||
|
||||
Section("Names over NPCs and players", w);
|
||||
Section("Names over NPCs, players and portals", w);
|
||||
changed |= Toggle("NPC names", ref MonsterHudSettings.NpcNames,
|
||||
"The name over vendors, quest givers, town criers and other NPCs: yellow, vendors gold (the radar's colours). " +
|
||||
"Name only, no health bar; click one to select it. Chat: /rv plates npcs.");
|
||||
|
|
@ -88,7 +93,7 @@ internal static class MonsterHudSettingsUi
|
|||
changed |= SliderI("Max names", ref MonsterHudSettings.MaxNpcLabels,
|
||||
MonsterHudSettings.MinNpcLabels, MonsterHudSettings.MaxNpcLabelsLimit, w);
|
||||
changed |= SizeSlider("NPC name size", ref MonsterHudSettings.NpcTextSize, MonsterHudSettings.MinTextSize, MonsterHudSettings.MaxTextSize, w,
|
||||
"Text size of the names over NPCs and vendors (1.00x = the default). Names have no bar.");
|
||||
"Text size of the names over NPCs and vendors, and over portals (1.00x = the default). Names have no bar.");
|
||||
changed |= Toggle("Player names", ref MonsterHudSettings.PlayerNames,
|
||||
"The name over other players too (blue), within the same distance and count. Chat: /rv plates players.");
|
||||
changed |= Toggle("Player health bars", ref MonsterHudSettings.PlayerBars,
|
||||
|
|
@ -96,6 +101,9 @@ internal static class MonsterHudSettingsUi
|
|||
"once you select them or they share it (fellowship), so a bar shows from then on; others keep just the name. Chat: /rv plates playerbars.");
|
||||
changed |= SizeSlider("Player name size", ref MonsterHudSettings.PlayerTextSize, MonsterHudSettings.MinTextSize, MonsterHudSettings.MaxTextSize, w,
|
||||
"Text size of the names over other players (1.00x = the default). Names have no bar.");
|
||||
changed |= Toggle("Portal names", ref MonsterHudSettings.PortalNames, PortalNamesTip);
|
||||
changed |= SliderF("Portal name distance (yd)", ref MonsterHudSettings.PortalMaxDistance,
|
||||
MonsterHudSettings.MinPortalDistance, MonsterHudSettings.MaxPortalDistanceLimit, "%.0f", w);
|
||||
Note("Names count apart from the monster plates, so they never push one out; the nearest win.", w);
|
||||
|
||||
Section("Debuffs", w);
|
||||
|
|
@ -105,6 +113,11 @@ internal static class MonsterHudSettingsUi
|
|||
changed |= Toggle("Debuffed by others", ref MonsterHudSettings.ShowOthersDebuff,
|
||||
"A small marker when an appraisal shows a lowered attribute or vital that none of your own debuffs explains. " +
|
||||
"It only updates when the monster is appraised (your combat target is appraised often).", sub: true);
|
||||
changed |= PercentSlider("Debuff icon size", ref MonsterHudSettings.MonsterDebuffIconSize,
|
||||
MonsterHudSettings.MinDebuffIconSize, MonsterHudSettings.MaxDebuffIconSize, w,
|
||||
"How big the debuff icons on monster plates are (100% = the default): the icons, their countdown lines, " +
|
||||
"the stack digits and \"+N\". On its own: the text size doesn't change it. On top of Look > Scale. " +
|
||||
"Chat: /rv plates debuffs size 50-200.");
|
||||
|
||||
Section("Your plate", w);
|
||||
changed |= Toggle("Show your plate", ref MonsterHudSettings.SelfPlate,
|
||||
|
|
@ -114,7 +127,11 @@ internal static class MonsterHudSettingsUi
|
|||
changed |= Toggle("Debuffs on you", ref MonsterHudSettings.SelfDebuffs,
|
||||
"Icons under your mana bar for harmful spells on you (vulnerabilities, Imperil, Magic Yield, attribute and skill debuffs...), " +
|
||||
"the monster plates' icons: one per kind, a line that runs out with the spell, blinking in its last 5 seconds, \"+N\" when more than fit. " +
|
||||
"Only shows while you have one.", sub: true);
|
||||
"Only shows while you have one. Chat: /rv plates self debuffs.", sub: true);
|
||||
changed |= PercentSlider("Your debuff icon size", ref MonsterHudSettings.SelfDebuffIconSize,
|
||||
MonsterHudSettings.MinDebuffIconSize, MonsterHudSettings.MaxDebuffIconSize, w,
|
||||
"How big the icons under your bars are (100% = the default), apart from the monster plates' and from " +
|
||||
"Your text size. On top of Look > Scale. Chat: /rv plates self debuffs size 50-200.");
|
||||
changed |= SizeSlider("Your bar width", ref MonsterHudSettings.SelfBarWidth, MonsterHudSettings.MinBarWidth, MonsterHudSettings.MaxBarWidth, w,
|
||||
"How wide your health, stamina and mana bars are (1.00x = the default).");
|
||||
changed |= SizeSlider("Your bar height", ref MonsterHudSettings.SelfBarHeight, MonsterHudSettings.MinBarHeight, MonsterHudSettings.MaxBarHeight, w,
|
||||
|
|
@ -188,13 +205,13 @@ internal static class MonsterHudSettingsUi
|
|||
changed |= Toggle("Fade and shrink with distance", ref MonsterHudSettings.FadeWithDistance, null);
|
||||
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 8));
|
||||
if (SmallButton("Reset bar and text sizes"))
|
||||
if (SmallButton("Reset bar, text and icon sizes"))
|
||||
{
|
||||
MonsterHudSettings.ResetSizes(); // saves
|
||||
changed = false;
|
||||
}
|
||||
if (ImGuiNET.ImGui.IsItemHovered())
|
||||
ImGuiNET.ImGui.SetTooltip("Every plate type's bar width, bar height and text size back to 1.00x.");
|
||||
SafeImGui.SetTooltip("Every plate type's bar width, bar height and text size back to 1.00x, and both debuff icon sizes to 100%.");
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
if (SmallButton("Reset all to defaults"))
|
||||
{
|
||||
|
|
@ -292,6 +309,15 @@ internal static class MonsterHudSettingsUi
|
|||
return EndSliderRow(changed);
|
||||
}
|
||||
|
||||
/// <summary>A percent slider ("100%" = the default look) with a tooltip. Labels are the ids: keep them unique.</summary>
|
||||
private static bool PercentSlider(string label, ref int value, int min, int max, float w, string tip)
|
||||
{
|
||||
BeginSliderRow(label, w);
|
||||
bool changed = ImGuiNET.ImGui.SliderInt("##v", ref value, min, max, "%d%%", ImGuiSliderFlags.AlwaysClamp);
|
||||
if (ImGuiNET.ImGui.IsItemHovered()) SafeImGui.SetTooltip(tip);
|
||||
return EndSliderRow(changed);
|
||||
}
|
||||
|
||||
private static bool SliderI(string label, ref int value, int min, int max, float w)
|
||||
{
|
||||
BeginSliderRow(label, w);
|
||||
|
|
|
|||
33
src/RynthCore.Engine/ImGui/MonsterHud/PlateClass.cs
Normal file
33
src/RynthCore.Engine/ImGui/MonsterHud/PlateClass.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/MonsterHud/PlateClass.cs
|
||||
// What a world object is to the nameplates (MonsterHud.Classify), from the
|
||||
// main-thread snapshot's ITEM_TYPE: a creature (its PublicWeenieDesc then
|
||||
// says player, pet, vendor or other), a portal (a name label over it, since
|
||||
// 2026-10-28), or nothing that gets a plate or a name.
|
||||
//
|
||||
// Pure code: MonsterHud feeds it the snapshot values; tools/PlateSizingTests
|
||||
// compiles it in.
|
||||
// ============================================================================
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Hud;
|
||||
|
||||
internal static class PlateClass
|
||||
{
|
||||
// The values of MonsterHud's per-id cache (MonsterHud.Classes). Unknown: the snapshot has no type yet.
|
||||
public const byte Unknown = 0, Other = 1, Creature = 2, Vendor = 3, Player = 4, Pet = 5;
|
||||
/// <summary>A creature whose PWD isn't in the snapshot yet: never cached, asked again next scan.</summary>
|
||||
public const byte CreatureNoPwd = 6;
|
||||
/// <summary>A portal: a name label over it ("Portal names").</summary>
|
||||
public const byte Portal = 7;
|
||||
|
||||
public const uint TypeCreature = 0x10; // ITEM_TYPE TYPE_CREATURE
|
||||
public const uint TypePortal = 0x10000; // ITEM_TYPE TYPE_PORTAL (the radar and the Sense scan read it too)
|
||||
|
||||
/// <summary>
|
||||
/// What the item type alone decides: <see cref="Creature"/> (its PWD then decides which kind),
|
||||
/// <see cref="Portal"/>, or <see cref="Other"/>. A creature bit wins, so nothing that has a
|
||||
/// monster plate ever turns into a portal name.
|
||||
/// </summary>
|
||||
public static byte FromItemType(uint type) =>
|
||||
(type & TypeCreature) != 0 ? Creature : (type & TypePortal) != 0 ? Portal : Other;
|
||||
}
|
||||
151
src/RynthCore.Engine/ImGui/MonsterHud/PlateMetrics.cs
Normal file
151
src/RynthCore.Engine/ImGui/MonsterHud/PlateMetrics.cs
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/MonsterHud/PlateMetrics.cs
|
||||
// The plates' lengths that need no font, so the offline tests can check them:
|
||||
// DebuffRowMetrics - the debuff icon row (DebuffIconRow) at a plate's scale
|
||||
// and its "Debuff icon size" setting (2026-10-28: a player asked for
|
||||
// bigger icons, apart from the text size). The monster plates and your
|
||||
// own plate each have their own setting.
|
||||
// SelfPlateMetrics - your plate's bars, the name's room above them and the
|
||||
// debuff row under them (PlayerPlate.Measure), and the clamp that keeps
|
||||
// all of it on screen.
|
||||
// At 100 % every length is the expression the plates used before the setting
|
||||
// existed (k x 1 is k exactly), so nothing moves by a pixel until it is set.
|
||||
// Plain math, no engine dependencies (the offline tests compile it in).
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Hud;
|
||||
|
||||
/// <summary>
|
||||
/// The debuff icon row's lengths at a plate's scale <c>k</c> and an icon size setting (a percentage,
|
||||
/// 100 = the size before the setting). Everything the row draws or reserves follows k x the setting:
|
||||
/// the icon square, its glyph, the countdown line, the spacing; the stack digit and "+N" scale their
|
||||
/// text size by <see cref="Scale"/> (<see cref="TextSize"/>). Text size settings never change it.
|
||||
/// </summary>
|
||||
internal readonly struct DebuffRowMetrics
|
||||
{
|
||||
/// <summary>The setting as a factor (1 = 100 %).</summary>
|
||||
public readonly float Scale;
|
||||
/// <summary>The plate's k times <see cref="Scale"/>: what the row's own lengths follow.</summary>
|
||||
public readonly float K;
|
||||
/// <summary>The icon square (13 px at k 1, 100 %).</summary>
|
||||
public readonly float Icon;
|
||||
/// <summary>The glyph inside the square (px).</summary>
|
||||
public readonly float Glyph;
|
||||
/// <summary>Between the bar(s) above and the icons.</summary>
|
||||
public readonly float Above;
|
||||
/// <summary>Under each icon: room for the countdown line.</summary>
|
||||
public readonly float Below;
|
||||
/// <summary>Between two icons (and before "+N" and the "debuffed by others" marker).</summary>
|
||||
public readonly float Gap;
|
||||
/// <summary>The countdown line: its distance under the icon and its thickness.</summary>
|
||||
public readonly float LineGap, LineH;
|
||||
/// <summary>The icon square's corner radius.</summary>
|
||||
public readonly float Round;
|
||||
/// <summary>The stack digit's offset from the icon's top-right corner (right, up).</summary>
|
||||
public readonly float DigitDx, DigitDy;
|
||||
|
||||
/// <param name="k">The plate's scale (Look > Scale x UI scale, x the monster plate's distance shrink).</param>
|
||||
/// <param name="sizePercent">The icon size setting (MonsterHudSettings: 50-200; 0 or less = 100).</param>
|
||||
public DebuffRowMetrics(float k, int sizePercent)
|
||||
{
|
||||
float s = Scale = sizePercent > 0 ? sizePercent / 100f : 1f;
|
||||
float ik = K = k * s;
|
||||
Icon = MathF.Round(13f * ik);
|
||||
Glyph = MathF.Round(Icon * 0.8f);
|
||||
Above = MathF.Round(3f * ik);
|
||||
Below = MathF.Round(3f * s);
|
||||
Gap = MathF.Max(2f, MathF.Round(2f * ik));
|
||||
LineGap = MathF.Max(1f, MathF.Round(s));
|
||||
LineH = MathF.Max(1f, MathF.Round(1.5f * ik));
|
||||
Round = 2f * ik;
|
||||
DigitDx = MathF.Round(s);
|
||||
DigitDy = MathF.Round(2f * s);
|
||||
}
|
||||
|
||||
/// <summary>The room the row takes under the bar(s): the gap above, the icons, the countdown line.</summary>
|
||||
public float Height => Above + Icon + Below;
|
||||
|
||||
/// <summary>The row's text size (stack digit, "+N") from the plate's small text size (whole px).</summary>
|
||||
public float TextSize(float smallSize) => MathF.Round(smallSize * Scale);
|
||||
|
||||
/// <summary>
|
||||
/// The row's width: <paramref name="slots"/> squares (icons and the "debuffed by others" marker) and,
|
||||
/// when <paramref name="more"/>, the "+N" text <paramref name="moreTextW"/> px wide after them.
|
||||
/// </summary>
|
||||
public float Width(int slots, bool more, float moreTextW)
|
||||
{
|
||||
float moreW = more ? MoreWidth(moreTextW) : 0f;
|
||||
return slots * Icon + Math.Max(0, slots - 1) * Gap + (more ? Gap + moreW : 0f);
|
||||
}
|
||||
|
||||
/// <summary>The "+N" text's slot: its width plus a little room.</summary>
|
||||
public float MoreWidth(float moreTextW) => moreTextW + 4f * K;
|
||||
|
||||
/// <summary>
|
||||
/// A plate box <paramref name="width"/> wide, grown to hold an enlarged row (<paramref name="rowWidth"/>
|
||||
/// plus <paramref name="pad"/>). At 100 % or smaller the box is left as it was before the setting.
|
||||
/// </summary>
|
||||
public float CoverWidth(float width, float rowWidth, float pad) =>
|
||||
Scale > 1f ? MathF.Max(width, rowWidth + pad) : width;
|
||||
|
||||
/// <summary>
|
||||
/// How far an enlarged row centred under bars <paramref name="barW"/> wide reaches past each of their
|
||||
/// ends (whole px). 0 at 100 % or smaller, as before the setting.
|
||||
/// </summary>
|
||||
public float Overhang(float rowWidth, float barW) =>
|
||||
Scale > 1f ? MathF.Max(0f, MathF.Ceiling((rowWidth - barW) * 0.5f)) : 0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Your own plate's lengths (PlayerPlate.Measure): three bars, the name's room above them and the debuff
|
||||
/// row under them. The plate is placed by the bars' top-left; it reaches <see cref="NameH"/> above that,
|
||||
/// <see cref="BlockH"/> + <see cref="IconsH"/> below it and <see cref="IconsOver"/> past either end, and
|
||||
/// <see cref="ClampLeft"/> / <see cref="ClampTop"/> keep all of it on screen (the fixed plate, and a
|
||||
/// following one with Keep on screen); the drag area covers the same rect.
|
||||
/// </summary>
|
||||
internal struct SelfPlateMetrics
|
||||
{
|
||||
public float K, BarW, BarH, Gap, Round, BlockH, NameH;
|
||||
/// <summary>The debuff row's room under the bars (0 without an icon) and its reach past the bars' ends.</summary>
|
||||
public float IconsH, IconsOver;
|
||||
public DebuffRowMetrics Row;
|
||||
|
||||
/// <summary>Your plate's measured height: the name, the bars and the debuff row.</summary>
|
||||
public readonly float Height => NameH + BlockH + IconsH;
|
||||
|
||||
/// <summary>The debuff row's top, down from the bars' top.</summary>
|
||||
public readonly float RowTop => BlockH + Row.Above;
|
||||
|
||||
/// <param name="k">Look > Scale x UI scale.</param>
|
||||
/// <param name="numbers">"Numbers on your bars" (taller, wider bars).</param>
|
||||
/// <param name="barWidth">"Your bar width" (1 = default).</param>
|
||||
/// <param name="barHeight">"Your bar height" (1 = default).</param>
|
||||
/// <param name="nameSize">The name's text size, 0 when the name is off.</param>
|
||||
/// <param name="icons">There is a debuff icon to show.</param>
|
||||
/// <param name="iconPercent">"Your debuff icon size" (100 = default).</param>
|
||||
public static SelfPlateMetrics Measure(float k, bool numbers, float barWidth, float barHeight, float nameSize, bool icons, int iconPercent)
|
||||
{
|
||||
SelfPlateMetrics m = default;
|
||||
m.K = k;
|
||||
m.BarW = MathF.Round((numbers ? 124f : 96f) * k * barWidth);
|
||||
m.BarH = MathF.Round((numbers ? 15f : 5f) * k * barHeight);
|
||||
m.Gap = MathF.Max(2f, MathF.Round(2f * k));
|
||||
m.Round = MathF.Max(1f, 1.5f * k);
|
||||
m.BlockH = 3 * m.BarH + 2 * m.Gap;
|
||||
m.NameH = nameSize > 0f ? nameSize + 3f * k : 0f;
|
||||
m.Row = new DebuffRowMetrics(k, iconPercent);
|
||||
m.IconsH = icons ? m.Row.Height : 0f;
|
||||
m.IconsOver = 0f; // PlayerPlate sets it from the row's width (needs the "+N" text): Row.Overhang
|
||||
return m;
|
||||
}
|
||||
|
||||
/// <summary>The bars' left edge kept 4 px inside the screen, an enlarged debuff row's ends included.</summary>
|
||||
public readonly float ClampLeft(float left, float displayW) =>
|
||||
Math.Clamp(left, 4f + IconsOver, MathF.Max(4f + IconsOver, displayW - BarW - 4f - IconsOver));
|
||||
|
||||
/// <summary>The bars' top kept 4 px inside the screen, with the name above and the debuff row under.</summary>
|
||||
public readonly float ClampTop(float y, float displayH) =>
|
||||
Math.Clamp(y, 4f + NameH, MathF.Max(4f + NameH, displayH - BlockH - IconsH - 4f));
|
||||
}
|
||||
|
|
@ -42,6 +42,11 @@
|
|||
// (PortalSpellTable, queued by MonsterHud.Update while the row is on). The
|
||||
// row hangs under the bars: placement keeps the bars where they are and
|
||||
// only the clamp and the drag area grow to cover it.
|
||||
// "Your debuff icon size" (2026-10-28, 50-200 %, 100 = as before): the row's
|
||||
// own scale, apart from your text size. The lengths that need no font are in
|
||||
// SelfPlateMetrics (PlateMetrics.cs, offline-tested): the clamp and the drag
|
||||
// area cover the row at any size, and an enlarged row wider than the bars
|
||||
// (IconsOver) too.
|
||||
//
|
||||
// Render thread only. Engine-owned statics.
|
||||
// ============================================================================
|
||||
|
|
@ -145,7 +150,7 @@ internal static class PlayerPlate
|
|||
PlayerVitalsHooks.TryGetSnapshot(out _);
|
||||
if (!Advance(ref f, show)) return;
|
||||
Layout l = Measure(f.UiScale);
|
||||
float k = l.K, barW = l.BarW, blockH = l.BlockH, nameH = l.NameH, iconsH = l.IconsH;
|
||||
float k = l.M.K, barW = l.M.BarW, blockH = l.M.BlockH, nameH = l.M.NameH, iconsH = l.M.IconsH;
|
||||
|
||||
// Where the block goes: above the head (default), under the feet, or beside the character.
|
||||
float left, y;
|
||||
|
|
@ -181,8 +186,8 @@ internal static class PlayerPlate
|
|||
}
|
||||
if (MonsterHudSettings.KeepOnScreen)
|
||||
{
|
||||
left = Math.Clamp(left, 4f, MathF.Max(4f, f.Display.X - barW - 4f));
|
||||
y = Math.Clamp(y, 4f + nameH, MathF.Max(4f + nameH, f.Display.Y - blockH - iconsH - 4f));
|
||||
left = l.M.ClampLeft(left, f.Display.X);
|
||||
y = l.M.ClampTop(y, f.Display.Y);
|
||||
}
|
||||
float top = Paint(f.Dl, ref l, MathF.Round(left), MathF.Round(y), f.Now);
|
||||
// Gain text floats above the plate when it's over the head, else above the head itself.
|
||||
|
|
@ -204,6 +209,7 @@ internal static class PlayerPlate
|
|||
// The bars' centre from the saved fractions, then the block kept inside the screen.
|
||||
Vector2 display = f.Display;
|
||||
float cx = MonsterHudSettings.SelfFixedX * display.X, cy = MonsterHudSettings.SelfFixedY * display.Y;
|
||||
ref SelfPlateMetrics m = ref l.M;
|
||||
ImGuiIOPtr io = ImGuiNET.ImGui.GetIO();
|
||||
bool unlocked = !MonsterHudSettings.SelfLocked;
|
||||
if (_dragging)
|
||||
|
|
@ -221,23 +227,23 @@ internal static class PlayerPlate
|
|||
}
|
||||
}
|
||||
// The saved spot is the bars' centre (a debuff row coming and going never moves them); the
|
||||
// clamp keeps the row under them on screen too.
|
||||
float left = Math.Clamp(cx - l.BarW * 0.5f, 4f, MathF.Max(4f, display.X - l.BarW - 4f));
|
||||
float y = Math.Clamp(cy - l.BlockH * 0.5f, 4f + l.NameH, MathF.Max(4f + l.NameH, display.Y - l.BlockH - l.IconsH - 4f));
|
||||
// clamp keeps the row under them (and past their ends, when it is wider) on screen too.
|
||||
float left = m.ClampLeft(cx - m.BarW * 0.5f, display.X);
|
||||
float y = m.ClampTop(cy - m.BlockH * 0.5f, display.Y);
|
||||
left = MathF.Round(left);
|
||||
y = MathF.Round(y);
|
||||
if (_dragging && display.X > 1 && display.Y > 1)
|
||||
{
|
||||
// The spot as fractions (clamped, so letting go off screen keeps it reachable).
|
||||
MonsterHudSettings.SelfFixedX = Math.Clamp((left + l.BarW * 0.5f) / display.X, 0f, 1f);
|
||||
MonsterHudSettings.SelfFixedY = Math.Clamp((y + l.BlockH * 0.5f) / display.Y, 0f, 1f);
|
||||
MonsterHudSettings.SelfFixedX = Math.Clamp((left + m.BarW * 0.5f) / display.X, 0f, 1f);
|
||||
MonsterHudSettings.SelfFixedY = Math.Clamp((y + m.BlockH * 0.5f) / display.Y, 0f, 1f);
|
||||
}
|
||||
|
||||
// The plate's rect (name and debuff row included), a little padded: the drag surface.
|
||||
float pad = MathF.Round(4f * l.K);
|
||||
var r0 = new Vector2(left - pad, y - l.NameH - pad);
|
||||
var r1 = new Vector2(left + l.BarW + pad, y + l.BlockH + l.IconsH + pad);
|
||||
Drag(unlocked, r0, r1, new Vector2(left + l.BarW * 0.5f, y + l.BlockH * 0.5f));
|
||||
float pad = MathF.Round(4f * m.K);
|
||||
var r0 = new Vector2(left - pad - m.IconsOver, y - m.NameH - pad);
|
||||
var r1 = new Vector2(left + m.BarW + pad + m.IconsOver, y + m.BlockH + m.IconsH + pad);
|
||||
Drag(unlocked, r0, r1, new Vector2(left + m.BarW * 0.5f, y + m.BlockH * 0.5f));
|
||||
|
||||
ImDrawListPtr dl = ImGuiNET.ImGui.GetBackgroundDrawList();
|
||||
if (unlocked)
|
||||
|
|
@ -333,45 +339,46 @@ internal static class PlayerPlate
|
|||
/// <summary>The plate's sizes, fonts and look this frame.</summary>
|
||||
private struct Layout
|
||||
{
|
||||
public float K, BarW, BarH, Gap, Round, BlockH, NameH, SmallSize, NameSize;
|
||||
// The lengths that need no font: bars, the name's room, the debuff row (SelfPlateMetrics, offline-tested).
|
||||
public SelfPlateMetrics M;
|
||||
public float SmallSize, NameSize;
|
||||
public bool Numbers;
|
||||
public ImFontPtr Small, NameFont;
|
||||
// Look options (MonsterHudSettings.SelfBarTrack ...), read once per frame.
|
||||
public bool Track, Chip, Outline, Band;
|
||||
// The debuff row under the bars: icon square, its text (stack digit, "+N"), and the room it takes (0 = none).
|
||||
public float IconSize, IconTextSize, IconsH;
|
||||
// The debuff row's text (stack digit, "+N") before the row's own size scales it.
|
||||
public float IconTextSize;
|
||||
public ImFontPtr IconText;
|
||||
}
|
||||
|
||||
private static Layout Measure(float uiScale)
|
||||
{
|
||||
Layout l = default;
|
||||
float k = l.K = MonsterHudSettings.Scale * uiScale;
|
||||
float k = MonsterHudSettings.Scale * uiScale;
|
||||
bool numbers = l.Numbers = MonsterHudSettings.SelfNumbers;
|
||||
// With numbers on, the bars grow to fit bold, outlined text that reads over any fill.
|
||||
// Width, height and text each have their own multiplier on top (1 = the default look).
|
||||
l.BarW = MathF.Round((numbers ? 124f : 96f) * k * MonsterHudSettings.SelfBarWidth);
|
||||
l.BarH = MathF.Round((numbers ? 15f : 5f) * k * MonsterHudSettings.SelfBarHeight);
|
||||
l.Gap = MathF.Max(2f, MathF.Round(2f * k));
|
||||
l.Round = MathF.Max(1f, 1.5f * k);
|
||||
// Sized from the 11 px bold bake, drawn from the smallest bake at least that big (no blur when scaled up;
|
||||
// nothing is re-baked when the text size changes).
|
||||
float text = MonsterHudSettings.Scale * MonsterHudSettings.SelfTextSize;
|
||||
l.SmallSize = MathF.Round(ImGuiFonts.Get(UiFont.UiBold11).FontSize * text);
|
||||
l.Small = ImGuiFonts.Sharp(l.SmallSize, bold: true);
|
||||
l.BlockH = 3 * l.BarH + 2 * l.Gap;
|
||||
l.NameSize = MathF.Round(ImGuiFonts.Get(UiFont.UiBold11).FontSize * text);
|
||||
l.NameFont = ImGuiFonts.Sharp(l.NameSize, bold: true);
|
||||
l.NameH = MonsterHudSettings.SelfName ? l.NameSize + 3f * k : 0f;
|
||||
// With numbers on, the bars grow to fit bold, outlined text that reads over any fill. Width, height
|
||||
// and text each have their own multiplier on top (1 = the default look). The debuff row takes room
|
||||
// only while there is an icon, at "Your debuff icon size" (not the text size).
|
||||
l.M = SelfPlateMetrics.Measure(k, numbers, MonsterHudSettings.SelfBarWidth, MonsterHudSettings.SelfBarHeight,
|
||||
MonsterHudSettings.SelfName ? l.NameSize : 0f, _iconCount > 0, MonsterHudSettings.SelfDebuffIconSize);
|
||||
l.Track = MonsterHudSettings.SelfBarTrack;
|
||||
l.Chip = MonsterHudSettings.SelfBarChip;
|
||||
l.Outline = MonsterHudSettings.SelfTextOutline;
|
||||
l.Band = MonsterHudSettings.SelfNumberBand;
|
||||
// The debuff row: the monster plates' icon size and small text, only while there is an icon.
|
||||
l.IconSize = MathF.Round(13f * k);
|
||||
// The debuff row's small text: the monster plates' 9 px bake at your text size (the row scales it).
|
||||
l.IconTextSize = MathF.Round(ImGuiFonts.Get(UiFont.Ui9).FontSize * text);
|
||||
l.IconText = ImGuiFonts.Sharp(l.IconTextSize, bold: false);
|
||||
l.IconsH = _iconCount > 0 ? MathF.Round(3f * k) + l.IconSize + 3f : 0f;
|
||||
// Icons made bigger than the default can be wider than the bars: the clamp and the drag area cover them.
|
||||
if (_iconCount > 0 && l.M.Row.Scale > 1f)
|
||||
l.M.IconsOver = l.M.Row.Overhang(DebuffIconRow.Width(_icons.Length, _iconCount, others: false, in l.M.Row,
|
||||
l.IconText, l.IconTextSize, ref _overflowKey, ref _overflowText), l.M.BarW);
|
||||
return l;
|
||||
}
|
||||
|
||||
|
|
@ -382,12 +389,13 @@ internal static class PlayerPlate
|
|||
private static float Paint(ImDrawListPtr dl, ref Layout l, float left, float y, long now)
|
||||
{
|
||||
float a = Math.Clamp(_alpha, 0f, 1f);
|
||||
ref SelfPlateMetrics m = ref l.M;
|
||||
PaintOne(dl, ref _hp, ref l, left, y, a, HealthCol);
|
||||
PaintOne(dl, ref _st, ref l, left, y + l.BarH + l.Gap, a, StaminaCol);
|
||||
PaintOne(dl, ref _mn, ref l, left, y + 2 * (l.BarH + l.Gap), a, ManaCol);
|
||||
PaintOne(dl, ref _st, ref l, left, y + m.BarH + m.Gap, a, StaminaCol);
|
||||
PaintOne(dl, ref _mn, ref l, left, y + 2 * (m.BarH + m.Gap), a, ManaCol);
|
||||
if (_iconCount > 0)
|
||||
DebuffIconRow.Paint(dl, _icons, _iconCount, others: false, l.IconSize, l.IconText, l.IconTextSize,
|
||||
ref _overflowKey, ref _overflowText, left + l.BarW * 0.5f, y + l.BlockH + MathF.Round(3f * l.K), l.K, a, now);
|
||||
DebuffIconRow.Paint(dl, _icons, _iconCount, others: false, in m.Row, l.IconText, l.IconTextSize,
|
||||
ref _overflowKey, ref _overflowText, left + m.BarW * 0.5f, y + m.RowTop, a, now);
|
||||
float top = y - 1f;
|
||||
if (MonsterHudSettings.SelfName)
|
||||
{
|
||||
|
|
@ -395,7 +403,7 @@ internal static class PlayerPlate
|
|||
if (name.Length > 0)
|
||||
{
|
||||
float w = MonsterHud.TextWidth(l.NameFont, l.NameSize, name);
|
||||
var pos = new Vector2(MathF.Round(left + (l.BarW - w) * 0.5f), MathF.Round(y - 3f * l.K - l.NameSize));
|
||||
var pos = new Vector2(MathF.Round(left + (m.BarW - w) * 0.5f), MathF.Round(y - 3f * m.K - l.NameSize));
|
||||
if (l.Outline) MonsterHud.OutlinedText(dl, l.NameFont, l.NameSize, pos, a, name);
|
||||
dl.AddText(l.NameFont, l.NameSize, pos, MonsterHud.Mul(NameCol, a), name);
|
||||
top = pos.Y;
|
||||
|
|
@ -430,11 +438,11 @@ internal static class PlayerPlate
|
|||
|
||||
private static void PaintOne(ImDrawListPtr dl, ref BarState b, ref Layout l, float left, float top, float a, uint col)
|
||||
{
|
||||
float w = l.BarW, h = l.BarH, size = l.SmallSize;
|
||||
float w = l.M.BarW, h = l.M.BarH, size = l.SmallSize;
|
||||
ImFontPtr font = l.Small;
|
||||
var b0 = new Vector2(left, top);
|
||||
var b1 = new Vector2(left + w, top + h);
|
||||
MonsterHud.PaintBar(dl, b0, b1, l.Round, a, b.Shown, b.Trail, col, ticks: false, track: l.Track, chip: l.Chip);
|
||||
MonsterHud.PaintBar(dl, b0, b1, l.M.Round, a, b.Shown, b.Trail, col, ticks: false, track: l.Track, chip: l.Chip);
|
||||
if (!l.Numbers || h < 8f || b.Max == 0) return;
|
||||
long key = ((long)b.Max << 32) | b.Cur;
|
||||
string? text = b.Text;
|
||||
|
|
|
|||
Loading…
Reference in a new issue