From ab5367be8f22f42c5c1cb7243726cad2e6fa643f Mon Sep 17 00:00:00 2001 From: Josuan Albin Date: Sun, 5 Nov 2017 21:58:33 +0100 Subject: [PATCH] Add back loadout caching --- addons/arsenal/functions/fnc_buttonLoadoutsLoad.sqf | 2 +- addons/arsenal/functions/fnc_buttonLoadoutsRename.sqf | 5 ++--- addons/arsenal/functions/fnc_buttonLoadoutsSave.sqf | 11 +++++------ addons/arsenal/functions/fnc_buttonLoadoutsShare.sqf | 2 +- addons/arsenal/functions/fnc_fillLoadoutsList.sqf | 10 ++++++++-- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/addons/arsenal/functions/fnc_buttonLoadoutsLoad.sqf b/addons/arsenal/functions/fnc_buttonLoadoutsLoad.sqf index acca9693f1..a0cf886582 100644 --- a/addons/arsenal/functions/fnc_buttonLoadoutsLoad.sqf +++ b/addons/arsenal/functions/fnc_buttonLoadoutsLoad.sqf @@ -26,7 +26,7 @@ private _loadout = switch GVAR(currentLoadoutsTab) do { case IDC_buttonMyLoadouts; case IDC_buttonDefaultLoadouts:{ - _contentPanelCtrl getVariable _loadoutName + str GVAR(currentLoadoutsTab) + (_contentPanelCtrl getVariable _loadoutName + str GVAR(currentLoadoutsTab)) select 0 }; case IDC_buttonSharedLoadouts:{ diff --git a/addons/arsenal/functions/fnc_buttonLoadoutsRename.sqf b/addons/arsenal/functions/fnc_buttonLoadoutsRename.sqf index 79b532dfeb..4dad6e2c18 100644 --- a/addons/arsenal/functions/fnc_buttonLoadoutsRename.sqf +++ b/addons/arsenal/functions/fnc_buttonLoadoutsRename.sqf @@ -23,7 +23,7 @@ private _data = [profileNamespace getVariable [QGVAR(saved_loadouts), []], GVAR( private _contentPanelCtrl = _display displayCtrl IDC_contentPanel; private _curSelRow = lnbCurSelRow _contentPanelCtrl; private _loadoutName = _contentPanelCtrl lnbText [_curSelRow, 1]; -private _loadout = _contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab)); +private _loadout = (_contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab))) select 0; private _editBoxCtrl = _display displayCtrl IDC_textEditBox; private _editBoxContent = ctrlText _editBoxCtrl; @@ -37,7 +37,7 @@ if (count _similarLoadouts > 0) exitWith { // Update loadout info in profile and list namespaces _data set [_data find ((_data select {_x select 0 == _loadoutName}) select 0), [_editBoxContent, _loadout]]; _contentPanelCtrl setVariable [_loadoutName + str GVAR(currentLoadoutsTab), nil]; -_contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), _loadout]; +_contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), [_loadout] call FUNC(verifyLoadout)]; _contentPanelCtrl lnbDeleteRow _curSelRow; @@ -51,7 +51,6 @@ _contentPanelCtrl lnbSetPicture [[_newRow, 6], getText (configFile >> "cfgWeapon _contentPanelCtrl lnbSetPicture [[_newRow, 7], getText (configFile >> "cfgVehicles" >> ((_loadout select 5) select 0) >> "picture")]; _contentPanelCtrl lnbSetPicture [[_newRow, 8], getText (configFile >> "cfgWeapons" >> (_loadout select 6) >> "picture")]; _contentPanelCtrl lnbSetPicture [[_newRow, 9], getText (configFile >> "cfgGlasses" >> (_loadout select 7) >> "picture")]; -_contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), _loadout]; // Sort and select the current row _contentPanelCtrl lnbSort [1, false]; diff --git a/addons/arsenal/functions/fnc_buttonLoadoutsSave.sqf b/addons/arsenal/functions/fnc_buttonLoadoutsSave.sqf index 65b01de46b..6236b86c1f 100644 --- a/addons/arsenal/functions/fnc_buttonLoadoutsSave.sqf +++ b/addons/arsenal/functions/fnc_buttonLoadoutsSave.sqf @@ -30,7 +30,7 @@ private _contentPanelCtrl = _display displayCtrl IDC_contentPanel; private _cursSelRow = lnbCurSelRow _contentPanelCtrl; private _loadoutName = _contentPanelCtrl lnbText [_cursSelRow, 1]; -private _curSelLoadout = _contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab)); +private _curSelLoadout = (_contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab))) select 0; private _loadout = getUnitLoadout GVAR(center); private _sameNameLoadoutsList = _data select {_x select 0 == _editBoxContent}; @@ -116,7 +116,7 @@ switch (GVAR(currentLoadoutsTab)) do { _contentPanelCtrl lnbSetPicture [[_newRow, 8], getText (configFile >> "cfgWeapons" >> (_loadout select 6) >> "picture")]; _contentPanelCtrl lnbSetPicture [[_newRow, 9], getText (configFile >> "cfgGlasses" >> (_loadout select 7) >> "picture")]; - _contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), _loadout]; + _contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), [_loadout] call FUNC(verifyLoadout)]; _contentPanelCtrl lnbSort [1, false]; @@ -203,7 +203,7 @@ switch (GVAR(currentLoadoutsTab)) do { _contentPanelCtrl lnbSetPicture [[_newRow, 8], getText (configFile >> "cfgWeapons" >> (_loadout select 6) >> "picture")]; _contentPanelCtrl lnbSetPicture [[_newRow, 9], getText (configFile >> "cfgGlasses" >> (_loadout select 7) >> "picture")]; - _contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), _loadout]; + _contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), [_loadout] call FUNC(verifyLoadout)]; _contentPanelCtrl lnbSort [1, false]; @@ -213,15 +213,13 @@ switch (GVAR(currentLoadoutsTab)) do { }; set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]]; - - private _savedLoadout = (_data select {_x select 0 == _editBoxContent}) select 0; - [QGVAR(onLoadoutSave), [_data find _savedLoadout, _savedLoadout]] call CBA_fnc_localEvent; } else { if (count _sameNameLoadoutsList == 0) then { _data pushBack [_editBoxContent, _curSelLoadout]; } else { _data set [_data find (_sameNameLoadoutsList select 0), [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _curSelLoadout]]; + _contentPanelCtrl setVariable [_editBoxContent + str IDC_buttonMyLoadouts, [_curSelLoadout] call FUNC(verifyLoadout)]; }; profileNamespace setVariable [QGVAR(saved_loadouts), _data]; @@ -236,6 +234,7 @@ switch (GVAR(currentLoadoutsTab)) do { _data pushBack [_editBoxContent, _loadout]; } else { _data set [_data find (_sameNameLoadoutsList select 0), [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _loadout]]; + _contentPanelCtrl setVariable [_editBoxContent + str IDC_buttonMyLoadouts, [_loadout] call FUNC(verifyLoadout)]; }; profileNamespace setVariable [QGVAR(saved_loadouts), _data]; diff --git a/addons/arsenal/functions/fnc_buttonLoadoutsShare.sqf b/addons/arsenal/functions/fnc_buttonLoadoutsShare.sqf index 406cee9764..d2765566b3 100644 --- a/addons/arsenal/functions/fnc_buttonLoadoutsShare.sqf +++ b/addons/arsenal/functions/fnc_buttonLoadoutsShare.sqf @@ -25,7 +25,7 @@ private _profileName = profileName; // GVAR(center) could be a remote unit private _loadoutVar = _profileName + _loadoutName; private _loadoutIndex = GVAR(sharedLoadoutsVars) find _loadoutVar; -private _loadoutData = _contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab)); +private _loadoutData = (_contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab))) select 0; if (_loadoutIndex > -1) then { GVAR(sharedLoadoutsNamespace) setVariable [_loadoutVar, nil, true]; diff --git a/addons/arsenal/functions/fnc_fillLoadoutsList.sqf b/addons/arsenal/functions/fnc_fillLoadoutsList.sqf index 3d37bab576..49a964f765 100644 --- a/addons/arsenal/functions/fnc_fillLoadoutsList.sqf +++ b/addons/arsenal/functions/fnc_fillLoadoutsList.sqf @@ -31,7 +31,13 @@ if (GVAR(currentLoadoutsTab) != IDC_buttonSharedLoadouts) then { { _x params ["_loadoutName", "_loadoutData"]; - [_loadoutData] call FUNC(verifyLoadout) params ["_loadout", "_nullItemsAmount", "_unavailableItemsAmount", "_nullItemsList", "_unavailableItemsList"]; + private _loadoutCachedInfo = _contentListCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab)); + + if (isNil "_loadoutCachedInfo") then { + [_loadoutData] call FUNC(verifyLoadout) + } else { + _loadoutCachedInfo + } params ["_loadout", "_nullItemsAmount", "_unavailableItemsAmount", "_nullItemsList", "_unavailableItemsList"]; // Log missing / nil items to RPT if (_nullItemsAmount > 0 || {_unavailableItemsAmount > 0}) then { @@ -70,7 +76,7 @@ if (GVAR(currentLoadoutsTab) != IDC_buttonSharedLoadouts) then { }; }; - _contentListCtrl setVariable [_loadoutName + str GVAR(currentLoadoutsTab), _loadout]; + _contentListCtrl setVariable [_loadoutName + str GVAR(currentLoadoutsTab), [_loadout, _nullItemsAmount, _unavailableItemsAmount, _nullItemsList, _unavailableItemsList]]; if ((profileName + _loadoutName) in GVAR(sharedLoadoutsVars)) then { _contentListCtrl lnbSetText [[_newRow, 0], "X"];