mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Arsenal - Make Zeuses able to save, delete, and edit Default Loadouts (#9278)
* allow zeus to edit default loadouts * typo
This commit is contained in:
parent
12905a0702
commit
5e6476aa5a
@ -28,6 +28,7 @@ PREP(buttonLoadoutsRename);
|
|||||||
PREP(buttonLoadoutsSave);
|
PREP(buttonLoadoutsSave);
|
||||||
PREP(buttonLoadoutsShare);
|
PREP(buttonLoadoutsShare);
|
||||||
PREP(buttonStatsPage);
|
PREP(buttonStatsPage);
|
||||||
|
PREP(canEditDefaultLoadout);
|
||||||
PREP(clearSearchbar);
|
PREP(clearSearchbar);
|
||||||
PREP(compileActions);
|
PREP(compileActions);
|
||||||
PREP(compileSorts);
|
PREP(compileSorts);
|
||||||
@ -62,9 +63,11 @@ PREP(openBox);
|
|||||||
PREP(portVALoadouts);
|
PREP(portVALoadouts);
|
||||||
PREP(refresh);
|
PREP(refresh);
|
||||||
PREP(removeBox);
|
PREP(removeBox);
|
||||||
|
PREP(removeDefaultLoadout);
|
||||||
PREP(removeSort);
|
PREP(removeSort);
|
||||||
PREP(removeStat);
|
PREP(removeStat);
|
||||||
PREP(removeVirtualItems);
|
PREP(removeVirtualItems);
|
||||||
|
PREP(renameDefaultLoadout);
|
||||||
PREP(replaceUniqueItemsLoadout);
|
PREP(replaceUniqueItemsLoadout);
|
||||||
PREP(scanConfig);
|
PREP(scanConfig);
|
||||||
PREP(showItem);
|
PREP(showItem);
|
||||||
|
@ -14,6 +14,9 @@ GVAR(lastSortDirectionRight) = DESCENDING;
|
|||||||
|
|
||||||
[QGVAR(initBox), LINKFUNC(initBox)] call CBA_fnc_addEventHandler;
|
[QGVAR(initBox), LINKFUNC(initBox)] call CBA_fnc_addEventHandler;
|
||||||
[QGVAR(removeBox), LINKFUNC(removeBox)] call CBA_fnc_addEventHandler;
|
[QGVAR(removeBox), LINKFUNC(removeBox)] call CBA_fnc_addEventHandler;
|
||||||
|
[QGVAR(addDefaultLoadout), LINKFUNC(addDefaultLoadout)] call CBA_fnc_addEventHandler;
|
||||||
|
[QGVAR(removeDefaultLoadout), LINKFUNC(removeDefaultLoadout)] call CBA_fnc_addEventHandler;
|
||||||
|
[QGVAR(renameDefaultLoadout), LINKFUNC(renameDefaultLoadout)] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
[QGVAR(broadcastFace), {
|
[QGVAR(broadcastFace), {
|
||||||
params ["_unit", "_face"];
|
params ["_unit", "_face"];
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Name of loadout <STRING>
|
* 0: Name of loadout <STRING>
|
||||||
* 1: CBA extended loadout or getUnitLoadout array <ARRAY>
|
* 1: CBA extended loadout or getUnitLoadout array <ARRAY>
|
||||||
|
* 2: Add globally <BOOL> (default: false)
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
@ -17,7 +18,11 @@
|
|||||||
* Public: Yes
|
* Public: Yes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
params [["_name", "", [""]], ["_loadout", [], [[]]]];
|
params [["_name", "", [""]], ["_loadout", [], [[]]], ["_global", false, [false]]];
|
||||||
|
|
||||||
|
if (_global) then {
|
||||||
|
[QGVAR(addDefaultLoadout), [_name, _loadout]] call CBA_fnc_remoteEvent;
|
||||||
|
};
|
||||||
|
|
||||||
private _extendedInfo = createHashMap;
|
private _extendedInfo = createHashMap;
|
||||||
|
|
||||||
@ -45,3 +50,7 @@ if (_index != -1) then {
|
|||||||
// Otherwise just add
|
// Otherwise just add
|
||||||
GVAR(defaultLoadoutsList) pushBack [_name, [_loadout, _extendedInfo]];
|
GVAR(defaultLoadoutsList) pushBack [_name, [_loadout, _extendedInfo]];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (is3DEN) then {
|
||||||
|
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
|
||||||
|
};
|
||||||
|
@ -25,10 +25,8 @@ private _loadoutName = _contentPanelCtrl lnbText [_contentPanelCursSel, 1];
|
|||||||
// If loadout is local or default
|
// If loadout is local or default
|
||||||
if (GVAR(currentLoadoutsTab) != IDC_buttonSharedLoadouts) then {
|
if (GVAR(currentLoadoutsTab) != IDC_buttonSharedLoadouts) then {
|
||||||
// Find loadout and delete from list
|
// Find loadout and delete from list
|
||||||
if (is3DEN && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts}) then {
|
if (GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts) then {
|
||||||
GVAR(defaultLoadoutsList) deleteAt (GVAR(defaultLoadoutsList) findIf {(_x select 0) == _loadoutName});
|
[_loadoutName, !is3DEN] call FUNC(removeDefaultLoadout);
|
||||||
|
|
||||||
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
|
|
||||||
} else {
|
} else {
|
||||||
private _data = profileNamespace getVariable [QGVAR(saved_loadouts), []];
|
private _data = profileNamespace getVariable [QGVAR(saved_loadouts), []];
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ private _editBoxContent = ctrlText (_display displayCtrl IDC_textEditBox);
|
|||||||
// If it's the exact same name, don't do anything
|
// If it's the exact same name, don't do anything
|
||||||
if (_editBoxContent isEqualTo _loadoutName) exitWith {};
|
if (_editBoxContent isEqualTo _loadoutName) exitWith {};
|
||||||
|
|
||||||
private _data = [profileNamespace getVariable [QGVAR(saved_loadouts), []], GVAR(defaultLoadoutsList)] select (is3DEN && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts});
|
private _data = [profileNamespace getVariable [QGVAR(saved_loadouts), []], GVAR(defaultLoadoutsList)] select (call FUNC(canEditDefaultLoadout) && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts});
|
||||||
|
|
||||||
// If there is a loadout with a similar name and it's not chosen to be renamed, don't rename and exit
|
// If there is a loadout with a similar name and it's not chosen to be renamed, don't rename and exit
|
||||||
if (_editBoxContent != _loadoutName && {_data findIf {(_x select 0) == _editBoxContent} != -1}) exitWith {
|
if (_editBoxContent != _loadoutName && {_data findIf {(_x select 0) == _editBoxContent} != -1}) exitWith {
|
||||||
@ -42,8 +42,12 @@ private _loadoutIndex = _data findIf {(_x select 0) == _loadoutName};
|
|||||||
// Set new name
|
// Set new name
|
||||||
(_data select _loadoutIndex) set [0, _editBoxContent];
|
(_data select _loadoutIndex) set [0, _editBoxContent];
|
||||||
|
|
||||||
if (is3DEN && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts}) then {
|
if (GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts) then {
|
||||||
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
|
if (is3DEN) then {
|
||||||
|
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
|
||||||
|
} else {
|
||||||
|
[QGVAR(renameDefaultLoadout), [_loadoutName, _editBoxContent]] call CBA_fnc_remoteEvent;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
private _currentLoadoutsTab = str GVAR(currentLoadoutsTab);
|
private _currentLoadoutsTab = str GVAR(currentLoadoutsTab);
|
||||||
|
@ -49,7 +49,7 @@ private _curSelLoadout = (_contentPanelCtrl getVariable (_loadoutName + str GVAR
|
|||||||
private _extendedLoadout = GVAR(center) call CBA_fnc_getLoadout;
|
private _extendedLoadout = GVAR(center) call CBA_fnc_getLoadout;
|
||||||
_extendedLoadout params ["_loadout"];
|
_extendedLoadout params ["_loadout"];
|
||||||
|
|
||||||
private _loadouts = [profileNamespace getVariable [QGVAR(saved_loadouts), []], GVAR(defaultLoadoutsList)] select (is3DEN && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts});
|
private _loadouts = [profileNamespace getVariable [QGVAR(saved_loadouts), []], GVAR(defaultLoadoutsList)] select ((call FUNC(canEditDefaultLoadout)) && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts});
|
||||||
private _loadoutIndex = _loadouts findIf {(_x select 0) == _editBoxContent};
|
private _loadoutIndex = _loadouts findIf {(_x select 0) == _editBoxContent};
|
||||||
|
|
||||||
// Return what loadout was saved
|
// Return what loadout was saved
|
||||||
@ -57,16 +57,14 @@ private _savedLoadout = switch (GVAR(currentLoadoutsTab)) do {
|
|||||||
// Local loadouts tab
|
// Local loadouts tab
|
||||||
case IDC_buttonMyLoadouts: {
|
case IDC_buttonMyLoadouts: {
|
||||||
// If saved to default loadout
|
// If saved to default loadout
|
||||||
if (GVAR(shiftState) && {is3DEN} && {_loadoutName != ""} && {_curSelRow != -1} && {_loadoutIndex != -1}) then {
|
if (GVAR(shiftState) && FUNC(canEditDefaultLoadout) && {_loadoutName != ""} && {_curSelRow != -1} && {_loadoutIndex != -1}) then {
|
||||||
private _defaultLoadoutsSearch = GVAR(defaultLoadoutsList) findIf {(_x select 0) == _loadoutName};
|
private _defaultLoadoutsSearch = GVAR(defaultLoadoutsList) findIf {(_x select 0) == _loadoutName};
|
||||||
|
|
||||||
if (_defaultLoadoutsSearch == -1) then {
|
[_loadoutName, _curSelLoadout, !is3DEN] call FUNC(addDefaultLoadout);
|
||||||
_loadoutIndex = GVAR(defaultLoadoutsList) pushBack [_loadoutName, _curSelLoadout];
|
|
||||||
} else {
|
|
||||||
GVAR(defaultLoadoutsList) set [_defaultLoadoutsSearch, [_loadoutName, _curSelLoadout]];
|
|
||||||
};
|
|
||||||
|
|
||||||
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
|
if (_defaultLoadoutsSearch == -1) then {
|
||||||
|
_loadoutIndex = (count GVAR(defaultLoadoutsList)) - 1;
|
||||||
|
};
|
||||||
|
|
||||||
_curSelLoadout
|
_curSelLoadout
|
||||||
} else {
|
} else {
|
||||||
@ -111,19 +109,15 @@ private _savedLoadout = switch (GVAR(currentLoadoutsTab)) do {
|
|||||||
};
|
};
|
||||||
// Default loadouts tab
|
// Default loadouts tab
|
||||||
case IDC_buttonDefaultLoadouts: {
|
case IDC_buttonDefaultLoadouts: {
|
||||||
if (is3DEN) then {
|
if (call FUNC(canEditDefaultLoadout)) then {
|
||||||
// Replace unique items with their bases and replace weapons with their base weapons
|
|
||||||
_loadout = [_loadout] call FUNC(replaceUniqueItemsLoadout);
|
|
||||||
|
|
||||||
// Add or overwrite loadout in loadout storage
|
[_editBoxContent, _extendedLoadout, !is3DEN] call FUNC(addDefaultLoadout);
|
||||||
|
|
||||||
|
// Get loadout index
|
||||||
if (_loadoutIndex == -1) then {
|
if (_loadoutIndex == -1) then {
|
||||||
_loadoutIndex = GVAR(defaultLoadoutsList) pushBack [_editBoxContent, _extendedLoadout];
|
_loadoutIndex = (count GVAR(defaultLoadoutsList)) - 1;
|
||||||
} else {
|
|
||||||
GVAR(defaultLoadoutsList) set [_loadoutIndex, [_editBoxContent, _extendedLoadout]];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
|
|
||||||
|
|
||||||
// Refresh loadout list; Delete previous loadout row
|
// Refresh loadout list; Delete previous loadout row
|
||||||
for "_lbIndex" from 0 to (lnbSize _contentPanelCtrl select 0) - 1 do {
|
for "_lbIndex" from 0 to (lnbSize _contentPanelCtrl select 0) - 1 do {
|
||||||
if ((_contentPanelCtrl lnbText [_lbIndex, 1]) == _editBoxContent) exitWith {
|
if ((_contentPanelCtrl lnbText [_lbIndex, 1]) == _editBoxContent) exitWith {
|
||||||
|
16
addons/arsenal/functions/fnc_canEditDefaultLoadout.sqf
Normal file
16
addons/arsenal/functions/fnc_canEditDefaultLoadout.sqf
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
#include "..\defines.hpp"
|
||||||
|
/*
|
||||||
|
* Author: LinkIsGrim
|
||||||
|
* Whether the player can save a default loadout in the current mission state
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* Can Save <BOOL>
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
is3DEN || EFUNC(common,hasZeusAccess)
|
@ -48,7 +48,7 @@ switch (ctrlIDC _control) do {
|
|||||||
case IDC_buttonMyLoadouts: {
|
case IDC_buttonMyLoadouts: {
|
||||||
_centerBoxTitleCtrl ctrlSetText LLSTRING(tabMyLoadoutsText);
|
_centerBoxTitleCtrl ctrlSetText LLSTRING(tabMyLoadoutsText);
|
||||||
|
|
||||||
if (is3DEN) then {
|
if (call FUNC(canEditDefaultLoadout)) then {
|
||||||
_saveButtonCtrl ctrlSetTooltip format ["%1\n%2", LLSTRING(buttonSaveTooltip), LLSTRING(buttonSaveTooltip_shiftClick)];
|
_saveButtonCtrl ctrlSetTooltip format ["%1\n%2", LLSTRING(buttonSaveTooltip), LLSTRING(buttonSaveTooltip_shiftClick)];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -59,18 +59,18 @@ switch (ctrlIDC _control) do {
|
|||||||
case IDC_buttonDefaultLoadouts: {
|
case IDC_buttonDefaultLoadouts: {
|
||||||
_centerBoxTitleCtrl ctrlSetText LLSTRING(tabDefaultLoadoutsText);
|
_centerBoxTitleCtrl ctrlSetText LLSTRING(tabDefaultLoadoutsText);
|
||||||
|
|
||||||
if (is3DEN) then {
|
if (call FUNC(canEditDefaultLoadout)) then {
|
||||||
_saveButtonCtrl ctrlSetTooltip LLSTRING(buttonSaveTooltip);
|
_saveButtonCtrl ctrlSetTooltip LLSTRING(buttonSaveTooltip);
|
||||||
};
|
};
|
||||||
|
|
||||||
_saveButtonCtrl ctrlEnable is3DEN;
|
_saveButtonCtrl ctrlEnable call FUNC(canEditDefaultLoadout);
|
||||||
_saveButtonCtrl ctrlCommit 0;
|
_saveButtonCtrl ctrlCommit 0;
|
||||||
};
|
};
|
||||||
// Shared loadouts
|
// Shared loadouts
|
||||||
case IDC_buttonSharedLoadouts: {
|
case IDC_buttonSharedLoadouts: {
|
||||||
_centerBoxTitleCtrl ctrlSetText LLSTRING(tabSharedLoadoutsText);
|
_centerBoxTitleCtrl ctrlSetText LLSTRING(tabSharedLoadoutsText);
|
||||||
|
|
||||||
if (is3DEN) then {
|
if (call FUNC(canEditDefaultLoadout)) then {
|
||||||
_saveButtonCtrl ctrlSetTooltip LLSTRING(buttonSaveTooltip);
|
_saveButtonCtrl ctrlSetTooltip LLSTRING(buttonSaveTooltip);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ switch (GVAR(currentLoadoutsTab)) do {
|
|||||||
|
|
||||||
// Enable delete and renaming button if in 3DEN
|
// Enable delete and renaming button if in 3DEN
|
||||||
{
|
{
|
||||||
_x ctrlEnable (is3DEN);
|
_x ctrlEnable (call FUNC(canEditDefaultLoadout));
|
||||||
_x ctrlCommit 0;
|
_x ctrlCommit 0;
|
||||||
} forEach [_renameButtonCtrl, _deleteButtonCtrl];
|
} forEach [_renameButtonCtrl, _deleteButtonCtrl];
|
||||||
|
|
||||||
|
28
addons/arsenal/functions/fnc_removeDefaultLoadout.sqf
Normal file
28
addons/arsenal/functions/fnc_removeDefaultLoadout.sqf
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: LinkIsGrim
|
||||||
|
* Removes a loadout from the "Default Loadouts" list.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Name of loadout <STRING>
|
||||||
|
* 1: Remove globally <BOOL> (default: false)
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ["Squad Leader", true] call ace_arsenal_fnc_removeDefaultLoadout
|
||||||
|
*
|
||||||
|
* Public: Yes
|
||||||
|
*/
|
||||||
|
params [["_name", "", [""]], ["_global", false, [false]]];
|
||||||
|
|
||||||
|
if (_global) then {
|
||||||
|
[QGVAR(removeDefaultLoadout), [_name]] call CBA_fnc_remoteEvent;
|
||||||
|
};
|
||||||
|
|
||||||
|
GVAR(defaultLoadoutsList) deleteAt (GVAR(defaultLoadoutsList) findIf {(_x select 0) == _name});
|
||||||
|
|
||||||
|
if (is3DEN) then {
|
||||||
|
set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]];
|
||||||
|
};
|
25
addons/arsenal/functions/fnc_renameDefaultLoadout.sqf
Normal file
25
addons/arsenal/functions/fnc_renameDefaultLoadout.sqf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: LinkIsGrim
|
||||||
|
* Renames a loadout from the "Default Loadouts" list.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Current name of loadout <STRING>
|
||||||
|
* 1: New name of loadout <STRING>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ["Squad Leader", "Team Leader"] call ace_arsenal_fnc_renameDefaultLoadout
|
||||||
|
*
|
||||||
|
* Public: Yes
|
||||||
|
*/
|
||||||
|
params [["_currentName", "", [""]], ["_newName", "", [""]]];
|
||||||
|
|
||||||
|
if (_currentName isEqualTo _newName) exitWith {};
|
||||||
|
|
||||||
|
private _loadoutIndex = GVAR(defaultLoadoutsList) findIf {(_x select 0) == _currentName};
|
||||||
|
if (_loadoutIndex isEqualTo -1) exitWith {};
|
||||||
|
|
||||||
|
(GVAR(defaultLoadoutsList) select _index) set [0, _newName];
|
@ -174,7 +174,13 @@ To do so:
|
|||||||
|
|
||||||
This loadout list can be exported to the clipboard by using <kbd>Shift</kbd> + <kbd>LMB</kbd>. on the export button, doing the same on the import button will import the list currently in the clipboard.
|
This loadout list can be exported to the clipboard by using <kbd>Shift</kbd> + <kbd>LMB</kbd>. on the export button, doing the same on the import button will import the list currently in the clipboard.
|
||||||
|
|
||||||
### 4.2 Adding default loadouts via script
|
You can also save one of your personal loadouts as a default loadout by <kbd>Shift</kbd> + <kbd>LMB</kbd> on the save button while highlighting or saving a loadout in My Loadouts.
|
||||||
|
|
||||||
|
### 4.2 Adding default loadouts ingame
|
||||||
|
|
||||||
|
Players with Zeus access can save default loadouts ingame, doing so will make the saved loadout available to all players. The procedure is the same as with 3DEN, but loadouts cannot be exported or imported in Multiplayer. Default loadouts are not deleted when their creator disconnects, unlike Public Loadouts.
|
||||||
|
|
||||||
|
### 4.3 Adding default loadouts via script
|
||||||
|
|
||||||
`ace_arsenal_fnc_addDefaultLoadout`
|
`ace_arsenal_fnc_addDefaultLoadout`
|
||||||
|
|
||||||
@ -182,9 +188,10 @@ This loadout list can be exported to the clipboard by using <kbd>Shift</kbd> + <
|
|||||||
---| -------- | ---- | ------------------------
|
---| -------- | ---- | ------------------------
|
||||||
0 | Name of loadout | String | Required
|
0 | Name of loadout | String | Required
|
||||||
1 | getUnitLoadout array or CBA extended loadout array | Array | Required
|
1 | getUnitLoadout array or CBA extended loadout array | Array | Required
|
||||||
|
2 | Add loadout globally | Boolean | Optional (default: `false`)
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
`["Squad Leader", getUnitLoadout sql1] call ace_arsenal_fnc_addDefaultLoadout`
|
`["Squad Leader", getUnitLoadout sql1, true] call ace_arsenal_fnc_addDefaultLoadout`
|
||||||
|
|
||||||
If a loadout with the same name exists, it will be overwritten.
|
If a loadout with the same name exists, it will be overwritten.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user