Arsenal - Add generic itemsChanged event - #11484
Open
LinkIsGrim wants to merge 2 commits into
Open
Conversation
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
force-pushed
the
arsenal-selection-event
branch
from
September 4, 2026 06:44
830a460 to
5f315c1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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
Component - Add|Fix|Improve|Change|Make|Remove {changes}.