diff --git a/Plugins/RynthCore.Plugin.RynthDefective/Model/DefData.cs b/Plugins/RynthCore.Plugin.RynthDefective/Model/DefData.cs index ebf5c74..91f9f1f 100644 --- a/Plugins/RynthCore.Plugin.RynthDefective/Model/DefData.cs +++ b/Plugins/RynthCore.Plugin.RynthDefective/Model/DefData.cs @@ -105,6 +105,12 @@ internal sealed class DefSettings public KindFilter PreferredKind = KindFilter.All; /// Weapon swaps are refused while RynthAi's macro runs (it picks the weapon itself); this lets them through. public bool SwapWhileBotRuns; + /// + /// The Weapons button (the sword) in the Shortcuts bar's title (2026-10-29). Off (the default): the + /// title holds only edit, settings and hide, so a click aimed at one doesn't open the weapon picker; + /// the picker opens from the settings window, the bar's right-click menu and /rdef weapons. + /// + public bool WeaponsButtonOnBar; public bool BarOpen; public bool PickerOpen; diff --git a/Plugins/RynthCore.Plugin.RynthDefective/Model/DefStore.cs b/Plugins/RynthCore.Plugin.RynthDefective/Model/DefStore.cs index eee477f..43ec30a 100644 --- a/Plugins/RynthCore.Plugin.RynthDefective/Model/DefStore.cs +++ b/Plugins/RynthCore.Plugin.RynthDefective/Model/DefStore.cs @@ -66,6 +66,7 @@ internal sealed class DefStore st.ShowCounts = Bool(s, "showCounts", st.ShowCounts); st.PreferredKind = (KindFilter)Int(s, "preferredKind", (int)st.PreferredKind); st.SwapWhileBotRuns = Bool(s, "swapWhileBotRuns", st.SwapWhileBotRuns); + st.WeaponsButtonOnBar = Bool(s, "weaponsButtonOnBar", st.WeaponsButtonOnBar); // missing (a file from before 2026-10-29): off st.IndependentBar = Bool(s, "independentBar", st.IndependentBar); // missing (a file from before 2026-10-27): off st.BarOpen = Bool(s, "barOpen", st.BarOpen); st.PickerOpen = Bool(s, "pickerOpen", st.PickerOpen); @@ -163,6 +164,7 @@ internal sealed class DefStore w.WriteBoolean("showCounts", s.ShowCounts); w.WriteNumber("preferredKind", (int)s.PreferredKind); w.WriteBoolean("swapWhileBotRuns", s.SwapWhileBotRuns); + w.WriteBoolean("weaponsButtonOnBar", s.WeaponsButtonOnBar); w.WriteBoolean("independentBar", s.IndependentBar); w.WriteBoolean("barOpen", s.BarOpen); w.WriteBoolean("pickerOpen", s.PickerOpen); diff --git a/Plugins/RynthCore.Plugin.RynthDefective/RynthDefectivePlugin.cs b/Plugins/RynthCore.Plugin.RynthDefective/RynthDefectivePlugin.cs index 63da65b..93c731c 100644 --- a/Plugins/RynthCore.Plugin.RynthDefective/RynthDefectivePlugin.cs +++ b/Plugins/RynthCore.Plugin.RynthDefective/RynthDefectivePlugin.cs @@ -96,6 +96,7 @@ public sealed partial class RynthDefectivePlugin : RynthPluginBase WindowShown = PanelShown, ShowWindow = (title, show) => Host.SetPanelOpen(title, show ? RynthPanelOpen.Open : RynthPanelOpen.Close), Tell = text => { _session.SetStatus(text); Print(text); _nextBarBuildMs = 0; }, + ShowWeapons = () => ShowPicker(true), }; _settingsWindow = _ui.Add(new UiWindow("RynthDefective/Settings", "Defective Settings") { diff --git a/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/BarSnapshot.cs b/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/BarSnapshot.cs index 64fc854..f8e05a1 100644 --- a/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/BarSnapshot.cs +++ b/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/BarSnapshot.cs @@ -48,10 +48,11 @@ internal sealed record BarSlot( /// /// The bar as drawn. Independent: every slot is RynthDefective's own (DefSettings.IndependentBar). /// Spells: the character's spells, A-Z, for "Put a spell here..." (empty when they can't be read); -/// CanCast: the engine casts for plugins. +/// CanCast: the engine casts for plugins. WeaponsButton: the title shows the Weapons button +/// (DefSettings.WeaponsButtonOnBar). /// internal sealed record BarSnapshot(BarSlot[] Slots, bool Ready, int IconSize, bool Independent = false, - IReadOnlyList? Spells = null, bool CanCast = false) + IReadOnlyList? Spells = null, bool CanCast = false, bool WeaponsButton = false) { public static readonly BarSnapshot NotReady = new(Array.Empty(), false, 36); @@ -98,7 +99,7 @@ internal sealed class BarSnapshotBuilder // 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); + return new BarSnapshot(own, true, st.ButtonSize, true, spells, canCast, st.WeaponsButtonOnBar); } if (_host.GetShortcuts(_ids, _spells) == 0) return BarSnapshot.NotReady; RefreshKeys(now); @@ -108,7 +109,7 @@ 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); + return new BarSnapshot(slots, true, st.ButtonSize, false, spells, canCast, st.WeaponsButtonOnBar); } private BarSlot Retail(int n, Dictionary byId) diff --git a/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/ShortcutBarWindow.cs b/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/ShortcutBarWindow.cs index 7af1acb..da19556 100644 --- a/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/ShortcutBarWindow.cs +++ b/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/ShortcutBarWindow.cs @@ -184,7 +184,8 @@ internal sealed class ShortcutBarWindow private float Header(ImDrawListPtr dl, BarSnapshot view, float x0, float y, float w) { float h = Px(HeaderH), chip = Px(ChipSize); - const int chips = 4; + // The Weapons button only when the settings ask for it (DefSettings.WeaponsButtonOnBar). + int chips = view.WeaponsButton ? 4 : 3; float chipsW = chips * chip + (chips - 1) * Px(1); ImGui.SetCursorScreenPos(new Vector2(x0, y)); @@ -207,9 +208,12 @@ internal sealed class ShortcutBarWindow _edit ? "Done editing." : "Edit: the slot numbers, and - / + to take a slot off or add one.", _edit)) _edit = !_edit; cx += chip + Px(1); - if (Chip("##sb_weapons", RynthIcons.Sword, new Vector2(cx, cy), _faint, "Weapons: every weapon and wand you carry, wield one with a click.")) - _act.ShowWeapons(); - cx += chip + Px(1); + if (view.WeaponsButton) + { + if (Chip("##sb_weapons", RynthIcons.Sword, new Vector2(cx, cy), _faint, "Weapons: every weapon and wand you carry, wield one with a click.")) + _act.ShowWeapons(); + cx += chip + Px(1); + } if (Chip("##sb_settings", RynthIcons.Gear, new Vector2(cx, cy), _faint, "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(); diff --git a/Plugins/RynthCore.Plugin.RynthDefective/Views/BarSettingsView.cs b/Plugins/RynthCore.Plugin.RynthDefective/Views/BarSettingsView.cs index 811b21a..d2321bf 100644 --- a/Plugins/RynthCore.Plugin.RynthDefective/Views/BarSettingsView.cs +++ b/Plugins/RynthCore.Plugin.RynthDefective/Views/BarSettingsView.cs @@ -26,6 +26,8 @@ internal sealed class BarSettingsView public Action ShowWindow = (_, _) => { }; /// A message for the player (the chat, and the status line). public Action Tell = _ => { }; + /// Opens the weapon picker (/rdef weapons). + public Action ShowWeapons = () => { }; public BarSettingsView(DefSession session) => _s = session; @@ -74,6 +76,10 @@ internal sealed class BarSettingsView w.Tooltip("Ctrl+wheel over the bar's title makes the whole bar bigger or smaller."); w.SeparatorText("Weapons"); + w.SmallButton("Weapon picker...", "set.weapons", () => ShowWeapons()); + w.Tooltip("Every weapon and wand you carry, wield one with a click (/rdef weapons, or Weapons... in the bar's right-click menu)."); + w.Checkbox("Weapons button on the bar", "set.weaponsbtn", st.WeaponsButtonOnBar, v => { st.WeaponsButtonOnBar = v; Changed(); }); + w.Tooltip("Shows the sword button in the Shortcuts bar's title, next to edit, settings and hide. Off (the default): the picker opens from here."); w.Checkbox("Allow weapon swaps while RynthAi's macro runs", "set.swap", st.SwapWhileBotRuns, v => { st.SwapWhileBotRuns = v; Changed(); }); w.Tooltip("Off (the default): a weapon, wand or shield is not wielded while the RynthAi macro runs - it picks the weapon itself and would swap back. Kits, potions and other items always work."); w.SliderInt("Weapon picker row icon", "set.picker", st.PickerIconSize, DefSettings.PickerIconMin, DefSettings.PickerIconMax, v => { st.PickerIconSize = v; Changed(); }); diff --git a/Tools/RynthDefective.Tests/BarTests.cs b/Tools/RynthDefective.Tests/BarTests.cs index 5c509b3..88459d1 100644 --- a/Tools/RynthDefective.Tests/BarTests.cs +++ b/Tools/RynthDefective.Tests/BarTests.cs @@ -218,6 +218,8 @@ namespace RynthDefective.Tests view.WindowShown = t => shown.TryGetValue(t, out bool v) ? v : null; // no Game Panels on this "engine" view.ShowWindow = (t, v) => shown[t] = v; view.Tell = told.Add; + int pickers = 0; + view.ShowWeapons = () => pickers++; void Draw() { win.Begin(); view.Draw(win); win.End(); } string Text() => Encoding.UTF8.GetString(win.Body); @@ -239,6 +241,14 @@ namespace RynthDefective.Tests Check(shown[BarSettingsView.SelectionTitle], "the Selection box shows the window"); SetBool("set.swap", true); Check(b.S.Settings.SwapWhileBotRuns, "the swap switch"); + Check(Text().Contains("Weapon picker...") && Text().Contains("Weapons button on the bar"), "the picker button and the bar-button switch are in the settings"); + Click("set.weapons"); + Eq(pickers, 1, "Weapon picker... opens the picker"); + Check(!b.S.Settings.WeaponsButtonOnBar, "the bar has no Weapons button by default"); + SetBool("set.weaponsbtn", true); + Check(b.S.Settings.WeaponsButtonOnBar, "the switch puts it back"); + SetBool("set.weaponsbtn", false); + Check(!b.S.Settings.WeaponsButtonOnBar, "and takes it off again"); SetBool("set.indep", true); Check(b.S.Settings.IndependentBar && told.Count == 1 && told[0].Contains("independent"), "the independent switch, told in chat"); diff --git a/Tools/RynthDefective.Tests/ModelTests.cs b/Tools/RynthDefective.Tests/ModelTests.cs index 3d43206..c15ba34 100644 --- a/Tools/RynthDefective.Tests/ModelTests.cs +++ b/Tools/RynthDefective.Tests/ModelTests.cs @@ -348,6 +348,7 @@ namespace RynthDefective.Tests d.Settings.ShowCounts = false; d.Settings.PreferredKind = KindFilter.War; d.Settings.SwapWhileBotRuns = true; + d.Settings.WeaponsButtonOnBar = true; d.Settings.BarOpen = true; d.Settings.PickerOpen = true; var kit = Kit(0x7000_0001u); @@ -367,6 +368,7 @@ namespace RynthDefective.Tests DefSettings s = r.Settings; Check(s.SlotCount == 12 && s.SlotsPerRow == 6 && s.ButtonSize == 44 && s.PickerIconSize == 28, "sizes"); Check(!s.ShowIcons && !s.ShowCounts && s.SwapWhileBotRuns && s.BarOpen && s.PickerOpen && s.PreferredKind == KindFilter.War, "switches"); + Check(s.WeaponsButtonOnBar, "the Weapons button on the bar, kept"); Check(r.Slots.Count == DefSettings.SlotsMax, "all 42 slots"); ItemRef a = r.Slots[0].Item!; Check(a.Id == 0x7000_0001u && a.Name == "Peerless Healing Kit" && a.Wcid == 628 && a.Icon == 0x06001234 && a.Underlay == 0x06000FFF && a.Overlay == 0x06000EEE, "a slot's item with its identity and picture"); @@ -399,6 +401,7 @@ namespace RynthDefective.Tests File.WriteAllText(own, "{}"); d = st.Load("S", "A", out problem); Check(problem == null && d.Settings.SlotCount == 8 && d.Slots.Count == DefSettings.SlotsMax, "{} = defaults"); + Check(!d.Settings.WeaponsButtonOnBar, "a file from before has no Weapons button on the bar"); File.WriteAllText(own, "{\"settings\":{\"slotCount\":99,\"slotsPerRow\":0,\"buttonSize\":1000,\"pickerIconSize\":-5,\"preferredKind\":42,\"showIcons\":\"yes\"}," + "\"slots\":[7,{\"item\":{\"id\":5.0,\"name\":\"Kit\"},\"mode\":9},{\"item\":{\"id\":1}},{\"item\":{\"name\":\" \"}},{\"item\":\"x\"},null],"