Arsenal - Less magic numbers (#8089)

* Add macro for virtualItems index 0 (weapons)

* Add macro for virtualItems index 1 (attachments)

* Add macro for virtualItems index 2 (all items)

* Add macro for virtualItems index 3 (headgear)

* Add macro for virtualItems index 4 (uniform)

* Add macro for virtualItems index 5 (vest)

* Add macro for virtualItems index 6 (backpack)

* Add macro for virtualItems index 7 (goggles)
This commit is contained in:
Filip Maciejewski 2021-02-27 18:21:26 +01:00 committed by GitHub
parent b2da1792e1
commit 4d71607e81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 27 deletions

View File

@ -165,6 +165,18 @@
#define IDC_ATTRIBUTE_IMPORT_BUTTON 8109 #define IDC_ATTRIBUTE_IMPORT_BUTTON 8109
#define IDC_ATTRIBUTE_ADD_COMPATIBLE 8110 #define IDC_ATTRIBUTE_ADD_COMPATIBLE 8110
// Indexes of virtual items array
#define IDX_VIRT_WEAPONS 0
#define IDX_VIRT_ATTACHEMENTS 1
#define IDX_VIRT_ITEMS_ALL 2
#define IDX_VIRT_HEADGEAR 3
#define IDX_VIRT_UNIFORM 4
#define IDX_VIRT_VEST 5
#define IDX_VIRT_BACKPACK 6
#define IDX_VIRT_GOGGLES 7
#define SYMBOL_ITEM_NONE "" #define SYMBOL_ITEM_NONE ""
#define SYMBOL_ITEM_REMOVE "×" #define SYMBOL_ITEM_REMOVE "×"
#define SYMBOL_ITEM_VIRTUAL "∞" #define SYMBOL_ITEM_VIRTUAL "∞"

View File

@ -51,7 +51,7 @@ switch true do {
{ {
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach ((GVAR(virtualItems) select 0) select ([IDC_buttonPrimaryWeapon, IDC_buttonSecondaryWeapon, IDC_buttonHandgun] find _ctrlIDC)); } foreach ((GVAR(virtualItems) select IDX_VIRT_WEAPONS) select ([IDC_buttonPrimaryWeapon, IDC_buttonSecondaryWeapon, IDC_buttonHandgun] find _ctrlIDC));
}; };
case (_ctrlIDC in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack]) : { case (_ctrlIDC in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack]) : {
@ -65,19 +65,19 @@ switch true do {
case IDC_buttonUniform : { case IDC_buttonUniform : {
{ {
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select 4); } foreach (GVAR(virtualItems) select IDX_VIRT_UNIFORM);
}; };
case IDC_buttonVest : { case IDC_buttonVest : {
{ {
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select 5); } foreach (GVAR(virtualItems) select IDX_VIRT_VEST);
}; };
case IDC_buttonBackpack : { case IDC_buttonBackpack : {
{ {
["CfgVehicles", _x, _ctrlPanel] call FUNC(addListBoxItem); ["CfgVehicles", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select 6); } foreach (GVAR(virtualItems) select IDX_VIRT_BACKPACK);
}; };
}; };
}; };
@ -96,12 +96,12 @@ switch true do {
case IDC_buttonHeadgear: { case IDC_buttonHeadgear: {
{ {
["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select 3); } foreach (GVAR(virtualItems) select IDX_VIRT_HEADGEAR);
}; };
case IDC_buttonGoggles : { case IDC_buttonGoggles : {
{ {
["CfgGlasses", _x, _ctrlPanel] call FUNC(addListBoxItem); ["CfgGlasses", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach (GVAR(virtualItems) select 7); } foreach (GVAR(virtualItems) select IDX_VIRT_GOGGLES);
}; };
case IDC_buttonNVG : { case IDC_buttonNVG : {
{ {

View File

@ -224,7 +224,7 @@ switch (_ctrlIDC) do {
if (_leftPanelState) then { if (_leftPanelState) then {
{ {
["CfgMagazines", _x, _ctrlPanel] call FUNC(addListBoxItem); ["CfgMagazines", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach ((GVAR(virtualItems) select 2) arrayIntersect _compatibleMagsPrimaryMuzzle); } foreach ((GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL) arrayIntersect _compatibleMagsPrimaryMuzzle);
}; };
}; };
@ -232,14 +232,14 @@ switch (_ctrlIDC) do {
if (_leftPanelState) then { if (_leftPanelState) then {
{ {
["CfgMagazines", _x, _ctrlPanel] call FUNC(addListBoxItem); ["CfgMagazines", _x, _ctrlPanel] call FUNC(addListBoxItem);
} foreach ((GVAR(virtualItems) select 2) arrayIntersect _compatibleMagsSecondaryMuzzle); } foreach ((GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL) arrayIntersect _compatibleMagsSecondaryMuzzle);
}; };
}; };
case IDC_buttonMag : { case IDC_buttonMag : {
{ {
["CfgMagazines", _x, true] call _fnc_fill_right_Container; ["CfgMagazines", _x, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 2) arrayIntersect _allCompatibleMags); } foreach ((GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL) arrayIntersect _allCompatibleMags);
{ {
["CfgMagazines", _x, true, true] call _fnc_fill_right_Container; ["CfgMagazines", _x, true, true] call _fnc_fill_right_Container;
} foreach ((GVAR(virtualItems) select 19) arrayIntersect _allCompatibleMags); } foreach ((GVAR(virtualItems) select 19) arrayIntersect _allCompatibleMags);
@ -248,7 +248,7 @@ switch (_ctrlIDC) do {
case IDC_buttonMagALL : { case IDC_buttonMagALL : {
{ {
["CfgMagazines", _x, true] call _fnc_fill_right_Container; ["CfgMagazines", _x, true] call _fnc_fill_right_Container;
} foreach (GVAR(virtualItems) select 2); } foreach (GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL);
{ {
["CfgMagazines", _x, true, true] call _fnc_fill_right_Container; ["CfgMagazines", _x, true, true] call _fnc_fill_right_Container;
} foreach (GVAR(virtualItems) select 19); } foreach (GVAR(virtualItems) select 19);

View File

@ -64,7 +64,7 @@ GVAR(statsInfo) = [true, 0, controlNull, nil, nil];
for "_index" from 0 to 10 do { for "_index" from 0 to 10 do {
switch (_index) do { switch (_index) do {
// primary, secondary, handgun weapons // primary, secondary, handgun weapons
case 0: { case IDX_VIRT_WEAPONS: {
private _array = LIST_DEFAULTS select _index; private _array = LIST_DEFAULTS select _index;
if ((_array select 0) isNotEqualTo "") then { if ((_array select 0) isNotEqualTo "") then {
@ -81,7 +81,7 @@ for "_index" from 0 to 10 do {
}; };
// Accs for the weapons above // Accs for the weapons above
case 1: { case IDX_VIRT_ATTACHEMENTS: {
private _array = LIST_DEFAULTS select _index; private _array = LIST_DEFAULTS select _index;
_array params ["_accsArray", "_magsArray"]; _array params ["_accsArray", "_magsArray"];
@ -99,18 +99,18 @@ for "_index" from 0 to 10 do {
if (_x isNotEqualTo []) then { if (_x isNotEqualTo []) then {
if (_x select 0 != "") then { if (_x select 0 != "") then {
(GVAR(virtualItems) select 2) pushBackUnique (_x select 0); (GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL) pushBackUnique (_x select 0);
}; };
if (count _x > 1 && {_x select 1 != ""}) then { if (count _x > 1 && {_x select 1 != ""}) then {
(GVAR(virtualItems) select 2) pushBackUnique (_x select 1); (GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL) pushBackUnique (_x select 1);
}; };
}; };
} forEach _magsArray; } forEach _magsArray;
}; };
// Inventory items // Inventory items
case 2: { case IDX_VIRT_ITEMS_ALL: {
call FUNC(updateUniqueItemsList); call FUNC(updateUniqueItemsList);
}; };

View File

@ -21,7 +21,7 @@ GVAR(virtualItems) set [22, [[], [], [], []]];
GVAR(virtualItems) set [23, []]; GVAR(virtualItems) set [23, []];
GVAR(virtualItems) set [24, []]; GVAR(virtualItems) set [24, []];
private _array = LIST_DEFAULTS select 2; private _array = LIST_DEFAULTS select IDX_VIRT_ITEMS_ALL;
private _itemsCache = uiNamespace getVariable QGVAR(configItems); private _itemsCache = uiNamespace getVariable QGVAR(configItems);
private _configCfgWeapons = configFile >> "CfgWeapons"; private _configCfgWeapons = configFile >> "CfgWeapons";
@ -35,7 +35,7 @@ private _configGlasses = configFile >> "CfgGlasses";
case ( case (
isClass (_configMagazines >> _x) && isClass (_configMagazines >> _x) &&
{_x in (_itemsCache select 2)} && {_x in (_itemsCache select 2)} &&
{!(_x in (GVAR(virtualItems) select 2))} {!(_x in (GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL))}
): { ): {
(GVAR(virtualItems) select 19) pushBackUnique _x; (GVAR(virtualItems) select 19) pushBackUnique _x;
}; };
@ -61,7 +61,7 @@ private _configGlasses = configFile >> "CfgGlasses";
// acc // acc
case ( case (
isClass (_configCfgWeapons >> _x) && isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select 1) select 0))} && {!(_x in ((GVAR(virtualItems) select IDX_VIRT_ATTACHEMENTS) select 0))} &&
{_x in ((_itemsCache select 1) select 0)} {_x in ((_itemsCache select 1) select 0)}
): { ): {
((GVAR(virtualItems) select 22) select 0) pushBackUnique _x; ((GVAR(virtualItems) select 22) select 0) pushBackUnique _x;
@ -70,7 +70,7 @@ private _configGlasses = configFile >> "CfgGlasses";
// acc // acc
case ( case (
isClass (_configCfgWeapons >> _x) && isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select 1) select 1))} && {!(_x in ((GVAR(virtualItems) select IDX_VIRT_ATTACHEMENTS) select 1))} &&
{_x in ((_itemsCache select 1) select 1)} {_x in ((_itemsCache select 1) select 1)}
): { ): {
((GVAR(virtualItems) select 22) select 1) pushBackUnique _x; ((GVAR(virtualItems) select 22) select 1) pushBackUnique _x;
@ -79,7 +79,7 @@ private _configGlasses = configFile >> "CfgGlasses";
// acc // acc
case ( case (
isClass (_configCfgWeapons >> _x) && isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select 1) select 2))} && {!(_x in ((GVAR(virtualItems) select IDX_VIRT_ATTACHEMENTS) select 2))} &&
{_x in ((_itemsCache select 1) select 2)} {_x in ((_itemsCache select 1) select 2)}
): { ): {
((GVAR(virtualItems) select 22) select 2) pushBackUnique _x; ((GVAR(virtualItems) select 22) select 2) pushBackUnique _x;
@ -87,7 +87,7 @@ private _configGlasses = configFile >> "CfgGlasses";
// acc // acc
case ( case (
isClass (_configCfgWeapons >> _x) && isClass (_configCfgWeapons >> _x) &&
{!(_x in ((GVAR(virtualItems) select 1) select 3))} && {!(_x in ((GVAR(virtualItems) select IDX_VIRT_ATTACHEMENTS) select 3))} &&
{_x in ((_itemsCache select 1) select 3)} {_x in ((_itemsCache select 1) select 3)}
): { ): {
((GVAR(virtualItems) select 22) select 3) pushBackUnique _x; ((GVAR(virtualItems) select 22) select 3) pushBackUnique _x;

View File

@ -19,8 +19,8 @@ private _weaponCfg = configFile >> "CfgWeapons";
private _magCfg = configFile >> "CfgMagazines"; private _magCfg = configFile >> "CfgMagazines";
private _vehcCfg = configFile >> "CfgVehicles"; private _vehcCfg = configFile >> "CfgVehicles";
private _glassesCfg = configFile >> "CfgGlasses"; private _glassesCfg = configFile >> "CfgGlasses";
private _weaponsArray = GVAR(virtualItems) select 0; private _weaponsArray = GVAR(virtualItems) select IDX_VIRT_WEAPONS;
private _accsArray = GVAR(virtualItems) select 1; private _accsArray = GVAR(virtualItems) select IDX_VIRT_ATTACHEMENTS;
private _nullItemsAmount = 0; private _nullItemsAmount = 0;
private _unavailableItemsAmount = 0; private _unavailableItemsAmount = 0;
@ -58,7 +58,7 @@ private _fnc_weaponCheck = {
private _mag = _x select 0; private _mag = _x select 0;
if (isClass (_magCfg >> _mag)) then { if (isClass (_magCfg >> _mag)) then {
if !(_mag in (GVAR(virtualItems) select 2)) then { if !(_mag in (GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL)) then {
_unavailableItemsList pushBackUnique _mag; _unavailableItemsList pushBackUnique _mag;
_dataPath set [_forEachIndex, []]; _dataPath set [_forEachIndex, []];
@ -137,7 +137,7 @@ for "_dataIndex" from 0 to 9 do {
if (isClass (_magCfg >> _item)) then { if (isClass (_magCfg >> _item)) then {
if !( if !(
_item in (GVAR(virtualItems) select 2) || _item in (GVAR(virtualItems) select IDX_VIRT_ITEMS_ALL) ||
_item in (GVAR(virtualItems) select 15) || _item in (GVAR(virtualItems) select 15) ||
_item in (GVAR(virtualItems) select 16) _item in (GVAR(virtualItems) select 16)
) then { ) then {
@ -173,7 +173,7 @@ for "_dataIndex" from 0 to 9 do {
if (isClass (_weaponCfg >> _item)) then { if (isClass (_weaponCfg >> _item)) then {
if !(_item in (GVAR(virtualItems) select 3)) then { if !(_item in (GVAR(virtualItems) select IDX_VIRT_HEADGEAR)) then {
_unavailableItemsList pushBackUnique _item; _unavailableItemsList pushBackUnique _item;
_loadout set [_dataIndex, ""]; _loadout set [_dataIndex, ""];
@ -195,7 +195,7 @@ for "_dataIndex" from 0 to 9 do {
if (isClass (_glassesCfg >> _item)) then { if (isClass (_glassesCfg >> _item)) then {
if !(_item in (GVAR(virtualItems) select 7)) then { if !(_item in (GVAR(virtualItems) select IDX_VIRT_GOGGLES)) then {
_unavailableItemsList pushBackUnique _item; _unavailableItemsList pushBackUnique _item;
_loadout set [_dataIndex, ""]; _loadout set [_dataIndex, ""];