Add back loadout caching

This commit is contained in:
Josuan Albin
2017-11-05 21:58:33 +01:00
parent 3b98b7c196
commit ab5367be8f
5 changed files with 17 additions and 13 deletions

View File

@ -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:{

View File

@ -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];

View File

@ -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];

View File

@ -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];

View File

@ -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"];