RynthSuite as of 2026-11-08 (internal 6ec9b64): release 2026.11.8.1

This commit is contained in:
Tom Bohar 2026-11-08 15:48:47 -05:00
commit f8fa62b64c
196 changed files with 24980 additions and 633 deletions

View file

@ -13,6 +13,8 @@
// N is own slot N (BarMapping), and AC's toolbar isn't read at all.
// An own slot can hold a spell (2026-10-28): its picture is the spell's, and
// the snapshot carries the character's spells for the slot menu's search.
// An extra bar (2026-11-04, ExtraBar: "Shortcuts 2" ...) is built the same
// way from its own slots (BuildExtra): no AC slots, no keys.
// ============================================================================
using System;
@ -57,6 +59,17 @@ internal sealed record BarSnapshot(BarSlot[] Slots, bool Ready, int IconSize, bo
public static readonly BarSnapshot NotReady = new(Array.Empty<BarSlot>(), false, 36);
public IReadOnlyList<SpellInfo> KnownSpells => Spells ?? Array.Empty<SpellInfo>();
/// <summary>The extra bar this is (2-4; 0 = the Shortcuts bar itself): no AC slots, no keys.</summary>
public int Bar { get; init; }
/// <summary>The fewest and most slots the edit buttons allow.</summary>
public int MinSlots { get; init; } = DefSettings.BarSlotsMin;
public int MaxSlots { get; init; } = DefSettings.BarSlotsMax;
/// <summary>The extra bars there are (number, slots holding something), for the bars' menus.</summary>
public IReadOnlyList<(int Number, int Filled)> Extras { get; init; } = Array.Empty<(int, int)>();
/// <summary>Another extra bar can be added (fewer than <see cref="ExtraBar.Max"/>).</summary>
public bool CanAddBar => Extras.Count < ExtraBar.Max;
}
/// <summary>Builds the snapshot on the plugin tick (reads the host and the carried items).</summary>
@ -94,12 +107,13 @@ internal sealed class BarSnapshotBuilder
DefSettings st = session.Settings;
IReadOnlyList<SpellInfo> spells = session.KnownSpells();
bool canCast = _host.HasCastSpell;
var extras = Extras(session);
if (st.IndependentBar)
{
// Every slot is RynthDefective's own: AC's toolbar isn't read or shown (BarMapping).
var own = new BarSlot[st.BarSlots];
for (int n = 1; n <= st.BarSlots; n++) own[n - 1] = Own(n, BarMapping.OwnSlot(n, true), true, session, items, spells, _host);
return new BarSnapshot(own, true, st.ButtonSize, true, spells, canCast, st.WeaponsButtonOnBar);
return new BarSnapshot(own, true, st.ButtonSize, true, spells, canCast, st.WeaponsButtonOnBar) { Extras = extras };
}
if (_host.GetShortcuts(_ids, _spells) == 0) return BarSnapshot.NotReady;
RefreshKeys(now);
@ -109,7 +123,52 @@ internal sealed class BarSnapshotBuilder
var slots = new BarSlot[st.BarSlots];
for (int n = 1; n <= st.BarSlots; n++)
slots[n - 1] = BarMapping.IsRetail(n, false) ? Retail(n, byId) : Own(n, BarMapping.OwnSlot(n, false), false, session, items, spells, _host);
return new BarSnapshot(slots, true, st.ButtonSize, false, spells, canCast, st.WeaponsButtonOnBar);
return new BarSnapshot(slots, true, st.ButtonSize, false, spells, canCast, st.WeaponsButtonOnBar) { Extras = extras };
}
/// <summary>The extra bars there are, for the menus.</summary>
private static (int, int)[] Extras(DefSession session)
{
var list = session.Data.ExtraBars;
var a = new (int, int)[list.Count];
for (int i = 0; i < list.Count; i++) a[i] = (list[i].Number, list[i].Filled);
return a;
}
/// <summary>
/// Extra bar <paramref name="number"/> (2026-11-04): its own slots, the first SlotCount of them,
/// shown as the main bar's own ones are (picture, count, spell), with no keys. Pure apart from the
/// spell table: the tests build it offline.
/// </summary>
public static BarSnapshot BuildExtra(DefSession session, int number, IReadOnlyList<CarriedItem> items, bool canCast)
{
ExtraBar? bar = session.Data.Extra(number);
if (bar == null) return BarSnapshot.NotReady;
IReadOnlyList<SpellInfo> spells = session.KnownSpells();
var slots = new BarSlot[bar.SlotCount];
for (int n = 1; n <= bar.SlotCount; n++) slots[n - 1] = ExtraSlot(n, number, bar.Slots[n - 1], items, spells);
DefSettings st = session.Settings;
return new BarSnapshot(slots, true, st.ButtonSize, true, spells, canCast, st.WeaponsButtonOnBar)
{
Bar = number,
MinSlots = ExtraBar.SlotsMin,
MaxSlots = ExtraBar.SlotsMax,
Extras = Extras(session),
};
}
private static BarSlot ExtraSlot(int n, int bar, DefSlot slot, IReadOnlyList<CarriedItem> items, IReadOnlyList<SpellInfo> spells)
{
string whose = $"Shortcuts bar {bar}: clicks only, no keys";
if (slot.IsSpell) return OwnSpell(n, n, slot, whose, string.Empty, string.Empty, spells, keys: false);
if (slot.Item == null)
return new BarSlot(n, false, n, 0, 0, string.Empty, string.Empty, CountTone.Plain, string.Empty, string.Empty,
$"Slot {n} ({whose}): empty.\nDrag an item from your pack onto it, or right-click: put the selected item or one of your spells here.");
SlotStatus s = ItemMatcher.Status(slot.Item, items);
string count = SlotText.Count(s, out uint color);
CountTone tone = color == SlotText.InHand ? CountTone.InHand : color == SlotText.Missing ? CountTone.Missing : CountTone.Plain;
string tip = SlotText.Tooltip(n, slot.Item, s, slot.Mode, null, keys: false) + $"\n({whose}.)";
return new BarSlot(n, false, n, s.Item?.Id ?? 0, 0, s.Item?.FullName ?? slot.Item.FullName, count, tone, string.Empty, string.Empty, tip);
}
private BarSlot Retail(int n, Dictionary<uint, CarriedItem> byId)
@ -167,16 +226,17 @@ internal sealed class BarSnapshotBuilder
/// A spell slot: the spell's picture and name. A spell the character doesn't know (another
/// character's file, a spell lost) shows dimmed with "?" (when the spellbook can be read at all).
/// </summary>
private static BarSlot OwnSpell(int n, int own, DefSlot slot, string whose, string key, string all, IReadOnlyList<SpellInfo> spells)
private static BarSlot OwnSpell(int n, int own, DefSlot slot, string whose, string key, string all, IReadOnlyList<SpellInfo> spells, bool keys = true)
{
string name = slot.SpellLabel;
SpellInfo? info = SpellTable.TryGet(slot.SpellId, out SpellInfo si) ? si : null;
bool known = spells.Count == 0;
foreach (SpellInfo s in spells)
if (s.Id == slot.SpellId) { known = true; break; }
string tip = $"Slot {n}: {name}, a spell.\nClick or press the key: {SpellTargeting.Describe(info)} (Magic mode first)."
string tip = $"Slot {n}: {name}, a spell.\n{(keys ? "Click or press the key" : "Click")}: {SpellTargeting.Describe(info)} (Magic mode first)."
+ (known ? "" : "\nYou don't know this spell: pressing it does nothing.")
+ (key.Length > 0 ? "\nKey: " + key : "\nNo key yet.") + $"\n({whose}.)\nRight-click: change the slot or its keys.";
+ (!keys ? "" : key.Length > 0 ? "\nKey: " + key : "\nNo key yet.")
+ $"\n({whose}.)\nRight-click: change the slot{(keys ? " or its keys" : "")}.";
return new BarSlot(n, false, own, 0, slot.SpellId, name, known ? string.Empty : "?", known ? CountTone.Plain : CountTone.Missing,
SlotText.ShortKey(key), all, tip);
}

View file

@ -25,6 +25,10 @@
// /rdef use N. A key comes off whatever had it, after the player says so.
// An independent bar (DefSettings.IndependentBar) has only RynthDefective's
// own slots: every key is an engine hotkey (BarMapping, BarSlot.Own).
// Extra bars (2026-11-04, ExtraBar): the same window class draws "Shortcuts
// 2" ... with that bar's own slots (BarSnapshot.Bar): no AC slots and no keys,
// 1-24 slots. The bars' menu adds one (at most ExtraBar.Max), shows or hides
// them and removes one (its own menu: "Remove this bar").
// Spells (2026-10-28): an own slot's menu has "Put a spell here...", a search
// over the character's spells (the engine can't read the spell selected in
// the game's spellbook); the slot then casts it (UseController).
@ -62,6 +66,10 @@ internal interface IBarActions
/// <summary>RynthDefective's settings window (the weapon swap switch, the independent bar ...).</summary>
void ShowSettings();
void Hide();
/// <summary>Adds an extra Shortcuts bar (2026-11-04: "Shortcuts 2" ..., at most ExtraBar.Max).</summary>
void AddBar();
/// <summary>Removes extra bar <paramref name="number"/> and forgets its slots.</summary>
void RemoveBar(int number);
// A slot's keys (any thread: the engine queues the change). AC's slot: AC's keymap action
// UseQuickSlot_N; one of RynthDefective's own: its seam for own-slot keys (BindOwnSlotKey).
@ -76,13 +84,16 @@ internal sealed class ShortcutBarWindow
private readonly RynthCoreHost _host;
private readonly IBarActions _act;
/// <summary>The window this one draws: <see cref="Title"/>, or an extra bar's ("Shortcuts 2", ExtraBar.TitleOf).</summary>
private readonly string _title;
private bool _edit;
private float _k = 1f, _r = 1f;
public ShortcutBarWindow(RynthCoreHost host, IBarActions actions)
public ShortcutBarWindow(RynthCoreHost host, IBarActions actions, string title = Title)
{
_host = host;
_act = actions;
_title = title;
}
private float Px(float v) => v * _k;
@ -97,7 +108,7 @@ internal sealed class ShortcutBarWindow
private void Scale()
{
float fontK = Math.Max(0.5f, Font(RynthUiFont.Ui10).FontSize / 10f);
int pct = _host.PanelScale(Title);
int pct = _host.PanelScale(_title);
_k = pct > 0 ? pct / 100f : fontK;
_r = _k / fontK;
}
@ -154,7 +165,7 @@ internal sealed class ShortcutBarWindow
ImGui.SetCursorScreenPos(origin);
ImGui.Dummy(new Vector2(width, height));
SlotMenu(view);
BarMenu();
BarMenu(view);
if (_openKeyPopup)
{
_openKeyPopup = false;
@ -193,12 +204,13 @@ internal sealed class ShortcutBarWindow
bool menu = ImGui.IsItemClicked(ImGuiMouseButton.Right);
_host.PanelDragWithLastItem();
if (menu) ImGui.OpenPopup(BarMenuId);
SafeImGui.SetItemTooltip("Drag to move the bar. Ctrl+wheel here: bigger or smaller. Right-click: settings, Game Panels, Selection.\n"
SafeImGui.SetItemTooltip("Drag to move the bar. Ctrl+wheel here: bigger or smaller. Right-click: settings, Game Panels, Selection, more bars.\n"
+ "Drag the window's edge to change how many slots fit in a row.");
ImFontPtr tf = Font(RynthUiFont.NarrowBold11);
float size = Fs(tf) * 10f / 11f;
float tx = Tracked(dl, tf, size, new Vector2(x0, MathF.Round(y + (h - size) * 0.5f)), _text, "SHORTCUTS", 0.18f * size);
string name = view.Bar > 0 ? HeaderName(view.Bar) : "SHORTCUTS";
float tx = Tracked(dl, tf, size, new Vector2(x0, MathF.Round(y + (h - size) * 0.5f)), _text, name, 0.18f * size);
ImFontPtr nf = Font(RynthUiFont.Dash9);
string count = view.Ready ? view.Slots.Length.ToString(System.Globalization.CultureInfo.InvariantCulture) : "";
dl.AddText(nf, Fs(nf), new Vector2(MathF.Round(tx + Px(6)), MathF.Round(y + (h - Fs(nf)) * 0.5f + Px(1))), _faint, count);
@ -218,11 +230,25 @@ internal sealed class ShortcutBarWindow
"Settings (/rdef settings): weapon swaps under RynthAi, a bar independent of the game's toolbar,\nand showing the Game Panels buttons and the Selection window."))
_act.ShowSettings();
cx += chip + Px(1);
if (Chip("##sb_hide", RynthIcons.X, new Vector2(cx, cy), _faint, "Hide the bar (/rdef shows it again). Its keys keep working."))
if (Chip("##sb_hide", RynthIcons.X, new Vector2(cx, cy), _faint, view.Bar > 0
? $"Hide this bar (the Shortcuts bar's right-click menu, or /rdef bars show {view.Bar}, shows it again)."
: "Hide the bar (/rdef shows it again). Its keys keep working."))
_act.Hide();
return y + h;
}
private static readonly string[] HeaderNames = BuildHeaderNames();
private static string[] BuildHeaderNames()
{
var a = new string[ExtraBar.LastNumber + 1];
for (int n = ExtraBar.FirstNumber; n <= ExtraBar.LastNumber; n++) a[n] = "SHORTCUTS " + n;
return a;
}
/// <summary>"SHORTCUTS 2" (no string built per frame).</summary>
private static string HeaderName(int bar) => bar >= 0 && bar < HeaderNames.Length && HeaderNames[bar] != null ? HeaderNames[bar] : "SHORTCUTS";
private bool Chip(string id, string icon, Vector2 pos, uint color, string tip, bool held = false)
{
Vector2 size = new(Px(ChipSize), Px(ChipSize));
@ -256,7 +282,7 @@ internal sealed class ShortcutBarWindow
// Items dragged out of AC's UI: the slots' area takes them (the engine keeps the drop from AC).
Vector2 areaMin = new(x0, y), areaMax = new(x0 + perRow * (cell + gap), y + rows * (cell + gap));
uint dropped = _host.HasDropTargets ? _host.DropTarget(Title, areaMin, areaMax, true, out _dragging) : 0;
uint dropped = _host.HasDropTargets ? _host.DropTarget(_title, areaMin, areaMax, true, out _dragging) : 0;
int under = SlotAt(ImGui.GetIO().MousePos, x0, y, cell, gap, perRow, view.Slots.Length);
_dropSlot = _dragging ? under : 0;
if (dropped != 0 && under > 0) _act.DropItem(under, dropped);
@ -266,7 +292,7 @@ internal sealed class ShortcutBarWindow
int col = i % perRow, row = i / perRow;
Vector2 p = new(MathF.Round(x0 + col * (cell + gap)), MathF.Round(y + row * (cell + gap)));
if (i < view.Slots.Length) Slot(dl, view.Slots[i], p, cell);
else EditButton(dl, i == view.Slots.Length ? -1 : 1, p, cell, view.Slots.Length, view.Independent);
else EditButton(dl, i == view.Slots.Length ? -1 : 1, p, cell, view);
}
return y + rows * (cell + gap) - gap;
}
@ -345,16 +371,18 @@ internal sealed class ShortcutBarWindow
}
}
private void EditButton(ImDrawListPtr dl, int delta, Vector2 p, float cell, int count, bool independent)
private void EditButton(ImDrawListPtr dl, int delta, Vector2 p, float cell, BarSnapshot view)
{
Vector2 size = new(cell, cell);
bool can = delta < 0 ? count > DefSettings.BarSlotsMin : count < DefSettings.BarSlotsMax;
int count = view.Slots.Length;
bool can = delta < 0 ? count > view.MinSlots : count < view.MaxSlots;
ImGui.SetCursorScreenPos(p);
bool clicked = ImGui.InvisibleButton(delta < 0 ? "##sb_less" : "##sb_more", size);
bool hot = can && ImGui.IsItemHovered();
SafeImGui.SetItemTooltip(delta < 0
? "One slot fewer (the last one's item stays: add the slot back and it is there)."
: independent ? "One more slot (RynthCore's: this bar is independent of the game's toolbar)."
: view.Bar > 0 ? $"One more slot (up to {view.MaxSlots})."
: view.Independent ? "One more slot (RynthCore's: this bar is independent of the game's toolbar)."
: count < DefSettings.RetailSlots ? "One more slot (the game's own, up to 18)."
: "One more slot (RynthCore's: the game's toolbar holds 18).");
float r = Px(3);
@ -378,7 +406,7 @@ internal sealed class ShortcutBarWindow
{
BarSlot? s = _menuSlot >= 1 && _menuSlot <= view.Slots.Length ? view.Slots[_menuSlot - 1] : null;
if (s == null) { ImGui.CloseCurrentPopup(); return; }
ImGui.TextDisabled($"Slot {s.Number}{(s.Retail ? " (the game's own)" : " (RynthCore's)")}");
ImGui.TextDisabled(view.Bar > 0 ? $"Slot {s.Number} (Shortcuts bar {view.Bar})" : $"Slot {s.Number}{(s.Retail ? " (the game's own)" : " (RynthCore's)")}");
if (s.Name.Length > 0) SafeImGui.Text(s.Name);
ImGui.Separator();
bool hasSelection = _host.HasGetSelectedItemId && _host.GetSelectedItemId() != 0;
@ -394,7 +422,13 @@ internal sealed class ShortcutBarWindow
}
if (ImGui.MenuItem("Empty this slot", null, false, !s.Empty)) _act.Clear(s.Number);
ImGui.Separator();
if (!_host.HasKeyBinding)
if (view.Bar > 0)
{
// An extra bar's slots are clicked: the keys are the Shortcuts bar's own slots' (/rdef use N).
ImGui.TextDisabled("No keys: click it");
SafeImGui.SetItemTooltip("Keys go on the Shortcuts bar's own slots (right-click one there > Add a key).");
}
else if (!_host.HasKeyBinding)
{
ImGui.TextDisabled(s.AllKeys.Length > 0 ? "Keys: " + s.AllKeys
: s.Retail ? "No key: bind UseQuickSlot_" + s.Number + " in Configure Keyboard." : "No key: /rdef bind " + s.Own + " F9");
@ -425,7 +459,7 @@ internal sealed class ShortcutBarWindow
private const string BarMenuId = "##sb_bar_menu";
private void BarMenu()
private void BarMenu(BarSnapshot view)
{
if (!ImGui.IsPopupOpen(BarMenuId)) return;
ImGui.PushStyleColor(ImGuiCol.PopupBg, WithAlpha(_bg, 0xFA));
@ -438,17 +472,82 @@ internal sealed class ShortcutBarWindow
if (!open) return;
try
{
ImGui.TextDisabled("RynthDefective's Shortcuts bar");
ImGui.TextDisabled(view.Bar > 0 ? $"RynthDefective's Shortcuts bar {view.Bar}" : "RynthDefective's Shortcuts bar");
ImGui.Separator();
BarMenuItems();
ImGui.Separator();
MoreBarsItems(view);
ImGui.Separator();
if (ImGui.MenuItem("Weapons...")) _act.ShowWeapons();
if (ImGui.MenuItem("Hide the bar")) _act.Hide();
SafeImGui.SetItemTooltip("/rdef, or the lightning button on the RynthCore bar, shows it again. Its keys keep working.");
if (ImGui.MenuItem(view.Bar > 0 ? "Hide this bar" : "Hide the bar")) _act.Hide();
SafeImGui.SetItemTooltip(view.Bar > 0
? $"The Shortcuts bar's right-click menu, Defective Settings, or /rdef bars show {view.Bar} shows it again."
: "/rdef, or the lightning button on the RynthCore bar, shows it again. Its keys keep working.");
}
finally { ImGui.EndPopup(); }
}
/// <summary>
/// The extra bars (2026-11-04): add one; on the Shortcuts bar, show or hide each (they have no RynthCore
/// bar button) and remove one; on an extra bar, remove it. Removing asks once more (a submenu) when the
/// bar holds something: its slots are forgotten.
/// </summary>
private void MoreBarsItems(BarSnapshot view)
{
if (ImGui.MenuItem("Add a shortcut bar", null, false, view.CanAddBar)) _act.AddBar();
SafeImGui.SetItemTooltip(view.CanAddBar
? $"Another bar of {ExtraBar.DefaultSlots} slots in a window of its own, to put anywhere (/rdef bars add).\n"
+ "Fill it as this one: drag items from your pack onto it, or right-click a slot. Its slots are clicked; they have no keys."
: $"There are {ExtraBar.Max} extra bars, as many as there can be. Remove one first.");
if (view.Bar > 0)
{
int filled = 0;
foreach ((int n, int f) in view.Extras) if (n == view.Bar) filled = f;
RemoveItem("Remove this bar", view.Bar, filled);
return;
}
if (view.Extras.Count == 0) return;
foreach ((int n, _) in view.Extras)
PanelToggle(ExtraBar.TitleOf(n), BarLabel(n), $"Show or hide Shortcuts bar {n} (/rdef bars show {n}).");
if (ImGui.BeginMenu("Remove a bar"))
{
try
{
foreach ((int n, int f) in view.Extras) RemoveItem(BarLabel(n), n, f);
}
finally { ImGui.EndMenu(); }
}
}
/// <summary>A bar's remove item: at once when it is empty, else a submenu that says what goes with it.</summary>
private void RemoveItem(string label, int bar, int filled)
{
if (filled == 0)
{
if (ImGui.MenuItem(label)) _act.RemoveBar(bar);
SafeImGui.SetItemTooltip($"Shortcuts bar {bar} is empty: it goes (/rdef bars remove {bar}).");
return;
}
if (!ImGui.BeginMenu(label)) return;
try
{
if (ImGui.MenuItem($"Remove bar {bar} and its {filled} slot{(filled == 1 ? "" : "s")}")) _act.RemoveBar(bar);
SafeImGui.SetItemTooltip("Its slots are forgotten (the items stay in your pack).");
}
finally { ImGui.EndMenu(); }
}
private static readonly string[] BarLabels = BuildBarLabels();
private static string[] BuildBarLabels()
{
var a = new string[ExtraBar.LastNumber + 1];
for (int n = ExtraBar.FirstNumber; n <= ExtraBar.LastNumber; n++) a[n] = "Shortcuts bar " + n;
return a;
}
private static string BarLabel(int n) => n >= 0 && n < BarLabels.Length && BarLabels[n] != null ? BarLabels[n] : "Shortcuts bar " + n;
/// <summary>Settings..., and the two windows RynthDefective draws besides the bar (no RynthBar buttons of their own).</summary>
private void BarMenuItems()
{