From eb04784eaf5128cb329401221d84168065cb4057 Mon Sep 17 00:00:00 2001 From: BlankenshipG Date: Mon, 12 Oct 2026 00:32:53 -0400 Subject: [PATCH] feat(items): Remove Missing button on the Items panel See Changelog/2026-10-11-items-remove-missing.md. --- Changelog/2026-10-11-items-remove-missing.md | 16 ++++++++++++++++ src/RynthCore.Engine/ImGui/Panels/ItemsFace.cs | 10 +++++++++- src/RynthCore.Engine/UI/Data/ItemsData.cs | 16 ++++++++++++++-- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 Changelog/2026-10-11-items-remove-missing.md diff --git a/Changelog/2026-10-11-items-remove-missing.md b/Changelog/2026-10-11-items-remove-missing.md new file mode 100644 index 0000000..de9304b --- /dev/null +++ b/Changelog/2026-10-11-items-remove-missing.md @@ -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. diff --git a/src/RynthCore.Engine/ImGui/Panels/ItemsFace.cs b/src/RynthCore.Engine/ImGui/Panels/ItemsFace.cs index 432164a..95e3e43 100644 --- a/src/RynthCore.Engine/ImGui/Panels/ItemsFace.cs +++ b/src/RynthCore.Engine/ImGui/Panels/ItemsFace.cs @@ -54,6 +54,13 @@ internal sealed class ItemsFace : IImGuiPanel ImGuiNET.ImGui.BeginChild("##items_body", new Vector2(w, Math.Max(60, Remaining(origin, size)))); 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 Section("Weapons", bw); if (_data.Weapons.Count == 0) Empty("No weapons configured", bw); @@ -242,11 +249,12 @@ internal sealed class ItemsFace : IImGuiPanel 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); float bw = ButtonWidth(label) + 4; 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); 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); diff --git a/src/RynthCore.Engine/UI/Data/ItemsData.cs b/src/RynthCore.Engine/UI/Data/ItemsData.cs index 26e55bf..ca47cc4 100644 --- a/src/RynthCore.Engine/UI/Data/ItemsData.cs +++ b/src/RynthCore.Engine/UI/Data/ItemsData.cs @@ -63,14 +63,14 @@ internal sealed unsafe class ItemsSource : UiSource internal static unsafe class ItemsCommands { private static delegate* unmanaged[Cdecl] _set; - private static delegate* unmanaged[Cdecl] _addWeapon, _addShield, _addConsumable; + private static delegate* unmanaged[Cdecl] _addWeapon, _addShield, _addConsumable, _clean; /// ItemRule.Action value the plugin uses for off-hand shields. public const string ShieldAction = "Shield"; 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" }; @@ -117,6 +117,18 @@ internal static unsafe class ItemsCommands UiSources.Items.RequestRefresh(); }); + /// + /// 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. + /// + public static void CleanMissing() => UiDataHub.Post("Items clean", () => + { + if (_clean == null) _clean = (delegate* unmanaged[Cdecl])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) => JsonSerializer.Serialize(payload, ItemsPanelJsonContext.Default.Payload); }