From 69f7484f12a8f3462e55a1cd558953e8851334f6 Mon Sep 17 00:00:00 2001 From: Josuan Albin Date: Wed, 27 Dec 2017 00:43:33 +0100 Subject: [PATCH] Add a function to port BI VA loadouts to ACE Arsenal (#5943) * Add a function to port BI VA loadouts to ACE Arsenal * Fix typos in the header * Remove override argument, add button in 3DEN * Add null player exception * Remove unused passed argument * Add error messages to portVALoadouts * Change error messages * Add missing dot in string --- addons/arsenal/XEH_PREP.hpp | 1 + .../arsenal/functions/fnc_portVALoadouts.sqf | 43 +++++++++++++++++++ addons/arsenal/stringtable.xml | 12 ++++++ addons/arsenal/ui/RscCommon.hpp | 14 ++++++ 4 files changed, 70 insertions(+) create mode 100644 addons/arsenal/functions/fnc_portVALoadouts.sqf diff --git a/addons/arsenal/XEH_PREP.hpp b/addons/arsenal/XEH_PREP.hpp index 576115ad68..76c77c8a7c 100644 --- a/addons/arsenal/XEH_PREP.hpp +++ b/addons/arsenal/XEH_PREP.hpp @@ -34,6 +34,7 @@ PREP(onSelChangedRight); PREP(onSelChangedRightListnBox); PREP(open3DEN); PREP(openBox); +PREP(portVALoadouts); PREP(removeBox); PREP(removeVirtualItems); PREP(scanConfig); diff --git a/addons/arsenal/functions/fnc_portVALoadouts.sqf b/addons/arsenal/functions/fnc_portVALoadouts.sqf new file mode 100644 index 0000000000..7ad141819d --- /dev/null +++ b/addons/arsenal/functions/fnc_portVALoadouts.sqf @@ -0,0 +1,43 @@ +/* + * Author: alganthe + * Port VA loadouts to ACE Arsenal. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: Yes +*/ +#include "script_component.hpp" + +private _VALoadouts = +(profilenamespace getvariable ["bis_fnc_saveInventory_data",[]]); +private _aceLoadouts = +(profileNamespace getVariable [QGVAR(saved_loadouts),[]]); + +if (isNull player) exitWith { + [localize LSTRING(portLoadoutsPlayerError)] call BIS_fnc_error; +}; + +if (_VALoadouts isEqualTo []) exitWith { + [localize LSTRING(portLoadoutsLoadoutError)] call BIS_fnc_error; +}; + +for "_i" from 0 to (count _VALoadouts - 1) step 2 do { + _name = _VALoadouts select _i; + _inventory = _VALoadouts select (_i + 1); + + private _sameNameLoadoutsList = _aceLoadouts select {_x select 0 == _name}; + [player, [profilenamespace, _name]] call bis_fnc_loadinventory; + + private _loadout = getUnitLoadout player; + + if (count _sameNameLoadoutsList > 0) then { + _aceLoadouts set [_aceLoadouts find (_sameNameLoadoutsList select 0), [_name, _loadout]]; + + } else { + _aceLoadouts pushBack [_name, _loadout]; + }; +}; + +profileNamespace setVariable [QGVAR(saved_loadouts), _aceLoadouts]; diff --git a/addons/arsenal/stringtable.xml b/addons/arsenal/stringtable.xml index 0c28240b9b..9c9f0f4198 100644 --- a/addons/arsenal/stringtable.xml +++ b/addons/arsenal/stringtable.xml @@ -433,5 +433,17 @@ Impossibile aprire l'arsenale ACE ACE 武器庫を開けません + + Import BI VA loadouts to ACE Arsenal + Importe les loadouts de BI VA dans ACE Arsenal + + + No player unit available! Place a unit and mark it as "Player". + Aucune unité joueur disponible ! Placez une unité et marquez la en tant que "joueur". + + + No loadouts to import. + Aucun loadout à importer. + diff --git a/addons/arsenal/ui/RscCommon.hpp b/addons/arsenal/ui/RscCommon.hpp index 2a88204d7b..5db52bf704 100644 --- a/addons/arsenal/ui/RscCommon.hpp +++ b/addons/arsenal/ui/RscCommon.hpp @@ -275,4 +275,18 @@ class Display3DEN { }; }; }; + class Controls { + class MenuStrip: ctrlMenuStrip { + class Items { + class Tools { + items[] += {"ACE_arsenal_portVALoadouts"}; + }; + class ACE_arsenal_portVALoadouts { + text = CSTRING(portLoadoutsText); + picture = "\z\ace\logo_ace3_ca.paa"; + action = "call ace_arsenal_fnc_portVALoadouts;"; + }; + }; + }; + }; };