Merge pull request #28 from alganthe/arsenal_3DEN

Arsenal 3DEN support
This commit is contained in:
Josuan Albin
2017-11-03 16:52:48 +01:00
committed by GitHub
13 changed files with 194 additions and 25 deletions

View File

@ -33,6 +33,7 @@ PREP(onSelChangedLeft);
PREP(onSelChangedLoadouts);
PREP(onSelChangedRight);
PREP(onSelChangedRightListnBox);
PREP(open3DEN);
PREP(openBox);
PREP(removeBox);
PREP(removeVirtualItems);

View File

@ -2,7 +2,6 @@
#include "defines.hpp"
GVAR(EH_ID) = 0;
GVAR(modList) = ["","curator","kart","heli","mark","expansion","expansionpremium"];
GVAR(lastSearchTextLeft) = "";
GVAR(lastSearchTextRight) = "";

View File

@ -7,7 +7,10 @@ PREP_RECOMPILE_START;
PREP_RECOMPILE_END;
// Arsenal
[QGVAR(camInverted), "CHECKBOX", "Invert camera controls", "ACE3 Arsenal", true] call CBA_Settings_fnc_init; // TBL
GVAR(modList) = ["","curator","kart","heli","mark","expansion","expansionpremium"];
[QGVAR(camInverted), "CHECKBOX", "Invert camera controls", "ACE3 Arsenal", false] call CBA_Settings_fnc_init; // TBL
[QGVAR(canUseCurrentMagTab), "CHECKBOX", "Can use currentMag tab", "ACE3 Arsenal", false] call CBA_Settings_fnc_init; // TBL
[QGVAR(enableModIcons), "CHECKBOX", "Enable mod logos", "ACE3 Arsenal", true] call CBA_Settings_fnc_init; // TBL
[QGVAR(fontHeight), "SLIDER", "Font height for left and right panels", "ACE3 Arsenal", [1, 10, 4.5, 1]] call CBA_Settings_fnc_init; // TBL

View File

@ -25,7 +25,6 @@ if (_cachedItemInfo isEqualTo []) then {//Not in cache. So get info and put into
};
};
if (_dlcName != "") then {
_cachedItemInfo set [2, (modParams [_dlcName,["logo"]]) param [0,""]];//mod picture
_modID = GVAR(modList) find _dlcName;

View File

@ -11,8 +11,14 @@ private _loadoutName = _contentPanelCtrl lnbText [_contentPanelCursSel, 1];
if (GVAR(currentLoadoutsTab) != IDC_buttonSharedLoadouts) then {
private _data = profileNamespace getVariable [QGVAR(saved_loadouts), []];
_data deleteAt (_data find ((_data select {_x select 0 == _loadoutName}) select 0));
if (is3DEN && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts}) then {
GVAR(defaultLoadoutsList) deleteAt (GVAR(defaultLoadoutsList) find ((GVAR(defaultLoadoutsList) select {_x select 0 == _loadoutName}) select 0));
} else {
private _data = profileNamespace getVariable [QGVAR(saved_loadouts), []];
_data deleteAt (_data find ((_data select {_x select 0 == _loadoutName}) select 0));
};
_contentPanelCtrl setVariable [_loadoutName + QGVAR(currentLoadoutsTab), nil];
_contentPanelCtrl lnbDeleteRow _contentPanelCursSel;

View File

@ -126,26 +126,110 @@ switch (GVAR(currentLoadoutsTab)) do {
case IDC_buttonDefaultLoadouts:{
if (count _sameNameLoadoutsList > 0) then {
if (is3DEN) then {
{
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
_sameNameLoadoutsList = GVAR(defaultLoadoutsList) select {_x select 0 == _editBoxContent};
if ((_contentPanelCtrl lnbText [_i, 1]) == (_x select 0)) exitwith {
if ((_contentPanelCtrl lnbText [_i, 0]) != "") then {
[(findDisplay IDD_ace_arsenal), format ["A loadout of yours with the same name is being shared", _editBoxContent]] call FUNC(message); // TBL
breakOut "main";
for "_dataIndex" from 0 to 10 do {
switch (_dataIndex) do {
case 0;
case 1;
case 2;
case 8: {
if (count (_loadout select _dataIndex) > 0) then {
private _weapon = (_loadout select _dataIndex) select 0;
if (_weapon != "") then {
private _baseWeapon = _weapon call BIS_fnc_baseWeapon;
if (_weapon != _baseWeapon) then {
(_loadout select _dataIndex) set [0, _baseWeapon];
};
};
};
};
case 3;
case 4;
case 5: {
if (count (_loadout select _dataIndex) > 0) then {
private _containerContents = (_loadout select _dataIndex) select 1;
if (count _containerContents > 0) then {
{
if (count _x == 2 && {!((_x select 0) isEqualType "")}) then {
private _weapon = (_x select 0) select 0;
if (_weapon != "") then {
private _baseWeapon = _weapon call BIS_fnc_baseWeapon;
if (_weapon != _baseWeapon) then {
(_x select 0)set [0, _baseWeapon];
};
};
};
} foreach _containerContents;
};
};
};
};
};
} foreach _sameNameLoadoutsList;
};
if (count _sameNameLoadoutsList == 0) then {
if (count _sameNameLoadoutsList == 0) then {
_data pushBack [_editBoxContent, _curSelLoadout];
} else {
GVAR(defaultLoadoutsList) pushBack [_editBoxContent, _loadout];
} else {
GVAR(defaultLoadoutsList) set [GVAR(defaultLoadoutsList) find (_sameNameLoadoutsList select 0), [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _loadout]];
};
_data set [_data find (_sameNameLoadoutsList select 0), [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _curSelLoadout]];
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbText [_i, 1]) == _editBoxContent) exitwith {_contentPanelCtrl lnbDeleteRow _i};
};
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 setVariable [_editBoxContent, _loadout];
_contentPanelCtrl lnbSort [1, false];
// Select newly saved loadout
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbText [_i, 1]) == _editBoxContent) exitwith {_contentPanelCtrl lnbSetCurSelRow _i};
};
} else {
{
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbText [_i, 1]) == (_x select 0)) exitwith {
if ((_contentPanelCtrl lnbText [_i, 0]) != "") then {
[(findDisplay IDD_ace_arsenal), format ["A loadout of yours with the same name is being shared", _editBoxContent]] call FUNC(message); // TBL
breakOut "main";
};
};
};
} foreach _sameNameLoadoutsList;
if (count _sameNameLoadoutsList == 0) then {
_data pushBack [_editBoxContent, _curSelLoadout];
} else {
_data set [_data find (_sameNameLoadoutsList select 0), [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _curSelLoadout]];
};
};
};
};

