Snapshot for release 2026.10.9.3 (internal 3bc5f9f)
This commit is contained in:
parent
c94fa9deec
commit
194ea479a0
28 changed files with 1902 additions and 127 deletions
|
|
@ -138,7 +138,10 @@ internal static unsafe class DX9Backend
|
|||
private const uint D3DRS_WRAP0 = 128;
|
||||
|
||||
// D3DTEXTUREFILTERTYPE
|
||||
private const uint D3DTEXF_LINEAR = 2;
|
||||
private const uint D3DTEXF_LINEAR = 2, D3DTEXF_POINT = 1;
|
||||
// Draw-list callbacks this renderer understands besides ResetRenderState (see IconSampling): the sampler
|
||||
// for the draw commands that follow, until the next one or the end of the list.
|
||||
|
||||
|
||||
// FVF: xyz (3 floats) + diffuse (uint) + 1 tex coord (2 floats)
|
||||
private const uint D3DFVF_XYZ = 0x002;
|
||||
|
|
@ -661,8 +664,15 @@ internal static unsafe class DX9Backend
|
|||
|
||||
if (cmd->UserCallback != IntPtr.Zero)
|
||||
{
|
||||
if ((int)cmd->UserCallback == ResetRenderStateSentinel)
|
||||
int cb = (int)cmd->UserCallback;
|
||||
if (cb == ResetRenderStateSentinel)
|
||||
SetupRenderStateNative(pDevice, displayPos, displaySize);
|
||||
else if (cb == IconSampling.PointSentinel || cb == IconSampling.LinearSentinel)
|
||||
{
|
||||
uint f = cb == IconSampling.PointSentinel ? D3DTEXF_POINT : D3DTEXF_LINEAR;
|
||||
_setSamplerState!(pDevice, 0, D3DSAMP_MINFILTER, f);
|
||||
_setSamplerState!(pDevice, 0, D3DSAMP_MAGFILTER, f);
|
||||
}
|
||||
// Other callbacks are not supported (no managed callbacks
|
||||
// from inside the render path); they carry no geometry.
|
||||
continue;
|
||||
|
|
|
|||
24
src/RynthCore.Engine/ImGui/IconSampling.cs
Normal file
24
src/RynthCore.Engine/ImGui/IconSampling.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/IconSampling.cs
|
||||
// Item icons are 32x32 pictures drawn bigger; retail draws them point-sampled (crisp, hard-edged
|
||||
// pixels, so its black outline stays a black line) and ImGui's default is a linear filter that blurs
|
||||
// them. A face wraps its icon draws in Begin / End: two draw-list "callbacks" that DX9Backend answers by
|
||||
// switching sampler 0's filter for the commands after them (no managed code runs in the render path).
|
||||
// Every list starts back on linear (SetupRenderState), so a missed End cannot leak past its list.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend;
|
||||
|
||||
internal static class IconSampling
|
||||
{
|
||||
public const int PointSentinel = -101, LinearSentinel = -102;
|
||||
|
||||
/// <summary>The draws after this are point-sampled.</summary>
|
||||
public static void Begin(ImDrawListPtr dl) => dl.AddCallback(new IntPtr(PointSentinel), IntPtr.Zero);
|
||||
|
||||
/// <summary>The draws after this are linear again.</summary>
|
||||
public static void End(ImDrawListPtr dl) => dl.AddCallback(new IntPtr(LinearSentinel), IntPtr.Zero);
|
||||
}
|
||||
|
|
@ -90,8 +90,7 @@ internal static class MonsterHud
|
|||
|
||||
// Element colours, shared by the "weak to" pill and the vulnerability icons.
|
||||
private static readonly uint ElemSlash = C(0xFFC9D1DB), ElemPierce = C(0xFFD9C19A), ElemBludgeon = C(0xFFB59A7E),
|
||||
ElemFire = C(0xFFFF7A3D), ElemCold = C(0xFF7FD3FF), ElemLightning = C(0xFFC89BFF), ElemAcid = C(0xFF8FE36A),
|
||||
ElemNether = C(0xFFB06BE0);
|
||||
ElemFire = C(0xFFFF7A3D), ElemCold = C(0xFF7FD3FF), ElemLightning = C(0xFFC89BFF), ElemAcid = C(0xFF8FE36A);
|
||||
|
||||
// One glyph and tint per DebuffKind (index = kind).
|
||||
private static readonly string[] KindGlyph =
|
||||
|
|
@ -174,7 +173,8 @@ internal static class MonsterHud
|
|||
public int OverflowKey = -1;
|
||||
}
|
||||
|
||||
private sealed record WeakTag(string Label, uint Color);
|
||||
// Icon: a Phosphor glyph drawn before the letters, so the element reads at a glance.
|
||||
private sealed record WeakTag(string Label, uint Color, string Icon);
|
||||
|
||||
private const float DefaultHeadHeight = 2.0f;
|
||||
private static readonly Dictionary<uint, Plate> Plates = new(64);
|
||||
|
|
@ -687,23 +687,34 @@ internal static class MonsterHud
|
|||
_weakByName = byName;
|
||||
}
|
||||
|
||||
/// <summary>"Bludgeon 1.0, Pierce 0.86" -> the first (most damage taken) element.</summary>
|
||||
/// <summary>
|
||||
/// "Bludgeon 1.0, Pierce 0.86" -> the first (most damage taken) element. Nether is
|
||||
/// skipped: everything takes it, so the pill shows the next element instead.
|
||||
/// </summary>
|
||||
private static WeakTag? ParseWeak(string weak)
|
||||
{
|
||||
int comma = weak.IndexOf(',');
|
||||
string first = (comma > 0 ? weak[..comma] : weak).Trim();
|
||||
int sp = first.IndexOf(' ');
|
||||
string elem = sp > 0 ? first[..sp] : first;
|
||||
return elem.ToLowerInvariant() switch
|
||||
foreach (string part in weak.Split(','))
|
||||
{
|
||||
"slash" or "slashing" => new WeakTag("SL", ElemSlash),
|
||||
"pierce" or "piercing" => new WeakTag("PI", ElemPierce),
|
||||
"bludgeon" or "bludgeoning" => new WeakTag("BL", ElemBludgeon),
|
||||
"fire" => new WeakTag("FI", ElemFire),
|
||||
"cold" => new WeakTag("CO", ElemCold),
|
||||
"lightning" or "electric" => new WeakTag("LI", ElemLightning),
|
||||
"acid" => new WeakTag("AC", ElemAcid),
|
||||
"nether" => new WeakTag("NE", ElemNether),
|
||||
string first = part.Trim();
|
||||
int sp = first.IndexOf(' ');
|
||||
string elem = (sp > 0 ? first[..sp] : first).ToLowerInvariant();
|
||||
if (elem.Length == 0 || elem == "nether") continue;
|
||||
return ElementTag(elem);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static WeakTag? ElementTag(string elem)
|
||||
{
|
||||
return elem switch
|
||||
{
|
||||
"slash" or "slashing" => new WeakTag("SL", ElemSlash, PhosphorIcons.Sword),
|
||||
"pierce" or "piercing" => new WeakTag("PI", ElemPierce, PhosphorIcons.Knife),
|
||||
"bludgeon" or "bludgeoning" => new WeakTag("BL", ElemBludgeon, PhosphorIcons.Hammer),
|
||||
"fire" => new WeakTag("FI", ElemFire, PhosphorIcons.Fire),
|
||||
"cold" => new WeakTag("CO", ElemCold, PhosphorIcons.Snowflake),
|
||||
"lightning" or "electric" => new WeakTag("LI", ElemLightning, PhosphorIcons.Lightning),
|
||||
"acid" => new WeakTag("AC", ElemAcid, PhosphorIcons.Flask),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
|
@ -1244,17 +1255,19 @@ internal static class MonsterHud
|
|||
}
|
||||
}
|
||||
|
||||
// Left of the bar: the "weak to" element pill.
|
||||
// Left of the bar: the "weak to" element pill, its icon then its letters.
|
||||
if (p.Weak != null)
|
||||
{
|
||||
float pw = TextWidth(p.SmallFont, p.SmallSize, p.Weak.Label) + 6f * k;
|
||||
float iw = TextWidth(p.SmallFont, p.SmallSize, p.Weak.Icon) + 2f * k;
|
||||
float pw = iw + TextWidth(p.SmallFont, p.SmallSize, p.Weak.Label) + 6f * k;
|
||||
float ph = MathF.Max(p.BarH + 2f, p.SmallSize + 2f);
|
||||
var q0 = new Vector2(MathF.Round(barL - 4f * k - pw), MathF.Round(barTop + (p.BarH - ph) * 0.5f));
|
||||
var q1 = q0 + new Vector2(pw, ph);
|
||||
dl.AddRectFilled(q0, q1, Mul(BadgeBack, a), 3f * k);
|
||||
dl.AddRect(q0, q1, Mul(p.Weak.Color, a * 0.9f), 3f * k, ImDrawFlags.None, 1f);
|
||||
var tp = new Vector2(MathF.Round(q0.X + 3f * k), MathF.Round(q0.Y + (ph - p.SmallSize) * 0.5f));
|
||||
dl.AddText(p.SmallFont, p.SmallSize, tp, Mul(p.Weak.Color, a), p.Weak.Label);
|
||||
dl.AddText(p.SmallFont, p.SmallSize, tp, Mul(p.Weak.Color, a), p.Weak.Icon);
|
||||
dl.AddText(p.SmallFont, p.SmallSize, tp + new Vector2(MathF.Round(iw), 0), Mul(p.Weak.Color, a), p.Weak.Label);
|
||||
}
|
||||
|
||||
// Distance, right of the bar.
|
||||
|
|
|
|||
|
|
@ -45,6 +45,18 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
{
|
||||
public const string Title = "Chat";
|
||||
|
||||
// The channel tabs live in a drawer on the window's left edge (Tom 2026-10-09: the
|
||||
// wrapped tab rows took too much room), the way the dashboard's ranges do.
|
||||
private readonly ChannelsDrawer _channels;
|
||||
private readonly DashboardDrawers _drawers;
|
||||
private bool _openTabsPopup;
|
||||
|
||||
public ChatFace()
|
||||
{
|
||||
_channels = new ChannelsDrawer(this);
|
||||
_drawers = new DashboardDrawers("##chat_drawers", _channels);
|
||||
}
|
||||
|
||||
public static void Register() => ImGuiPanelHost.Register(Title,
|
||||
new PanelSpec(new Vector2(460, 300), new Vector2(260, 140), Background: 0, EdgeToEdge: true, GripInBody: true),
|
||||
() => new ChatFace());
|
||||
|
|
@ -142,10 +154,7 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
string tab = ChatModel.CurrentTab();
|
||||
UpdateUnread(lines, snap?.Version ?? -1, tab);
|
||||
|
||||
float y = DrawTabStrip(new Vector2(x0, origin.Y + 4), w);
|
||||
|
||||
DrawSearch(new Vector2(x0, y), w);
|
||||
y += 26;
|
||||
float y = DrawHeader(new Vector2(x0, origin.Y + 4), w);
|
||||
|
||||
SyncLines(snap, lines, tab);
|
||||
|
||||
|
|
@ -163,77 +172,174 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.PopStyleVar();
|
||||
DrawPopups();
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
_drawers.Draw(); // last: its own window, placed against this one
|
||||
}
|
||||
|
||||
// ── Tabs ─────────────────────────────────────────────────────────────
|
||||
|
||||
private const string SearchHint = PhosphorIcons.MagnifyingGlass + " Search…";
|
||||
private const string FiltersLabel = PhosphorIcons.Funnel + " Filters";
|
||||
|
||||
/// <summary>Tabs wrap left of Filters and the settings gear. Returns the y below the strip.</summary>
|
||||
private float DrawTabStrip(Vector2 start, float w)
|
||||
/// <summary>
|
||||
/// One row: the channel button (current tab, unread elsewhere; it opens the channels
|
||||
/// drawer, or a list when popped out), search, Filters and the gear. Returns the y below it.
|
||||
/// </summary>
|
||||
private float DrawHeader(Vector2 start, float w)
|
||||
{
|
||||
const float h = 20;
|
||||
float gearW = 22, filtW = ButtonWidth(FiltersLabel) - 4;
|
||||
float right = start.X + w;
|
||||
const float h = 22;
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float gearW = 22, filtW = 22, right = start.X + w;
|
||||
if (IconButton("##chat_gear", PhosphorIcons.Gear, new Vector2(right - gearW, start.Y), new Vector2(gearW, h), Text, BtnFill))
|
||||
_openSettings = true;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Chat settings");
|
||||
if (Button("##chat_filters", FiltersLabel, new Vector2(right - gearW - 3 - filtW, start.Y), new Vector2(filtW, h), Text, BtnFill))
|
||||
if (IconButton("##chat_filters", PhosphorIcons.Funnel, new Vector2(right - gearW - 3 - filtW, start.Y), new Vector2(filtW, h), Text, BtnFill))
|
||||
PanelRouter.Toggle("ChatFilters");
|
||||
ImGuiNET.ImGui.SetItemTooltip("Rules: move, copy or hide lines by regex, and colour them");
|
||||
ImGuiNET.ImGui.SetItemTooltip("Filters: move, copy or hide lines by regex, and colour them");
|
||||
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float stripRight = right - gearW - filtW - 8;
|
||||
float x = start.X, y = start.Y;
|
||||
// The channel button: icon, current tab, and the unread count of every other tab.
|
||||
string current = ChatModel.CurrentTab();
|
||||
int others = 0;
|
||||
bool mention = false;
|
||||
foreach (var kv in _unread)
|
||||
{
|
||||
if (string.Equals(kv.Key, current, StringComparison.OrdinalIgnoreCase)) continue;
|
||||
others += kv.Value.Count;
|
||||
mention |= kv.Value.Mention && kv.Value.Count > 0;
|
||||
}
|
||||
string? badge = others > 0 ? (others > 99 ? "99+" : others.ToString()) : null;
|
||||
float badgeW = badge != null ? BadgeWidth(badge) : 0;
|
||||
string label = PhosphorIcons.ChatCircleText + " " + current;
|
||||
float labelW = ImGuiNET.ImGui.CalcTextSize(label).X;
|
||||
float caretW = ImGuiNET.ImGui.CalcTextSize(PhosphorIcons.CaretDown).X;
|
||||
float bw = MathF.Min(labelW + 16 + caretW + (badge != null ? badgeW + 4 : 0), w * 0.45f);
|
||||
bool drawerOpen = _drawers.IsOpen(_channels);
|
||||
if (Button("##chat_channel", "", start, new Vector2(bw, h), Text, drawerOpen ? TabActive : BtnFill))
|
||||
{
|
||||
if (ImGuiPopOuts.InPopOutFrame) _openTabsPopup = true; // no drawer beside a popped-out window
|
||||
else _drawers.Toggle(_channels);
|
||||
}
|
||||
if (ImGuiNET.ImGui.IsItemHovered(ImGuiHoveredFlags.ForTooltip))
|
||||
ImGuiNET.ImGui.SetTooltip(mention ? "Channels (someone mentioned you)" : "Channels: pick a tab, see what's unread");
|
||||
float ty = start.Y + (h - ImGuiNET.ImGui.GetFontSize()) * 0.5f;
|
||||
dl.PushClipRect(start, start + new Vector2(bw - caretW - 6 - (badge != null ? badgeW + 4 : 0), h), true);
|
||||
dl.AddText(new Vector2(start.X + 6, ty), Text, label);
|
||||
dl.PopClipRect();
|
||||
float bx = start.X + bw - caretW - 6;
|
||||
if (badge != null)
|
||||
{
|
||||
bx -= badgeW + 4;
|
||||
DrawBadge(dl, new Vector2(bx, start.Y + 4), badgeW, h - 8, badge, mention);
|
||||
bx += badgeW + 4;
|
||||
}
|
||||
dl.AddText(new Vector2(start.X + bw - caretW - 5, ty), Mute, PhosphorIcons.CaretDown);
|
||||
|
||||
// Search fills the rest.
|
||||
float sx = start.X + bw + 4, sw = right - gearW - filtW - 7 - sx;
|
||||
if (sw > 40) DrawSearch(new Vector2(sx, start.Y), sw);
|
||||
return start.Y + h + 4;
|
||||
}
|
||||
|
||||
private static float BadgeWidth(string badge)
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
float w = ImGuiNET.ImGui.CalcTextSize(badge).X + 8;
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
return w;
|
||||
}
|
||||
|
||||
private static void DrawBadge(ImDrawListPtr dl, Vector2 p, float w, float h, string badge, bool mention)
|
||||
{
|
||||
dl.AddRectFilled(p, p + new Vector2(w, h), mention ? BadgeMention : BadgeBg, h * 0.5f);
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
dl.AddText(p + new Vector2(4, (h - ImGuiNET.ImGui.GetFontSize()) * 0.5f), Text, badge);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The channel rows (the drawer's panel; the popped-out list draws its own): each tab with
|
||||
/// its unread count, the current one highlighted; click picks it, right-click renames or
|
||||
/// deletes a created tab; "+ New tab" at the end.
|
||||
/// </summary>
|
||||
private void DrawChannelRows(Vector2 start, float w, float rowH)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
string current = ChatModel.CurrentTab();
|
||||
float y = start.Y;
|
||||
foreach (string tab in ChatModel.AllTabs())
|
||||
{
|
||||
bool custom = !ChatModel.IsBaseTab(tab);
|
||||
bool active = string.Equals(tab, current, StringComparison.OrdinalIgnoreCase);
|
||||
_unread.TryGetValue(tab, out var unread);
|
||||
string? badge = !active && unread.Count > 0 ? (unread.Count > 99 ? "99+" : unread.Count.ToString()) : null;
|
||||
float badgeW = 0;
|
||||
if (badge != null)
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
badgeW = ImGuiNET.ImGui.CalcTextSize(badge).X + 8;
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
float textW = ImGuiNET.ImGui.CalcTextSize(tab).X;
|
||||
// No inline delete button on custom tabs: right-click → Delete tab does it and
|
||||
// the red X cost a tab's worth of strip width (2026-09-30).
|
||||
float bw = textW + 12 + (badge != null ? badgeW + 3 : 0), extra = 0;
|
||||
if (x > start.X && x + bw + extra > stripRight) { x = start.X; y += h + 2; }
|
||||
ImGuiNET.ImGui.PushID(tab);
|
||||
var p = new Vector2(x, y);
|
||||
if (Button("##tab", "", p, new Vector2(bw, h), Text, active ? TabActive : BtnFill))
|
||||
var p = new Vector2(start.X, y);
|
||||
if (Button("##row", "", p, new Vector2(w, rowH), Text, active ? TabActive : BtnFill))
|
||||
ChatModel.SelectTab(tab);
|
||||
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right)) { _ctxTab = tab; _openTabMenu = true; }
|
||||
if (unread.Mention && !active) ImGuiNET.ImGui.SetItemTooltip("Someone mentioned you here");
|
||||
else if (custom) ImGuiNET.ImGui.SetItemTooltip("Right-click to rename or delete this tab");
|
||||
float ty = y + (h - ImGuiNET.ImGui.GetFontSize()) * 0.5f;
|
||||
dl.AddText(new Vector2(x + 6, ty), Text, tab);
|
||||
if (badge != null)
|
||||
{
|
||||
var b0 = new Vector2(x + 6 + textW + 3, y + 4);
|
||||
dl.AddRectFilled(b0, b0 + new Vector2(badgeW, h - 8), unread.Mention ? BadgeMention : BadgeBg, (h - 8) * 0.5f);
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
dl.AddText(b0 + new Vector2(4, (h - 8 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), Text, badge);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
else if (!ChatModel.IsBaseTab(tab)) ImGuiNET.ImGui.SetItemTooltip("Right-click to rename or delete this tab");
|
||||
float badgeW = badge != null ? BadgeWidth(badge) : 0;
|
||||
float ty = y + (rowH - ImGuiNET.ImGui.GetFontSize()) * 0.5f;
|
||||
dl.PushClipRect(p, p + new Vector2(w - (badge != null ? badgeW + 8 : 0), rowH), true);
|
||||
dl.AddText(new Vector2(p.X + 6, ty), active ? Teal : Text, tab);
|
||||
dl.PopClipRect();
|
||||
if (badge != null) DrawBadge(dl, new Vector2(p.X + w - badgeW - 4, y + 3), badgeW, rowH - 6, badge, unread.Mention);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
x += bw + extra + 2;
|
||||
y += rowH + 2;
|
||||
}
|
||||
if (x > start.X && x + 18 > stripRight) { x = start.X; y += h + 2; }
|
||||
if (IconButton("##chat_addtab", PhosphorIcons.Plus, new Vector2(x, y), new Vector2(18, h), TabAdd, BtnFill, font: UiFont.Ui11))
|
||||
if (Button("##chat_addtab", PhosphorIcons.Plus + " New tab", new Vector2(start.X, y), new Vector2(w, rowH), TabAdd, BtnFill))
|
||||
{
|
||||
_pendingRule = null;
|
||||
WriteUtf8(_newTab, "");
|
||||
_openNewTab = _focusNewTab = true;
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("New tab (fill it with a rule: right-click a line, or Filters)");
|
||||
return y + h + 4;
|
||||
}
|
||||
|
||||
/// <summary>Popped out (no drawer beside the window): the channels as a list under the button.</summary>
|
||||
private void DrawTabsPopup()
|
||||
{
|
||||
if (!ImGuiNET.ImGui.BeginPopup("##chat_tabs")) return;
|
||||
string current = ChatModel.CurrentTab();
|
||||
foreach (string tab in ChatModel.AllTabs())
|
||||
{
|
||||
_unread.TryGetValue(tab, out var unread);
|
||||
bool active = string.Equals(tab, current, StringComparison.OrdinalIgnoreCase);
|
||||
string label = !active && unread.Count > 0 ? $"{tab} ({unread.Count})" : tab;
|
||||
if (ImGuiNET.ImGui.Selectable(label + "##tabsel_" + tab, active)) ChatModel.SelectTab(tab);
|
||||
}
|
||||
ImGuiNET.ImGui.Separator();
|
||||
if (ImGuiNET.ImGui.Selectable(PhosphorIcons.Plus + " New tab"))
|
||||
{
|
||||
_pendingRule = null;
|
||||
WriteUtf8(_newTab, "");
|
||||
_openNewTab = _focusNewTab = true;
|
||||
}
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
|
||||
/// <summary>The channels drawer on the chat window's left edge (DashboardDrawers' mechanics).</summary>
|
||||
private sealed class ChannelsDrawer : DashboardDrawer
|
||||
{
|
||||
private const float RowH = 20;
|
||||
private static bool s_open; // this session only
|
||||
private readonly ChatFace _face;
|
||||
|
||||
public ChannelsDrawer(ChatFace face) => _face = face;
|
||||
|
||||
public override string Key => "chat_channels";
|
||||
public override string Icon => PhosphorIcons.ChatCircleText;
|
||||
public override string Name => "channels";
|
||||
public override string TabTooltip(bool right) => "Channels: every tab, with what's unread";
|
||||
public override float Width(float k) => 150 * k;
|
||||
public override float Height(float k) =>
|
||||
(2 * Pad + TitleH + 4) * k + (ChatModel.AllTabs().Length + 1) * (RowH + 2) * k;
|
||||
public override bool SavedOpen => s_open;
|
||||
public override void SaveOpen(bool open) => s_open = open;
|
||||
|
||||
public override void DrawPanel(Vector2 origin, float width, float height, float k)
|
||||
{
|
||||
float y = PanelFrame(origin, width, height, k, Icon, "CHANNELS", null, "Hide the channels");
|
||||
_face.DrawChannelRows(new Vector2(origin.X + Pad * k, y), width - 2 * Pad * k, RowH * k);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -727,6 +833,7 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
if (_openTabMenu) { _openTabMenu = false; ImGuiNET.ImGui.OpenPopup("##chat_tabmenu"); }
|
||||
if (_openLineMenu) { _openLineMenu = false; ImGuiNET.ImGui.OpenPopup("##chat_linemenu"); }
|
||||
if (_openRename) { _openRename = false; ImGuiNET.ImGui.OpenPopup("##chat_rename"); }
|
||||
if (_openTabsPopup) { _openTabsPopup = false; ImGuiNET.ImGui.OpenPopup("##chat_tabs"); }
|
||||
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, RynthTheme.Argb(0xF2060C14));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, TabActive);
|
||||
|
|
@ -739,6 +846,7 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(10, 8));
|
||||
|
||||
DrawSettingsPopup();
|
||||
DrawTabsPopup();
|
||||
DrawNewTabPopup();
|
||||
DrawTabMenu();
|
||||
DrawRenamePopup();
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ internal abstract class DashboardDrawer
|
|||
/// <summary>The tabs and the one open drawer beside the RynthAi dashboard.</summary>
|
||||
internal sealed class DashboardDrawers
|
||||
{
|
||||
private const string WindowId = "##rynthai_drawers";
|
||||
private readonly string WindowId; // "##rynthai_drawers" for the dashboard; the chat has its own
|
||||
private const float SlideSeconds = 0.14f;
|
||||
|
||||
private static readonly uint Teal = RynthTheme.Argb(0xFF26D9E6), Mute = RynthTheme.Argb(0xFFB8C8D8),
|
||||
|
|
@ -123,8 +123,12 @@ internal sealed class DashboardDrawers
|
|||
private float _t; // slide position of _shown, 0 closed .. 1 open
|
||||
private bool _loaded;
|
||||
|
||||
public DashboardDrawers(params DashboardDrawer[] drawers)
|
||||
public DashboardDrawers(params DashboardDrawer[] drawers) : this("##rynthai_drawers", drawers) { }
|
||||
|
||||
/// <summary>A drawer set beside another panel (RynthChat's channels): its own window id.</summary>
|
||||
public DashboardDrawers(string windowId, params DashboardDrawer[] drawers)
|
||||
{
|
||||
WindowId = windowId;
|
||||
_drawers = drawers;
|
||||
foreach (DashboardDrawer d in drawers) d.Host = this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,10 +34,12 @@
|
|||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.Compatibility;
|
||||
using RynthCore.Engine.Net;
|
||||
using RynthCore.Engine.UI;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.FaceKit;
|
||||
|
||||
|
|
@ -143,9 +145,14 @@ internal sealed partial class InventoryFace
|
|||
float ui = EngineFrameController.FontScale * PanelTextScale.Factor(ImGuiFonts.CurrentStep);
|
||||
if (!(ui > 0f) || !float.IsFinite(ui)) ui = 1f;
|
||||
ui *= InventorySettingsStore.SizeFactor; // the panel's own size (the - / + in the title bar)
|
||||
float s = Math.Max(0.4f, Math.Min(ui, size.X / RetailW));
|
||||
// Whole-pixel cells keep point-sampled icons even (32 px art drawn at 46.4 px is uneven).
|
||||
float want = Math.Max(0.4f, MathF.Round(32f * ui) / 32f);
|
||||
float s = Math.Max(0.4f, Math.Min(want, size.X / RetailW));
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float w = size.X;
|
||||
// Retail's window is a fixed width at its size: the panel follows it (the - / + in the title bar
|
||||
// resize it), so there is no spare strip beside the burden meter.
|
||||
FitWidth(size, RetailW * want);
|
||||
float w = Math.Min(size.X, RetailW * s);
|
||||
Vector2 o = origin;
|
||||
float statusH = MathF.Round(20 * s);
|
||||
float bottom = o.Y + size.Y - statusH;
|
||||
|
|
@ -171,7 +178,9 @@ internal sealed partial class InventoryFace
|
|||
float ry = toolsBottom - TitleH * s; // where retail y = 0 lands
|
||||
float r = Math.Max(ContentsY + 60, (bottom - ry) / s); // the retail window's height (px at scale 1)
|
||||
|
||||
float sx = o.X + w - SideW * s; // the side column follows the right edge
|
||||
// The side column sits against the grid, where retail has it: the retail window is a fixed width,
|
||||
// so a wider panel leaves its spare room on the right instead of a gap in the middle.
|
||||
float sx = o.X + Math.Min(w - SideW * s, (RetailW - SideW) * s);
|
||||
Paperdoll(view, dl, new Vector2(o.X, ry + FieldY * s), s);
|
||||
SideColumn(view, dl, new Vector2(sx, ry + FieldY * s), r, s, filtered);
|
||||
Contents(view, dl, new Vector2(o.X, ry + ContentsY * s), sx, r, s, filtered);
|
||||
|
|
@ -234,14 +243,37 @@ internal sealed partial class InventoryFace
|
|||
InventorySettingsStore.StepSize(+1);
|
||||
ImGuiNET.ImGui.SetItemTooltip($"Bigger ({InventorySettingsStore.SizePct}%)");
|
||||
if (TitleToggle("##inv_tools", PhosphorIcons.Funnel, b1, btn, InventorySettingsStore.ShowTools))
|
||||
{
|
||||
// Closing the search / filter row shows every item again.
|
||||
if (InventorySettingsStore.ShowTools) ClearFilters();
|
||||
InventorySettingsStore.SetShowTools(!InventorySettingsStore.ShowTools);
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Search, sort and filter");
|
||||
if (TitleToggle("##inv_modern", PhosphorIcons.SquaresFour, b2, btn, false))
|
||||
InventorySettingsStore.SetClassic(false);
|
||||
ImGuiNET.ImGui.SetItemTooltip("Modern look");
|
||||
|
||||
// Vault (Aelrynth only): the contents area shows the account vault instead of the open pack.
|
||||
float leftmost = bMinus.X;
|
||||
if (VaultFeed.Available)
|
||||
{
|
||||
var vsz = new Vector2(MathF.Round(38 * s), btn);
|
||||
var bV = new Vector2(bMinus.X - vsz.X - 8 * s, b2.Y);
|
||||
if (TitleTextToggle("##inv_vault", "Vault", bV, vsz, _vaultOpen))
|
||||
{
|
||||
_vaultOpen = !_vaultOpen;
|
||||
if (_vaultOpen) VaultFeed.ViewOpened();
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Your Aelrynth account vault");
|
||||
leftmost = bV.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
_vaultOpen = false;
|
||||
}
|
||||
|
||||
// Drag surface: the bar left of the toggles (moves the panel, like the header).
|
||||
float dragW = Math.Max(1, bMinus.X - o.X - 2);
|
||||
float dragW = Math.Max(1, leftmost - o.X - 2);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(o);
|
||||
ImGuiNET.ImGui.InvisibleButton("##inv_titledrag", new Vector2(dragW, h));
|
||||
ImGuiPanelHost.DragWindowWithLastItem();
|
||||
|
|
@ -256,10 +288,12 @@ internal sealed partial class InventoryFace
|
|||
ImGuiNET.ImGui.PushFont(f);
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(_titleText);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
float titlePx = 12 * s;
|
||||
ts *= titlePx / f.FontSize;
|
||||
float tx = o.X + (barW - ts.X) * 0.5f;
|
||||
if (tx + ts.X > bMinus.X - 4) tx = Math.Max(o.X + 10 * s, bMinus.X - 4 - ts.X);
|
||||
dl.PushClipRect(o + new Vector2(6 * s, 0), new Vector2(bMinus.X - 2, o.Y + h), true);
|
||||
dl.AddText(f, f.FontSize * InventorySettingsStore.SizeFactor, new Vector2(tx, o.Y + (h - ts.Y) * 0.5f), White, _titleText);
|
||||
if (tx + ts.X > leftmost - 4) tx = Math.Max(o.X + 10 * s, leftmost - 4 - ts.X);
|
||||
dl.PushClipRect(o + new Vector2(6 * s, 0), new Vector2(leftmost - 2, o.Y + h), true);
|
||||
dl.AddText(f, titlePx, new Vector2(tx, o.Y + (h - ts.Y) * 0.5f), White, _titleText);
|
||||
dl.PopClipRect();
|
||||
|
||||
// The retail close button.
|
||||
|
|
@ -301,7 +335,7 @@ internal sealed partial class InventoryFace
|
|||
if ((it.Location & slot.Mask) != 0) { worn = it; break; }
|
||||
if (slot.Sigil != 0 && worn == null && (view.AetheriaMask & slot.Sigil) == 0) continue; // locked sigil slot
|
||||
|
||||
var min = new Vector2(field.X + slot.X * s, field.Y + slot.Y * s);
|
||||
var min = new Vector2(MathF.Round(field.X + slot.X * s), MathF.Round(field.Y + slot.Y * s));
|
||||
var max = min + new Vector2(cell, cell);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(min);
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
|
|
@ -309,6 +343,9 @@ internal sealed partial class InventoryFace
|
|||
bool hovered = ImGuiNET.ImGui.IsItemHovered();
|
||||
ImGuiNET.ImGui.PopID();
|
||||
|
||||
// The slot's tile is drawn filled or not: it is part of the panel, and it is what says an
|
||||
// item is worn (retail draws a worn item like any other, over its slot).
|
||||
CellPicture(dl, slot.Empty, min, cell);
|
||||
if (worn != null)
|
||||
{
|
||||
DrawItemIcon(dl, worn.Id, min, cell, ReferenceEquals(worn, _dragItem) ? 0x60FFFFFFu : 0xFFFFFFFFu);
|
||||
|
|
@ -316,7 +353,6 @@ internal sealed partial class InventoryFace
|
|||
}
|
||||
else
|
||||
{
|
||||
CellPicture(dl, slot.Empty, min, cell);
|
||||
if (hovered)
|
||||
{
|
||||
_hoverLabel = slot.Name;
|
||||
|
|
@ -344,9 +380,10 @@ internal sealed partial class InventoryFace
|
|||
private void SideColumn(InventoryView view, ImDrawListPtr dl, Vector2 field, float r, float s, bool filtered)
|
||||
{
|
||||
// Burden: caption and percent (36x15 each at y 7 and 18), meter 11x58 at (44, 8).
|
||||
ImFontPtr f = ImGuiFonts.Get(UiFont.Ui9);
|
||||
CenterText(dl, f, "Burden", new Vector2(field.X, field.Y + 7 * s), new Vector2(36 * s, 15 * s), White);
|
||||
CenterText(dl, f, view.BurdenText, new Vector2(field.X, field.Y + 18 * s), new Vector2(36 * s, 15 * s), White);
|
||||
// Retail's text here is about 13 px (a serif face); the smallest UI font was too small to read.
|
||||
ImFontPtr f = ImGuiFonts.Get(UiFont.Ui14);
|
||||
CenterText(dl, f, "Burden", new Vector2(field.X - 3 * s, field.Y + 5 * s), new Vector2(42 * s, 15 * s), White, 13 * s);
|
||||
CenterText(dl, f, view.BurdenText, new Vector2(field.X - 3 * s, field.Y + 18 * s), new Vector2(42 * s, 15 * s), White, 13 * s);
|
||||
var mMin = new Vector2(field.X + 44 * s, field.Y + 8 * s);
|
||||
var mSize = new Vector2(11 * s, 58 * s);
|
||||
// Retail's meter holds 0-300% of capacity (OpenAC's BurdenMath.LoadToFill: load / 3).
|
||||
|
|
@ -369,7 +406,7 @@ internal sealed partial class InventoryFace
|
|||
|
||||
// Main pack (36x36 at (6, 32)).
|
||||
InventoryPack? main = view.Packs.Length > 0 ? view.Packs[0] : null;
|
||||
PackCell(view, dl, main, new Vector2(field.X + 6 * s, field.Y + 32 * s), s, -1, filtered);
|
||||
PackCell(view, dl, main, new Vector2(MathF.Round(field.X + 6 * s), MathF.Round(field.Y + 32 * s)), s, -1, filtered);
|
||||
|
||||
// The main pack's pack slots (36 px pitch at (6, 73)): the side packs, then the items
|
||||
// that take a pack slot (foci), as retail lists them; retail's seven slots (eight with
|
||||
|
|
@ -386,7 +423,7 @@ internal sealed partial class InventoryFace
|
|||
{
|
||||
int i = _packFirstRow + row;
|
||||
if (i >= slots) break;
|
||||
var min = new Vector2(field.X + 6 * s, listY + row * PackPx * s);
|
||||
var min = new Vector2(MathF.Round(field.X + 6 * s), MathF.Round(listY + row * PackPx * s));
|
||||
if (i < sidePacks) PackCell(view, dl, view.Packs[i + 1], min, s, i, filtered);
|
||||
else if (i < used) SlotItemCell(view, dl, view.SlotItems[i - sidePacks], min, s, i, pendingId);
|
||||
else
|
||||
|
|
@ -404,7 +441,9 @@ internal sealed partial class InventoryFace
|
|||
if (MouseIn(new Vector2(field.X, listY), new Vector2(field.X + SideW * s, listY + listH))
|
||||
&& ImGuiNET.ImGui.IsWindowHovered())
|
||||
Wheel(ref _packFirstRow, slots - rows);
|
||||
Scrollbar("##inv_packsb", new Vector2(field.X + 41 * s, listY), listH, s, ref _packFirstRow, slots, rows);
|
||||
// Retail draws this scrollbar only when the slots do not all fit.
|
||||
if (slots > rows)
|
||||
Scrollbar("##inv_packsb", new Vector2(field.X + 41 * s, listY), listH, s, ref _packFirstRow, slots, rows);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -422,6 +461,7 @@ internal sealed partial class InventoryFace
|
|||
ImGuiNET.ImGui.PopID();
|
||||
ItemPointer(it, hovered);
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11)); // stack counts
|
||||
CellPicture(dl, Art.PackEmpty, inner, cell); // the slot stays under what fills it
|
||||
ItemCell(dl, it, inner, cell, pendingId);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
SlotDropHint(view, dl, inner, cell);
|
||||
|
|
@ -454,6 +494,7 @@ internal sealed partial class InventoryFace
|
|||
return;
|
||||
}
|
||||
if (clicked && _dragItem == null) _pack = pack.Id;
|
||||
CellPicture(dl, Art.PackEmpty, inner, cell); // the slot stays under what fills it
|
||||
if (pack.IsMain)
|
||||
{
|
||||
if (!Sprite(dl, Art.MainPackIcon, inner, new Vector2(cell, cell)))
|
||||
|
|
@ -503,16 +544,21 @@ internal sealed partial class InventoryFace
|
|||
|
||||
private void Contents(InventoryView view, ImDrawListPtr dl, Vector2 field, float sideX, float r, float s, bool filtered)
|
||||
{
|
||||
if (_vaultOpen && VaultFeed.Available)
|
||||
{
|
||||
VaultContents(dl, field, sideX, r, s);
|
||||
return;
|
||||
}
|
||||
float cell = CellPx * s;
|
||||
var gridPos = new Vector2(field.X + 15 * s, field.Y + 20 * s);
|
||||
var gridPos = new Vector2(MathF.Round(field.X + 15 * s), MathF.Round(field.Y + 20 * s));
|
||||
float availW = sideX - 32 * s - gridPos.X; // retail: grid 15..207, scrollbar 207..223, column at 239
|
||||
int cols = Math.Max(1, (int)(availW / cell));
|
||||
int cols = Math.Max(1, (int)(availW / cell + 0.01f)); // exact multiples must not round down (6 columns at retail size)
|
||||
float gridW = cols * cell;
|
||||
float gridH = Math.Max(cell, (r - ContentsY - 5 - 24) * s);
|
||||
int rows = Math.Max(1, (int)(gridH / cell + 0.01f));
|
||||
|
||||
// "Contents of <pack>" over the grid.
|
||||
CenterText(dl, ImGuiFonts.Get(UiFont.Ui10), _captionText, new Vector2(gridPos.X, field.Y), new Vector2(gridW, 15 * s), White);
|
||||
CenterText(dl, ImGuiFonts.Get(UiFont.Ui14), _captionText, new Vector2(gridPos.X, field.Y), new Vector2(gridW, 15 * s), White, 12 * s);
|
||||
|
||||
InventoryPack? open = filtered ? null : view.PackOf(_pack);
|
||||
int cells = open != null ? Math.Max(open.Capacity, _shown.Count) : _shown.Count;
|
||||
|
|
@ -533,7 +579,8 @@ internal sealed partial class InventoryFace
|
|||
}
|
||||
if (hovered && hoverCell >= 0 && hoverCell < _shown.Count) ItemPointer(_shown[hoverCell], true);
|
||||
|
||||
// Only the rows on show; retail draws an item's icon in place of the empty cell.
|
||||
// Only the rows on show. Retail draws the empty-cell picture under EVERY cell and the item
|
||||
// over it (AcClientReborn does the same), so the grid's lines show behind an item's icon.
|
||||
uint pendingId = InventoryModel.Pending?.ItemId ?? 0;
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11)); // stack counts
|
||||
for (int rr = 0; rr < rows; rr++)
|
||||
|
|
@ -543,11 +590,8 @@ internal sealed partial class InventoryFace
|
|||
int i = (_gridFirstRow + rr) * cols + c;
|
||||
if (i >= cells) break;
|
||||
var min = new Vector2(gridPos.X + c * cell, gridPos.Y + rr * cell);
|
||||
if (i >= _shown.Count)
|
||||
{
|
||||
CellPicture(dl, Art.GridEmpty, min, cell);
|
||||
continue;
|
||||
}
|
||||
CellPicture(dl, Art.GridEmpty, min, cell);
|
||||
if (i >= _shown.Count) continue;
|
||||
ItemCell(dl, _shown[i], min, cell, pendingId);
|
||||
}
|
||||
}
|
||||
|
|
@ -555,15 +599,30 @@ internal sealed partial class InventoryFace
|
|||
|
||||
if (open != null)
|
||||
{
|
||||
// Dropping on the grid moves the item into the open pack.
|
||||
if (_dragItem != null && hoverCell >= 0 && hoverCell < cells && !(_dragItem.Container == open.Id && _dragItem.Wielder == 0))
|
||||
// Dropping on the grid moves the item into the open pack - to the slot under the mouse when
|
||||
// the cells are the server's slots (retail: a drop on a cell places it there, which is also
|
||||
// how items are reordered inside a pack).
|
||||
int dropSlot = -1;
|
||||
if (_dragItem != null && hoverCell >= 0 && CellsAreSlots(_dragItem))
|
||||
{
|
||||
int mine = _dragItem.Container == open.Id && _dragItem.Wielder == 0 ? SlotOf(_dragItem) : -1;
|
||||
int others = _shown.Count - (mine >= 0 ? 1 : 0);
|
||||
dropSlot = Math.Min(hoverCell, Math.Max(0, others));
|
||||
}
|
||||
// A drop inside the item's own pack that cannot be a slot says why, instead of doing nothing.
|
||||
if (dropSlot < 0 && _dragItem != null && hoverCell >= 0 && _dragItem.Container == open.Id && _dragItem.Wielder == 0
|
||||
&& !_dragItem.RequiresPackSlot && !_dragItem.IsPack)
|
||||
dropSlot = -2;
|
||||
bool sameSpot = dropSlot >= 0 && _dragItem != null && _dragItem.Container == open.Id && _dragItem.Wielder == 0 && SlotOf(_dragItem) == dropSlot;
|
||||
if (_dragItem != null && hoverCell >= 0 && hoverCell < cells
|
||||
&& (dropSlot >= 0 ? !sameSpot : !(_dragItem.Container == open.Id && _dragItem.Wielder == 0)))
|
||||
{
|
||||
int c = hoverCell % cols, rr = hoverCell / cols - _gridFirstRow;
|
||||
var min = new Vector2(gridPos.X + c * cell, gridPos.Y + rr * cell);
|
||||
bool full = PackRefuses(view, open, _dragItem);
|
||||
Overlay(dl, full ? Art.Reject : Art.AcceptGrid, min, cell, full ? RejectRed : AcceptGreen);
|
||||
}
|
||||
_targets.Add(new Target { Min = gridPos, Max = gridPos + area, Kind = DropKind.Pack, Id = open.Id, Name = open.Name });
|
||||
_targets.Add(new Target { Min = gridPos, Max = gridPos + area, Kind = DropKind.Pack, Id = open.Id, Name = open.Name, Slot = dropSlot });
|
||||
}
|
||||
else if (_shown.Count == 0)
|
||||
{
|
||||
|
|
@ -573,6 +632,140 @@ internal sealed partial class InventoryFace
|
|||
Scrollbar("##inv_gridsb", new Vector2(gridPos.X + gridW, gridPos.Y), rows * cell, s, ref _gridFirstRow, totalRows, rows);
|
||||
}
|
||||
|
||||
|
||||
// ── The Aelrynth account vault (Inventory > Vault) ──────────────────
|
||||
|
||||
private bool _vaultOpen;
|
||||
private int _vaultFirstRow;
|
||||
private VaultItem? _vaultCtx;
|
||||
private bool _openVaultCtx;
|
||||
|
||||
/// <summary>A small labelled button in the title bar.</summary>
|
||||
private static bool TitleTextToggle(string id, string label, Vector2 pos, Vector2 size, bool on)
|
||||
{
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, size);
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
uint col = on || hot ? Gold : Faded(Gold);
|
||||
dl.AddRect(pos, pos + size, col, 3);
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(label);
|
||||
dl.AddText(pos + new Vector2((size.X - ts.X) * 0.5f, (size.Y - ts.Y) * 0.5f), col, label);
|
||||
return clicked;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Vault view: the contents area shows the account vault (the grid's own frames for every slot,
|
||||
/// items drawn as they are in a pack). Read-only apart from right-click > Withdraw.
|
||||
/// </summary>
|
||||
private void VaultContents(ImDrawListPtr dl, Vector2 field, float sideX, float r, float s)
|
||||
{
|
||||
float cell = CellPx * s;
|
||||
var gridPos = new Vector2(MathF.Round(field.X + 15 * s), MathF.Round(field.Y + 20 * s));
|
||||
float availW = sideX - 32 * s - gridPos.X;
|
||||
int cols = Math.Max(1, (int)(availW / cell + 0.01f)); // exact multiples must not round down (6 columns at retail size)
|
||||
float gridW = cols * cell;
|
||||
float gridH = Math.Max(cell, (r - ContentsY - 5 - 24) * s);
|
||||
int rows = Math.Max(1, (int)(gridH / cell + 0.01f));
|
||||
|
||||
VaultSnapshot? snap = VaultFeed.Snapshot;
|
||||
VaultItem[] items = snap?.Items ?? Array.Empty<VaultItem>();
|
||||
int cells = snap == null ? 0 : Math.Max(snap.Max, items.Length);
|
||||
string caption = snap == null ? VaultFeed.Status
|
||||
: snap.Max > 0 ? $"Aelrynth Vault: {items.Length:N0} of {snap.Max:N0}" : $"Aelrynth Vault: {items.Length:N0}";
|
||||
CenterText(dl, ImGuiFonts.Get(UiFont.Ui14), caption, new Vector2(gridPos.X, field.Y), new Vector2(gridW, 15 * s), White, 12 * s);
|
||||
|
||||
// Read again (the vault changes when anything is deposited or withdrawn).
|
||||
var rb = new Vector2(gridPos.X + gridW - 44 * s, field.Y + 1 * s);
|
||||
if (TitleTextToggle("##vault_refresh", "Refresh", rb, new Vector2(44 * s, 14 * s), VaultFeed.Awaiting))
|
||||
VaultFeed.RequestRefresh();
|
||||
|
||||
int totalRows = (cells + cols - 1) / cols;
|
||||
_vaultFirstRow = Math.Clamp(_vaultFirstRow, 0, Math.Max(0, totalRows - rows));
|
||||
var area = new Vector2(gridW, rows * cell);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(gridPos);
|
||||
ImGuiNET.ImGui.InvisibleButton("##vault_cells", area, ImGuiButtonFlags.MouseButtonLeft | ImGuiButtonFlags.MouseButtonRight);
|
||||
bool hovered = ImGuiNET.ImGui.IsItemHovered();
|
||||
Vector2 mouse = ImGuiNET.ImGui.GetMousePos();
|
||||
int hoverCell = -1;
|
||||
if (MouseIn(gridPos, gridPos + area))
|
||||
{
|
||||
int c = (int)((mouse.X - gridPos.X) / cell), rr = (int)((mouse.Y - gridPos.Y) / cell);
|
||||
if (c >= 0 && c < cols && rr >= 0 && rr < rows) hoverCell = (_vaultFirstRow + rr) * cols + c;
|
||||
if (ImGuiNET.ImGui.IsWindowHovered()) Wheel(ref _vaultFirstRow, totalRows - rows);
|
||||
}
|
||||
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11)); // stack counts
|
||||
for (int rr = 0; rr < rows; rr++)
|
||||
{
|
||||
for (int c = 0; c < cols; c++)
|
||||
{
|
||||
int i = (_vaultFirstRow + rr) * cols + c;
|
||||
if (i >= cells) break;
|
||||
var min = new Vector2(gridPos.X + c * cell, gridPos.Y + rr * cell);
|
||||
CellPicture(dl, Art.GridEmpty, min, cell);
|
||||
if (i >= items.Length) continue;
|
||||
VaultItem it = items[i];
|
||||
if (ScriptIcons.TryGetItem(it.Icon, it.Underlay, it.Overlay, it.Effects, it.ItemType, out IntPtr tex))
|
||||
{
|
||||
IconSampling.Begin(dl);
|
||||
dl.AddImage(tex, min, min + new Vector2(cell, cell));
|
||||
IconSampling.End(dl);
|
||||
}
|
||||
else
|
||||
dl.AddRectFilled(min, min + new Vector2(cell, cell), Placeholder, 2);
|
||||
if (it.Stack > 1)
|
||||
{
|
||||
string st = it.Stack.ToString(CultureInfo.InvariantCulture);
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(st);
|
||||
var tp = new Vector2(min.X + cell - ts.X - 1, min.Y + cell - ts.Y);
|
||||
dl.AddText(tp + Vector2.One, StackShadow, st);
|
||||
dl.AddText(tp, StackCol, st);
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
|
||||
if (hovered && hoverCell >= 0 && hoverCell < items.Length)
|
||||
{
|
||||
VaultItem hot = items[hoverCell];
|
||||
ImGuiNET.ImGui.SetTooltip(hot.Stack > 1 ? $"{hot.Name} ({hot.Stack:N0})" : hot.Name);
|
||||
if (ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Right))
|
||||
{
|
||||
_vaultCtx = hot;
|
||||
_openVaultCtx = true;
|
||||
}
|
||||
}
|
||||
else if (snap == null && !VaultFeed.Awaiting)
|
||||
{
|
||||
dl.AddText(gridPos + new Vector2(4, 22 * s), Mute, VaultFeed.Unsupported ? "The vault is not open on this server yet." : "Click Refresh to read the vault.");
|
||||
}
|
||||
|
||||
if (_openVaultCtx)
|
||||
{
|
||||
_openVaultCtx = false;
|
||||
ImGuiNET.ImGui.OpenPopup("##vault_ctx");
|
||||
}
|
||||
PushMenuStyle();
|
||||
if (ImGuiNET.ImGui.BeginPopup("##vault_ctx"))
|
||||
{
|
||||
VaultItem? it = _vaultCtx;
|
||||
if (it == null) ImGuiNET.ImGui.CloseCurrentPopup();
|
||||
else
|
||||
{
|
||||
ImGuiNET.ImGui.TextDisabled(it.Name);
|
||||
ImGuiNET.ImGui.Separator();
|
||||
if (ImGuiNET.ImGui.MenuItem("Withdraw", "", false, VaultFeed.Available))
|
||||
VaultFeed.Withdraw(it);
|
||||
}
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
PopMenuStyle();
|
||||
|
||||
if (snap != null) // nothing to scroll before the vault has been read
|
||||
Scrollbar("##inv_vaultsb", new Vector2(gridPos.X + gridW, gridPos.Y), rows * cell, s, ref _vaultFirstRow, totalRows, rows);
|
||||
}
|
||||
|
||||
// ── Status strip: the action / outcome (or pyreals), Drop, Give ─────
|
||||
|
||||
private void StatusStrip(InventoryView view, ImDrawListPtr dl, Vector2 p, float w, float h, float s)
|
||||
|
|
@ -736,17 +929,36 @@ internal sealed partial class InventoryFace
|
|||
dl.AddRect(min, min + new Vector2(size, size), fallback, 2, ImDrawFlags.None, 1.5f);
|
||||
}
|
||||
|
||||
private static void CenterText(ImDrawListPtr dl, ImFontPtr f, string text, Vector2 pos, Vector2 size, uint color)
|
||||
/// <summary>
|
||||
/// Text centred in a box. <paramref name="px"/> is the drawn size in screen pixels (retail's text is a fixed
|
||||
/// size per 32 px cell, so callers pass N * the layout scale); 0 = the font's own size times the panel size.
|
||||
/// </summary>
|
||||
private static void CenterText(ImDrawListPtr dl, ImFontPtr f, string text, Vector2 pos, Vector2 size, uint color, float px = 0f)
|
||||
{
|
||||
if (text.Length == 0) return;
|
||||
float drawPx = px > 0f ? px : f.FontSize * InventorySettingsStore.SizeFactor;
|
||||
ImGuiNET.ImGui.PushFont(f);
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(text);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
ts *= drawPx / f.FontSize;
|
||||
dl.PushClipRect(pos, pos + size, true);
|
||||
dl.AddText(f, f.FontSize * InventorySettingsStore.SizeFactor, new Vector2(pos.X + (size.X - ts.X) * 0.5f, pos.Y + (size.Y - ts.Y) * 0.5f), color, text);
|
||||
dl.AddText(f, drawPx, new Vector2(pos.X + (size.X - ts.X) * 0.5f, pos.Y + (size.Y - ts.Y) * 0.5f), color, text);
|
||||
dl.PopClipRect();
|
||||
}
|
||||
|
||||
private long _fitAtMs;
|
||||
|
||||
/// <summary>Asks the host to make the panel exactly <paramref name="wantPx"/> wide (screen px) when it is not; at most twice a second.</summary>
|
||||
private void FitWidth(Vector2 size, float wantPx)
|
||||
{
|
||||
if (ImGuiPopOuts.InPopOutFrame || Math.Abs(size.X - wantPx) <= 4f) return;
|
||||
long now = Environment.TickCount64;
|
||||
if (now - _fitAtMs < 500) return;
|
||||
_fitAtMs = now;
|
||||
float place = ImGuiPanelHost.PlacementScale();
|
||||
ImGuiPanelHost.RequestSize(Title, new Vector2(wantPx / place, size.Y / place));
|
||||
}
|
||||
|
||||
private static bool MouseIn(Vector2 min, Vector2 max)
|
||||
{
|
||||
Vector2 m = ImGuiNET.ImGui.GetMousePos();
|
||||
|
|
@ -768,7 +980,7 @@ internal static class InventorySettingsStore
|
|||
public static bool Classic { get; private set; } = true;
|
||||
/// <summary>Classic view: the search / sort / category row under the title bar.</summary>
|
||||
public static bool ShowTools { get; private set; }
|
||||
/// <summary>The panel's size in percent of the UI scale (50-150, steps of 10); text follows it.</summary>
|
||||
/// <summary>The panel's size in percent of the UI scale (50-150, steps of 5); text follows it.</summary>
|
||||
public static int SizePct { get; private set; } = 80;
|
||||
public static float SizeFactor => SizePct / 100f;
|
||||
|
||||
|
|
@ -809,7 +1021,7 @@ internal static class InventorySettingsStore
|
|||
|
||||
public static void StepSize(int dir)
|
||||
{
|
||||
int next = Math.Clamp(SizePct + 10 * Math.Sign(dir), 50, 150);
|
||||
int next = Math.Clamp(SizePct + 5 * Math.Sign(dir), 50, 150);
|
||||
if (next == SizePct) return;
|
||||
SizePct = next;
|
||||
Save();
|
||||
|
|
|
|||
|
|
@ -42,8 +42,12 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
public const string Title = "Inventory";
|
||||
|
||||
// Default: the Classic view at its retail size (300 x 362 body, plus the status strip).
|
||||
// Chromeless: the Classic look has the retail title bar (drag, close) and the Modern look
|
||||
// draws its own background, drag area and close button, so the engine's DRAG header would
|
||||
// be a second title bar.
|
||||
public static void Register() => ImGuiPanelHost.Register(Title,
|
||||
new PanelSpec(new Vector2(302, 426), new Vector2(240, 300), EdgeToEdge: true),
|
||||
new PanelSpec(new Vector2(302, 426), new Vector2(140, 300), PanelChrome.None,
|
||||
Background: 0, Rounding: 0, EdgeToEdge: true),
|
||||
() => new InventoryFace());
|
||||
|
||||
// ── Layout (px, like the other faces) ───────────────────────────────
|
||||
|
|
@ -78,6 +82,10 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
private int _builtSort = -1, _builtCategory = -1;
|
||||
private string _builtSearch = "\0";
|
||||
private bool _builtClassic;
|
||||
private int _builtOrderVersion = -1;
|
||||
// The shown list follows the server's slot order for this pack (so a cell is a slot).
|
||||
private bool _orderKnown;
|
||||
private readonly Dictionary<uint, int> _rank = new();
|
||||
// Leave pack-slot items (foci) out of this list: the Classic main pack grid (they're in the side column).
|
||||
private bool _skipSlotItems;
|
||||
private string _countText = string.Empty;
|
||||
|
|
@ -93,7 +101,7 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
// PackSlots: the Classic side column's pack slots (Id = the main pack): only a
|
||||
// pack-slot item (a focus) goes there, which moves it to the main pack.
|
||||
private enum DropKind : byte { None, Pack, Equip, Drop, Give, Slot, PackSlots }
|
||||
private struct Target { public Vector2 Min, Max; public DropKind Kind; public uint Id; public string Name; }
|
||||
private struct Target { public Vector2 Min, Max; public DropKind Kind; public uint Id; public string Name; public int Slot; }
|
||||
private readonly List<Target> _targets = new(16);
|
||||
|
||||
// Context menu and split dialog (opened at the end of Draw, outside any child).
|
||||
|
|
@ -168,6 +176,8 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
private void ModernBody(InventoryView view, Vector2 origin, Vector2 size, float w)
|
||||
{
|
||||
if (_pack != AllPacks && _pack != WornPacks && view.PackOf(_pack) == null) _pack = AllPacks;
|
||||
ImGuiNET.ImGui.GetWindowDrawList().AddRectFilled(origin, origin + size, RynthTheme.PanelGlass, 6);
|
||||
ImGuiNET.ImGui.GetWindowDrawList().AddRect(origin, origin + size, RynthTheme.PanelBorder, 6);
|
||||
RebuildIfNeeded(view, _pack); // the header shows the count
|
||||
Header(view, w);
|
||||
Tools(w);
|
||||
|
|
@ -207,14 +217,28 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
PhosphorIcons.DrawCentered(dl, icons, PhosphorIcons.Coins, new Vector2(x, p.Y), new Vector2(18, RowH), Amber);
|
||||
dl.AddText(new Vector2(x + 20, ty), Text, view.PyrealText);
|
||||
|
||||
// Close (the engine's header is off for this panel).
|
||||
if (IconButton("##inv_close", PhosphorIcons.X, new Vector2(p.X + w - 22, p.Y + 1), new Vector2(22, 22), Amber, BtnFill, font: UiFont.Ui11))
|
||||
ImGuiPanelHost.Close(Title);
|
||||
ImGuiNET.ImGui.SetItemTooltip("Close");
|
||||
|
||||
// Switch to the Classic (retail) look.
|
||||
var tb = new Vector2(p.X + w - 22, p.Y + 1);
|
||||
var tb = new Vector2(p.X + w - 46, p.Y + 1);
|
||||
if (IconButton("##inv_classic", PhosphorIcons.AppWindow, tb, new Vector2(22, 22), Amber, BtnFill, font: UiFont.Ui11))
|
||||
InventorySettingsStore.SetClassic(true);
|
||||
ImGuiNET.ImGui.SetItemTooltip("Classic look (the retail inventory window)");
|
||||
|
||||
float cw = ImGuiNET.ImGui.CalcTextSize(_countText).X;
|
||||
dl.AddText(new Vector2(tb.X - cw - 6, ty), Mute, _countText);
|
||||
|
||||
// Drag surface: the empty part of the header, between the pyreals and the count.
|
||||
float dragFrom = x + 20 + ImGuiNET.ImGui.CalcTextSize(view.PyrealText).X + 6, dragTo = tb.X - cw - 10;
|
||||
if (dragTo > dragFrom)
|
||||
{
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(dragFrom, p.Y));
|
||||
ImGuiNET.ImGui.InvisibleButton("##inv_drag", new Vector2(dragTo - dragFrom, RowH));
|
||||
ImGuiPanelHost.DragWindowWithLastItem();
|
||||
}
|
||||
NextLine(p, RowH + 2);
|
||||
}
|
||||
|
||||
|
|
@ -293,7 +317,8 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
{
|
||||
bool classic = InventorySettingsStore.Classic;
|
||||
if (ReferenceEquals(view, _builtFor) && _builtPack == pack && _builtSort == _sort
|
||||
&& _builtCategory == _category && ReferenceEquals(_builtSearch, _searchText) && _builtClassic == classic)
|
||||
&& _builtCategory == _category && ReferenceEquals(_builtSearch, _searchText) && _builtClassic == classic
|
||||
&& _builtOrderVersion == Net.InventoryOrder.Version)
|
||||
return;
|
||||
if (_builtPack != pack || !ReferenceEquals(_builtSearch, _searchText) || _builtCategory != _category)
|
||||
_gridFirstRow = 0; // another pack or filter: back to the top (Classic grid)
|
||||
|
|
@ -303,6 +328,7 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
_builtCategory = _category;
|
||||
_builtSearch = _searchText;
|
||||
_builtClassic = classic;
|
||||
_builtOrderVersion = Net.InventoryOrder.Version;
|
||||
|
||||
_shown.Clear();
|
||||
InventoryPack? one = pack == WornPacks || pack == AllPacks ? null : view.PackOf(pack);
|
||||
|
|
@ -323,6 +349,7 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
_ => null, // pack order: as captured (packs in order, ascending id inside each)
|
||||
};
|
||||
if (cmp != null) _shown.Sort(cmp);
|
||||
else ApplyServerOrder(one);
|
||||
|
||||
int total = pack == WornPacks ? view.Worn.Length : one == null ? view.ItemCount
|
||||
: _skipSlotItems ? one.Used : one.Items.Length;
|
||||
|
|
@ -336,6 +363,40 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
: "Contents of " + one.Name;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pack order = the server's: the list ACE sent for this pack (Net/InventoryOrder), so cell k is
|
||||
/// slot k. A pack whose list was never seen (a side pack not opened yet, or an engine that
|
||||
/// reloaded after login) stays in id order and <see cref="_orderKnown"/> says so: drops there
|
||||
/// take the first empty slot, as before.
|
||||
/// </summary>
|
||||
private void ApplyServerOrder(InventoryPack? pack)
|
||||
{
|
||||
_orderKnown = false;
|
||||
if (pack == null || !Net.InventoryOrder.TryGetOrder(pack.Id, false, out uint[] items)) return;
|
||||
Net.InventoryOrder.TryGetOrder(pack.Id, true, out uint[] slots);
|
||||
_rank.Clear();
|
||||
for (int i = 0; i < items.Length; i++) _rank[items[i]] = i;
|
||||
for (int i = 0; i < slots.Length; i++) _rank[slots[i]] = 1_000_000 + i;
|
||||
_shown.Sort((a, b) =>
|
||||
{
|
||||
int ra = _rank.TryGetValue(a.Id, out int x) ? x : int.MaxValue, rb = _rank.TryGetValue(b.Id, out int y) ? y : int.MaxValue;
|
||||
return ra != rb ? ra.CompareTo(rb) : a.Id.CompareTo(b.Id);
|
||||
});
|
||||
_orderKnown = true;
|
||||
}
|
||||
|
||||
/// <summary>A grid cell is a slot only while the list is the server's, whole and in pack order, and the item is an ordinary one.</summary>
|
||||
private bool CellsAreSlots(InventoryItem item) =>
|
||||
_orderKnown && _sort == 0 && _category == 0 && _searchText.Length == 0 && !item.RequiresPackSlot && !item.IsPack;
|
||||
|
||||
/// <summary>The slot an item holds now among its pack's ordinary items, or -1 when unknown.</summary>
|
||||
private static int SlotOf(InventoryItem item)
|
||||
{
|
||||
if (!Net.InventoryOrder.TryGetOrder(item.Container, false, out uint[] ids)) return -1;
|
||||
return Array.IndexOf(ids, item.Id);
|
||||
}
|
||||
|
||||
private static int ByName(InventoryItem a, InventoryItem b)
|
||||
{
|
||||
int c = string.CompareOrdinal(a.SearchName, b.SearchName);
|
||||
|
|
@ -535,7 +596,11 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
private static void DrawItemIcon(ImDrawListPtr dl, uint objectId, Vector2 min, float size, uint tint = 0xFFFFFFFF)
|
||||
{
|
||||
if (ScriptIcons.TryGet(ScriptIconKind.Object, objectId, out IntPtr tex))
|
||||
{
|
||||
IconSampling.Begin(dl); // retail draws icons crisp
|
||||
dl.AddImage(tex, min, min + new Vector2(size, size), Vector2.Zero, Vector2.One, tint);
|
||||
IconSampling.End(dl);
|
||||
}
|
||||
else
|
||||
dl.AddRectFilled(min, min + new Vector2(size, size), Placeholder, 2);
|
||||
}
|
||||
|
|
@ -661,11 +726,11 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
|
||||
// ── Actions ─────────────────────────────────────────────────────────
|
||||
|
||||
private void Act(InventoryActionKind kind, InventoryItem item, uint target, string targetName, int amount)
|
||||
private void Act(InventoryActionKind kind, InventoryItem item, uint target, string targetName, int amount, int slot = -1)
|
||||
{
|
||||
var req = new InventoryRequest
|
||||
{
|
||||
Kind = kind, ItemId = item.Id, TargetId = target, TargetName = targetName, Amount = amount, ItemName = item.Name,
|
||||
Kind = kind, ItemId = item.Id, TargetId = target, TargetName = targetName, Amount = amount, ItemName = item.Name, Slot = slot,
|
||||
};
|
||||
if (!InventoryModel.Request(req, out string why))
|
||||
{
|
||||
|
|
@ -678,11 +743,25 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
}
|
||||
}
|
||||
|
||||
private void DropOn(DropKind kind, uint targetId, string targetName, InventoryItem item)
|
||||
private void DropOn(DropKind kind, uint targetId, string targetName, InventoryItem item, int slot = -1)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
case DropKind.Pack:
|
||||
if (slot == -2)
|
||||
{
|
||||
Refuse(_sort != 0 || _category != 0 || _searchText.Length > 0
|
||||
? "To reorder, set Sort to Pack order and clear the search and filter."
|
||||
: "The pack's order isn't known yet: log in again so the panel can learn it.");
|
||||
return;
|
||||
}
|
||||
if (slot >= 0)
|
||||
{
|
||||
// Dropped on a cell of the grid: that slot in the pack, which is also a reorder inside it.
|
||||
if (item.Container == targetId && item.Wielder == 0 && SlotOf(item) == slot) return; // already there
|
||||
Act(InventoryActionKind.Move, item, targetId, targetName, 0, slot);
|
||||
break;
|
||||
}
|
||||
if (item.Container == targetId && item.Wielder == 0) return; // same pack: nothing to do
|
||||
if (item.RequiresPackSlot && targetId != InventoryModel.Current.PlayerId)
|
||||
{
|
||||
|
|
@ -723,6 +802,14 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Back to everything: no search text, no category.</summary>
|
||||
private void ClearFilters()
|
||||
{
|
||||
Array.Clear(_search);
|
||||
_searchText = string.Empty;
|
||||
_category = 0;
|
||||
}
|
||||
|
||||
private void Refuse(string why)
|
||||
{
|
||||
_refusal = why;
|
||||
|
|
@ -755,7 +842,7 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
foreach (Target t in _targets)
|
||||
{
|
||||
if (m.X < t.Min.X || m.Y < t.Min.Y || m.X >= t.Max.X || m.Y >= t.Max.Y) continue;
|
||||
DropOn(t.Kind, t.Id, t.Name, item);
|
||||
DropOn(t.Kind, t.Id, t.Name, item, t.Slot);
|
||||
return;
|
||||
}
|
||||
// Let go outside this panel: another engine panel that takes items (Item Count,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// ImGui face of the RynthAi dashboard (docs/IMGUI_PARITY_PLAN.md §2.1),
|
||||
// first laid out from the Avalonia face (UI/Panels/RynthAiPanel.cs), then
|
||||
// made compact with Phosphor icons, after DrakBot's dashboard. Top to bottom:
|
||||
// title row RYNTHAI DASHBOARD | target, vitals, lock, opacity -/+,
|
||||
// title row RYNTH | target, vitals, lock, opacity -/+,
|
||||
// minimize, pop out
|
||||
// header grid popped out only: meta state, bot activity | pickers (docked,
|
||||
// they are the Loaded files drawer)
|
||||
|
|
@ -168,7 +168,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
}
|
||||
}
|
||||
|
||||
// ── Title row: "R" + "YNTHAI DASHBOARD" | chips (drag surface) ──────
|
||||
// ── Title row: "R" + "YNTH" | chips (drag surface) ──────
|
||||
|
||||
private void TitleRow(RynthAiSnapshot raw, float x0, float width, bool minimized)
|
||||
{
|
||||
|
|
@ -189,7 +189,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
dl.PushClipRect(new Vector2(x0, y), new Vector2(x0 + Math.Max(1, width - chipsW - 4), y + rowH), true);
|
||||
dl.AddText(title, title.FontSize, new Vector2(x0, ty), Teal, "R");
|
||||
float rw = CalcWidth(title, "R");
|
||||
dl.AddText(title, title.FontSize, new Vector2(x0 + rw, ty), White, "YNTHAI DASHBOARD");
|
||||
dl.AddText(title, title.FontSize, new Vector2(x0 + rw, ty), White, "YNTH");
|
||||
dl.PopClipRect();
|
||||
|
||||
float cx = x0 + width - chipsW;
|
||||
|
|
|
|||
|
|
@ -55,10 +55,11 @@ internal static class ScriptIcons
|
|||
private static readonly long FailedRetryTicks = Stopwatch.Frequency * 30; // an icon that didn't decode
|
||||
private static readonly long BudgetRetryTicks = Stopwatch.Frequency * 2; // no room in the byte budget
|
||||
|
||||
private const uint StypeIcon = 8, StypeIconOverlay = 50, StypeIconUnderlay = 52;
|
||||
private const uint StypeIcon = 8, StypeIconOverlay = 50, StypeIconUnderlay = 52, StypeUiEffects = 18, StypeItemType = 1;
|
||||
|
||||
/// <summary>What one picture is made of: icon, underlay and overlay texture ids (0 = none).</summary>
|
||||
private readonly record struct Layers(uint Icon, uint Underlay, uint Overlay);
|
||||
// Effects / ItemType (Object icons only) pick the plate the icon is drawn on when the server sent no underlay.
|
||||
private readonly record struct Layers(uint Icon, uint Underlay, uint Overlay, uint Effects = 0, uint ItemType = 0);
|
||||
|
||||
/// <summary>One asked-for (kind, id): the layers it resolved to.</summary>
|
||||
private sealed class Slot
|
||||
|
|
@ -198,6 +199,34 @@ internal static class ScriptIcons
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The texture for an item given as its layers rather than as a live object (the vault's items): the
|
||||
/// icon on the plate its type / effects ask for, with underlay and overlay, as an object would be drawn.
|
||||
/// False until it is ready (the work is queued). AC's render thread.
|
||||
/// </summary>
|
||||
public static bool TryGetItem(uint icon, uint underlay, uint overlay, uint effects, uint itemType, out IntPtr texture)
|
||||
{
|
||||
texture = IntPtr.Zero;
|
||||
if (icon == 0) return false;
|
||||
long now = Stopwatch.GetTimestamp();
|
||||
var layers = new Layers(AcIconDecoder.NormalizeIconId(icon), underlay, overlay, effects, itemType);
|
||||
if (!Textures.TryGetValue(layers, out Texture? tex))
|
||||
{
|
||||
tex = new Texture();
|
||||
Textures[layers] = tex;
|
||||
}
|
||||
tex.LastUsed = _frame;
|
||||
if (tex.Ptr != IntPtr.Zero)
|
||||
{
|
||||
texture = tex.Ptr;
|
||||
return true;
|
||||
}
|
||||
if (!tex.Pending && (tex.FailedAt == 0 || now - tex.FailedAt >= tex.RetryTicks)
|
||||
&& Enqueue(new Request(Work.Decode, ScriptIconKind.Object, icon, layers, _generation)))
|
||||
tex.Pending = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start of the ImGui frame, before anything draws: creates the textures decoded since
|
||||
/// the last frame (at most 8) and evicts the least recently drawn ones over the cap.
|
||||
|
|
@ -419,7 +448,9 @@ internal static class ScriptIcons
|
|||
return new Result(Work.Resolve, key, default, false, null, r.Generation);
|
||||
ClientObjectHooks.TryGetObjectDataIdProperty(r.Id, StypeIconUnderlay, out uint under);
|
||||
ClientObjectHooks.TryGetObjectDataIdProperty(r.Id, StypeIconOverlay, out uint over);
|
||||
return new Result(Work.Resolve, key, new Layers(icon, under, over), true, null, r.Generation);
|
||||
ClientObjectHooks.TryGetObjectIntProperty(r.Id, StypeUiEffects, out int effects);
|
||||
ClientObjectHooks.TryGetObjectIntProperty(r.Id, StypeItemType, out int itemType);
|
||||
return new Result(Work.Resolve, key, new Layers(icon, under, over, unchecked((uint)effects), unchecked((uint)itemType)), true, null, r.Generation);
|
||||
}
|
||||
if (r.Kind == ScriptIconKind.Spell)
|
||||
{
|
||||
|
|
@ -445,7 +476,9 @@ internal static class ScriptIcons
|
|||
RynthLog.UI($"ScriptIcons: no icons ({why}); script windows draw placeholders.");
|
||||
}
|
||||
}
|
||||
AcIconImage? image = dat == null ? null : AcIconDecoder.Compose(dat, r.Layers.Icon, r.Layers.Underlay, r.Layers.Overlay);
|
||||
// An object's icon sits on its plate (the server's underlay, else the one its effects / type ask for).
|
||||
uint under = dat != null && r.Kind == ScriptIconKind.Object ? AcIconPlates.For(dat, r.Layers.Underlay, r.Layers.Effects, r.Layers.ItemType) : r.Layers.Underlay;
|
||||
AcIconImage? image = dat == null ? null : AcIconDecoder.Compose(dat, r.Layers.Icon, under, r.Layers.Overlay, dat != null && r.Kind == ScriptIconKind.Object ? AcIconPlates.RimFor(dat, r.Layers.Effects) : 0u);
|
||||
return new Result(Work.Decode, key, r.Layers, image != null, image, r.Generation);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue