feat(items): Remove Missing button on the Items panel
See Changelog/2026-10-11-items-remove-missing.md.
This commit is contained in:
parent
3366cc544d
commit
eb04784eaf
3 changed files with 39 additions and 3 deletions
16
Changelog/2026-10-11-items-remove-missing.md
Normal file
16
Changelog/2026-10-11-items-remove-missing.md
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Items panel: Remove Missing button
|
||||||
|
|
||||||
|
## What changed
|
||||||
|
|
||||||
|
- `ImGui/Panels/ItemsFace.cs`: a "Remove Missing" button at the top of the Items panel, above the
|
||||||
|
lists (which can run long), with a tooltip. `AddSelected` takes an optional tooltip.
|
||||||
|
- `UI/Data/ItemsData.cs`: `ItemsCommands.CleanMissing()` calls RynthAi's `RynthPluginCleanItems`
|
||||||
|
export, then refreshes the panel.
|
||||||
|
- What RynthAi does when the button is clicked:
|
||||||
|
- removes listed weapons and consumables that are no longer in your inventory;
|
||||||
|
- re-points an entry at an unlisted item of the same name, when your pack has one;
|
||||||
|
- does nothing while your inventory is still loading;
|
||||||
|
- reports in chat what it removed and re-pointed.
|
||||||
|
- With a RynthAi that lacks `RynthPluginCleanItems`, the click is logged and nothing happens.
|
||||||
|
|
||||||
|
The engine builds in Release. Not yet tested in game.
|
||||||
|
|
@ -54,6 +54,13 @@ internal sealed class ItemsFace : IImGuiPanel
|
||||||
ImGuiNET.ImGui.BeginChild("##items_body", new Vector2(w, Math.Max(60, Remaining(origin, size))));
|
ImGuiNET.ImGui.BeginChild("##items_body", new Vector2(w, Math.Max(60, Remaining(origin, size))));
|
||||||
float bw = ImGuiNET.ImGui.GetContentRegionAvail().X;
|
float bw = ImGuiNET.ImGui.GetContentRegionAvail().X;
|
||||||
|
|
||||||
|
// Above the lists, which can run long: drops entries for items sold, dropped, used up or traded.
|
||||||
|
AddSelected("##clean_missing", PhosphorIcons.Eraser + " Remove Missing", "(weapons and consumables no longer in your inventory)", ItemsCommands.CleanMissing,
|
||||||
|
"Removes listed weapons and consumables that are no longer in your inventory.\n" +
|
||||||
|
"An entry whose item is gone but with an unlisted item of the same name in your pack\n" +
|
||||||
|
"(a new stack of kits, a replacement weapon) is pointed at that item instead.\n" +
|
||||||
|
"Does nothing while your inventory is still loading. Also: /ra items clean.");
|
||||||
|
|
||||||
// Weapons
|
// Weapons
|
||||||
Section("Weapons", bw);
|
Section("Weapons", bw);
|
||||||
if (_data.Weapons.Count == 0) Empty("No weapons configured", bw);
|
if (_data.Weapons.Count == 0) Empty("No weapons configured", bw);
|
||||||
|
|
@ -242,11 +249,12 @@ internal sealed class ItemsFace : IImGuiPanel
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddSelected(string id, string label, string hint, Action onClick)
|
private static void AddSelected(string id, string label, string hint, Action onClick, string? tooltip = null)
|
||||||
{
|
{
|
||||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos() + new Vector2(4, 4);
|
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos() + new Vector2(4, 4);
|
||||||
float bw = ButtonWidth(label) + 4;
|
float bw = ButtonWidth(label) + 4;
|
||||||
if (Button(id, label, p, new Vector2(bw, 24), Teal, BtnFill)) onClick();
|
if (Button(id, label, p, new Vector2(bw, 24), Teal, BtnFill)) onClick();
|
||||||
|
if (tooltip != null) ImGuiNET.ImGui.SetItemTooltip(tooltip);
|
||||||
ImFontPtr f9 = ImGuiFonts.Get(UiFont.Ui9);
|
ImFontPtr f9 = ImGuiFonts.Get(UiFont.Ui9);
|
||||||
ImGuiNET.ImGui.GetWindowDrawList().AddText(f9, f9.FontSize, new Vector2(p.X + bw + 8, p.Y + (24 - f9.FontSize) * 0.5f), Mute, hint);
|
ImGuiNET.ImGui.GetWindowDrawList().AddText(f9, f9.FontSize, new Vector2(p.X + bw + 8, p.Y + (24 - f9.FontSize) * 0.5f), Mute, hint);
|
||||||
NextLine(new Vector2(p.X - 4, p.Y - 4), 32);
|
NextLine(new Vector2(p.X - 4, p.Y - 4), 32);
|
||||||
|
|
|
||||||
|
|
@ -63,14 +63,14 @@ internal sealed unsafe class ItemsSource : UiSource<ItemsSnapshot>
|
||||||
internal static unsafe class ItemsCommands
|
internal static unsafe class ItemsCommands
|
||||||
{
|
{
|
||||||
private static delegate* unmanaged[Cdecl]<IntPtr, void> _set;
|
private static delegate* unmanaged[Cdecl]<IntPtr, void> _set;
|
||||||
private static delegate* unmanaged[Cdecl]<void> _addWeapon, _addShield, _addConsumable;
|
private static delegate* unmanaged[Cdecl]<void> _addWeapon, _addShield, _addConsumable, _clean;
|
||||||
|
|
||||||
/// <summary>ItemRule.Action value the plugin uses for off-hand shields.</summary>
|
/// <summary>ItemRule.Action value the plugin uses for off-hand shields.</summary>
|
||||||
public const string ShieldAction = "Shield";
|
public const string ShieldAction = "Shield";
|
||||||
|
|
||||||
static ItemsCommands()
|
static ItemsCommands()
|
||||||
{
|
{
|
||||||
PluginManager.PluginsUnloaded += () => { _set = null; _addWeapon = null; _addShield = null; _addConsumable = null; };
|
PluginManager.PluginsUnloaded += () => { _set = null; _addWeapon = null; _addShield = null; _addConsumable = null; _clean = null; };
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly string[] Elements = { "Slash", "Pierce", "Bludgeon", "Fire", "Cold", "Lightning", "Acid", "Nether" };
|
public static readonly string[] Elements = { "Slash", "Pierce", "Bludgeon", "Fire", "Cold", "Lightning", "Acid", "Nether" };
|
||||||
|
|
@ -117,6 +117,18 @@ internal static unsafe class ItemsCommands
|
||||||
UiSources.Items.RequestRefresh();
|
UiSources.Items.RequestRefresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes weapons and consumables no longer in the inventory; RynthAi reports what it did
|
||||||
|
/// in chat. RynthAi older than 0.5.43 has no such export: the click is logged and dropped.
|
||||||
|
/// </summary>
|
||||||
|
public static void CleanMissing() => UiDataHub.Post("Items clean", () =>
|
||||||
|
{
|
||||||
|
if (_clean == null) _clean = (delegate* unmanaged[Cdecl]<void>)Export("RynthPluginCleanItems");
|
||||||
|
if (_clean != null) _clean();
|
||||||
|
else RynthLog.UI("ItemsCommands: Remove Missing unavailable - RynthAi 0.5.43 or newer is required.");
|
||||||
|
UiSources.Items.RequestRefresh();
|
||||||
|
});
|
||||||
|
|
||||||
public static string Serialize(ItemsPanel.Payload payload) =>
|
public static string Serialize(ItemsPanel.Payload payload) =>
|
||||||
JsonSerializer.Serialize(payload, ItemsPanelJsonContext.Default.Payload);
|
JsonSerializer.Serialize(payload, ItemsPanelJsonContext.Default.Payload);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue