mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Add proper saving and loading for shared loadouts
This commit is contained in:
@ -9,54 +9,51 @@ private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
|
||||
private _curSel = lnbCurSelRow _contentPanelCtrl;
|
||||
private _loadoutName = _contentPanelCtrl lnbText [_curSel, 1];
|
||||
|
||||
if (ctrlIDC _control == IDC_buttonSharedLoadouts) then {
|
||||
|
||||
} else {
|
||||
private _loadout = (GVAR(sharedLoadoutsNamespace) getVariable ((_contentPanelCtrl lnbText [_curSel, 0]) + (_contentPanelCtrl lnbText [_curSel, 1]))) select 2;
|
||||
GVAR(center) setUnitLoadout [[_contentPanelCtrl getVariable _loadoutName, _loadout] select (GVAR(currentLoadoutsTab) == IDC_buttonSharedLoadouts), true];
|
||||
|
||||
GVAR(center) setUnitLoadout [_contentPanelCtrl getVariable _loadoutName, true];
|
||||
GVAR(currentItems) = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", [], [], [], [], [], []];
|
||||
for "_index" from 0 to 15 do {
|
||||
switch (_index) do {
|
||||
case 0;
|
||||
case 1;
|
||||
case 2:{
|
||||
GVAR(currentItems) set [_index, ((LIST_DEFAULTS select 0) select _index)];
|
||||
};
|
||||
case 3;
|
||||
case 4;
|
||||
case 5;
|
||||
case 6;
|
||||
case 7;
|
||||
case 8;
|
||||
case 9: {
|
||||
GVAR(currentItems) set [_index, (LIST_DEFAULTS select _index) select 0];
|
||||
|
||||
GVAR(currentItems) = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", [], [], [], [], [], []];
|
||||
for "_index" from 0 to 15 do {
|
||||
switch (_index) do {
|
||||
case 0;
|
||||
case 1;
|
||||
case 2:{
|
||||
GVAR(currentItems) set [_index, ((LIST_DEFAULTS select 0) select _index)];
|
||||
};
|
||||
case 3;
|
||||
case 4;
|
||||
case 5;
|
||||
case 6;
|
||||
case 7;
|
||||
case 8;
|
||||
case 9: {
|
||||
GVAR(currentItems) set [_index, (LIST_DEFAULTS select _index) select 0];
|
||||
|
||||
};
|
||||
case 10: {
|
||||
{(GVAR(currentItems) select 15) pushBack _x} forEach (uniformItems GVAR(center));
|
||||
};
|
||||
case 11: {
|
||||
{(GVAR(currentItems) select 16) pushBack _x} forEach (vestItems GVAR(center));
|
||||
};
|
||||
case 12: {
|
||||
{(GVAR(currentItems) select 17) pushBack _x} forEach (backpackItems GVAR(center));
|
||||
};
|
||||
case 13: {
|
||||
GVAR(currentItems) set [18, (primaryWeaponItems GVAR(center)) + (primaryWeaponMagazine GVAR(center))];
|
||||
};
|
||||
case 14: {
|
||||
GVAR(currentItems) set [19, (secondaryWeaponItems GVAR(center)) + (secondaryWeaponMagazine GVAR(center))];
|
||||
};
|
||||
case 15: {
|
||||
GVAR(currentItems) set [20, (handgunItems GVAR(center)) + (handgunMagazine GVAR(center))];
|
||||
};
|
||||
};
|
||||
case 10: {
|
||||
{(GVAR(currentItems) select 15) pushBack _x} forEach (uniformItems GVAR(center));
|
||||
};
|
||||
case 11: {
|
||||
{(GVAR(currentItems) select 16) pushBack _x} forEach (vestItems GVAR(center));
|
||||
};
|
||||
case 12: {
|
||||
{(GVAR(currentItems) select 17) pushBack _x} forEach (backpackItems GVAR(center));
|
||||
};
|
||||
case 13: {
|
||||
GVAR(currentItems) set [18, (primaryWeaponItems GVAR(center)) + (primaryWeaponMagazine GVAR(center))];
|
||||
};
|
||||
case 14: {
|
||||
GVAR(currentItems) set [19, (secondaryWeaponItems GVAR(center)) + (secondaryWeaponMagazine GVAR(center))];
|
||||
};
|
||||
case 15: {
|
||||
GVAR(currentItems) set [20, (handgunItems GVAR(center)) + (handgunMagazine GVAR(center))];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Reapply insignia
|
||||
[GVAR(center), ""] call bis_fnc_setUnitInsignia;
|
||||
[GVAR(center), GVAR(currentInsignia)] call bis_fnc_setUnitInsignia;
|
||||
// Reapply insignia
|
||||
[GVAR(center), ""] call bis_fnc_setUnitInsignia;
|
||||
[GVAR(center), GVAR(currentInsignia)] call bis_fnc_setUnitInsignia;
|
||||
|
||||
[(findDisplay IDD_ace_arsenal), format ["Loadout '%1' was loaded", _loadoutName]] call FUNC(message); // TBL
|
||||
};
|
||||
[(findDisplay IDD_ace_arsenal), format ["Loadout '%1' was loaded", _loadoutName]] call FUNC(message); // TBL
|
||||
|
@ -152,16 +152,18 @@ switch (GVAR(currentLoadoutsTab)) do {
|
||||
case IDC_buttonSharedLoadouts :{
|
||||
|
||||
if ((_contentPanelCtrl lnbText [_cursSelRow, 0]) == profileName) exitWith {
|
||||
[(findDisplay IDD_ace_arsenal), format ["You are sharing this loadout", _editBoxContent]] call FUNC(message); // TBL
|
||||
[(findDisplay IDD_ace_arsenal), format ["You are sharing a loadout with this name", _editBoxContent]] call FUNC(message); // TBL
|
||||
breakOut "main";
|
||||
};
|
||||
|
||||
private _loadout = (GVAR(sharedLoadoutsNamespace) getVariable ((_contentPanelCtrl lnbText [_cursSelRow, 0]) + (_contentPanelCtrl lnbText [_cursSelRow, 1]))) select 2;
|
||||
|
||||
if (count _sameNameLoadoutsList == 0) then {
|
||||
|
||||
_data pushBack [_editBoxContent, _curSelLoadout];
|
||||
_data pushBack [_editBoxContent, _loadout];
|
||||
} else {
|
||||
|
||||
_data set [_data find (_sameNameLoadoutsList select 0), [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _curSelLoadout]];
|
||||
_data set [_data find (_sameNameLoadoutsList select 0), [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _loadout]];
|
||||
};
|
||||
};
|
||||
};
|
||||
@ -170,4 +172,4 @@ switch (GVAR(currentLoadoutsTab)) do {
|
||||
profileNamespace setVariable [QGVAR(saved_loadouts), _data];
|
||||
|
||||
private _savedLoadout = (_data select {_x select 0 == _editBoxContent}) select 0;
|
||||
[QGVAR(onLoadoutSave), [_data find _savedLoadout, _savedLoadout]] call CBA_fnc_localEvent;
|
||||
[QGVAR(onLoadoutSave), [_data find _savedLoadout, _savedLoadout]] call CBA_fnc_localEvent;
|
||||
|
@ -27,4 +27,4 @@ if (_loadoutIndex > -1) then {
|
||||
_contentPanelCtrl lnbSetText [[_contentPanelCursSel, 0], "X"];
|
||||
};
|
||||
|
||||
publicVariable QGVAR(sharedLoadoutsVars);
|
||||
publicVariable QGVAR(sharedLoadoutsVars);
|
||||
|
@ -67,8 +67,12 @@ switch (GVAR(currentLoadoutsTab)) do {
|
||||
_shareButtonCtrl ctrlCommit 0;
|
||||
|
||||
if ((serverCommandAvailable "#logout") || {(_control lnbText [_curSel, 0]) == profileName}) then {
|
||||
|
||||
_deleteButtonCtrl ctrlEnable true;
|
||||
_deleteButtonCtrl ctrlCommit 0;
|
||||
} else {
|
||||
_deleteButtonCtrl ctrlEnable false;
|
||||
_deleteButtonCtrl ctrlCommit 0;
|
||||
};
|
||||
|
||||
_textEditBoxCtrl ctrlSetText (_control lnbText [_curSel, 1]);
|
||||
|
Reference in New Issue
Block a user