Skip to content

Arsenal - Add generic itemsChanged event - #11484

Open
LinkIsGrim wants to merge 2 commits into
masterfrom
arsenal-selection-event
Open

Arsenal - Add generic itemsChanged event#11484
LinkIsGrim wants to merge 2 commits into
masterfrom
arsenal-selection-event

Conversation

@LinkIsGrim

Copy link
Copy Markdown
Member

Adds QGVAR(itemsChanged), fired as [_display, _panel, _newItem, _oldItem] where _newItem/_oldItem are classname -> count HashMaps of what was gained/lost.

Intended as a single generic replacement for piecing together cargoChanged/weaponItemChanged/leftPanelFilled/rightPanelFilled plus manual ButtonClick hooks on the remove-all buttons to figure out "what did the player just take or return," which is what any limited/pooled virtual arsenal (e.g. an inventory- or external-economy-backed one) needs.

Covers every place items can move in or out of the arsenal:

  • fnc_onSelChangedLeft.sqf / fnc_onSelChangedRight.sqf: snapshot the unit's full item counts (fnc_getLoadoutItemCounts.sqf) before and after the existing selection-change logic runs, diff after. Generic enough to catch cascading side effects (an incompatible weapon swap dropping magazines, the primary/secondary magazine swap case) without needing to touch each case individually.
  • fnc_buttonCargo.sqf: fires directly as the exact classname and amount are already known here.
  • fnc_buttonClearAll.sqf: same snapshot/diff approach, since it clears a container via three different commands depending on container type.
  • fnc_buttonLoadoutsLoad.sqf / fnc_buttonImport.sqf

Not fired from fnc_onArsenalOpen.sqf's or the 3DEN-only branch of fnc_onArsenalClose.sqf's setLoadout calls.

Usecase: https://github.com/LinkIsGrim/antistasi-ace3-arsenal

IMPORTANT

  • If the contribution affects the documentation, please include your changes in this pull request so the documentation will appear on the website.
  • Development Guidelines are read, understood and applied.
  • Title of this PR uses our standard template Component - Add|Fix|Improve|Change|Make|Remove {changes}.

@LinkIsGrim LinkIsGrim added this to the Ongoing milestone Sep 4, 2026
@LinkIsGrim LinkIsGrim self-assigned this Sep 4, 2026
@LinkIsGrim LinkIsGrim added the kind/enhancement Release Notes: **IMPROVED:** label Sep 4, 2026
Adds QGVAR(itemsChanged), fired as [_display, _panel, _newItem, _oldItem]
where _newItem/_oldItem are classname -> count HashMaps of what was
gained/lost - a diff, not a full snapshot, so an unchanged classname
appears in neither.

Intended as a single generic replacement for piecing together
cargoChanged/weaponItemChanged/leftPanelFilled/rightPanelFilled plus
manual ButtonClick hooks on the remove-all buttons to figure out "what
did the player just take or return," which is what any limited/pooled
virtual arsenal (e.g. an inventory- or external-economy-backed one)
otherwise has to hand-roll by diffing loadout snapshots itself.

Covers every place items can move in or out of the arsenal:
- fnc_onSelChangedLeft.sqf / fnc_onSelChangedRight.sqf: snapshot the
  unit's full item counts (fnc_getLoadoutItemCounts.sqf) before and
  after the existing selection-change logic runs, diff after -
  generic enough to catch cascading side effects (an incompatible
  weapon swap dropping magazines, the primary/secondary magazine
  swap case) without needing to touch each case individually.
- fnc_buttonCargo.sqf: the +/- cargo button requests a fixed amount
  (1, or 5 on shift-click), but that's not guaranteed to fully apply -
  the container might not fit 5, or might hold fewer than 5 to remove -
  so it counts the item before and after within each case (not the
  request amount) and lets that measured delta go through the same
  diff as everything else.
- fnc_buttonClearAll.sqf: same snapshot/diff approach, since it clears
  a container via three different commands depending on container type.
- fnc_buttonLoadoutsLoad.sqf / fnc_buttonImport.sqf (in-game import):
  both replace the whole loadout via CBA_fnc_setLoadout in one call,
  bypassing every per-slot/per-panel handler above, so they need their
  own snapshot/diff around that call.

Deliberately not fired from fnc_onArsenalOpen.sqf's or the 3DEN-only
branch of fnc_onArsenalClose.sqf's setLoadout calls - neither is a
player pulling from stock (mirroring an already-owned loadout onto the
arsenal's display unit, and copying a finalized loadout to other
editor-selected objects, respectively).
Adds the event to the eventhandlers table, a short explanation of its
HashMap diff shape, and a worked example (10.5) showing the intended
use: a limited/pooled arsenal charging/crediting its own stock off
this instead of hand-rolling a loadout diff.
@LinkIsGrim
LinkIsGrim force-pushed the arsenal-selection-event branch from 830a460 to 5f315c1 Compare September 4, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement Release Notes: **IMPROVED:**

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant