Fix loadout import, update unique items list after import / loadout load

This commit is contained in:
Josuan Albin 2017-11-07 20:01:45 +01:00
parent c0bac53f23
commit dd0f3844f4
5 changed files with 126 additions and 103 deletions

View File

@ -41,4 +41,5 @@ PREP(showItem);
PREP(sortPanel);
PREP(updateCamPos);
PREP(updateRightPanel);
PREP(updateUniqueItemsList);
PREP(verifyLoadout);

View File

@ -11,6 +11,7 @@
* Public: No
*/
#include "script_component.hpp"
#include "..\defines.hpp"
params ["_display"];
@ -106,6 +107,8 @@ if (GVAR(shiftState) && {is3DEN}) then {
};
} foreach (assignedItems GVAR(center));
call FUNC(updateUniqueItemsList);
// Reapply insignia
[GVAR(center), ""] call bis_fnc_setUnitInsignia;
[GVAR(center), GVAR(currentInsignia)] call bis_fnc_setUnitInsignia;

View File

@ -92,6 +92,8 @@ for "_index" from 0 to 15 do {
};
} foreach (assignedItems GVAR(center));
call FUNC(updateUniqueItemsList);
// Reapply insignia
[GVAR(center), ""] call bis_fnc_setUnitInsignia;
[GVAR(center), GVAR(currentInsignia)] call bis_fnc_setUnitInsignia;

View File

@ -46,13 +46,6 @@ if (isNil QGVAR(virtualItems)) then {
GVAR(virtualItems) = [[[], [], []], [[], [], [], []], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []];
};
GVAR(virtualItems) set [18, []];
GVAR(virtualItems) set [19, []];
GVAR(virtualItems) set [20, []];
GVAR(virtualItems) set [21, []];
GVAR(virtualItems) set [22, [[], [], [], []]];
GVAR(virtualItems) set [23, []];
GVAR(virtualItems) set [24, []];
GVAR(currentItems) = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", [], [], [], [], [], []];
GVAR(currentFace) = face GVAR(center);
@ -105,102 +98,8 @@ for "_index" from 0 to 10 do {
// Inventory items
case 2: {
private _array = LIST_DEFAULTS select _index;
private _itemsCache = uiNamespace getVariable QGVAR(configItems);
private _configCfgWeapons = configFile >> "CfgWeapons";
private _configMagazines = configFile >> "CfgMagazines";
private _configVehicles = configFile >> "CfgVehicles";
private _configGlasses = configFile >> "CfgGlasses";
{
switch true do {
// Weapon mag
case (
isClass (_configMagazines >> _x) &&
{_x in (_itemsCache select 2)} &&
{!(_x in (GVAR(virtualItems) select 2))}
): {
(GVAR(virtualItems) select 19) pushBackUnique _x;
};
// Mag throw
case (
isClass (_configMagazines >> _x) &&
{_x in (_itemsCache select 15)} &&
{!(_x in (GVAR(virtualItems) select 15))}
): {
(GVAR(virtualItems) select 20) pushBackUnique _x;
};
// Mag put
case (
isClass (_configMagazines >> _x) &&
{_x in (_itemsCache select 16)} &&
{!(_x in (GVAR(virtualItems) select 16))}
): {
(GVAR(virtualItems) select 21) pushBackUnique _x;
};
// acc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select 1) select 0))} &&
{_x in ((_itemsCache select 1) select 0)}
): {
((GVAR(virtualItems) select 22) select 0) pushBackUnique _x;
};
// acc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select 1) select 1))} &&
{_x in ((_itemsCache select 1) select 1)}
): {
((GVAR(virtualItems) select 22) select 1) pushBackUnique _x;
};
// acc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select 1) select 2))} &&
{_x in ((_itemsCache select 1) select 2)}
): {
((GVAR(virtualItems) select 22) select 2) pushBackUnique _x;
};
// acc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select 1) select 3))} &&
{_x in ((_itemsCache select 1) select 3)}
): {
((GVAR(virtualItems) select 22) select 3) pushBackUnique _x;
};
// Misc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in (GVAR(virtualItems) select 17))} &&
{!(_x in ((_itemsCache select 1) select 0))} &&
{!(_x in ((_itemsCache select 1) select 1))} &&
{!(_x in ((_itemsCache select 1) select 2))} &&
{!(_x in ((_itemsCache select 1) select 3))}
): {
(GVAR(virtualItems) select 18) pushBackUnique _x;
};
// Backpacks
case (isClass (_configVehicles >> _x)): {
(GVAR(virtualItems) select 23) pushBackUnique _x;
};
// Facewear
case (isClass (_configGlasses >> _x)): {
(GVAR(virtualItems) select 24) pushBackUnique _x;
};
};
} foreach _array;
};
call FUNC(updateUniqueItemsList);
};
// The rest
default {

View File

@ -0,0 +1,118 @@
/*
* Author: Alganthe
* Update the list of unique items.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
#include "..\defines.hpp"
GVAR(virtualItems) set [18, []];
GVAR(virtualItems) set [19, []];
GVAR(virtualItems) set [20, []];
GVAR(virtualItems) set [21, []];
GVAR(virtualItems) set [22, [[], [], [], []]];
GVAR(virtualItems) set [23, []];
GVAR(virtualItems) set [24, []];
private _array = LIST_DEFAULTS select 2;
private _itemsCache = uiNamespace getVariable QGVAR(configItems);
private _configCfgWeapons = configFile >> "CfgWeapons";
private _configMagazines = configFile >> "CfgMagazines";
private _configVehicles = configFile >> "CfgVehicles";
private _configGlasses = configFile >> "CfgGlasses";
{
switch true do {
// Weapon mag
case (
isClass (_configMagazines >> _x) &&
{_x in (_itemsCache select 2)} &&
{!(_x in (GVAR(virtualItems) select 2))}
): {
(GVAR(virtualItems) select 19) pushBackUnique _x;
};
// Mag throw
case (
isClass (_configMagazines >> _x) &&
{_x in (_itemsCache select 15)} &&
{!(_x in (GVAR(virtualItems) select 15))}
): {
(GVAR(virtualItems) select 20) pushBackUnique _x;
};
// Mag put
case (
isClass (_configMagazines >> _x) &&
{_x in (_itemsCache select 16)} &&
{!(_x in (GVAR(virtualItems) select 16))}
): {
(GVAR(virtualItems) select 21) pushBackUnique _x;
};
// acc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select 1) select 0))} &&
{_x in ((_itemsCache select 1) select 0)}
): {
((GVAR(virtualItems) select 22) select 0) pushBackUnique _x;
};
// acc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select 1) select 1))} &&
{_x in ((_itemsCache select 1) select 1)}
): {
((GVAR(virtualItems) select 22) select 1) pushBackUnique _x;
};
// acc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select 1) select 2))} &&
{_x in ((_itemsCache select 1) select 2)}
): {
((GVAR(virtualItems) select 22) select 2) pushBackUnique _x;
};
// acc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select 1) select 3))} &&
{_x in ((_itemsCache select 1) select 3)}
): {
((GVAR(virtualItems) select 22) select 3) pushBackUnique _x;
};
// Misc
case (
isClass (_configCfgWeapons >> _x) &&
{!(_x in (GVAR(virtualItems) select 17))} &&
{!(_x in ((_itemsCache select 1) select 0))} &&
{!(_x in ((_itemsCache select 1) select 1))} &&
{!(_x in ((_itemsCache select 1) select 2))} &&
{!(_x in ((_itemsCache select 1) select 3))}
): {
(GVAR(virtualItems) select 18) pushBackUnique _x;
};
// Backpacks
case (isClass (_configVehicles >> _x)): {
(GVAR(virtualItems) select 23) pushBackUnique _x;
};
// Facewear
case (isClass (_configGlasses >> _x)): {
(GVAR(virtualItems) select 24) pushBackUnique _x;
};
};
} foreach _array;