Prepare sharedLoadouts addition

This commit is contained in:
Josuan Albin
2017-11-02 15:51:19 +01:00
parent 0ffe21691a
commit b743e5bc49
4 changed files with 56 additions and 4 deletions

View File

@ -3,6 +3,28 @@
params ["_display", "_control"];
systemChat str [_display, _control];
if !(ctrlEnabled _control) exitWith {};
private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
private _contentPanelCursSel = lnbCurSelRow _contentPanelCtrl;
private _loadoutName = _contentPanelCtrl lnbText [_contentPanelCursSel, 1];
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;
if (_loadoutIndex > -1) then {
GVAR(sharedLoadoutsNamespace) setVariable [_loadoutVar, nil, true];
GVAR(sharedLoadoutsVars) = GVAR(sharedLoadoutsVars) - [_loadoutVar];
_contentPanelCtrl lnbSetText [[_contentPanelCursSel, 0], ""];
} else {
GVAR(sharedLoadoutsNamespace) setVariable [_loadoutVar, [_profileName ,_loadoutName , _loadoutData], true];
GVAR(sharedLoadoutsVars) pushBackUnique _loadoutVar;
_contentPanelCtrl lnbSetText [[_contentPanelCursSel, 0], "X"];
};
publicVariable QGVAR(sharedLoadoutsVars);

View File

@ -21,6 +21,13 @@ if (GVAR(currentLoadoutsTab) != IDC_buttonSharedLoadouts) then {
private _newRow = _contentListCtrl lnbAddRow ["",_loadoutName];
if (GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts) then {
_contentListCtrl lnbSetColumnsPos [0, 0, 0.40, 0.50, 0.60, 0.70, 0.75, 0.80, 0.85, 0.90];
} else {
_contentListCtrl lnbSetColumnsPos [0, 0.05, 0.40, 0.50, 0.60, 0.70, 0.75, 0.80, 0.85, 0.90];
};
_contentListCtrl lnbSetPicture [[_newRow, 2], getText (configFile >> "cfgWeapons" >> ((_loadout select 0) select 0) >> "picture")];
_contentListCtrl lnbSetPicture [[_newRow, 3], getText (configFile >> "cfgWeapons" >> ((_loadout select 1) select 0) >> "picture")];
_contentListCtrl lnbSetPicture [[_newRow, 4], getText (configFile >> "cfgWeapons" >> ((_loadout select 2) select 0) >> "picture")];
@ -41,9 +48,14 @@ if (GVAR(currentLoadoutsTab) != IDC_buttonSharedLoadouts) then {
};
_contentListCtrl setVariable [_loadoutName, _loadout];
if ((profileName + _loadoutName) in GVAR(sharedLoadoutsVars)) then {
_contentListCtrl lnbSetText [[_newRow, 0], "X"];
};
} foreach ([_data, ([GVAR(defaultLoadoutsList), []] select (isNil QGVAR(defaultLoadoutsList)))] select (ctrlIDC _control == IDC_buttonDefaultLoadouts));
} else {
//TODO
};
_contentListCtrl lnbSort [1, false];

View File

@ -15,14 +15,23 @@ private _renameButtonCtrl = _display displayCtrl IDC_buttonRename;
switch (ctrlIDC _control) do {
case IDC_buttonMyLoadouts: {
_centerBoxTitleCtrl ctrlSetText "My loadouts"; // TBL
_saveButtonCtrl ctrlEnable true;
_saveButtonCtrl ctrlCommit 0;
};
case IDC_buttonDefaultLoadouts: {
_centerBoxTitleCtrl ctrlSetText "Default loadouts"; // TBL
_saveButtonCtrl ctrlEnable false;
_saveButtonCtrl ctrlCommit 0;
};
case IDC_buttonSharedLoadouts: {
_centerBoxTitleCtrl ctrlSetText "Shared loadouts"; // TBL
_saveButtonCtrl ctrlEnable false;
_saveButtonCtrl ctrlCommit 0;
};
};
@ -31,6 +40,6 @@ switch (ctrlIDC _control) do {
_x ctrlCommit 0;
} foreach [_shareButtonCtrl, _loadButtonCtrl, _deleteButtonCtrl, _renameButtonCtrl];
[_display, _control] call FUNC(fillLoadoutsList);
GVAR(currentLoadoutsTab) = ctrlIDC _control;
[_display, _control] call FUNC(fillLoadoutsList);

View File

@ -14,6 +14,15 @@ if (isNil QGVAR(mode)) then {
GVAR(mode) = 1;
};
if (isNil QGVAR(sharedLoadoutsNamespace)) then {
GVAR(sharedLoadoutsNamespace) = true call CBA_fnc_createNamespace;
publicVariable QGVAR(sharedLoadoutsNamespace);
};
if (isNil QGVAR(sharedLoadoutsVars)) then {
GVAR(sharedLoadoutsVars) = [];
};
if (isNil QGVAR(virtualItems)) then {
GVAR(virtualItems) = [[[], [], []], [[], [], [], []], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []];
};