mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Add loadout saving and deleting
This commit is contained in:
@ -1,4 +1,16 @@
|
||||
#include "script_component.hpp"
|
||||
#include "..\defines.hpp"
|
||||
|
||||
params ["_display", "_control"];
|
||||
params ["_display", "_control"];
|
||||
|
||||
if !(ctrlEnabled _control) exitWith {};
|
||||
|
||||
private _data = profileNamespace getVariable [QGVAR(saved_loadouts), []];
|
||||
|
||||
private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
|
||||
private _contentPanelCursSel = lnbCurSelRow _contentPanelCtrl;
|
||||
private _loadoutName = _contentPanelCtrl lnbText [_contentPanelCursSel, 1];
|
||||
|
||||
_data deleteAt (_data find ((_data select {_x select 0 == _loadoutName}) select 0));
|
||||
|
||||
_contentPanelCtrl lnbDeleteRow _contentPanelCursSel;
|
@ -7,8 +7,53 @@ systemChat str [_display, _control];
|
||||
|
||||
if !(ctrlEnabled _control) exitWith {};
|
||||
|
||||
private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
|
||||
private _contentPanelRow = lnbCurSelRow _contentPanelCtrl;
|
||||
private _loadoutName = _contentPanelCtrl lnbText [_contentPanelRow, 1];
|
||||
private _data = profileNamespace getVariable [QGVAR(saved_loadouts), []];
|
||||
private _loadout = getUnitLoadout GVAR(center);
|
||||
|
||||
profileNamespace setVariable [QGVAR(saved_loadouts), [_loadoutName, getUnitLoadout GVAR(center)]];
|
||||
private _contentPanelCtrl = _display displayCtrl IDC_contentPanel;
|
||||
private _loadoutName = _contentPanelCtrl lnbText [(lnbCurSelRow _contentPanelCtrl), 1];
|
||||
|
||||
private _editBoxCtrl = _display displayCtrl IDC_textEditBox;
|
||||
private _editBoxContent = ctrlText _editBoxCtrl;
|
||||
|
||||
private _sameNameLoadoutsList = _data select {_x select 0 == _editBoxContent};
|
||||
|
||||
TRACE_3("data", count _sameNameLoadoutsList, _editBoxContent, _loadoutName);
|
||||
|
||||
switch (GVAR(currentLoadoutsTab)) do {
|
||||
|
||||
case IDC_buttonMyLoadouts: {
|
||||
|
||||
if (count _sameNameLoadoutsList == 0) then {
|
||||
|
||||
_data pushBack [_editBoxContent, _loadout];
|
||||
|
||||
private _newRow = _contentPanelCtrl lnbAddRow ["",_editBoxContent];
|
||||
|
||||
_contentPanelCtrl lnbSetPicture [[_newRow, 2], getText (configFile >> "cfgWeapons" >> ((_loadout select 0) select 0) >> "picture")];
|
||||
_contentPanelCtrl lnbSetPicture [[_newRow, 3], getText (configFile >> "cfgWeapons" >> ((_loadout select 1) select 0) >> "picture")];
|
||||
_contentPanelCtrl lnbSetPicture [[_newRow, 4], getText (configFile >> "cfgWeapons" >> ((_loadout select 2) select 0) >> "picture")];
|
||||
_contentPanelCtrl lnbSetPicture [[_newRow, 5], getText (configFile >> "cfgWeapons" >> ((_loadout select 3) select 0) >> "picture")];
|
||||
_contentPanelCtrl lnbSetPicture [[_newRow, 6], getText (configFile >> "cfgWeapons" >> ((_loadout select 4) select 0) >> "picture")];
|
||||
_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 lnbSort [1, false];
|
||||
} else {
|
||||
_data set [_data find (_sameNameLoadoutsList select 0), [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _loadout]];
|
||||
};
|
||||
};
|
||||
|
||||
case IDC_buttonDefaultLoadouts: {
|
||||
|
||||
//TODO
|
||||
};
|
||||
|
||||
case IDC_buttonSharedLoadouts: {
|
||||
|
||||
//TODO
|
||||
};
|
||||
};
|
||||
|
||||
profileNamespace setVariable [QGVAR(saved_loadouts), _data];
|
||||
|
@ -32,9 +32,9 @@ if (ctrlIDC _control == IDC_buttonMyLoadouts) then {
|
||||
_contentListCtrl lnbSetColor [[_newRow, 1], [1, 1, 1, 0.25]];
|
||||
_contentListCtrl lbSetValue [_newRow, -1];
|
||||
};
|
||||
|
||||
_contentListCtrl lnbSort [1, false];
|
||||
} foreach _data;
|
||||
} else {
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
_contentListCtrl lnbSort [1, false];
|
@ -30,7 +30,7 @@ switch (ctrlIDC _control) do {
|
||||
{
|
||||
_x ctrlEnable false;
|
||||
_x ctrlCommit 0;
|
||||
} foreach [_saveButtonCtrl, _shareButtonCtrl, _loadButtonCtrl, _deleteButtonCtrl];
|
||||
} foreach [_shareButtonCtrl, _loadButtonCtrl, _deleteButtonCtrl];
|
||||
|
||||
[_display, _control] call FUNC(fillLoadoutsList);
|
||||
|
||||
|
@ -5,6 +5,8 @@ params ["_display", "_control", "_curSel"];
|
||||
|
||||
systemChat str _curSel;
|
||||
|
||||
if (_curSel == -1) exitWith {};
|
||||
|
||||
private _shareButtonCtrl = _display displayCtrl IDC_buttonShare;
|
||||
private _saveButtonCtrl = _display displayCtrl IDC_buttonSave;
|
||||
private _loadButtonCtrl = _display displayCtrl IDC_buttonLoad;
|
||||
@ -21,13 +23,8 @@ switch (GVAR(currentLoadoutsTab)) do {
|
||||
_shareButtonCtrl ctrlEnable ([false, true] select (GVAR(allowSharedLoadouts)));
|
||||
_shareButtonCtrl ctrlCommit 0;
|
||||
|
||||
_saveButtonCtrl ctrlEnable true;
|
||||
_saveButtonCtrl ctrlCommit 0;
|
||||
|
||||
{
|
||||
_x ctrlEnable (_curSel >= 0);
|
||||
_x ctrlCommit 0;
|
||||
} foreach [_saveButtonCtrl, _deleteButtonCtrl];
|
||||
_deleteButtonCtrl ctrlEnable (_curSel >= 0);
|
||||
_deleteButtonCtrl ctrlCommit 0;
|
||||
|
||||
_textEditBoxCtrl ctrlSetText (_control lnbText [_curSel, 1]);
|
||||
};
|
||||
@ -41,7 +38,7 @@ switch (GVAR(currentLoadoutsTab)) do {
|
||||
{
|
||||
_x ctrlEnable false;
|
||||
_x ctrlCommit 0;
|
||||
} foreach [_shareButtonCtrl, _saveButtonCtrl, _deleteButtonCtrl];
|
||||
} foreach [_shareButtonCtrl, _deleteButtonCtrl];
|
||||
|
||||
_textEditBoxCtrl ctrlSetText (_control lnbText [_curSel, 0]);
|
||||
};
|
||||
@ -54,7 +51,7 @@ switch (GVAR(currentLoadoutsTab)) do {
|
||||
{
|
||||
_x ctrlEnable false;
|
||||
_x ctrlCommit 0;
|
||||
} foreach [_shareButtonCtrl, _saveButtonCtrl, _deleteButtonCtrl];
|
||||
} foreach [_shareButtonCtrl, _deleteButtonCtrl];
|
||||
|
||||
_textEditBoxCtrl ctrlSetText (_control lnbText [_curSel, 0]);
|
||||
};
|
||||
|
Reference in New Issue
Block a user