View File

@ -23,7 +23,7 @@ switch (ctrlIDC _control) do {
case IDC_buttonDefaultLoadouts: {
_centerBoxTitleCtrl ctrlSetText "Default loadouts"; // TBL
_saveButtonCtrl ctrlEnable false;
_saveButtonCtrl ctrlEnable (is3DEN);
_saveButtonCtrl ctrlCommit 0;
};

View File

@ -9,7 +9,33 @@ camDestroy GVAR(camera);
GVAR(center) switchCamera GVAR(cameraView);
deleteVehicle GVAR(cameraHelper);
if (is3DEN) then {
GVAR(centerOrigin) hideObject false;
// Apply the loadout from the dummy to all selected units
{
_x setUnitLoadout (getUnitLoadout GVAR(center));
_x setFace GVAR(currentFace);
_x setSpeaker GVAR(currentVoice);
} foreach (get3DENSelected "object");
save3DENInventory (get3DENSelected "object");
setStatValue ["3DENArsenal", 1];
deleteVehicle GVAR(light);
deleteVehicle GVAR(center);
GVAR(centerOrigin) = nil;
GVAR(light) = nil;
get3DENCamera cameraEffect ["internal","back"];
["ShowInterface",true] call bis_fnc_3DENInterface;
GVAR(visionMode) call bis_fnc_3DENVisionMode;
};
if (isMultiplayer) then {
[QGVAR(broadcastFace), [GVAR(center), GVAR(currentFace)], QGVAR(center) + "_face"] call CBA_fnc_globalEventJIP;
[QGVAR(center) + "_face", GVAR(center)] call CBA_fnc_removeGlobalEventJIP;

View File

@ -20,6 +20,10 @@ if (isNil QGVAR(sharedLoadoutsVars)) then {
GVAR(sharedLoadoutsVars) = [];
};
if (isNil QGVAR(defaultLoadoutsList)) then {
GVAR(defaultLoadoutsList) = [];
};
if (isNil QGVAR(virtualItems)) then {
GVAR(virtualItems) = [[[], [], []], [[], [], [], []], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []];
};
@ -254,6 +258,38 @@ showHUD false;
private _mouseAreaCtrl = _display displayCtrl IDC_mouseArea;
ctrlSetFocus _mouseAreaCtrl;
// 3DEN support, lifted from BIS_fnc_arsenal
if (is3DEN) then {
GVAR(centerOrigin) = GVAR(center);
GVAR(centerOrigin) hideObject true;
private _centerPos = position GVAR(centerOrigin);
GVAR(center) = createAgent [typeOf GVAR(centerOrigin), position GVAR(centerOrigin), [], 0, "none"];
GVAR(center) setPosAtl getPosAtl GVAR(centerOrigin);
GVAR(center) setDir (getDir GVAR(centerOrigin));
GVAR(center) switchMove animationState GVAR(centerOrigin);
GVAR(center) switchAction "playerstand";
GVAR(center) enableSimulation false;
GVAR(center) setUnitLoadout (getUnitLoadout GVAR(centerOrigin));
GVAR(center) setFace GVAR(currentFace);
GVAR(center) setSpeaker GVAR(currentVoice);
//--- Create light for night editing (code based on BIS_fnc_3DENFlashlight)
private _intensity = 1;
GVAR(light) = "#lightpoint" createVehicle _centerPos;
GVAR(light) setLightBrightness _intensity;
GVAR(light) setLightAmbient [1,1,1];
GVAR(light) setLightColor [0,0,0];
GVAR(light) lightAttachObject [GVAR(centerOrigin), [0, 0, -_intensity * 7]];
//--- Use the same vision mode as in Eden
GVAR(visionMode)= -2 call bis_fnc_3DENVisionMode;
["ShowInterface",false] spawn bis_fnc_3DENInterface;
if (get3denactionstate "togglemap" > 0) then {do3DENAction "togglemap";};
};
//--------------- Init camera
GVAR(cameraPosition) = [5,0,0,[0,0,0.85]];

View File

@ -24,7 +24,7 @@ if !(GVAR(allowDefaultLoadouts)) then {
_buttonDefaultLoadoutsCtrl ctrlCommit 0;
};
if !(GVAR(allowSharedLoadouts) || {isMultiplayer}) then {
if !(GVAR(allowSharedLoadouts) && {isMultiplayer}) then {
private _buttonShareLoadoutsCtrl = _display displayCtrl IDC_buttonSharedLoadouts;
_buttonShareLoadoutsCtrl ctrlEnable false;
_buttonShareLoadoutsCtrl ctrlCommit 0;

View File

@ -12,7 +12,7 @@ private _textEditBoxCtrl= _display displayCtrl IDC_textEditBox;
if (_curSel == -1) exitWith {
if (GVAR(currentLoadoutsTab) != IDC_buttonMyLoadouts) then {
if (GVAR(currentLoadoutsTab) == IDC_buttonSharedLoadouts) then {
_saveButtonCtrl ctrlEnable false;
_saveButtonCtrl ctrlCommit 0;
};
@ -29,7 +29,7 @@ switch (GVAR(currentLoadoutsTab)) do {
case IDC_buttonMyLoadouts: {
_shareButtonCtrl ctrlEnable ([false, true] select (GVAR(allowSharedLoadouts)));
_shareButtonCtrl ctrlEnable (GVAR(allowSharedLoadouts) && {isMultiplayer});
_shareButtonCtrl ctrlCommit 0;
_loadButtonCtrl ctrlEnable true;
@ -52,10 +52,11 @@ switch (GVAR(currentLoadoutsTab)) do {
_x ctrlCommit 0;
} foreach [_saveButtonCtrl, _loadButtonCtrl];
{
_x ctrlEnable false;
_x ctrlCommit 0;
} foreach [_shareButtonCtrl, _deleteButtonCtrl];
_shareButtonCtrl ctrlEnable false;
_shareButtonCtrl ctrlCommit 0;
_deleteButtonCtrl ctrlEnable (is3DEN);
_deleteButtonCtrl ctrlCommit 0;
_textEditBoxCtrl ctrlSetText (_control lnbText [_curSel, 1]);
};

View File

@ -0,0 +1,4 @@
#include "script_component.hpp"
private _entity = (uinamespace getvariable ["bis_fnc_3DENEntityMenu_data",[]]) param [1, objnull];
[_entity, _entity, true] call FUNC(openBox);

View File

@ -266,3 +266,13 @@ class ctrlMapEmpty;
class ctrlMapMain;
class ctrlListNBox;
class ctrlCheckboxToolbar;
class Display3DEN {
class ContextMenu :ctrlMenu {
class Items {
class Arsenal {
action= QUOTE(call FUNC(open3DEN));
};
};
};
};