RynthCore/Changelog/2026-11-07-bar-menu.md

3.2 KiB

Bar icon dropdown: plugin API v95

Branch pr/bar-menu, from pr/web-panel (web panel, v94). Not deployed. The API number 95 is provisional, as 94 is (unmerged upstream branches also use these numbers; whichever merges second renumbers). The manifest is parsed here; the bar draws it (below).

What changed

  • A plugin window in the sections manifest (windows, with "bar": true) may declare "barMenu": up to 6 items of { "id", "tooltip", "icon", "command" }. SectionManifest.cs parses it into SectionWindowDecl.BarMenu (SectionBarMenuItem records; Menu is the never-null view).
  • Validation, with the window always kept: the id is a short lower-case word and unique in the menu, the tooltip is non-empty and capped at 48 characters, the command is a single /... chat command (the same rule as a contribution's), the icon is one Phosphor glyph or empty (an icon that is not a glyph is kept as an empty icon, and the bar draws the tooltip's first letter). An item with a bad id, tooltip or command is dropped; items past MaxBarMenuItems (6) are ignored; a barMenu that is not an array is ignored.
  • PluginContractVersion.Current and the SDK's RynthCoreSdkApiVersion (RynthCore.PluginSdk.targets) go to 95. No function table change. Engines before v95 ignore the key, so a plugin can declare it unconditionally.

Tests

tools/SectionsTests:

  • ManifestBarMenu: valid items in order with exact fields, rejected commands (no slash, a line break, over-long), empty id, duplicate id, empty tooltip, empty icon kept, 20 items capped to 6, a non-array barMenu, no key, and the 48-character tooltip cap.
  • BarMenuHoverTiming: the 0.15 s open delay, a quick sweep never opening, the 0.30 s close delay covering the gap from icon to dropdown, switching to another icon at once, no reopen while still hovering after a click, and a clock jump or a gap over 0.5 s resetting.
  • BarMenuReload: a change to only barMenu leaves the panel signature alone (no re-registration) and changes the menu signature (so the bar rebuilds).

tools/PluginManifestTests pins the SDK and engine numbers together, and that PluginContractVersion.BarMenu is at or below Current.

Not yet tested in game.

The dropdown

  • Hovering a plugin window's bar icon for 0.15 s drops a column of icon buttons flush below it (flush above when it would cross the bottom of the screen; clamped sideways). It stays while the mouse is over the icon or the column, and for 0.30 s after it leaves both. Another icon's dropdown replaces it at once. Clicking an item runs its command as a player chat command (the hotkey path) and closes the dropdown. The icon's own click still toggles the window.
  • A plugin reload that changes only barMenu reaches the bar: PluginWindows.Sync refreshes the hosted declaration (WindowPlan.MenuSignature) without re-registering the panel, and bumps the version so the bar rebuilds its buttons.
  • The dropdown is brought to the display front every frame (cimgui igBringWindowToDisplayFront, no focus change), so a panel focused since does not cover it; without those exports it keeps its normal order and logs once.
  • Timing is ImGui/BarMenuHover.cs (pure; SectionsTests BarMenuHoverTiming). Drawing is in-game only.