mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Arsenal - Add support for modifying Virtual Items while opened (#9542)
* add support for mod. virt. items while opened * updateUniqueItems * execNextFrame * add notification and TRACE * remove debug * Update addons/arsenal/functions/fnc_addVirtualItems.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Update addons/arsenal/functions/fnc_refresh.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * move to removeBox * update english to plural, others are fine * missing include * directCall in refresh --------- Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
This commit is contained in:
parent
f35f872963
commit
339cfa8024
@ -104,4 +104,5 @@ PREP(updateCamPos);
|
||||
PREP(updateRightPanel);
|
||||
PREP(updateCurrentItemsList);
|
||||
PREP(updateUniqueItemsList);
|
||||
PREP(updateVirtualItemsFlat);
|
||||
PREP(verifyLoadout);
|
||||
|
@ -123,3 +123,8 @@ if (_items isEqualType true) then {
|
||||
};
|
||||
|
||||
_object setVariable [QGVAR(virtualItems), _cargo, _global];
|
||||
|
||||
// If the arsenal is already open, refresh arsenal display
|
||||
if (!isNil QGVAR(currentBox) && {GVAR(currentBox) isEqualTo _object}) then {
|
||||
[true, true] call FUNC(refresh);
|
||||
};
|
||||
|
@ -61,25 +61,10 @@ if (isNil QGVAR(virtualItems)) then {
|
||||
GVAR(virtualItems) = _virtualItems;
|
||||
|
||||
// Flatten out hashmaps for easy checking later
|
||||
private _virtualItemsFlat = +_virtualItems;
|
||||
private _weapons = _virtualItemsFlat deleteAt IDX_VIRT_WEAPONS;
|
||||
private _attachments = _virtualItemsFlat deleteAt IDX_VIRT_ATTACHMENTS;
|
||||
|
||||
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
|
||||
_virtualItemsFlat merge [_virtualItemsFlat deleteAt _index, true];
|
||||
};
|
||||
|
||||
for "_index" from IDX_VIRT_PRIMARY_WEAPONS to IDX_VIRT_HANDGUN_WEAPONS do {
|
||||
_virtualItemsFlat merge [_weapons deleteAt _index, true];
|
||||
};
|
||||
|
||||
for "_index" from IDX_VIRT_OPTICS_ATTACHMENTS to IDX_VIRT_BIPOD_ATTACHMENTS do {
|
||||
_virtualItemsFlat merge [_attachments deleteAt _index, true];
|
||||
};
|
||||
|
||||
GVAR(virtualItemsFlat) = _virtualItemsFlat;
|
||||
call FUNC(updateVirtualItemsFlat);
|
||||
};
|
||||
|
||||
// Includes items not in the arsenal but equipped on player
|
||||
GVAR(virtualItemsFlatAll) = +GVAR(virtualItemsFlat);
|
||||
|
||||
GVAR(currentFace) = face GVAR(center);
|
||||
|
@ -72,23 +72,7 @@ if (_mode) then {
|
||||
};
|
||||
|
||||
// Flatten out hashmaps for easy checking later
|
||||
private _virtualItemsFlat = +_virtualItems;
|
||||
private _weapons = _virtualItemsFlat deleteAt IDX_VIRT_WEAPONS;
|
||||
private _attachments = _virtualItemsFlat deleteAt IDX_VIRT_ATTACHMENTS;
|
||||
|
||||
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
|
||||
_virtualItemsFlat merge [_virtualItemsFlat deleteAt _index, true];
|
||||
};
|
||||
|
||||
for "_index" from IDX_VIRT_PRIMARY_WEAPONS to IDX_VIRT_HANDGUN_WEAPONS do {
|
||||
_virtualItemsFlat merge [_weapons deleteAt _index, true];
|
||||
};
|
||||
|
||||
for "_index" from IDX_VIRT_OPTICS_ATTACHMENTS to IDX_VIRT_BIPOD_ATTACHMENTS do {
|
||||
_virtualItemsFlat merge [_attachments deleteAt _index, true];
|
||||
};
|
||||
|
||||
GVAR(virtualItemsFlat) = _virtualItemsFlat;
|
||||
call FUNC(updateVirtualItemsFlat);
|
||||
};
|
||||
|
||||
GVAR(center) = _center;
|
||||
|
@ -6,6 +6,7 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Update current and unique items lists <BOOL> (default: true)
|
||||
* 1: Update virtual items list <BOOL> (default: false)
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -15,13 +16,37 @@
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
params [["_updateItems", true, [true]]];
|
||||
params [["_updateItems", true, [true]], ["_updateVirtualItems", false, [false]]];
|
||||
|
||||
TRACE_2("",_updateItems,_updateVirtualItems);
|
||||
|
||||
// Don't execute in scheduled environment
|
||||
if (canSuspend) exitWith {
|
||||
[{_this call FUNC(refresh)}, _this] call CBA_fnc_directCall;
|
||||
};
|
||||
|
||||
if (_updateItems) then {
|
||||
// Update current item list
|
||||
call FUNC(updateCurrentItemsList);
|
||||
|
||||
// This takes care of unique inventory items (arsenal doesn't have it whitelisted)
|
||||
if (!_updateVirtualItems) then {
|
||||
call FUNC(updateUniqueItemsList);
|
||||
};
|
||||
};
|
||||
|
||||
private _virtualItems = GVAR(currentBox) getVariable QGVAR(virtualItems);
|
||||
if (isNil "_virtualItems") exitWith {
|
||||
[LLSTRING(noVirtualItems), false, 5, 1] call EFUNC(common,displayText);
|
||||
// Delay a frame in case this is running on display open
|
||||
[{(findDisplay IDD_ace_arsenal) closeDisplay 0}] call CBA_fnc_execNextFrame;
|
||||
};
|
||||
|
||||
if (_updateVirtualItems) then {
|
||||
GVAR(virtualItems) = +_virtualItems;
|
||||
call FUNC(updateVirtualItemsFlat);
|
||||
|
||||
// Gotta update this regardless of condition to prevent desync
|
||||
call FUNC(updateUniqueItemsList);
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "..\script_component.hpp"
|
||||
#include "..\defines.hpp"
|
||||
/*
|
||||
* Author: Alganthe, johnb43
|
||||
* Remove arsenal from target.
|
||||
@ -39,3 +40,10 @@ if (_global && {isMultiplayer} && {!isNil "_id"}) then {
|
||||
[_object, 0, ["ACE_MainActions", QGVAR(interaction)]] call EFUNC(interact_menu,removeActionFromObject);
|
||||
[QGVAR(boxRemoved), _object] call CBA_fnc_localEvent;
|
||||
};
|
||||
|
||||
// If the arsenal is already open, close arsenal display
|
||||
if (!isNil QGVAR(currentBox) && {GVAR(currentBox) isEqualTo _object}) then {
|
||||
[LLSTRING(noVirtualItems), false, 5, 1] call EFUNC(common,displayText);
|
||||
// Delay a frame in case this is running on display open
|
||||
[{(findDisplay IDD_ace_arsenal) closeDisplay 0}] call CBA_fnc_execNextFrame;
|
||||
};
|
||||
|
@ -100,5 +100,9 @@ if (_items isEqualType true) then {
|
||||
[_object, _global] call FUNC(removeBox);
|
||||
} else {
|
||||
_object setVariable [QGVAR(virtualItems), _cargo, _global];
|
||||
// If the arsenal is already open, refresh arsenal display
|
||||
if (!isNil QGVAR(currentBox) && {GVAR(currentBox) isEqualTo _object}) then {
|
||||
[true, true] call FUNC(refresh);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
32
addons/arsenal/functions/fnc_updateVirtualItemsFlat.sqf
Normal file
32
addons/arsenal/functions/fnc_updateVirtualItemsFlat.sqf
Normal file
@ -0,0 +1,32 @@
|
||||
#include "..\script_component.hpp"
|
||||
#include "..\defines.hpp"
|
||||
/*
|
||||
* Author: johnb43, Grim
|
||||
* Updates flattened list of virtual items for checking
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
private _virtualItemsFlat = +GVAR(virtualItems);
|
||||
private _weapons = _virtualItemsFlat deleteAt IDX_VIRT_WEAPONS;
|
||||
private _attachments = _virtualItemsFlat deleteAt IDX_VIRT_ATTACHMENTS;
|
||||
|
||||
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
|
||||
_virtualItemsFlat merge [_virtualItemsFlat deleteAt _index, true];
|
||||
};
|
||||
|
||||
for "_index" from IDX_VIRT_PRIMARY_WEAPONS to IDX_VIRT_HANDGUN_WEAPONS do {
|
||||
_virtualItemsFlat merge [_weapons deleteAt _index, true];
|
||||
};
|
||||
|
||||
for "_index" from IDX_VIRT_OPTICS_ATTACHMENTS to IDX_VIRT_BIPOD_ATTACHMENTS do {
|
||||
_virtualItemsFlat merge [_attachments deleteAt _index, true];
|
||||
};
|
||||
|
||||
GVAR(virtualItemsFlat) = _virtualItemsFlat;
|
@ -98,7 +98,7 @@
|
||||
<Turkish>Kapat</Turkish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Arsenal_noVirtualItems">
|
||||
<English>No virtual item available</English>
|
||||
<English>No virtual items available</English>
|
||||
<Spanish>Ningún objeto virtual disponible</Spanish>
|
||||
<French>Aucun objet virtuel disponible.</French>
|
||||
<German>Kein virtuelles Objekt verfügbar</German>
|
||||
|
Loading…
Reference in New Issue
Block a user