Arsenal - Fix displaying virtual items & weapon attachments in cargo (#9692)

* Unique items fix

* attachment lookup

Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>

* container item lookup

Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>

---------

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
This commit is contained in:
johnb432 2023-12-31 01:30:52 +01:00 committed by GitHub
parent 86649edc1e
commit 92d199e6ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 18 deletions

View File

@ -47,8 +47,8 @@ private _container = switch (GVAR(currentLeftPanel)) do {
};
};
/// Get all items from container (excluding container itself)
_containerItems = [GVAR(center), 0, 3, 0, 0, false] call EFUNC(common,uniqueUnitItems);
// Get all items from container
_containerItems = uniformItems GVAR(center);
// Update currentItems
GVAR(currentItems) set [IDX_CURR_UNIFORM_ITEMS, ((getUnitLoadout GVAR(center)) select IDX_LOADOUT_UNIFORM) param [1, []]];
@ -75,8 +75,8 @@ private _container = switch (GVAR(currentLeftPanel)) do {
};
};
// Get all items from container (excluding container itself)
_containerItems = [GVAR(center), 0, 0, 3, 0, false] call EFUNC(common,uniqueUnitItems);
// Get all items from container
_containerItems = vestItems GVAR(center);
// Update currentItems
GVAR(currentItems) set [IDX_CURR_VEST_ITEMS, ((getUnitLoadout GVAR(center)) select IDX_LOADOUT_VEST) param [1, []]];
@ -103,8 +103,8 @@ private _container = switch (GVAR(currentLeftPanel)) do {
};
};
// Get all items from container (excluding container itself)
_containerItems = [GVAR(center), 0, 0, 0, 3, false] call EFUNC(common,uniqueUnitItems);
// Get all items from container
_containerItems = backpackItems GVAR(center);
// Update currentItems
GVAR(currentItems) set [IDX_CURR_BACKPACK_ITEMS, ((getUnitLoadout GVAR(center)) select IDX_LOADOUT_BACKPACK) param [1, []]];
@ -117,7 +117,7 @@ private _container = switch (GVAR(currentLeftPanel)) do {
};
// Find out how many items of that type there are and update the number displayed
_ctrlList lnbSetText [[_lnbCurSel, 2], str (_containerItems getOrDefault [_item, 0])];
_ctrlList lnbSetText [[_lnbCurSel, 2], str ({_item == _x} count _containerItems)];
[QGVAR(cargoChanged), [_display, _item, _addOrRemove, GVAR(shiftState)]] call CBA_fnc_localEvent;

View File

@ -389,8 +389,8 @@ if (_isContainer) then {
// Update load bar
(_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadUniform GVAR(center));
// Get all items from container (excluding container itself)
_containerItems = [GVAR(center), 0, 3, 0, 0, false] call EFUNC(common,uniqueUnitItems);
// Get all items from container
_containerItems = uniformItems GVAR(center);
uniformContainer GVAR(center)
};
@ -399,8 +399,8 @@ if (_isContainer) then {
// Update load bar
(_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadVest GVAR(center));
// Get all items from container (excluding container itself)
_containerItems = [GVAR(center), 0, 0, 3, 0, false] call EFUNC(common,uniqueUnitItems);
// Get all items from container
_containerItems = vestItems GVAR(center);
vestContainer GVAR(center)
};
@ -409,8 +409,8 @@ if (_isContainer) then {
// Update load bar
(_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadBackpack GVAR(center));
// Get all items from container (excluding container itself)
_containerItems = [GVAR(center), 0, 0, 0, 3, false] call EFUNC(common,uniqueUnitItems);
// Get all items from container
_containerItems = backpackItems GVAR(center);
backpackContainer GVAR(center)
};
@ -418,7 +418,8 @@ if (_isContainer) then {
// Find out how many items of a type there are and update the number displayed
for "_lbIndex" from 0 to (lnbSize _ctrlPanel select 0) - 1 do {
_ctrlPanel lnbSetText [[_lbIndex, 2], str (_containerItems getOrDefault [_ctrlPanel lnbData [_lbIndex, 0], 0])];
private _xItem = _ctrlPanel lnbData [_lbIndex, 0];
_ctrlPanel lnbSetText [[_lbIndex, 2], str ({_xItem == _x} count _containerItems)];
};
// Refresh availibility of items based on space remaining in container

View File

@ -125,7 +125,8 @@ private _fnc_uniqueEquipment = {
};
} forEach (getUnitLoadout GVAR(center)); // Only need items, not extended loadout
// Get all items from unit
_items = itemsWithMagazines GVAR(center);
private _isMagazine = false;
private _isWeapon = false;
private _isGrenade = false;
@ -184,7 +185,12 @@ private _itemInfoType = 0;
// Unknown
default {
// Don't add items that are part of the arsenal
if !(_x in GVAR(virtualItemsFlatAll)) then {
if (
!(_x in (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS)) &&
{!(_x in (GVAR(virtualItems) get IDX_VIRT_GRENADES))} &&
{!(_x in (GVAR(virtualItems) get IDX_VIRT_EXPLOSIVES))} &&
{!(_x in (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL))}
) then {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, nil];
};
};
@ -255,7 +261,14 @@ private _itemInfoType = 0;
// Unknown
default {
// Don't add items that are part of the arsenal
if !(_x in GVAR(virtualItemsFlatAll)) then {
private _attachments = GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS;
if (
!(_x in (_attachments get IDX_VIRT_OPTICS_ATTACHMENTS)) &&
{!(_x in (_attachments get IDX_VIRT_FLASHLIGHT_ATTACHMENTS))} &&
{!(_x in (_attachments get IDX_VIRT_MUZZLE_ATTACHMENTS))} &&
{!(_x in (_attachments get IDX_VIRT_BIPOD_ATTACHMENTS))} &&
{!(_x in (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS))}
) then {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, nil];
};
};
@ -277,4 +290,4 @@ private _itemInfoType = 0;
};
};
};
} forEach (keys ([GVAR(center), 0, 3, 3, 3, false] call EFUNC(common,uniqueUnitItems))); // Get all items from unit
} forEach (_items arrayIntersect _items);