RynthSuite/Plugins/RynthCore.Plugin.RynthAi/Huds/HudDraw.cs
BlankenshipG 09b14d4ed1 feat(rynthai): ILT Hub, HUDs, item info, chat translation, ground loot and nav editing
- ILT Hub (overlay window, /ra hub): character progression, pets, quests,
  gear, banking, guardian, buff keepers, session rates, USD import.
- Floating HUDs: combat tracker, item count HUD, Mini Remote (/ra remote,
  /ra huds).
- Item info (Mag-style describer) on select, with its own settings window.
- Chat translation (/ra translate) for chosen channels.
- Ground loot: loose items matching the loot profile are picked up when no
  corpse is in range (CorpseOpenController).
- Nav: breadcrumb recorder, route overlay, and the route editor commands
  the engine Nav panel sends (multi-select move/duplicate/delete, reverse,
  snap to path, pauses, portals, simplify, trail -> route).
- Pets: refill-loop guard for essences the server just confirmed full;
  optional ILT Hub hooks (summon on empty, hold, yield a cosmetic pet).
- QuestTracker: quiet refreshes, Disabled / LastStatus for the hub.
- WorldObjectCache: typed items (keys, gems, comps, food) are placed in
  inventory or landscape by ownership instead of staying Unknown.
- Install-aware data folders (RynthInstallPaths) and a per-category
  diagnostics log (Diagnostics/RynthLog, diagnostics.json).
- Monster Editor: VirindiTank USD import and "Import UB damage insights"
  (ub-mob-seed.json); RynthAi loads the seed (UbMobSeedStore).

Kept as on rynth/main: combat (ammo, off-hand/shield rules), AutoStack in
InventoryManager, LegacyAdvancedSettingsUi and the version stamping. No
host API slots are used; new engine data comes from optional exports
(RynthPluginRenderOverlay, RynthPluginGetProgressionJson,
RynthPluginGetCharmsJson).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-05 16:52:13 -04:00

56 lines
2.3 KiB
C#

// HudDraw.cs — Small ImGui drawing helpers shared by the HUD windows (render thread only).
using System;
using System.Numerics;
using ImGuiNET;
namespace RynthCore.Plugin.RynthAi.Huds;
internal static class HudDraw
{
private static readonly Vector4 Opaque = new(1f, 1f, 1f, 1f);
private static readonly Vector4 Faded = new(1f, 1f, 1f, 0.35f);
private static readonly Vector4 NoBorder = Vector4.Zero;
/// <summary>
/// Draws an item icon of <paramref name="size"/> pixels. While the texture is still
/// loading (or the item has no icon) a framed box with the name's first letter stands in.
/// <paramref name="dim"/> fades it (e.g. none carried).
/// </summary>
public static void Icon(HudIconCache icons, uint iconDid, string name, float size, bool dim)
{
IntPtr tex = icons.GetTexture(iconDid);
var sz = new Vector2(size, size);
if (tex != IntPtr.Zero)
{
ImGui.Image(tex, sz, Vector2.Zero, Vector2.One, dim ? Faded : Opaque, NoBorder);
return;
}
Placeholder(name, sz, dim);
}
/// <summary>Framed stand-in with the item's first letter, same footprint as an icon.</summary>
public static void Placeholder(string name, Vector2 size, bool dim)
{
Vector2 p = ImGui.GetCursorScreenPos();
ImGui.Dummy(size);
var dl = ImGui.GetWindowDrawList();
uint frame = ImGui.GetColorU32(new Vector4(0.45f, 0.55f, 0.65f, dim ? 0.35f : 0.8f));
uint fill = ImGui.GetColorU32(new Vector4(0.12f, 0.16f, 0.22f, dim ? 0.35f : 0.8f));
dl.AddRectFilled(p, p + size, fill, 3f);
dl.AddRect(p, p + size, frame, 3f);
if (string.IsNullOrEmpty(name)) return;
string letter = name.Substring(0, 1).ToUpperInvariant();
Vector2 ts = ImGui.CalcTextSize(letter);
dl.AddText(p + (size - ts) * 0.5f, ImGui.GetColorU32(new Vector4(0.9f, 0.9f, 0.9f, dim ? 0.4f : 1f)), letter);
}
/// <summary>"1468", "12.3k", "4.5m", "1.2b" — compact counts for tight HUD rows.</summary>
public static string Compact(double v)
{
double a = Math.Abs(v);
if (a >= 1e9) return (v / 1e9).ToString("0.0") + "b";
if (a >= 1e6) return (v / 1e6).ToString("0.0") + "m";
if (a >= 1e4) return (v / 1e3).ToString("0.0") + "k";
return v.ToString("0");
}
}