diff --git a/addons/arsenal/$PBOPREFIX$ b/addons/arsenal/$PBOPREFIX$ new file mode 100644 index 0000000000..fea3434f4b --- /dev/null +++ b/addons/arsenal/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\arsenal \ No newline at end of file diff --git a/addons/arsenal/CfgEventHandlers.hpp b/addons/arsenal/CfgEventHandlers.hpp new file mode 100644 index 0000000000..becf395052 --- /dev/null +++ b/addons/arsenal/CfgEventHandlers.hpp @@ -0,0 +1,18 @@ + +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; diff --git a/addons/arsenal/XEH_PREP.hpp b/addons/arsenal/XEH_PREP.hpp new file mode 100644 index 0000000000..576115ad68 --- /dev/null +++ b/addons/arsenal/XEH_PREP.hpp @@ -0,0 +1,45 @@ +PREP(addListBoxItem); +PREP(addVirtualItems); +PREP(buttonCargo); +PREP(buttonClearAll); +PREP(buttonExport); +PREP(buttonHide); +PREP(buttonImport); +PREP(buttonLoadoutsDelete); +PREP(buttonLoadoutsLoad); +PREP(buttonLoadoutsRename); +PREP(buttonLoadoutsSave); +PREP(buttonLoadoutsShare); +PREP(clearSearchbar); +PREP(fillLeftPanel); +PREP(fillLoadoutsList); +PREP(fillRightPanel); +PREP(handleMouse); +PREP(handleScrollWheel); +PREP(handleSearchbar); +PREP(initBox); +PREP(itemInfo); +PREP(loadoutsChangeTab); +PREP(message); +PREP(onArsenalClose); +PREP(onArsenalOpen); +PREP(onKeyDown); +PREP(onLoadoutsClose); +PREP(onLoadoutsOpen); +PREP(onMouseButtonDown); +PREP(onMouseButtonUp); +PREP(onSelChangedLeft); +PREP(onSelChangedLoadouts); +PREP(onSelChangedRight); +PREP(onSelChangedRightListnBox); +PREP(open3DEN); +PREP(openBox); +PREP(removeBox); +PREP(removeVirtualItems); +PREP(scanConfig); +PREP(showItem); +PREP(sortPanel); +PREP(updateCamPos); +PREP(updateRightPanel); +PREP(updateUniqueItemsList); +PREP(verifyLoadout); diff --git a/addons/arsenal/XEH_postInit.sqf b/addons/arsenal/XEH_postInit.sqf new file mode 100644 index 0000000000..e18afc6cc0 --- /dev/null +++ b/addons/arsenal/XEH_postInit.sqf @@ -0,0 +1,82 @@ +#include "script_component.hpp" +#include "defines.hpp" + +GVAR(EH_ID) = 0; +GVAR(lastSearchTextLeft) = ""; +GVAR(lastSearchTextRight) = ""; + +[QGVAR(initBox), {_this call FUNC(initBox)}] call CBA_fnc_addEventHandler; +[QGVAR(removeBox), {_this call FUNC(removeBox)}] call CBA_fnc_addEventHandler; + +[QGVAR(broadcastFace), { + params ["_unit", "_face"]; + + _unit setFace _face; +}] call CBA_fnc_addEventHandler; + +[QGVAR(broadcastVoice), { + params ["_unit", "_voice"]; + + _unit setSpeaker _voice; +}] call CBA_fnc_addEventHandler; + +[QGVAR(loadoutUnshared), { + params ["_contentPanelCtrl" , "_playerName", "_loadoutName"]; + + if (!(isNil QGVAR(currentLoadoutsTab)) && {GVAR(currentLoadoutsTab) == IDC_buttonSharedLoadouts}) then { + + private _dataToCheck = _playerName + _loadoutName; + + for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do { + if ((_contentPanelCtrl lnbData [_i, 1]) == _dataToCheck) exitwith {_contentPanelCtrl lnbDeleteRow _i}; + }; + } else { + + if ( + profileName == _playerName && + {!(isNil QGVAR(currentLoadoutsTab) && {GVAR(currentLoadoutsTab) == IDC_buttonMyLoadouts})} + ) then { + + for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do { + if ((_contentPanelCtrl lnbText [_i, 1]) == _loadoutName) exitwith { + _contentPanelCtrl lnbSetPicture [[_i, 0], QPATHTOF(data\iconPublicBlank.paa)]; + _contentPanelCtrl lnbSetValue [[_i, 0], 0]; + }; + }; + }; + }; +}] call CBA_fnc_addEventHandler; + +[QGVAR(loadoutShared), { + params ["_contentPanelCtrl" ,"_loadoutArgs"]; + _loadoutArgs params ["_playerName", "_loadoutName", "_loadoutData"]; + + if (!(isNil QGVAR(currentLoadoutsTab)) && {GVAR(currentLoadoutsTab) == IDC_buttonSharedLoadouts}) then { + + private _curSelData =_contentPanelCtrl lnbData [(lnbCurSelRow _contentPanelCtrl), 1]; + ([_loadoutData] call FUNC(verifyLoadout)) params ["_loadout", "_nullItemsAmount", "_unavailableItemsAmount"]; + + private _newRow = _contentPanelCtrl lnbAddRow [_playerName, _loadoutName]; + + ADD_LOADOUTS_LIST_PICTURES + + _contentPanelCtrl lnbSetData [[_newRow, 1], _playerName + _loadoutName]; + + if (_nullItemsAmount > 0) then { + + _contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 0, 0, 0.8]]; + } else { + + if (_unavailableItemsAmount > 0) then { + _contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 1, 1, 0.25]]; + }; + }; + + _contentPanelCtrl lnbSort [1, false]; + + // Select previously selected loadout + for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do { + if ((_contentPanelCtrl lnbText [_i, 1]) == _curSelData) exitwith {_contentPanelCtrl lnbSetCurSelRow _i}; + }; + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/arsenal/XEH_preInit.sqf b/addons/arsenal/XEH_preInit.sqf new file mode 100644 index 0000000000..537af9c11d --- /dev/null +++ b/addons/arsenal/XEH_preInit.sqf @@ -0,0 +1,21 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +// Arsenal +GVAR(modList) = ["","curator","kart","heli","mark","expansion","expansionpremium"]; + +[QGVAR(camInverted), "CHECKBOX", localize LSTRING(invertCameraSetting), localize LSTRING(settingCategory), false] call CBA_Settings_fnc_init; +[QGVAR(enableModIcons), "CHECKBOX", [LSTRING(modIconsSetting), LSTRING(modIconsTooltip)], localize LSTRING(settingCategory), true] call CBA_Settings_fnc_init; +[QGVAR(fontHeight), "SLIDER", [LSTRING(fontHeightSetting), LSTRING(fontHeightTooltip)], localize LSTRING(settingCategory), [1, 10, 4.5, 1]] call CBA_Settings_fnc_init; + +// Arsenal loadouts +[QGVAR(allowDefaultLoadouts), "CHECKBOX", [LSTRING(allowDefaultLoadoutsSetting), LSTRING(defaultLoadoutsTooltip)], localize LSTRING(settingCategory), true, true] call CBA_Settings_fnc_init; +[QGVAR(allowSharedLoadouts), "CHECKBOX", localize LSTRING(allowSharingSetting), localize LSTRING(settingCategory), true, true] call CBA_Settings_fnc_init; +[QGVAR(EnableRPTLog), "CHECKBOX", [LSTRING(printToRPTSetting), LSTRING(printToRPTTooltip)], localize LSTRING(settingCategory), false, false] call CBA_Settings_fnc_init; + +ADDON = true; diff --git a/addons/arsenal/XEH_preStart.sqf b/addons/arsenal/XEH_preStart.sqf new file mode 100644 index 0000000000..ed7f4f0345 --- /dev/null +++ b/addons/arsenal/XEH_preStart.sqf @@ -0,0 +1,5 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" + +call FUNC(scanConfig); diff --git a/addons/arsenal/config.cpp b/addons/arsenal/config.cpp new file mode 100644 index 0000000000..dcf101e172 --- /dev/null +++ b/addons/arsenal/config.cpp @@ -0,0 +1,40 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author = ECSTRING(common,ACETeam); + authors[] = {"alganthe"}; + url = ECSTRING(main,URL); + VERSION_CONFIG; + }; +}; + +class Cfg3DEN { + class Mission { + class GVAR(DummyCategory) { + displayName="Dummy attribute, should never show up"; + class AttributeCategories { + class ACE3_Arsenal { + class Attributes { + class GVAR(DefaultLoadoutsListAttribute) { + property = QGVAR(DefaultLoadoutsListAttribute); + value=0; + expression="if !(is3DEN) then {ace_arsenal_defaultLoadoutsList = _value};"; + defaultValue="[]"; + validate="none"; + wikiType="[[Array]]"; + }; + }; + }; + }; + }; + }; +}; + +#include "ui\RscAttributes.hpp" +#include "CfgEventHandlers.hpp" \ No newline at end of file diff --git a/addons/arsenal/data/iconClearContainer.paa b/addons/arsenal/data/iconClearContainer.paa new file mode 100644 index 0000000000..cf3ad52815 Binary files /dev/null and b/addons/arsenal/data/iconClearContainer.paa differ diff --git a/addons/arsenal/data/iconPublic.paa b/addons/arsenal/data/iconPublic.paa new file mode 100644 index 0000000000..d92675e8e2 Binary files /dev/null and b/addons/arsenal/data/iconPublic.paa differ diff --git a/addons/arsenal/data/iconPublicBlank.paa b/addons/arsenal/data/iconPublicBlank.paa new file mode 100644 index 0000000000..cf37c88b02 Binary files /dev/null and b/addons/arsenal/data/iconPublicBlank.paa differ diff --git a/addons/arsenal/data/iconSecondaryMuzzle.paa b/addons/arsenal/data/iconSecondaryMuzzle.paa new file mode 100644 index 0000000000..5cc7f17daa Binary files /dev/null and b/addons/arsenal/data/iconSecondaryMuzzle.paa differ diff --git a/addons/arsenal/defines.hpp b/addons/arsenal/defines.hpp new file mode 100644 index 0000000000..0f2b3ff62a --- /dev/null +++ b/addons/arsenal/defines.hpp @@ -0,0 +1,332 @@ +// Pixel grid +#define pixelScale 0.25 +#define GRID_W (pixelW * pixelGridNoUIScale * pixelScale) +#define GRID_H (pixelH * pixelGridNoUIScale * pixelScale) + +// IDCs +#define IDD_ace_arsenal 1127001 +#define IDC_mouseArea 0 +#define IDC_arrowMinus 101 +#define IDC_arrowPlus 102 +#define IDC_blockLeftFrame 3 +#define IDC_blockLeftBackground 4 +#define IDC_blockRightFrame 5 +#define IDC_blockRighttBackground 6 +#define IDC_loadIndicator 7 +#define IDC_loadIndicatorBar 701 +#define IDC_totalWeight 8 +#define IDC_totalWeightText 801 +#define IDC_message 9 +#define IDC_menuBar 10 +#define IDC_infoBox 11 +#define IDC_infoBackground 1101 +#define IDC_infoName 1102 +#define IDC_infoAuthor 1103 +#define IDC_DLCBackground 1104 +#define IDC_DLCIcon 1105 +#define IDC_mouseBlock 12 +#define IDC_leftTabContent 13 +#define IDC_rightTabContent 14 +#define IDC_rightTabContentListnBox 15 +#define IDC_sortLeftTab 16 +#define IDC_sortRightTab 17 +#define IDC_leftSearchbar 18 +#define IDC_leftSearchbarButton 41 +#define IDC_rightSearchbar 19 +#define IDC_rightSearchbarButton 42 +#define IDC_tabLeft 20 +#define IDC_iconBackgroundPrimaryWeapon 2001 +#define IDC_buttonPrimaryWeapon 2002 +#define IDC_iconBackgroundHandgun 2003 +#define IDC_buttonHandgun 2004 +#define IDC_iconBackgroundSecondaryWeapon 2005 +#define IDC_buttonSecondaryWeapon 2006 +#define IDC_iconBackgroundHeadgear 2007 +#define IDC_buttonHeadgear 2008 +#define IDC_iconBackgroundUniform 2009 +#define IDC_buttonUniform 2010 +#define IDC_iconBackgroundVest 2011 +#define IDC_buttonVest 2012 +#define IDC_iconBackgroundBackpack 2013 +#define IDC_buttonBackpack 2014 +#define IDC_iconBackgroundGoggles 2015 +#define IDC_buttonGoggles 2016 +#define IDC_iconBackgroundNVG 2017 +#define IDC_buttonNVG 2018 +#define IDC_iconBackgroundBinoculars 2019 +#define IDC_buttonBinoculars 2020 +#define IDC_iconBackgroundMap 2021 +#define IDC_buttonMap 2022 +#define IDC_iconBackgroundGPS 2023 +#define IDC_buttonGPS 2024 +#define IDC_iconBackgroundRadio 2025 +#define IDC_buttonRadio 2026 +#define IDC_iconBackgroundCompass 2028 +#define IDC_buttonCompass 2029 +#define IDC_iconBackgroundWatch 2030 +#define IDC_buttonWatch 2031 +#define IDC_iconBackgroundFace 2032 +#define IDC_buttonFace 2033 +#define IDC_iconBackgroundVoice 2034 +#define IDC_buttonVoice 2035 +#define IDC_iconBackgroundInsigna 2036 +#define IDC_buttonInsigna 2037 +#define IDC_iconBackgroundOptic 21 +#define IDC_buttonOptic 22 +#define IDC_iconBackgroundItemAcc 23 +#define IDC_buttonItemAcc 24 +#define IDC_iconBackgroundMuzzle 25 +#define IDC_buttonMuzzle 26 +#define IDC_iconBackgroundBipod 27 +#define IDC_buttonBipod 28 +#define IDC_iconBackgroundCurrentMag 3001 +#define IDC_buttonCurrentMag 3002 +#define IDC_iconBackgroundCurrentMag2 3003 +#define IDC_buttonCurrentMag2 3004 +#define IDC_iconBackgroundMag 29 +#define IDC_buttonMag 30 +#define IDC_iconBackgroundMagALL 31 +#define IDC_buttonMagALL 32 +#define IDC_iconBackgroundThrow 33 +#define IDC_buttonThrow 34 +#define IDC_iconBackgroundPut 35 +#define IDC_buttonPut 36 +#define IDC_iconBackgroundMisc 37 +#define IDC_buttonMisc 38 +#define IDC_buttonRemoveAllSelected 39 +#define IDC_buttonRemoveAll 40 + +#define IDD_loadouts_display 1127002 +#define IDC_centerBox 3 +#define IDC_centerTitle 301 +#define IDC_contentPanel 302 +#define IDC_textEditBox 303 +#define IDC_buttonSave 304 +#define IDC_buttonLoad 305 +#define IDC_buttonShare 306 +#define IDC_buttonDelete 307 +#define IDC_buttonRename 308 +#define IDC_buttonMyLoadoutsBackground 401 +#define IDC_buttonMyLoadouts 402 +#define IDC_buttonDefaultLoadoutsBackground 403 +#define IDC_buttonDefaultLoadouts 404 +#define IDC_buttonSharedLoadoutsBackground 405 +#define IDC_buttonSharedLoadouts 406 + +#define FADE_DELAY 0.15 +#define CAM_DIS_MAX 5 + +#define RIGHT_PANEL_ACC_IDCS IDC_buttonOptic, IDC_buttonItemAcc, IDC_buttonMuzzle, IDC_buttonBipod +#define RIGHT_PANEL_ACC_BACKGROUND_IDCS IDC_iconBackgroundOptic, IDC_iconBackgroundItemAcc, IDC_iconBackgroundMuzzle, IDC_iconBackgroundBipod +#define RIGHT_PANEL_ITEMS_IDCS IDC_buttonMag, IDC_buttonMagALL, IDC_buttonThrow, IDC_buttonPut, IDC_buttonMisc +#define RIGHT_PANEL_ITEMS_BACKGROUND_IDCS IDC_iconBackgroundMag, IDC_iconBackgroundMagALL, IDC_iconBackgroundThrow, IDC_iconBackgroundPut, IDC_iconBackgroundMisc +#define ARROWS_IDCS IDC_arrowMinus, IDC_arrowPlus + +#define GETDLC\ + {\ + private _dlc = "";\ + private _addons = configsourceaddonlist _this;\ + if (count _addons > 0) then {\ + private _mods = configsourcemodlist (configfile >> "CfgPatches" >> _addons select 0);\ + if (count _mods > 0) then {\ + _dlc = _mods select 0;\ + };\ + };\ + _dlc\ + } + +#define ADDMODICON\ + {\ + private _dlcName = _this call GETDLC;\ + if (_dlcName != "") then {\ + _ctrlPanel lbsetpictureright [_lbAdd,(modParams [_dlcName,["logo"]]) param [0,""]];\ + _modID = GVAR(modList) find _dlcName;\ + if (_modID < 0) then {_modID = GVAR(modList) pushback _dlcName;};\ + _ctrlPanel lbsetvalue [_lbAdd,_modID];\ + };\ + }; + +#define ADDBINOCULARSMAG\ + private _magazines = getarray (configfile >> "cfgweapons" >> _item >> "magazines");\ + if (count _magazines > 0) then {GVAR(center) addmagazine (_magazines select 0)}; + +#define TOGGLE_RIGHT_PANEL_WEAPON\ +{\ + _x = _display displayCtrl _x;\ + _x ctrlSetFade 0;\ + _x ctrlShow true;\ + _x ctrlEnable true;\ + _x ctrlCommit FADE_DELAY;\ +} foreach [\ + IDC_blockRightFrame,\ + IDC_blockRighttBackground,\ + IDC_rightTabContent,\ + IDC_sortRightTab,\ + RIGHT_PANEL_ACC_IDCS,\ + IDC_rightSearchbar,\ + IDC_rightSearchbarButton,\ + IDC_buttonCurrentMag\ +];\ +private _buttonCurrentMag2Ctrl = _display displayCtrl IDC_buttonCurrentMag2;\ +if (GVAR(currentLeftPanel) == IDC_buttonPrimaryWeapon) then {\ + _buttonCurrentMag2Ctrl ctrlSetFade 0;\ + _buttonCurrentMag2Ctrl ctrlShow true;\ + _buttonCurrentMag2Ctrl ctrlEnable true;\ +} else {\ + _buttonCurrentMag2Ctrl ctrlSetFade 1;\ + _buttonCurrentMag2Ctrl ctrlShow false;\ + _buttonCurrentMag2Ctrl ctrlEnable false;\ +};\ +_buttonCurrentMag2Ctrl ctrlCommit FADE_DELAY;\ +{\ + _x = _display displayCtrl _x;\ + _x ctrlSetFade 1;\ + _x ctrlShow false;\ + _x ctrlEnable false;\ + _x ctrlCommit FADE_DELAY;\ +} foreach [\ + IDC_loadIndicator,\ + RIGHT_PANEL_ITEMS_IDCS,\ + IDC_rightTabContentListnBox,\ + RIGHT_PANEL_ITEMS_BACKGROUND_IDCS,\ + IDC_buttonRemoveAll\ +]; + +#define TOGGLE_RIGHT_PANEL_CONTAINER\ +{\ + _x = _display displayCtrl _x;\ + _x ctrlSetFade 0;\ + _x ctrlShow true;\ + _x ctrlEnable true;\ + _x ctrlCommit FADE_DELAY;\ +} foreach [\ + IDC_blockRightFrame, \ + IDC_blockRighttBackground,\ + IDC_loadIndicator,\ + IDC_rightTabContentListnBox,\ + IDC_sortRightTab,\ + IDC_tabRight,\ + RIGHT_PANEL_ACC_IDCS,\ + RIGHT_PANEL_ITEMS_IDCS,\ + IDC_rightSearchbar,\ + IDC_rightSearchbarButton\ +];\ +{\ + _x = _display displayCtrl _x;\ + _x ctrlSetFade 1;\ + _x ctrlShow false;\ + _x ctrlEnable false;\ + _x ctrlCommit FADE_DELAY;\ +} foreach [\ + IDC_buttonCurrentMag,\ + IDC_buttonCurrentMag2,\ + IDC_iconBackgroundCurrentMag,\ + IDC_iconBackgroundCurrentMag2\ +]; + +#define TOGGLE_RIGHT_PANEL_HIDE\ +{\ + _x = _display displayCtrl _x;\ + _x ctrlSetFade 1;\ + _x ctrlShow false;\ + _x ctrlEnable false;\ + _x ctrlCommit FADE_DELAY;\ +} foreach [\ + IDC_blockRightFrame,\ + IDC_blockRighttBackground,\ + IDC_loadIndicator,\ + IDC_rightTabContent,\ + IDC_rightTabContentListnBox,\ + IDC_sortRightTab,\ + RIGHT_PANEL_ACC_BACKGROUND_IDCS,\ + RIGHT_PANEL_ACC_IDCS,\ + RIGHT_PANEL_ITEMS_BACKGROUND_IDCS,\ + RIGHT_PANEL_ITEMS_IDCS,\ + IDC_buttonRemoveAll,\ + IDC_rightSearchbar,\ + IDC_rightSearchbarButton,\ + IDC_buttonCurrentMag,\ + IDC_buttonCurrentMag2,\ + IDC_iconBackgroundCurrentMag,\ + IDC_iconBackgroundCurrentMag2\ +]; + +#define LIST_DEFAULTS\ + [\ + [\ + (primaryweapon GVAR(center) call bis_fnc_baseWeapon),\ + (secondaryweapon GVAR(center) call bis_fnc_baseWeapon),\ + (handgunweapon GVAR(center) call bis_fnc_baseWeapon)\ + ],\ + [\ + [primaryWeaponItems GVAR(center), secondaryWeaponItems GVAR(center), handgunItems GVAR(center)],\ + [primaryWeaponMagazine GVAR(center), secondaryWeaponMagazine GVAR(center), handgunMagazine GVAR(center)]\ + ],\ + uniformItems GVAR(center) + vestItems GVAR(center) + backpackItems GVAR(center),\ + [headgear GVAR(center)],\ + [uniform GVAR(center)],\ + [vest GVAR(center)],\ + [backpack GVAR(center)],\ + [goggles GVAR(center)],\ + [hmd GVAR(center)],\ + [binocular GVAR(center)]\ +] + +#define CHECK_WEAPON_OR_ACC\ + _item in (_weaponsArray select 0) ||\ + {_item in (_weaponsArray select 1)} ||\ + {_item in (_weaponsArray select 2)} ||\ + {_item in (GVAR(virtualItems) select 9)} ||\ + {_item in (_accsArray select 0)} ||\ + {_item in (_accsArray select 1)} ||\ + {_item in (_accsArray select 2)} ||\ + {_item in (_accsArray select 3)} + +#define CHECK_ASSIGNED_ITEMS\ + _item in (GVAR(virtualItems) select 10) ||\ + {_item in (GVAR(virtualItems) select 11)} ||\ + {_item in (GVAR(virtualItems) select 12)} ||\ + {_item in (GVAR(virtualItems) select 13)} ||\ + {_item in (GVAR(virtualItems) select 14)} ||\ + {_item in (GVAR(virtualItems) select 8)} + +#define CHECK_CONTAINER\ + _item in (GVAR(virtualItems) select 4) ||\ + {_item in (GVAR(virtualItems) select 5)} ||\ + {_item in (GVAR(virtualItems) select 6)} + +#define CLASS_CHECK_ITEM\ + isClass (_weaponCfg >> _item) ||\ + {isClass (_vehcCfg >> _item)} ||\ + {isClass (_glassesCfg >> _item)} ||\ + {isClass (_magCfg >> _item)} + +#define CHECK_CONTAINER_ITEMS\ + _item in (GVAR(virtualItems) select 3) ||\ + {_item in (_accsArray select 0)} ||\ + {_item in (_accsArray select 1)} ||\ + {_item in (_accsArray select 2)} ||\ + {_item in (_accsArray select 3)} ||\ + {_item in (GVAR(virtualItems) select 4)} ||\ + {_item in (GVAR(virtualItems) select 5)} ||\ + {_item in (GVAR(virtualItems) select 6)} ||\ + {_item in (GVAR(virtualItems) select 7)} ||\ + {_item in (GVAR(virtualItems) select 8)} ||\ + {_item in (GVAR(virtualItems) select 10)} ||\ + {_item in (GVAR(virtualItems) select 11)} ||\ + {_item in (GVAR(virtualItems) select 12)} ||\ + {_item in (GVAR(virtualItems) select 13)} ||\ + {_item in (GVAR(virtualItems) select 14)} ||\ + {_item in (GVAR(virtualItems) select 15)} ||\ + {_item in (GVAR(virtualItems) select 16)} ||\ + {_item in (GVAR(virtualItems) select 17)} + +#define ADD_LOADOUTS_LIST_PICTURES\ + _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")]; \ No newline at end of file diff --git a/addons/arsenal/functions/fnc_addListBoxItem.sqf b/addons/arsenal/functions/fnc_addListBoxItem.sqf new file mode 100644 index 0000000000..815e3511a8 --- /dev/null +++ b/addons/arsenal/functions/fnc_addListBoxItem.sqf @@ -0,0 +1,63 @@ +/* + * Author: Dedmen + * Add a listbox row. + * + * Arguments: + * 0: Config category (must be "CfgWeapons", "CfgVehicles", "CfgMagazines", "CfgVoice") + * 1: Classname + * 2: Panel control + * 3: Name of the picture entry in that Cfg class + * + * Return Value: + * None + * + * Public: Yes +*/ + +#include "script_component.hpp" +params ["_configCategory", "_className", "_ctrlPanel", ["_pictureEntryName", "picture", [""]]]; + +private _cacheNamespace = _ctrlPanel; //For better readability. + +private _cachedItemInfo = _cacheNamespace getVariable [_configCategory+_className, []]; + +//_cachedItemInfo == [_displayName, _itemPicture, _modPicture, _modID] +if (_cachedItemInfo isEqualTo []) then {//Not in cache. So get info and put into cache. + + private _configPath = configFile >> _configCategory >> _className; + + _cachedItemInfo set [0, getText (_configPath >> "displayName")]; + //if _pictureEntryName is empty then this item has no Icons. (Faces) + _cachedItemInfo set [1, if (_pictureEntryName isEqualTo "") then {""} else {getText (_configPath >> _pictureEntryName)}]; + + //get name of DLC + private _dlcName = ""; + private _addons = configsourceaddonlist _configPath; + if !(_addons isEqualTo []) then { + private _mods = configsourcemodlist (configfile >> "CfgPatches" >> _addons select 0); + if !(_mods isEqualTo []) then { + _dlcName = _mods select 0; + }; + }; + + if (_dlcName != "") then { + _cachedItemInfo set [2, (modParams [_dlcName,["logo"]]) param [0,""]];//mod picture + _modID = GVAR(modList) find _dlcName; + if (_modID < 0) then {_modID = GVAR(modList) pushback _dlcName;};//We keep a ordered list of all mods for sorting later. + _cachedItemInfo set [3, _modID];//mod ID + } else { + _cachedItemInfo set [2, ""];//mod picture + _cachedItemInfo set [3, 0];//mod ID + }; + _cacheNamespace setVariable [_configCategory+_className, _cachedItemInfo]; +}; + +_cachedItemInfo params ["_displayName", "_itemPicture", "_modPicture", "_modID"]; + +private _lbAdd = _ctrlPanel lbAdd _displayName; + +_ctrlPanel lbSetData [_lbAdd, _className]; +_ctrlPanel lbSetPicture [_lbAdd, _itemPicture]; +_ctrlPanel lbSetPictureRight [_lbAdd,["",_modPicture] select (GVAR(enableModIcons))]; +_ctrlPanel lbSetValue [_lbAdd,_modID]; +_ctrlPanel lbSetTooltip [_lbAdd, format ["%1\n%2", _displayName, _className]]; diff --git a/addons/arsenal/functions/fnc_addVirtualItems.sqf b/addons/arsenal/functions/fnc_addVirtualItems.sqf new file mode 100644 index 0000000000..742b305a89 --- /dev/null +++ b/addons/arsenal/functions/fnc_addVirtualItems.sqf @@ -0,0 +1,223 @@ +/* + * Author: Alganthe, Dedmen + * Add virtual items to the provided target. + * + * Arguments: + * 0: Target + * 1: Items + * 2: Add globally + * + * Return Value: + * None + * + * Example: + * [_box, ["item1", "item2", "itemN"]] call ace_arsenal_fnc_addVirtualItems + * [_box, true, false] call ace_arsenal_fnc_addVirtualItems + * + * Public: Yes +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params [["_object", objNull, [objNull]], ["_items", [], [true, []]], ["_global", false, [false]]]; + +if (_object == objNull) exitWith {}; +if (_items isEqualType [] && {count _items == 0}) exitWith {}; + +private _cargo = _object getVariable [QGVAR(virtualItems), [ + [[], [], []], // Weapons 0, primary, secondary, handgun + [[], [], [], []], // WeaponAccessories 1, optic,side,muzzle,bipod + [ ], // Magazines 2 + [ ], // Headgear 3 + [ ], // Uniform 4 + [ ], // Vest 5 + [ ], // Backpacks 6 + [ ], // Goggles 7 + [ ], // NVGs 8 + [ ], // Binoculars 9 + [ ], // Map 10 + [ ], // Compass 11 + [ ], // Radio slot 12 + [ ], // Watch slot 13 + [ ], // Comms slot 14 + [ ], // WeaponThrow 15 + [ ], // WeaponPut 16 + [ ] // InventoryItems 17 +]]; + +private _configCfgWeapons = configFile >> "CfgWeapons"; //Save this lookup in variable for perf improvement + +if (_items isEqualType true && {_items}) then { + private _configItems = uiNamespace getVariable QGVAR(configItems); + + { + (_x select 0) append (_x select 1); + (_x select 2) set [(_x select 3), (_x select 0) arrayIntersect (_x select 0)]; + } forEach [ + [(_cargo select 0 select 0),(_configItems select 0 select 0), _cargo select 0, 0], + [(_cargo select 0 select 1),(_configItems select 0 select 1), _cargo select 0, 1], + [(_cargo select 0 select 2),(_configItems select 0 select 2), _cargo select 0, 2], + [(_cargo select 1 select 0),(_configItems select 1 select 0), _cargo select 1, 0], + [(_cargo select 1 select 1),(_configItems select 1 select 1), _cargo select 1, 1], + [(_cargo select 1 select 2),(_configItems select 1 select 2), _cargo select 1, 2], + [(_cargo select 1 select 3),(_configItems select 1 select 3), _cargo select 1, 3] + ]; + + for "_index" from 2 to 17 do { + (_cargo select _index) append (_configItems select _index); + _cargo set [_index, (_cargo select _index) arrayIntersect (_cargo select _index)]; + }; + +} else { + { + if (_x isEqualType "") then { + private _configItemInfo = _configCfgWeapons >> _x >> "ItemInfo"; + private _simulationType = getText (_configCfgWeapons >> _x >> "simulation"); + switch true do { + case (isClass (_configCfgWeapons >> _x)): { + switch true do { + /* Weapon acc */ + case ( + isClass (_configItemInfo) && + {(getNumber (_configItemInfo >> "type")) in [101, 201, 301, 302]} && + {!(_x isKindOf ["CBA_MiscItem", (_configCfgWeapons)])} + ): { + switch (getNumber (_configItemInfo >> "type")) do { + case 201: { + (_cargo select 1) select 0 pushBackUnique _x; + }; + case 301: { + (_cargo select 1) select 1 pushBackUnique _x; + }; + case 101: { + (_cargo select 1) select 2 pushBackUnique _x; + }; + case 302: { + (_cargo select 1) select 3 pushBackUnique _x; + }; + }; + }; + /* Headgear */ + case (isClass (_configItemInfo) && + {getNumber (_configItemInfo >> "type") == 605}): { + (_cargo select 3) pushBackUnique _x; + }; + /* Uniform */ + case (isClass (_configItemInfo) && + {getNumber (_configItemInfo >> "type") == 801}): { + (_cargo select 4) pushBackUnique _x; + }; + /* Vest */ + case (isClass (_configItemInfo) && + {getNumber (_configItemInfo >> "type") == 701}): { + (_cargo select 5) pushBackUnique _x; + }; + /* NVgs */ + case (_simulationType == "NVGoggles"): { + (_cargo select 8) pushBackUnique _x; + }; + /* Binos */ + case (_simulationType == "Binocular" || + {(_simulationType == 'Weapon') && {(getNumber (_configCfgWeapons >> _x >> 'type') == 4096)}}): { + (_cargo select 9) pushBackUnique _x; + }; + /* Map */ + case (_simulationType == "ItemMap"): { + (_cargo select 10) pushBackUnique _x; + }; + /* Compass */ + case (_simulationType == "ItemCompass"): { + (_cargo select 11) pushBackUnique _x; + }; + /* Radio */ + case (_simulationType == "ItemRadio"): { + (_cargo select 12) pushBackUnique _x; + }; + /* Watch */ + case (_simulationType == "ItemWatch"): { + (_cargo select 13) pushBackUnique _x; + }; + /* GPS */ + case (_simulationType == "ItemGPS"): { + (_cargo select 14) pushBackUnique _x; + }; + /* UAV terminals */ + case (isClass (_configItemInfo) && + {getNumber (_configItemInfo >> "type") == 621}): { + (_cargo select 14) pushBackUnique _x; + }; + /* Weapon, at the bottom to avoid adding binos */ + case (isClass (_configCfgWeapons >> _x >> "WeaponSlotsInfo") && + {getNumber (_configCfgWeapons >> _x >> 'type') != 4096}): { + switch (getNumber (_configCfgWeapons >> _x >> "type")) do { + case 1: { + (_cargo select 0) select 0 pushBackUnique ([_x] call bis_fnc_baseWeapon); + }; + case 2: { + (_cargo select 0) select 2 pushBackUnique ([_x] call bis_fnc_baseWeapon); + }; + case 4: { + (_cargo select 0) select 1 pushBackUnique ([_x] call bis_fnc_baseWeapon); + }; + }; + }; + /* Misc items */ + case ( + isClass (_configItemInfo) && + ((getNumber (_configItemInfo >> "type")) in [101, 201, 301, 302] && + {(_x isKindOf ["CBA_MiscItem", (_configCfgWeapons)])}) || + {(getNumber (_configItemInfo >> "type")) in [401, 619, 620]} || + {(getText (_configCfgWeapons >> _x >> "simulation")) == "ItemMineDetector"} + ): { + (_cargo select 17) pushBackUnique _x; + }; + }; + }; + case (isClass (configFile >> "CfgMagazines" >> _x)): { + // Lists to check against + private _grenadeList = []; + { + _grenadeList append getArray (_configCfgWeapons >> "Throw" >> _x >> "magazines"); + false + } count getArray (_configCfgWeapons >> "Throw" >> "muzzles"); + + private _putList = []; + { + _putList append getArray (_configCfgWeapons >> "Put" >> _x >> "magazines"); + false + } count getArray (_configCfgWeapons >> "Put" >> "muzzles"); + + // Check what the magazine actually is + switch true do { + // Rifle, handgun, secondary weapons mags + case ( + (getNumber (configFile >> "CfgMagazines" >> _x >> "type") in [256,512,1536,16]) && + {!(_x in _grenadeList)} && + {!(_x in _putList)} + ): { + (_cargo select 2) pushBackUnique _x; + }; + // Grenades + case (_x in _grenadeList): { + (_cargo select 15) pushBackUnique _x; + }; + // Put + case (_x in _putList): { + (_cargo select 16) pushBackUnique _x; + }; + }; + }; + case (isClass (configFile >> "CfgVehicles" >> _x)): { + if (getText (configFile >> "CfgVehicles" >> _x >> "vehicleClass") == "Backpacks") then { + (_cargo select 6) pushBackUnique _x; + }; + }; + case (isClass (configFile >> "CfgGlasses" >> _x)): { + (_cargo select 7) pushBackUnique _x; + }; + }; + }; + } foreach _items; +}; + +_object setVariable [QGVAR(virtualItems), _cargo, _global]; diff --git a/addons/arsenal/functions/fnc_buttonCargo.sqf b/addons/arsenal/functions/fnc_buttonCargo.sqf new file mode 100644 index 0000000000..1af4008caf --- /dev/null +++ b/addons/arsenal/functions/fnc_buttonCargo.sqf @@ -0,0 +1,92 @@ +/* + * Author: Alganthe + * Add or remove item(s) when the + or - button is pressed in the right panel. + * + * Arguments: + * 0: Arsenal display + * 1: Add or remove (-1: remove, 1: Add) + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_addOrRemove"]; + +private _load = 0; +private _maxLoad = ""; +private _items = []; +private _ctrlList = (_display displayCtrl IDC_rightTabContentListnBox); +private _lnbCurSel = lnbCurSelRow _ctrlList; +private _item = _ctrlList lnbData [_lnbCurSel, 0]; + +if ((_ctrlList lnbValue [_lnbCurSel, 2]) == 1 && {_addOrRemove == 1}) exitWith {}; + +// Update item count and currentItems array +switch GVAR(currentLeftPanel) do { + + case IDC_buttonUniform : { + if (_addOrRemove > 0) then { + for "_count" from 1 to ([1, 5] select (GVAR(shiftState))) do { + GVAR(center) addItemToUniform _item; + }; + } else { + for "_count" from 1 to ([1, 5] select (GVAR(shiftState))) do { + GVAR(center) removeItemFromUniform _item; + }; + }; + + _load = loadUniform GVAR(center); + _maxLoad = gettext (configfile >> "CfgWeapons" >> uniform GVAR(center) >> "ItemInfo" >> "containerClass"); + _items = uniformItems GVAR(center); + GVAR(currentItems) set [15 ,_items]; + }; + + case IDC_buttonVest : { + if (_addOrRemove > 0) then { + for "_count" from 1 to ([1, 5] select (GVAR(shiftState))) do { + GVAR(center) addItemToVest _item; + }; + } else { + for "_count" from 1 to ([1, 5] select (GVAR(shiftState))) do { + GVAR(center) removeItemFromVest _item; + }; + }; + + _load = loadVest GVAR(center); + _maxLoad = gettext (configfile >> "CfgWeapons" >> vest GVAR(center) >> "ItemInfo" >> "containerClass"); + _items = vestItems GVAR(center); + GVAR(currentItems) set [16,_items]; + }; + + case IDC_buttonBackpack : { + if (_addOrRemove > 0) then { + for "_count" from 1 to ([1, 5] select (GVAR(shiftState))) do { + GVAR(center) addItemToBackpack _item; + }; + } else { + for "_count" from 1 to ([1, 5] select (GVAR(shiftState))) do { + GVAR(center) removeItemFromBackpack _item; + }; + }; + + _load = loadBackpack GVAR(center); + _maxLoad = backpack GVAR(center); + _items = backpackItems GVAR(center); + GVAR(currentItems) set [17,_items]; + }; +}; + +// Update progress bar status, weight info +private _loadIndicatorBarCtrl = _display displayCtrl IDC_loadIndicatorBar; +_loadIndicatorBarCtrl progressSetPosition _load; + +private _value = {_x == _item} count _items; +_ctrlList lnbSetText [[_lnbCurSel, 2],str _value]; + +[QGVAR(cargoChanged), [_display, _item, _addOrRemove, GVAR(shiftState)]] call CBA_fnc_localEvent; + +[_ctrlList, _maxLoad] call FUNC(updateRightPanel); diff --git a/addons/arsenal/functions/fnc_buttonClearAll.sqf b/addons/arsenal/functions/fnc_buttonClearAll.sqf new file mode 100644 index 0000000000..d73d777ace --- /dev/null +++ b/addons/arsenal/functions/fnc_buttonClearAll.sqf @@ -0,0 +1,62 @@ +/* + * Author: Alganthe + * Clear the current container. + * + * Arguments: + * 0: Arsenal display + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display"]; + +// Clear container +switch (GVAR(currentLeftPanel)) do { + case IDC_buttonUniform: { + {GVAR(center) removeItemFromUniform _x} foreach (uniformItems GVAR(center)); + GVAR(currentItems) set [15, []]; + }; + case IDC_buttonVest: { + {GVAR(center) removeItemFromVest _x} foreach (vestItems GVAR(center)); + GVAR(currentItems) set [16, []]; + }; + case IDC_buttonBackpack: { + {GVAR(center) removeItemFromBackpack _x} foreach (backpackItems GVAR(center)); + GVAR(currentItems) set [17, []]; + }; +}; + +// Clear number of owned items +private _ctrlList = _display displayCtrl IDC_rightTabContentListnBox; + +for "_l" from 0 to (lbSize _ctrlList - 1) do { + _ctrlList lnbSetText [[_l, 2], str 0]; +}; + +private _removeAllCtrl = _display displayCtrl IDC_buttonRemoveAll; +_removeAllCtrl ctrlSetFade 1; +_removeAllCtrl ctrlCommit FADE_DELAY; + +// Update load bar +private _loadIndicatorBarCtrl = _display displayCtrl IDC_loadIndicatorBar; +_loadIndicatorBarCtrl progressSetPosition 0; + +private _maxLoad = switch (GVAR(currentLeftPanel)) do { + case IDC_buttonUniform: { + gettext (configfile >> "CfgWeapons" >> uniform GVAR(center) >> "ItemInfo" >> "containerClass") + }; + case IDC_buttonVest: { + gettext (configfile >> "CfgWeapons" >> vest GVAR(center) >> "ItemInfo" >> "containerClass") + }; + case IDC_buttonBackpack: { + backpack GVAR(center) + }; +}; + +private _control = _display displayCtrl IDC_rightTabContentListnBox; +[_control, _maxLoad] call FUNC(updateRightPanel); diff --git a/addons/arsenal/functions/fnc_buttonExport.sqf b/addons/arsenal/functions/fnc_buttonExport.sqf new file mode 100644 index 0000000000..7bcac4c8ba --- /dev/null +++ b/addons/arsenal/functions/fnc_buttonExport.sqf @@ -0,0 +1,51 @@ +/* + * Author: Alganthe + * Export current loadout / default loadouts list to clipboard. + * + * Arguments: + * 0: Arsenal display + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_display"]; + +if (GVAR(shiftState)) then { + + if (isNil QGVAR(defaultLoadoutsList) || {GVAR(defaultLoadoutsList) isEqualTo []}) exitWith { + [_display, localize LSTRING(exportDefaultError)] call FUNC(message); + }; + + private _listLength = count GVAR(defaultLoadoutsList); + for "_index" from -1 to _listLength do { + + switch true do { + case (_index == -1): { + "ace_clipboard" callExtension (format ["[%1", endl]); + }; + + case (_index == _listLength): { + "ace_clipboard" callExtension "];"; + }; + + default { + "ace_clipboard" callExtension ([" ",str (GVAR(defaultLoadoutsList) select _index), [",", ""] select (_index == _listLength - 1), endl] joinString ""); + }; + }; + }; + + "ace_clipboard" callExtension "--COMPLETE--"; + + [_display, localize LSTRING(exportDefault)] call FUNC(message); +} else { + + private _export = str getUnitLoadout GVAR(center); + "ace_clipboard" callExtension (_export + ";"); + "ace_clipboard" callExtension "--COMPLETE--"; + + [_display, localize LSTRING(exportCurrent)] call FUNC(message); +}; diff --git a/addons/arsenal/functions/fnc_buttonHide.sqf b/addons/arsenal/functions/fnc_buttonHide.sqf new file mode 100644 index 0000000000..87912e40fe --- /dev/null +++ b/addons/arsenal/functions/fnc_buttonHide.sqf @@ -0,0 +1,56 @@ +/* + * Author: Alganthe + * Hide / show arsenal interface. + * + * Arguments: + * 0: Arsenal display + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display"]; + +private _showToggle = !ctrlShown (_display displayCtrl IDC_menuBar); + +if (_showToggle) then { + [_display, _display displayCtrl GVAR(currentLeftPanel)] call FUNC(populatePanel) +}; + +{ + private _ctrl = _display displayctrl _x; + _ctrl ctrlshow _showToggle; + _ctrl ctrlcommit 0.15; +} foreach [ + IDC_blockLeftFrame, + IDC_blockLeftBackground, + IDC_blockRightFrame, + IDC_blockRighttBackground, + IDC_loadIndicator, + IDC_totalWeight, + IDC_menuBar, + IDC_infoBox, + IDC_leftTabContent, + IDC_rightTabContent, + IDC_rightTabContentListnBox, + IDC_sortLeftTab, + IDC_sortRightTab, + IDC_leftSearchbarButton, + IDC_rightSearchbarButton, + IDC_leftSearchbar, + IDC_rightSearchbar, + IDC_tabLeft, + RIGHT_PANEL_ACC_BACKGROUND_IDCS, + RIGHT_PANEL_ACC_IDCS, + RIGHT_PANEL_ITEMS_BACKGROUND_IDCS, + RIGHT_PANEL_ITEMS_IDCS, + IDC_buttonRemoveAll, + IDC_buttonCurrentMag, + IDC_buttonCurrentMag2, + IDC_iconBackgroundCurrentMag, + IDC_iconBackgroundCurrentMag2 +]; diff --git a/addons/arsenal/functions/fnc_buttonImport.sqf b/addons/arsenal/functions/fnc_buttonImport.sqf new file mode 100644 index 0000000000..76cd2f3a75 --- /dev/null +++ b/addons/arsenal/functions/fnc_buttonImport.sqf @@ -0,0 +1,111 @@ +/* + * Author: Alganthe + * Import loadout / default loadouts list from clipboard. + * + * Arguments: + * 0: Arsenal display + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display"]; + +private _data = call (compile copyFromClipboard); + +if (isNil "_data" || {!(_data isEqualType [])}) exitWith { + [_display, localize LSTRING(importFormatError)] call FUNC(message); +}; + +if (GVAR(shiftState) && {is3DEN}) then { + + { + if ( + count _x == 2 && + {_x select 0 isEqualType ""} && + {_x select 0 != ""} && + {_x select 1 isEqualType []} && + {count (_x select 1) == 10} + ) then { + + _x params ["_loadoutName", "_loadout"]; + + private _sameNameLoadoutsList = GVAR(defaultLoadoutsList) select {_x select 0 == _loadoutName}; + + if (count _sameNameLoadoutsList == 0) then { + GVAR(defaultLoadoutsList) pushBack [_loadoutName, _loadout]; + } else { + GVAR(defaultLoadoutsList) set [GVAR(defaultLoadoutsList) find (_sameNameLoadoutsList select 0), _loadoutName, _loadout]; + }; + }; + } foreach _data; + + [_display, localize LSTRING(importedDefault)] call FUNC(message); + set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]]; + +} else { + if (count _data == 10) then { + GVAR(center) setUnitLoadout _data; + + 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))]; + }; + }; + }; + + + { + private _simulationType = getText (configFile >> "CfgWeapons" >> _x >> "simulation"); + private _index = 10 + (["itemmap", "itemcompass", "itemradio", "itemwatch", "itemgps"] find (tolower _simulationType)); + + GVAR(currentItems) set [_index, _x]; + } foreach (assignedItems GVAR(center)); + + call FUNC(updateUniqueItemsList); + + // Reapply insignia + [GVAR(center), ""] call bis_fnc_setUnitInsignia; + [GVAR(center), GVAR(currentInsignia)] call bis_fnc_setUnitInsignia; + + [_display, _display displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel); + + [_display, localize LSTRING(importedCurrent)] call FUNC(message); + }; +}; diff --git a/addons/arsenal/functions/fnc_buttonLoadoutsDelete.sqf b/addons/arsenal/functions/fnc_buttonLoadoutsDelete.sqf new file mode 100644 index 0000000000..d3621f5826 --- /dev/null +++ b/addons/arsenal/functions/fnc_buttonLoadoutsDelete.sqf @@ -0,0 +1,55 @@ +/* + * Author: Alganthe + * Delete / unshare loadout currently selected. + * + * Arguments: + * 0: Arsenal display + * 1: Button control + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control"]; + +if !(ctrlEnabled _control) exitWith {}; + +private _contentPanelCtrl = _display displayCtrl IDC_contentPanel; +private _contentPanelCursSel = lnbCurSelRow _contentPanelCtrl; +private _loadoutName = _contentPanelCtrl lnbText [_contentPanelCursSel, 1]; + +if (GVAR(currentLoadoutsTab) != IDC_buttonSharedLoadouts) then { + + if (is3DEN && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts}) then { + GVAR(defaultLoadoutsList) deleteAt (GVAR(defaultLoadoutsList) find ((GVAR(defaultLoadoutsList) select {_x select 0 == _loadoutName}) select 0)); + set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]]; + } else { + private _data = profileNamespace getVariable [QGVAR(saved_loadouts), []]; + _data deleteAt (_data find ((_data select {_x select 0 == _loadoutName}) select 0)); + }; + + _contentPanelCtrl setVariable [_loadoutName + str GVAR(currentLoadoutsTab), nil]; + _contentPanelCtrl lnbDeleteRow _contentPanelCursSel; + _contentPanelCtrl lnbSetCurSelRow (_contentPanelCursSel); + + [(findDisplay IDD_ace_arsenal), [localize LSTRING(loadoutDeleted), _loadoutName] joinString " "] call FUNC(message); +} else { + + private _profileName = profileName; // GVAR(center) could be a remote unit + private _loadoutVar = _profileName + _loadoutName; + private _sharedLoadoutsVars = GVAR(sharedLoadoutsNamespace) getVariable QGVAR(sharedLoadoutsVars); + + GVAR(sharedLoadoutsNamespace) setVariable [_loadoutVar, nil, true]; + GVAR(sharedLoadoutsNamespace) setVariable [QGVAR(sharedLoadoutsVars), _sharedLoadoutsVars - [_loadoutVar], true]; + + _contentPanelCtrl lnbDeleteRow _contentPanelCursSel; + _contentPanelCtrl lnbSetCurSelRow (_contentPanelCursSel); + + [QGVAR(loadoutUnshared), [_contentPanelCtrl, profileName, _loadoutName]] call CBA_fnc_remoteEvent; + + [(findDisplay IDD_ace_arsenal), [localize LSTRING(loadoutUnshared), _loadoutName] joinString " "] call FUNC(message); +}; diff --git a/addons/arsenal/functions/fnc_buttonLoadoutsLoad.sqf b/addons/arsenal/functions/fnc_buttonLoadoutsLoad.sqf new file mode 100644 index 0000000000..9d413a233c --- /dev/null +++ b/addons/arsenal/functions/fnc_buttonLoadoutsLoad.sqf @@ -0,0 +1,90 @@ +/* + * Author: Alganthe + * Load selected loadout. + * + * Arguments: + * 0: Arsenal display + * 1: Button control + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control"]; + +if !(ctrlEnabled _control) exitWith {}; + +private _contentPanelCtrl = _display displayCtrl IDC_contentPanel; +private _curSel = lnbCurSelRow _contentPanelCtrl; +private _loadoutName = _contentPanelCtrl lnbText [_curSel, 1]; + +private _loadout = switch GVAR(currentLoadoutsTab) do { + + case IDC_buttonMyLoadouts; + case IDC_buttonDefaultLoadouts:{ + (_contentPanelCtrl getVariable _loadoutName + str GVAR(currentLoadoutsTab)) select 0 + }; + + case IDC_buttonSharedLoadouts:{ + (GVAR(sharedLoadoutsNamespace) getVariable ((_contentPanelCtrl lnbText [_curSel, 0]) + (_contentPanelCtrl lnbText [_curSel, 1]))) select 2 + }; +}; + +GVAR(center) setUnitLoadout [_loadout, 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]; + + }; + 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))]; + }; + }; +}; +{ + private _simulationType = getText (configFile >> "CfgWeapons" >> _x >> "simulation"); + private _index = 10 + (["itemmap", "itemcompass", "itemradio", "itemwatch", "itemgps"] find (tolower _simulationType)); + + GVAR(currentItems) set [_index, _x]; +} foreach (assignedItems GVAR(center)); + +call FUNC(updateUniqueItemsList); + +// Reapply insignia +[GVAR(center), ""] call bis_fnc_setUnitInsignia; +[GVAR(center), GVAR(currentInsignia)] call bis_fnc_setUnitInsignia; + +[(findDisplay IDD_ace_arsenal), [localize LSTRING(loadoutLoaded), _loadoutName] joinString " "] call FUNC(message); diff --git a/addons/arsenal/functions/fnc_buttonLoadoutsRename.sqf b/addons/arsenal/functions/fnc_buttonLoadoutsRename.sqf new file mode 100644 index 0000000000..5435d07279 --- /dev/null +++ b/addons/arsenal/functions/fnc_buttonLoadoutsRename.sqf @@ -0,0 +1,70 @@ +/* + * Author: Alganthe + * Rename selected loadout. + * + * Arguments: + * 0: Arsenal display + * 1: Button control + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control"]; + +if !(ctrlEnabled _control) exitWith {}; + +// Retrieve panel data +private _contentPanelCtrl = _display displayCtrl IDC_contentPanel; +private _curSelRow = lnbCurSelRow _contentPanelCtrl; +private _loadoutName = _contentPanelCtrl lnbText [_curSelRow, 1]; + +private _editBoxCtrl = _display displayCtrl IDC_textEditBox; +private _editBoxContent = ctrlText _editBoxCtrl; + +private _data = [profileNamespace getVariable [QGVAR(saved_loadouts), []], GVAR(defaultLoadoutsList)] select (GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts && {is3DEN}); +private _similarLoadouts = _data select {_x select 0 == _editBoxContent}; + +if (count _similarLoadouts > 0) exitWith { + [(findDisplay IDD_ace_arsenal), localize LSTRING(renameExistError)] call FUNC(message); +}; + +// Update loadout info in profile / 3DEN and list namespaces +private _loadoutToRename = (_data select {_x select 0 == _loadoutName}) select 0; +(_contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab))) params ["_loadout", "_nullItemsAmount", "_unavailableItemsAmount", "_nullItemsList", "_unavailableItemsList"]; + +_data set [_data find _loadoutToRename, [_editBoxContent, (_loadoutToRename select 1)]]; +_contentPanelCtrl setVariable [_loadoutName + str GVAR(currentLoadoutsTab), nil]; +_contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), [_loadout, _nullItemsAmount, _unavailableItemsAmount, _nullItemsList, _unavailableItemsList]]; + +// Add new row +_contentPanelCtrl lnbDeleteRow _curSelRow; +private _newRow = _contentPanelCtrl lnbAddRow ["",_editBoxContent]; + +ADD_LOADOUTS_LIST_PICTURES + +if (_nullItemsAmount > 0) then { + + _contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 0, 0, 0.8]]; +} else { + + if (_unavailableItemsAmount > 0) then { + _contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 1, 1, 0.25]]; + }; +}; + +// Sort and select the current row +_contentPanelCtrl lnbSort [1, false]; +for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do { + if ((_contentPanelCtrl lnbText [_i, 1]) == _editBoxContent) exitwith {_contentPanelCtrl lnbSetCurSelRow _i}; +}; + +if (is3DEN && {GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts}) then { + set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]]; +}; + +[(findDisplay IDD_ace_arsenal), [_loadoutName, localize LSTRING(loadoutRenamed) ,_editBoxContent] joinString " "] call FUNC(message); diff --git a/addons/arsenal/functions/fnc_buttonLoadoutsSave.sqf b/addons/arsenal/functions/fnc_buttonLoadoutsSave.sqf new file mode 100644 index 0000000000..fecb6300e3 --- /dev/null +++ b/addons/arsenal/functions/fnc_buttonLoadoutsSave.sqf @@ -0,0 +1,288 @@ +/* + * Author: Alganthe + * Save selected loadout. + * + * Arguments: + * 0: Arsenal display + * 1: Button control + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control"]; + +if !(ctrlEnabled _control) exitWith {}; + +private _editBoxCtrl = _display displayCtrl IDC_textEditBox; +private _editBoxContent = ctrlText _editBoxCtrl; + +if (_editBoxContent == "") exitWith { + [(findDisplay IDD_ace_arsenal), localize LSTRING(saveEmptyNameBox)] call FUNC(message); +}; + +private _data = [+(profileNamespace getVariable [QGVAR(saved_loadouts),[]]), +(GVAR(defaultLoadoutsList))] select (GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts && {is3DEN}); +private _contentPanelCtrl = _display displayCtrl IDC_contentPanel; +private _cursSelRow = lnbCurSelRow _contentPanelCtrl; + +private _loadoutName = _contentPanelCtrl lnbText [_cursSelRow, 1]; +private _curSelLoadout = (_contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab))) select 0; +private _loadout = getUnitLoadout GVAR(center); + +private _sameNameLoadoutsList = _data select {_x select 0 == _editBoxContent}; +private _sharedLoadoutsVars = GVAR(sharedLoadoutsNamespace) getVariable QGVAR(sharedLoadoutsVars); + +// Make sure the loadout isn't yours (public tab) or being shared (my loadouts tab) +private _similarSharedLoadout = (profileName + _editBoxContent) in _sharedLoadoutsVars; +if ((_contentPanelCtrl lnbText [_cursSelRow, 0]) == profileName) exitWith { + [(findDisplay IDD_ace_arsenal), localize LSTRING(saveAuthorError)] call FUNC(message); +}; + +if (_similarSharedLoadout) exitWith { + [(findDisplay IDD_ace_arsenal), localize LSTRING(saveSharedError)] call FUNC(message); +}; + +switch (GVAR(currentLoadoutsTab)) do { + case IDC_buttonMyLoadouts:{ + + 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) then { + + if ((_x select 0) isEqualType "") then { + + private _item = (_x select 0); + if (_item != "") then { + + private _uniqueBaseCfgText = getText (configFile >> "CfgWeapons" >> _item >> "ace_arsenal_uniqueBase"); + if (_uniqueBaseCfgText != "") then { + + _x set [0, _uniqueBaseCfgText]; + }; + }; + } else { + 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; + }; + }; + }; + + case 9: { + for "_subIndex" from 0 to 4 do { + private _item = (_loadout select _dataIndex) select _subIndex; + + if (_item != "") then { + + private _uniqueBaseCfgText = getText (configFile >> "CfgWeapons" >> _item >> "ace_arsenal_uniqueBase"); + if (_uniqueBaseCfgText != "") then { + + (_loadout select _dataIndex) set [_subIndex, _uniqueBaseCfgText]; + }; + }; + }; + }; + }; + }; + + if (count _sameNameLoadoutsList == 0) then { + _data pushBack [_editBoxContent, _loadout]; + } else { + _data set [_data find (_sameNameLoadoutsList select 0), [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _loadout]]; + }; + + // Delete "old" loadout row + 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]; + + ADD_LOADOUTS_LIST_PICTURES + + _contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), [_loadout] call FUNC(verifyLoadout)]; + + _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}; + }; + + profileNamespace setVariable [QGVAR(saved_loadouts), _data]; + }; + + case IDC_buttonDefaultLoadouts:{ + + if (is3DEN) then { + + private _sameNameLoadoutsList = _data select {_x select 0 == _editBoxContent}; + + 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) then { + + if ((_x select 0) isEqualType "") then { + + private _item = (_x select 0); + if (_item != "") then { + + private _uniqueBaseCfgText = getText (configFile >> "CfgWeapons" >> _item >> "ace_arsenal_uniqueBase"); + if (_uniqueBaseCfgText != "") then { + + _x set [0, _uniqueBaseCfgText]; + }; + }; + } else { + 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; + }; + }; + }; + + case 9: { + for "_subIndex" from 0 to 4 do { + private _item = (_loadout select _dataIndex) select _subIndex; + + if (_item != "") then { + + private _uniqueBaseCfgText = getText (configFile >> "CfgWeapons" >> _item >> "ace_arsenal_uniqueBase"); + if (_uniqueBaseCfgText != "") then { + + (_loadout select _dataIndex) set [_subIndex, _uniqueBaseCfgText]; + }; + }; + }; + }; + }; + }; + + if (count _sameNameLoadoutsList == 0) then { + GVAR(defaultLoadoutsList) pushBack [_editBoxContent, _loadout]; + } else { + GVAR(defaultLoadoutsList) set [GVAR(defaultLoadoutsList) find (_sameNameLoadoutsList select 0), [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _loadout]]; + }; + + 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]; + + ADD_LOADOUTS_LIST_PICTURES + + _contentPanelCtrl setVariable [_editBoxContent + str GVAR(currentLoadoutsTab), [_loadout] call FUNC(verifyLoadout)]; + + _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}; + }; + + set3DENMissionAttributes [[QGVAR(DummyCategory), QGVAR(DefaultLoadoutsListAttribute), GVAR(defaultLoadoutsList)]]; + } else { + + if (count _sameNameLoadoutsList == 0) then { + _data pushBack [_editBoxContent, _curSelLoadout]; + } else { + _data set [_data find (_sameNameLoadoutsList select 0), [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _curSelLoadout]]; + _contentPanelCtrl setVariable [_editBoxContent + str IDC_buttonMyLoadouts, [_curSelLoadout] call FUNC(verifyLoadout)]; + }; + + profileNamespace setVariable [QGVAR(saved_loadouts), _data]; + }; + }; + + case IDC_buttonSharedLoadouts :{ + + _loadout = (GVAR(sharedLoadoutsNamespace) getVariable ((_contentPanelCtrl lnbText [_cursSelRow, 0]) + (_contentPanelCtrl lnbText [_cursSelRow, 1]))) select 2; + + if (count _sameNameLoadoutsList == 0) then { + _data pushBack [_editBoxContent, _loadout]; + } else { + _data set [_data find (_sameNameLoadoutsList select 0), [[_editBoxContent, _loadoutName] select (_loadoutName isEqualTo _editBoxContent), _loadout]]; + _contentPanelCtrl setVariable [_editBoxContent + str IDC_buttonMyLoadouts, [_loadout] call FUNC(verifyLoadout)]; + }; + + profileNamespace setVariable [QGVAR(saved_loadouts), _data]; + }; +}; +[(findDisplay IDD_ace_arsenal), [localize LSTRING(loadoutSaved), _editBoxContent] joinString " "] call FUNC(message); +private _savedLoadout = (_data select {_x select 0 == _editBoxContent}) select 0; +[QGVAR(onLoadoutSave), [_data find _savedLoadout, _savedLoadout]] call CBA_fnc_localEvent; diff --git a/addons/arsenal/functions/fnc_buttonLoadoutsShare.sqf b/addons/arsenal/functions/fnc_buttonLoadoutsShare.sqf new file mode 100644 index 0000000000..d167522823 --- /dev/null +++ b/addons/arsenal/functions/fnc_buttonLoadoutsShare.sqf @@ -0,0 +1,55 @@ +/* + * Author: Alganthe + * Share selected loadout. + * + * Arguments: + * 0: Arsenal display + * 1: Button control + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control"]; + +if !(ctrlEnabled _control) exitWith {}; + +private _contentPanelCtrl = _display displayCtrl IDC_contentPanel; +private _contentPanelCursSel = lnbCurSelRow _contentPanelCtrl; +private _loadoutName = _contentPanelCtrl lnbText [_contentPanelCursSel, 1]; +private _profileName = profileName; // GVAR(center) could be a remote unit +private _loadoutVar = _profileName + _loadoutName; +private _sharedLoadoutsVars = +(GVAR(sharedLoadoutsNamespace) getVariable QGVAR(sharedLoadoutsVars)); + +private _loadoutIndex = _sharedLoadoutsVars find _loadoutVar; +private _loadoutData = (_contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab))) select 0; + +// Loadout set to private +if (_loadoutIndex > -1) then { + GVAR(sharedLoadoutsNamespace) setVariable [_loadoutVar, nil, true]; + GVAR(sharedLoadoutsNamespace) setVariable [QGVAR(sharedLoadoutsVars), _sharedLoadoutsVars - [_loadoutVar], true]; + + _contentPanelCtrl lnbSetPicture [[_contentPanelCursSel, 0], QPATHTOF(data\iconPublicBlank.paa)]; + _contentPanelCtrl lnbSetValue [[_contentPanelCursSel, 0], 0]; + [QGVAR(loadoutUnshared), [_contentPanelCtrl, profileName, _loadoutName]] call CBA_fnc_remoteEvent; + +// Loadout set to public +} else { + GVAR(sharedLoadoutsNamespace) setVariable [_loadoutVar, [_profileName ,_loadoutName , _loadoutData], true]; + _sharedLoadoutsVars pushBackUnique _loadoutVar; + GVAR(sharedLoadoutsNamespace) setVariable [QGVAR(sharedLoadoutsVars), _sharedLoadoutsVars, true]; + + _contentPanelCtrl lnbSetPicture [[_contentPanelCursSel, 0], QPATHTOF(data\iconPublic.paa)]; + _contentPanelCtrl lnbSetValue [[_contentPanelCursSel, 0], 1]; + [QGVAR(loadoutShared), [_contentPanelCtrl, [_profileName ,_loadoutName , _loadoutData]]] call CBA_fnc_remoteEvent; +}; + +// Update share button text +_control ctrlSetText ( [ + localize LSTRING(buttonSharePrivateText), + localize LSTRING(buttonSharePublicText) +] select ((_contentPanelCtrl lnbValue [_contentPanelCursSel, 0]) == 1)); diff --git a/addons/arsenal/functions/fnc_clearSearchbar.sqf b/addons/arsenal/functions/fnc_clearSearchbar.sqf new file mode 100644 index 0000000000..c417b6d1a4 --- /dev/null +++ b/addons/arsenal/functions/fnc_clearSearchbar.sqf @@ -0,0 +1,28 @@ +/* + * Author: Alganthe + * Clear the provided searchbar. + * + * Arguments: + * 0: Arsenal display + * 1: Searchbar control + * 2: Right button state + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control", "_rightButton"]; + +if (_rightButton != 1) exitWith {}; + +_control ctrlSetText ''; + +if (ctrlIDC _control == IDC_leftSearchbar) then { + [_display, _display displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel); +} else { + [_display, _display displayCtrl GVAR(currentRightPanel)] call FUNC(fillRightPanel); +}; diff --git a/addons/arsenal/functions/fnc_fillLeftPanel.sqf b/addons/arsenal/functions/fnc_fillLeftPanel.sqf new file mode 100644 index 0000000000..83a4336ea0 --- /dev/null +++ b/addons/arsenal/functions/fnc_fillLeftPanel.sqf @@ -0,0 +1,189 @@ +/* + * Author: Alganthe + * Fill left panel. + * + * Arguments: + * 0: Arsenal display + * 1: Tab control + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control"]; + +private _ctrlIDC = ctrlIDC _control; + +if !(isNil QGVAR(currentLeftPanel)) then { + private _previousCtrlBackground = _display displayCtrl (GVAR(currentLeftPanel) - 1); + _previousCtrlBackground ctrlSetFade 1; + _previousCtrlBackground ctrlCommit FADE_DELAY; +}; + +private _ctrlBackground = _display displayCtrl (_ctrlIDC - 1); +private _ctrlPanel = _display displayCtrl IDC_leftTabContent; +_ctrlBackground ctrlSetFade 0; +_ctrlBackground ctrlCommit FADE_DELAY; + +_ctrlPanel lbSetCurSel -1; + +// Handle icons and filling +switch true do { + case (_ctrlIDC in [IDC_buttonPrimaryWeapon, IDC_buttonHandgun, IDC_buttonSecondaryWeapon]) : { + // Purge old data + lbClear _ctrlPanel; + private _addEmpty = _ctrlPanel lbadd format [" <%1>",localize "str_empty"]; + _ctrlPanel lbsetvalue [_addEmpty, -1]; + + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach ((GVAR(virtualItems) select 0) select ([IDC_buttonPrimaryWeapon, IDC_buttonSecondaryWeapon, IDC_buttonHandgun] find _ctrlIDC)); + }; + + case (_ctrlIDC in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack]) : { + + lbClear _ctrlPanel; + private _addEmpty = _ctrlPanel lbadd format [" <%1>",localize "str_empty"]; + _ctrlPanel lbsetvalue [_addEmpty, -1]; + + // Filling + switch (_ctrlIDC) do { + case IDC_buttonUniform : { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (GVAR(virtualItems) select 4); + }; + + case IDC_buttonVest : { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (GVAR(virtualItems) select 5); + }; + + case IDC_buttonBackpack : { + { + ["CfgVehicles", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (GVAR(virtualItems) select 6); + }; + }; + }; + + default { + GVAR(currentRightPanel) = nil; + + lbClear _ctrlPanel; + + if !(_ctrlIDC in [IDC_buttonFace, IDC_buttonVoice]) then { + private _addEmpty = _ctrlPanel lbadd format [" <%1>",localize "str_empty"]; + _ctrlPanel lbsetvalue [_addEmpty, -1]; + }; + + switch (_ctrlIDC) do { + case IDC_buttonHeadgear: { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (GVAR(virtualItems) select 3); + }; + case IDC_buttonGoggles : { + { + ["CfgGlasses", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (GVAR(virtualItems) select 7); + }; + case IDC_buttonNVG : { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (GVAR(virtualItems) select 8); + }; + case IDC_buttonBinoculars : { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (GVAR(virtualItems) select 9); + }; + case IDC_buttonMap : { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (GVAR(virtualItems) select 10); + }; + case IDC_buttonCompass : { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (GVAR(virtualItems) select 11); + }; + case IDC_buttonRadio : { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (GVAR(virtualItems) select 12); + }; + case IDC_buttonWatch : { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (GVAR(virtualItems) select 13); + }; + case IDC_buttonGPS : { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (GVAR(virtualItems) select 14); + }; + case IDC_buttonFace : { + { + { + if ( + getnumber (_x >> "disabled") == 0 && + {getText (_x >> "head") != ""} && + {configName _x != "Default"} + ) then { + private _configName = configName _x; + private _displayName = getText (_x >> "displayName"); + private _lbAdd = _ctrlPanel lbAdd _displayName; + _ctrlPanel lbSetData [_lbAdd, _configName]; + _ctrlPanel lbSetTooltip [_lbAdd,format ["%1\n%2",_displayName, _configName]]; + _x call ADDMODICON; + }; + } foreach ("isClass _x" configClasses _x); + } foreach ("isClass _x" configClasses (configfile >> "cfgfaces")); + }; + case IDC_buttonVoice : { + private _voices = (configProperties [(configFile >> "CfgVoice"), "isClass _x && {getNumber (_x >> 'scope') == 2}", true]) - [(configfile >> "CfgVoice" >> "NoVoice")]; + { + ["CfgVoice", configName _x, _ctrlPanel, "icon"] call FUNC(addListBoxItem); + } foreach _voices; + }; + case IDC_buttonInsigna : { + { + ["CfgUnitInsignia", configName _x, _ctrlPanel, "texture"] call FUNC(addListBoxItem); + } foreach ("true" configClasses (configFile >> "CfgUnitInsignia")); + }; + }; + }; +}; + +// Done +if (GVAR(currentLeftPanel) != _ctrlIDC) then { + (_display displayCtrl IDC_leftSearchbar) ctrlSetText ""; + (_display displayCtrl IDC_rightSearchbar) ctrlSetText ""; +}; + +GVAR(currentLeftPanel) = _ctrlIDC; +[QGVAR(leftPanelFilled), [_display, _ctrlIDC, GVAR(currentRightPanel)]] call CBA_fnc_localEvent; + +// Sort +private _sortLeftCtrl = _display displayCtrl IDC_sortLeftTab; +[_sortLeftCtrl, _sortLeftCtrl lbValue (lbCurSel _sortLeftCtrl)] call FUNC(sortPanel); + +//Select current item +private _itemsToCheck = ((GVAR(currentItems) select [0,15]) + [GVAR(currentFace), GVAR(currentVoice), GVAR(currentInsignia)]) apply {tolower _x}; + +for "_lbIndex" from 0 to (lbSize _ctrlPanel - 1) do { + private _currentData = _ctrlPanel lbData _lbIndex; + + if (!(_currentData isEqualTo "") && {tolower _currentData in _itemsToCheck}) exitWith { + _ctrlPanel lbSetCurSel _lbIndex; + }; +}; +if (lbCurSel _ctrlPanel < 0) then { + _ctrlPanel lbSetCurSel 0; +}; diff --git a/addons/arsenal/functions/fnc_fillLoadoutsList.sqf b/addons/arsenal/functions/fnc_fillLoadoutsList.sqf new file mode 100644 index 0000000000..118581c160 --- /dev/null +++ b/addons/arsenal/functions/fnc_fillLoadoutsList.sqf @@ -0,0 +1,118 @@ +/* + * Author: Alganthe + * Fill loadouts list. + * + * Arguments: + * 0: Loadouts display + * 1: Tab control + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control"]; + +private _contentPanelCtrl = _display displayCtrl IDC_contentPanel; +private _textEditBoxCtrl= _display displayCtrl IDC_textEditBox; +_textEditBoxCtrl ctrlSetText ""; +private _sharingEnabled = (GVAR(allowSharedLoadouts) && {isMultiplayer}); +private _sharedLoadoutsVars = GVAR(sharedLoadoutsNamespace) getVariable QGVAR(sharedLoadoutsVars); + +_contentPanelCtrl lnbSetCurSelRow -1; +lnbClear _contentPanelCtrl; + +private _data = +(profileNamespace getvariable [QGVAR(saved_loadouts),[]]); + +if (GVAR(currentLoadoutsTab) != IDC_buttonSharedLoadouts) then { + + { + _x params ["_loadoutName", "_loadoutData"]; + + private _loadoutCachedInfo = _contentPanelCtrl getVariable (_loadoutName + str GVAR(currentLoadoutsTab)); + + if (isNil "_loadoutCachedInfo") then { + [_loadoutData] call FUNC(verifyLoadout) + } else { + _loadoutCachedInfo + } params ["_loadout", "_nullItemsAmount", "_unavailableItemsAmount", "_nullItemsList", "_unavailableItemsList"]; + + // Log missing / nil items to RPT + if (GVAR(EnableRPTLog) && {isNil "_loadoutCachedInfo"} && {(_nullItemsAmount > 0) || {_unavailableItemsAmount > 0}}) then { + + private _printComponent = "ACE_Arsenal - Loadout:"; + private _printNullItemsList = ["Missing items:", str _nullItemsList] joinString " "; + private _printUnavailableItemsList = ["Unavailable items:", str _unavailableItemsList] joinString " "; + + diag_log text (format ["%1%5 %2%5 %3%5 %4", _printComponent, "Name: " + _loadoutName, _printNullItemsList, _printUnavailableItemsList, endl]); + }; + + if (GVAR(currentLoadoutsTab) == IDC_buttonDefaultLoadouts || {!_sharingEnabled}) then { + _contentPanelCtrl lnbSetColumnsPos [0, 0, 0.40, 0.50, 0.60, 0.70, 0.75, 0.80, 0.85, 0.90]; + } else { + _contentPanelCtrl lnbSetColumnsPos [0, 0.05, 0.40, 0.50, 0.60, 0.70, 0.75, 0.80, 0.85, 0.90]; + }; + + private _newRow = _contentPanelCtrl lnbAddRow ["",_loadoutName]; + + ADD_LOADOUTS_LIST_PICTURES + + if (_nullItemsAmount > 0) then { + + _contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 0, 0, 0.8]]; + } else { + + if (_unavailableItemsAmount > 0) then { + _contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 1, 1, 0.25]]; + }; + }; + + _contentPanelCtrl setVariable [_loadoutName + str GVAR(currentLoadoutsTab), [_loadout, _nullItemsAmount, _unavailableItemsAmount, _nullItemsList, _unavailableItemsList]]; + + if ((profileName + _loadoutName) in _sharedLoadoutsVars && {GVAR(currentLoadoutsTab) == IDC_buttonMyLoadouts}) then { + _contentPanelCtrl lnbSetPicture [[_newRow, 0], QPATHTOF(data\iconPublic.paa)]; + _contentPanelCtrl lnbSetValue [[_newRow, 0], 1]; + }; + } foreach ([_data, +GVAR(defaultLoadoutsList)] select (ctrlIDC _control == IDC_buttonDefaultLoadouts)); +} else { + + { + _x params ["_playerName", "_loadoutName", "_loadoutData"]; + + if ((allPlayers apply {name _x}) find _playerName == -1) then { + + private _loadoutVar = _playerName + _loadoutName; + + GVAR(sharedLoadoutsNamespace) setVariable [_loadoutVar, nil, true]; + _sharedLoadoutsVars = _sharedLoadoutsVars - [_loadoutVar]; + GVAR(sharedLoadoutsNamespace) setVariable [QGVAR(sharedLoadoutsNamespace), _sharedLoadoutsVars, true]; + + [QGVAR(loadoutUnshared), [_contentPanelCtrl, profileName, _loadoutName]] call CBA_fnc_remoteEvent; + } else { + + ([_loadoutData] call FUNC(verifyLoadout)) params ["_loadout", "_nullItemsAmount", "_unavailableItemsAmount"]; + + _contentPanelCtrl lnbSetColumnsPos [0, 0.15, 0.40, 0.50, 0.60, 0.70, 0.75, 0.80, 0.85, 0.90]; + private _newRow = _contentPanelCtrl lnbAddRow [_playerName, _loadoutName]; + + ADD_LOADOUTS_LIST_PICTURES + + _contentPanelCtrl lnbSetData [[_newRow, 1], _playerName + _loadoutName]; + + if (_nullItemsAmount > 0) then { + + _contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 0, 0, 0.8]]; + } else { + + if (_unavailableItemsAmount > 0) then { + _contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 1, 1, 0.25]]; + }; + }; + }; + } foreach (_sharedLoadoutsVars apply {GVAR(sharedLoadoutsNamespace) getVariable _x}); +}; + +_contentPanelCtrl lnbSort [1, false]; diff --git a/addons/arsenal/functions/fnc_fillRightPanel.sqf b/addons/arsenal/functions/fnc_fillRightPanel.sqf new file mode 100644 index 0000000000..99194b065e --- /dev/null +++ b/addons/arsenal/functions/fnc_fillRightPanel.sqf @@ -0,0 +1,361 @@ +/* + * Author: Alganthe + * Fill right panel. + * + * Arguments: + * 0: Arsenal display + * 1: Tab control + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control"]; + +private _ctrlIDC = ctrlIDC _control; + +// Fade old control background +if !(isNil QGVAR(currentRightPanel)) then { + private _previousCtrlBackground = _display displayCtrl (GVAR(currentRightPanel) - 1); + _previousCtrlBackground ctrlSetFade 1; + _previousCtrlBackground ctrlCommit FADE_DELAY; +}; + +// Show new control background +private _ctrlBackground = _display displayCtrl (_ctrlIDC - 1); +_ctrlBackground ctrlShow true; +_ctrlBackground ctrlSetFade 0; +_ctrlBackground ctrlCommit FADE_DELAY; + +private _searchbarCtrl = _display displayCtrl IDC_rightSearchbar; + +if (!(ctrlShown _searchbarCtrl) || {ctrlFade _searchbarCtrl > 0}) then { + _searchbarCtrl ctrlShow true; + _searchbarCtrl ctrlSetFade 0; + _searchbarCtrl ctrlCommit 0; +}; + +private _fnc_fill_right_Container = { + params ["_configCategory", "_className", "_isMagazine", ["_isUnique", false, [false]]]; + + private _cacheNamespace = _ctrlPanel; + private _cachedItemInfo = _cacheNamespace getVariable [_configCategory+_className, []]; + + // Not in cache. So get info and put into cache + if (_cachedItemInfo isEqualTo []) then { + private _configPath = configFile >> _configCategory >> _className; + + _cachedItemInfo set [0, getText (_configPath >> "displayName")]; + _cachedItemInfo set [1, getText (_configPath >> "picture")]; + _cachedItemInfo set [2, [getNumber (_configPath >> "itemInfo" >> "mass"), getNumber (_configPath >> "mass")] select _isMagazine]; + + _cacheNamespace setVariable [_configCategory+_className, _cachedItemInfo]; + }; + + _cachedItemInfo params ["_displayName","_picture", "_mass"]; + + private _lbAdd = _ctrlPanel lnbAddRow ["", _displayName, "0"]; + private _columns = count lnbGetColumnsPosition _ctrlPanel; + + _ctrlPanel lnbSetData [[_lbAdd, 0], _x]; + _ctrlPanel lnbSetPicture [[_lbAdd, 0], _picture]; + _ctrlPanel lnbSetValue [[_lbAdd, 0], _mass]; + _ctrlPanel setVariable [_x, _mass]; + _ctrlPanel lnbSetValue [[_lbAdd, 2], [0, 1] select (_isUnique)]; + _ctrlPanel lbSetTooltip [_lbAdd * _columns,format ["%1\n%2", _displayName, _x]]; +}; + +// Retrieve compatible mags +private _compatibleItems = []; +private _compatibleMagazines = [[[], []], [[], []], [[], []]]; +{ + if (_x != "") then { + private _weaponConfig = (configFile >> "CfgWeapons" >> _x); + private _index = _forEachIndex; + + { + private _subIndex = _forEachIndex; + { + // Magazine group + if !(isClass (configFile >> "CfgMagazines" >> _x)) then { + private _magazineGroups = uiNamespace getVariable [QGVAR(magazineGroups),["#CBA_HASH#",[],[],[]]]; + private _magArray = [_magazineGroups, _x] call CBA_fnc_hashGet; + {((_compatibleMagazines select _index) select _subIndex) pushBackUnique _x} forEach _magArray; + } else { + ((_compatibleMagazines select _index) select _subIndex) pushBackUnique _x + } + } foreach ([getArray (_weaponConfig >> _x >> "magazines"), getArray (_weaponConfig >> "magazines")] select (_x == "this")); + } foreach getArray (_weaponConfig >> "muzzles"); + }; +} foreach [primaryWeapon GVAR(center), handgunWeapon GVAR(center), secondaryWeapon GVAR(center)]; + +private _itemsToCheck = []; +private _compatibleMagsPrimaryMuzzle = []; +private _compatibleMagsSecondaryMuzzle = []; + +private _allCompatibleMags = []; +{ + _allCompatibleMags append (_x select 0); + _allCompatibleMags append (_x select 1); +} foreach _compatibleMagazines; + +private _ctrlPanel = _display displayCtrl IDC_rightTabContent; + +switch (GVAR(currentLeftPanel)) do { + case IDC_buttonPrimaryWeapon : { + _compatibleMagsPrimaryMuzzle = _compatibleMagazines select 0 select 0; + _compatibleMagsSecondaryMuzzle = _compatibleMagazines select 0 select 1; + _compatibleItems = (primaryWeapon GVAR(center)) call bis_fnc_compatibleItems; + _itemsToCheck = GVAR(currentItems) select 18; + }; + + case IDC_buttonHandgun : { + _compatibleMagsPrimaryMuzzle = _compatibleMagazines select 1 select 0; + _compatibleMagsSecondaryMuzzle = _compatibleMagazines select 1 select 1; + _compatibleItems = (handgunWeapon GVAR(center)) call bis_fnc_compatibleItems; + _itemsToCheck = GVAR(currentItems) select 20; + }; + + case IDC_buttonSecondaryWeapon : { + _compatibleMagsPrimaryMuzzle = _compatibleMagazines select 2 select 0; + _compatibleMagsSecondaryMuzzle = _compatibleMagazines select 2 select 1; + _compatibleItems = (secondaryWeapon GVAR(center)) call bis_fnc_compatibleItems; + _itemsToCheck = GVAR(currentItems) select 19; + }; + + case IDC_buttonUniform; + case IDC_buttonVest; + case IDC_buttonBackpack : { + _ctrlPanel = _display displayCtrl IDC_rightTabContentListnBox; + }; +}; + +_itemsToCheck = _itemsToCheck apply {toLower _x}; +_compatibleItems = _compatibleItems apply {toLower _x}; + +lbClear (_display displayCtrl IDC_rightTabContentListnBox); +lbClear (_display displayCtrl IDC_rightTabContent); + +(_display displayCtrl IDC_rightTabContentListnBox) lbSetCurSel -1; +(_display displayCtrl IDC_rightTabContent) lbSetCurSel -1; + +private _leftPanelState = GVAR(currentLeftPanel) in [IDC_buttonPrimaryWeapon, IDC_buttonHandgun, IDC_buttonSecondaryWeapon]; + +if (_ctrlIDC in [RIGHT_PANEL_ACC_IDCS, IDC_buttonCurrentMag, IDC_buttonCurrentMag2] && {_leftPanelState}) then { + private _addEmpty = _ctrlPanel lbadd format [" <%1>",localize "str_empty"]; + _ctrlPanel lbsetvalue [_addEmpty, -1]; +}; + +switch (_ctrlIDC) do { + + case IDC_buttonOptic : { + if (_leftPanelState) then { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (_compatibleItems arrayIntersect (((GVAR(virtualItems) select 1) select 0) apply {toLower _x})); + } else { + { + ["CfgWeapons", _x, false] call _fnc_fill_right_Container; + } foreach ((GVAR(virtualItems) select 1) select 0); + { + ["CfgWeapons", _x, false, true] call _fnc_fill_right_Container; + } foreach ((GVAR(virtualItems) select 22) select 0); + }; + }; + + case IDC_buttonItemAcc : { + if (_leftPanelState) then { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (_compatibleItems arrayIntersect (((GVAR(virtualItems) select 1) select 1) apply {toLower _x})); + } else { + { + ["CfgWeapons", _x, false] call _fnc_fill_right_Container; + } foreach ((GVAR(virtualItems) select 1) select 1); + { + ["CfgWeapons", _x, false, true] call _fnc_fill_right_Container; + } foreach ((GVAR(virtualItems) select 22) select 1); + }; + }; + + case IDC_buttonMuzzle : { + if (_leftPanelState) then { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (_compatibleItems arrayIntersect (((GVAR(virtualItems) select 1) select 2) apply {toLower _x})); + } else { + { + ["CfgWeapons", _x, false] call _fnc_fill_right_Container; + } foreach ((GVAR(virtualItems) select 1) select 2); + { + ["CfgWeapons", _x, false, true] call _fnc_fill_right_Container; + } foreach ((GVAR(virtualItems) select 22) select 2); + }; + }; + + case IDC_buttonBipod : { + if (_leftPanelState) then { + { + ["CfgWeapons", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach (_compatibleItems arrayIntersect (((GVAR(virtualItems) select 1) select 3) apply {toLower _x})); + } else { + { + ["CfgWeapons", _x, false] call _fnc_fill_right_Container; + } foreach ((GVAR(virtualItems) select 1) select 3); + { + ["CfgWeapons", _x, false, true] call _fnc_fill_right_Container; + } foreach ((GVAR(virtualItems) select 22) select 3); + }; + }; + + case IDC_buttonCurrentMag : { + if (_leftPanelState) then { + { + ["CfgMagazines", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach ((GVAR(virtualItems) select 2) arrayIntersect _compatibleMagsPrimaryMuzzle); + }; + }; + + case IDC_buttonCurrentMag2 : { + if (_leftPanelState) then { + { + ["CfgMagazines", _x, _ctrlPanel] call FUNC(addListBoxItem); + } foreach ((GVAR(virtualItems) select 2) arrayIntersect _compatibleMagsSecondaryMuzzle); + }; + }; + + case IDC_buttonMag : { + { + ["CfgMagazines", _x, true] call _fnc_fill_right_Container; + } foreach ((GVAR(virtualItems) select 2) arrayIntersect _allCompatibleMags); + { + ["CfgMagazines", _x, true, true] call _fnc_fill_right_Container; + } foreach ((GVAR(virtualItems) select 19) arrayIntersect _allCompatibleMags); + }; + + case IDC_buttonMagALL : { + { + ["CfgMagazines", _x, true] call _fnc_fill_right_Container; + } foreach (GVAR(virtualItems) select 2); + { + ["CfgMagazines", _x, true, true] call _fnc_fill_right_Container; + } foreach (GVAR(virtualItems) select 19); + }; + + case IDC_buttonThrow : { + { + ["CfgMagazines", _x, true] call _fnc_fill_right_Container; + } foreach (GVAR(virtualItems) select 15); + { + ["CfgMagazines", _x, true, true] call _fnc_fill_right_Container; + } foreach (GVAR(virtualItems) select 20); + }; + + case IDC_buttonPut : { + { + ["CfgMagazines", _x, true] call _fnc_fill_right_Container; + } foreach (GVAR(virtualItems) select 16); + { + ["CfgMagazines", _x, true, true] call _fnc_fill_right_Container; + } foreach (GVAR(virtualItems) select 21); + }; + + case IDC_buttonMisc : { + { + ["CfgWeapons", _x, false] call _fnc_fill_right_Container; + } foreach (GVAR(virtualItems) select 17); + { + ["CfgWeapons", _x, false, true] call _fnc_fill_right_Container; + } foreach (GVAR(virtualItems) select 18); + { + ["CfgVehicles", _x, false, true] call _fnc_fill_right_Container; + } foreach (GVAR(virtualItems) select 23); + { + ["CfgGlasses", _x, false, true] call _fnc_fill_right_Container; + } foreach (GVAR(virtualItems) select 24); + }; +}; + +if (GVAR(currentRightPanel) != _ctrlIDC) then { + (_display displayCtrl IDC_rightSearchbar) ctrlSetText ""; +}; + +GVAR(currentRightPanel) = _ctrlIDC; + +[QGVAR(rightPanelFilled), [_display, GVAR(currentLeftPanel), _ctrlIDC]] call CBA_fnc_localEvent; + +// Add current items and change progress bar +if (GVAR(currentLeftPanel) in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack]) then { + + private _maxLoad = 0; + private _container = switch (GVAR(currentLeftPanel)) do { + case IDC_buttonUniform : { + (_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadUniform GVAR(center)); + _maxLoad = gettext (configfile >> "CfgWeapons" >> uniform GVAR(center) >> "ItemInfo" >> "containerClass"); + uniformItems GVAR(center) + }; + case IDC_buttonVest : { + (_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadVest GVAR(center)); + _maxLoad = gettext (configfile >> "CfgWeapons" >> vest GVAR(center) >> "ItemInfo" >> "containerClass"); + vestItems GVAR(center) + }; + case IDC_buttonBackpack : { + (_display displayCtrl IDC_loadIndicatorBar) progressSetPosition (loadBackpack GVAR(center)); + _maxLoad = backpack GVAR(center); + backpackItems GVAR(center) + }; + }; + + for "_l" from 0 to ((lnbsize _ctrlPanel select 0) - 1) do { + private _class = _ctrlPanel lnbData [_l, 0]; + _ctrlPanel lnbSetText [[_l, 2], ["0", str ({_x == _class} count _container)] select (_class in _container)]; + }; + + [_ctrlPanel, _maxLoad] call FUNC(updateRightPanel); +}; + +// Sorting +private _sortRightCtrl = _display displayCtrl IDC_sortRightTab; +private _sortRightCurSel = lbCurSel _sortRightCtrl; + +if (lbSize _sortRightCtrl == 3) then { + _sortRightCtrl lbDelete 2; +}; + +if (_leftPanelState) then { + _sortRightCtrl lbDelete 1; + _sortRightCtrl lbAdd (localize "STR_a3_rscdisplayarsenal_sort_mod"); + _sortRightCtrl lbSetValue [1, 1]; + + _sortRightCtrl lbSetCurSel ([0, _sortRightCurSel] select (_sortRightCurSel != 2)); +} else { + _sortRightCtrl lbDelete 1; + _sortRightCtrl lbAdd localize LSTRING(sortByWeightText); + _sortRightCtrl lbSetValue [1, 1]; + + _sortRightCtrl lbAdd localize LSTRING(sortByAmountText); + _sortRightCtrl lbSetValue [2, 2]; + + _sortRightCtrl lbSetCurSel _sortRightCurSel; +}; + +[_sortRightCtrl, _sortRightCtrl lbValue (lbCurSel _sortRightCtrl)] call FUNC(sortPanel); + +// Select current data if not in a container +if !(_itemsToCheck isEqualTo []) then { + for "_lbIndex" from 0 to (lbSize _ctrlPanel - 1) do { + private _currentData = _ctrlPanel lbData _lbIndex; + + if ((_currentData != "") && {tolower _currentData in _itemsToCheck}) exitWith { + _ctrlPanel lbSetCurSel _lbIndex; + }; + }; + + if (lbCurSel _ctrlPanel < 0) then { + _ctrlPanel lbSetCurSel 0; + }; +}; diff --git a/addons/arsenal/functions/fnc_handleMouse.sqf b/addons/arsenal/functions/fnc_handleMouse.sqf new file mode 100644 index 0000000000..16548f3985 --- /dev/null +++ b/addons/arsenal/functions/fnc_handleMouse.sqf @@ -0,0 +1,73 @@ +/* + * Author: Karel Moricky, modified by Alganthe + * Update the camera position and pitch/bank. + * Modernized a bit, modified to fit the rewrite. + * + * Arguments: + * 0: Not used + * 1: Arguments + * 1.1: Mouse area control + * 1.2: Mouse X position + * 1.3: Mouse Y position + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["", "_args"]; + +_args params ["_control", "_mouseX", "_mouseY"]; +GVAR(cameraPosition) params ["_distance", "_dirH", "_dirV", "_helperPos"]; +GVAR(mouseButtonState) params ["_LMB", "_RMB"]; + +if (count _LMB > 0) then { + _LMB params ["_LMBcursorX", "_LMBcursorY"]; + private _dX = [(_mouseX - _LMBcursorX), (_LMBcursorX - _mouseX)] select GVAR(camInverted); + private _dY = [(_mouseY -_LMBcursorY), (_LMBcursorY - _mouseY)] select GVAR(camInverted); + GVAR(mouseButtonState) set [0,[_mouseX,_mouseY]]; + + private _centerBox = boundingboxreal GVAR(center); + private _centerSizeBottom = _centerBox select 0 select 2; + private _centerSizeUp = _centerBox select 1 select 2; + private _centerSize = sqrt ([_centerBox select 0 select 0,_centerBox select 0 select 1] distance [_centerBox select 1 select 0,_centerBox select 1 select 1]); + + _helperPos = [_helperPos, _dX * _centerSize, _dirH - 90] call bis_fnc_relpos; + _helperPos = [ + [0,0,((_helperPos select 2) - _dY * _centerSize) max _centerSizeBottom min _centerSizeUp], + ([0,0,0] distance2D _helperPos) min _centerSize, + [0,0,0] getDir _helperPos + ] call bis_fnc_relpos; + + _helperPos set [2,(_helperPos select 2) max ((boundingboxreal GVAR(center) select 0 select 2) + 0.2)]; + + //--- Do not let target go below ground + private _posZmin = 0.1; + private _targetWorldPosZ = (GVAR(center) modeltoworldvisual _helperPos) select 2; + if (_targetWorldPosZ < _posZmin) then {_helperPos set [2,(_helperPos select 2) - _targetWorldPosZ + _posZmin];}; + + GVAR(cameraPosition) set [3,_helperPos]; +}; + +if (count _RMB > 0) then { + _RMB params ["_RMBcursorX", "_RMBcursorY"]; + private _dX = (_RMBcursorX - _mouseX) * 0.75; + private _dY = (_RMBcursorY - _mouseY) * 0.75; + _helperPos = [ + [0,0,_helperPos select 2], + [0,0,0] distance2D _helperPos, + ([0,0,0] getDir _helperPos) - _dX * 360 + ] call bis_fnc_relpos; + + GVAR(cameraPosition) set [1,(_dirH - _dX * 360)]; + GVAR(cameraPosition) set [2,(_dirV - _dY * 100) max -89 min 89]; + GVAR(cameraPosition) set [3,_helperPos]; + GVAR(mouseButtonState) set [1,[_mouseX,_mouseY]]; +}; + +if (!alive (GVAR(center)) || isnull GVAR(center)) then { + (ctrlParent _control) closeDisplay 2; +}; diff --git a/addons/arsenal/functions/fnc_handleScrollWheel.sqf b/addons/arsenal/functions/fnc_handleScrollWheel.sqf new file mode 100644 index 0000000000..e7dc3bbc1e --- /dev/null +++ b/addons/arsenal/functions/fnc_handleScrollWheel.sqf @@ -0,0 +1,25 @@ +/* + * Author: Alganthe + * Handle the mouse wheel. + * + * Arguments: + * 0: Not used + * 1: Mousewheel Z position + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["", "_args"]; +_args params ["", "_zPos"]; + +private _distanceMax = ((boundingboxreal GVAR(center) select 0) vectordistance (boundingboxreal GVAR(center) select 1)) * 1.5; +private _distanceMin = _distanceMax * 0.15; +private _distance = GVAR(cameraPosition) select 0; + +_distance = (_distance - (_zPos / 10)) max _distanceMin min _distanceMax; +GVAR(cameraPosition) set [0, _distance]; diff --git a/addons/arsenal/functions/fnc_handleSearchbar.sqf b/addons/arsenal/functions/fnc_handleSearchbar.sqf new file mode 100644 index 0000000000..87b03d8c57 --- /dev/null +++ b/addons/arsenal/functions/fnc_handleSearchbar.sqf @@ -0,0 +1,92 @@ +/* + * Author: Alganthe + * Handles keyboard inputs inside the searchbars text boxes. + * + * Arguments: + * 0: Arsenal display + * 1: Searchbar control + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control"]; + +private _textString = ctrlText _control; + +if ((ctrlIDC _control) == IDC_rightSearchbar) then { + if !(GVAR(lastSearchTextRight) isEqualTo "" || {(_textString find GVAR(lastSearchTextRight)) == 0}) then {//don't refill if there is no need + [_display, _display displayCtrl GVAR(currentRightPanel)] call FUNC(fillRightPanel); + }; + GVAR(lastSearchTextRight) = _textString; + if (count _textString == 0) exitWith {}; + + private _rightPanelState = GVAR(currentLeftPanel) in [IDC_buttonPrimaryWeapon, IDC_buttonHandgun, IDC_buttonSecondaryWeapon]; + private _rightPanelCtrl = [_display displayCtrl IDC_rightTabContentListnBox, _display displayCtrl IDC_rightTabContent] select (_rightPanelState); + + if (_rightPanelState) then { + + private _itemsToGo = lbSize _rightPanelCtrl; + private _lbIndex = 0; + while {_itemsToGo > 0} do { + private _currentData = _rightPanelCtrl lbText _lbIndex; + private _currentClassname = _rightPanelCtrl lbData _lbIndex; + + if ((_currentData isEqualTo "") || {(((toUpper _currentData) find (toUpper _textString)) == -1) && {((toUpper _currentClassname) find (toUpper _textString)) == -1}}) then { + _rightPanelCtrl lbDelete _lbIndex; + } else { + _lbIndex = _lbIndex + 1; + }; + _itemsToGo = _itemsToGo - 1; + }; + _rightPanelCtrl lbSetCurSel -1; + } else { + + private _itemsToGo = (lnbSize _rightPanelCtrl) select 0; + private _lbIndex = 0; + while {_itemsToGo > 0} do { + private _currentData = _rightPanelCtrl lnbText [_lbIndex, 1]; + private _currentClassname = _rightPanelCtrl lnbData [_lbIndex, 0]; + + if ((_currentData isEqualTo "") || {(((toUpper _currentData) find (toUpper _textString)) == -1) && {((toUpper _currentClassname) find (toUpper _textString)) == -1}}) then { + _rightPanelCtrl lnbDeleteRow _lbIndex; + } else { + _lbIndex = _lbIndex + 1; + }; + _itemsToGo = _itemsToGo - 1; + }; + _rightPanelCtrl lnbSetCurSelRow -1; + }; + + [_display, nil, nil, configNull] call FUNC(itemInfo); +} else { + + if !(GVAR(lastSearchTextLeft) isEqualTo "" || {(_textString find GVAR(lastSearchTextLeft)) == 0}) then {//don't refill if there is no need + [_display, _display displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel); + }; + GVAR(lastSearchTextLeft) = _textString; + if (count _textString == 0) exitWith {}; + + private _leftPanelCtrl = _display displayCtrl IDC_leftTabContent; + + + private _itemsToGo = (lbSize _leftPanelCtrl); + private _lbIndex = 0; + while {_itemsToGo > 0} do { + private _currentData = _leftPanelCtrl lbText _lbIndex; + private _currentClassname = _leftPanelCtrl lbData _lbIndex; + + if ((_currentData isEqualTo "") || {(((toUpper _currentData) find (toUpper _textString)) == -1) && {((toUpper _currentClassname) find (toUpper _textString)) == -1}}) then { + _leftPanelCtrl lbDelete _lbIndex; + } else { + _lbIndex = _lbIndex + 1; + }; + _itemsToGo = _itemsToGo - 1; + }; + _leftPanelCtrl lbSetCurSel -1; + [_display, nil, nil, configNull] call FUNC(itemInfo); +}; diff --git a/addons/arsenal/functions/fnc_initBox.sqf b/addons/arsenal/functions/fnc_initBox.sqf new file mode 100644 index 0000000000..55c0ab653e --- /dev/null +++ b/addons/arsenal/functions/fnc_initBox.sqf @@ -0,0 +1,61 @@ +/* + * Author: Alganthe + * Initialize a box / object for arsenal. + * + * Arguments: + * 0: Target + * 1: Items or + * 2: Initialize globally + * + * Return Value: + * None + * + * Example: + * [_box, ["MyItem1", "MyItem2", "MyItemN"]] call ace_arsenal_fnc_initBox + * [_box, true] call ace_arsenal_fnc_initBox + * + * Public: Yes +*/ +#include "script_component.hpp" + +params [["_object", objNull, [objNull]], ["_items", true, [[], true]], ["_global", true, [true]]]; + +if (isNull _object) exitWith {}; + +if (isNil QGVAR(EHIDArray)) then { + GVAR(EHIDArray) = []; +}; + +if (_global && {isMultiplayer} && {{_object in _x} count GVAR(EHIDArray) == 0}) then { + + private _ID = [QGVAR(initBox), [_object, _items, false]] call CBA_fnc_globalEventJIP; + [_ID, _object] call CBA_fnc_removeGlobalEventJIP; + + GVAR(EHIDArray) pushBack [_ID, _object]; + publicVariable QGVAR(EHIDArray); +} else { + + if ({(_x select 0) select 0 isEqualTo QGVAR(interaction)} count (_object getVariable [QEGVAR(interact_menu,actions), []]) == 0) then { + + private _action = [ + QGVAR(interaction), + localize "STR_A3_Arsenal", + "", + { + params ["_target", "_player"]; + + [{[_this select 0, _this select 1] call FUNC(openBox)}, [_target, _player]] call CBA_fnc_execNextFrame; + }, + { + params ["_target", "_player"]; + + [_player, _target, ["isNotSwimming", "isNotCarrying", "isNotDragging", "notOnMap", "isNotEscorting", "isNotOnLadder"]] call EFUNC(common,canInteractWith) + }, + {}, + [] + ] call EFUNC(interact_menu,createAction); + [_object, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToObject); + + [_object, _items, false] call FUNC(addVirtualItems); + }; +}; diff --git a/addons/arsenal/functions/fnc_itemInfo.sqf b/addons/arsenal/functions/fnc_itemInfo.sqf new file mode 100644 index 0000000000..9dcfe2ea86 --- /dev/null +++ b/addons/arsenal/functions/fnc_itemInfo.sqf @@ -0,0 +1,75 @@ +/* + * Author: Alganthe + * Update arsenal's info box. + * + * Arguments: + * 0: Arsenal display + * 1: Current panel control + * 2: Current panel selection + * 3: Item config entry + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control", "_curSel" ,"_itemCfg"]; + +private _ctrlInfo = _display displayCtrl IDC_infoBox; + +if (isClass _itemCfg) then { + + _ctrlInfo ctrlSetFade 0; + _ctrlInfo ctrlCommit FADE_DELAY; + + // Name + author + private _ctrlInfoName = _display displayCtrl IDC_infoName; + _ctrlInfoName ctrlSetText ([_control lbText _curSel, _control lnbText [_curSel, 1]] select (ctrlType _control == 102)); + + private _ctrlInfoAuthor = _display displayctrl IDC_infoAuthor; + _ctrlInfoAuthor ctrlSetText ""; + + private _itemAuthor = getText (_itemCfg >> "author"); + _ctrlInfoAuthor ctrlSetText ([localize "STR_AUTHOR_UNKNOWN", format [localize "STR_FORMAT_AUTHOR_SCRIPTED",_itemAuthor]] select (_itemAuthor != "")); + + // DLC / mod icon + private _ctrlDLC = _display displayctrl IDC_DLCIcon; + private _ctrlDLCBackground = _display displayctrl IDC_DLCBackground; + private _dlc = _itemCfg call GETDLC; + if (_dlc != "") then { + + private _dlcParams = modParams [_dlc, ["name", "logo", "logoOver"]]; + _dlcParams params ["_name", "_logo", "_logoOver"]; + private _appId = getnumber (configfile >> "CfgMods" >> _dlc >> "appId"); + + _ctrlDLC ctrlsettooltip _name; + _ctrlDLC ctrlsettext _logo; + _ctrlDLCBackground ctrlsetfade 0; + _ctrlDLC ctrlsetfade 0; + if (_appId > 0) then { + _ctrlDLC ctrlseteventhandler ["mouseexit",format ["(_this select 0) ctrlsettext '%1';",_logo]]; + _ctrlDLC ctrlseteventhandler ["mouseenter",format ["(_this select 0) ctrlsettext '%1';",_logoOver]]; + _ctrlDLC ctrlseteventhandler [ + "buttonclick", + format ["uiNamespace setvariable ['RscDisplayDLCPreview_dlc','%1']; ctrlparent (_this select 0) createDisplay 'RscDisplayDLCPreview';", _dlc] + ]; + } else { + _ctrlDLC ctrlRemoveAllEventHandlers "buttonclick"; + _ctrlDLC ctrlRemoveAllEventHandlers "mouseexit"; + _ctrlDLC ctrlRemoveAllEventHandlers "mouseenter"; + }; + } else { + _ctrlDLC ctrlsetfade 1; + _ctrlDLCBackground ctrlsetfade 1; + }; + + _ctrlDLC ctrlcommit 0; + _ctrlDLCBackground ctrlcommit 0; + +} else { + _ctrlInfo ctrlSetFade 1; + _ctrlInfo ctrlCommit FADE_DELAY; +}; diff --git a/addons/arsenal/functions/fnc_loadoutsChangeTab.sqf b/addons/arsenal/functions/fnc_loadoutsChangeTab.sqf new file mode 100644 index 0000000000..7842df8704 --- /dev/null +++ b/addons/arsenal/functions/fnc_loadoutsChangeTab.sqf @@ -0,0 +1,77 @@ +/* + * Author: Alganthe + * Handles tab changing for the loadouts display. + * + * Arguments: + * 0: Arsenal display + * 1: Tab control + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control"]; + +if !(ctrlEnabled _control || {GVAR(currentLoadoutsTab) == ctrlIDC _control}) exitWith {}; + +private _centerBoxTitleCtrl = _display displayCtrl IDC_centerTitle; +private _shareButtonCtrl = _display displayCtrl IDC_buttonShare; +private _saveButtonCtrl = _display displayCtrl IDC_buttonSave; +private _loadButtonCtrl = _display displayCtrl IDC_buttonLoad; +private _deleteButtonCtrl = _display displayCtrl IDC_buttonDelete; +private _renameButtonCtrl = _display displayCtrl IDC_buttonRename; + +// Update UI visual elements +if (GVAR(currentLoadoutsTab) != -1) then { + + private _previousCtrlBackground = _display displayCtrl (GVAR(currentLoadoutsTab) - 1); + _previousCtrlBackground ctrlSetBackgroundColor [0, 0, 0, 0.8]; + _previousCtrlBackground ctrlCommit 0; + + private _previousCtrl = _display displayCtrl GVAR(currentLoadoutsTab); + _previousCtrl ctrlSetTextColor [1, 1, 1, 1]; + _previousCtrl ctrlCommit 0; +}; + +private _ctrlBackground = _display displayCtrl ((ctrlIDC _control) - 1); +_ctrlBackground ctrlSetBackgroundColor [1, 1, 1, 0.8]; +_ctrlBackground ctrlCommit 0; + +_control ctrlSetTextColor [0, 0, 0, 1]; +_control ctrlCommit 0; + +switch (ctrlIDC _control) do { + case IDC_buttonMyLoadouts: { + _centerBoxTitleCtrl ctrlSetText (localize LSTRING(tabMyLoadoutsText)); + + _saveButtonCtrl ctrlEnable true; + _saveButtonCtrl ctrlCommit 0; + }; + + case IDC_buttonDefaultLoadouts: { + _centerBoxTitleCtrl ctrlSetText (localize LSTRING(tabDefaultLoadoutsText)); + + _saveButtonCtrl ctrlEnable (is3DEN); + _saveButtonCtrl ctrlCommit 0; + }; + + case IDC_buttonSharedLoadouts: { + _centerBoxTitleCtrl ctrlSetText (localize LSTRING(tabSharedLoadoutsText)); + + _saveButtonCtrl ctrlEnable false; + _saveButtonCtrl ctrlCommit 0; + }; +}; + +{ + _x ctrlEnable false; + _x ctrlCommit 0; +} foreach [_shareButtonCtrl, _loadButtonCtrl, _deleteButtonCtrl, _renameButtonCtrl]; + +GVAR(currentLoadoutsTab) = ctrlIDC _control; + +[_display, _control] call FUNC(fillLoadoutsList); diff --git a/addons/arsenal/functions/fnc_message.sqf b/addons/arsenal/functions/fnc_message.sqf new file mode 100644 index 0000000000..92f922d7f9 --- /dev/null +++ b/addons/arsenal/functions/fnc_message.sqf @@ -0,0 +1,54 @@ +/* + * Author: Alganthe + * Displays messages in arsenal. + * + * Arguments: + * 0: Arsenal display + * 1: Message + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_message"]; + +private _messageBoxCtrl = _display displayCtrl IDC_message; +private _handle = _messageBoxCtrl getVariable QGVAR(messageBoxHandle); + +if !(isNil "_handle") then { + terminate _handle; +}; + +_handle = [_display, _messageBoxCtrl, time + 5, _message, FADE_DELAY] spawn { + disableSerialization; + + _this params ["_display", "_control", "_timer", "_message", "_delay"]; + + while {_timer >= time} do { + switch true do { + case (_display isEqualTo displayNull): { + terminate _thisScript; + }; + + case (round (_timer - time) == 5): { + _control ctrlSetText _message; + _control ctrlSetFade 1; + _control ctrlCommit 0; + + _control ctrlSetFade 0; + _control ctrlCommit _delay; + }; + }; + + uiSleep 1; + }; + + _control ctrlSetFade 1; + _control ctrlCommit _delay; + terminate _thisScript; +}; +_messageBoxCtrl setVariable [QGVAR(messageBoxHandle), _handle]; diff --git a/addons/arsenal/functions/fnc_onArsenalClose.sqf b/addons/arsenal/functions/fnc_onArsenalClose.sqf new file mode 100644 index 0000000000..52466f6746 --- /dev/null +++ b/addons/arsenal/functions/fnc_onArsenalClose.sqf @@ -0,0 +1,101 @@ +/* + * Author: Alganthe + * onUnLoad EH for arsenal. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +GVAR(camera) cameraEffect ["terminate", "back"]; +private _cameraData = [getposAtl GVAR(camera), (getposAtl GVAR(camera)) vectorFromTo (getposAtl GVAR(cameraHelper))]; + +[QGVAR(displayClosed), []] call CBA_fnc_localEvent; + +removeMissionEventHandler ["draw3D", GVAR(camPosUpdateHandle)]; + +camDestroy GVAR(camera); +GVAR(center) switchCamera GVAR(cameraView); +deleteVehicle GVAR(cameraHelper); + +if (is3DEN) then { + + private _centerOriginParent = objectParent GVAR(centerOrigin); + + if !(isNull _centerOriginParent) then { + _centerOriginParent hideObject false; + }; + + 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"); + + 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; +} else { + // Select correct weapon + switch GVAR(selectedWeaponType) do { + case 0: {GVAR(center) selectWeapon primaryWeapon GVAR(center);}; + case 1: {GVAR(center) selectWeapon secondaryWeapon GVAR(center);}; + case 2: {GVAR(center) selectWeapon handgunWeapon GVAR(center);}; + }; +}; + +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; + + [QGVAR(broadcastVoice), [GVAR(center), GVAR(currentVoice)], QGVAR(center) + "_voice"] call CBA_fnc_globalEventJIP; + [QGVAR(center) + "_voice", GVAR(center)] call CBA_fnc_removeGlobalEventJIP; +}; + +if !(isnull curatorCamera) then { + curatorcamera setPosAtl (_cameraData select 0); + curatorcamera setVectorDir (_cameraData select 1); + curatorcamera cameraEffect ["internal","back"]; +}; + +GVAR(camera) = nil; +GVAR(cameraHelper) = nil; + +GVAR(mouseButtonState) = nil; +GVAR(currentLeftPanel) = nil; +GVAR(currentRightPanel) = nil; +GVAR(leftSearchbarFocus) = nil; +GVAR(rightSearchbarFocus) = nil; +GVAR(shiftState) = nil; +GVAR(leftTabFocus) = nil; +GVAR(rightTabFocus) = nil; +GVAR(rightTabLnBFocus) = nil; + +GVAR(selectedWeaponType) = nil; +GVAR(virtualItems) = nil; +GVAR(currentItems) = nil; +GVAR(currentFace) = nil; +GVAR(currentVoice) = nil; +GVAR(currentInsignia) = nil; +GVAR(currentAction) = nil; + +GVAR(center) = nil; + +showHUD true; diff --git a/addons/arsenal/functions/fnc_onArsenalOpen.sqf b/addons/arsenal/functions/fnc_onArsenalOpen.sqf new file mode 100644 index 0000000000..6c53882008 --- /dev/null +++ b/addons/arsenal/functions/fnc_onArsenalOpen.sqf @@ -0,0 +1,287 @@ +/* + * Author: Alganthe + * onLoad EH for arsenal. + * + * Arguments: + * 0: Ignored + * 1: Arguments + * 1.1: Arsenal display + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["", "_args"]; +_args params ["_display"]; + +//--------------- General vars +if (isNil QGVAR(center)) then { + GVAR(center) = player; +}; + +GVAR(mouseButtonState) = [[],[]]; + +if (isNil QGVAR(sharedLoadoutsNamespace)) then { + GVAR(sharedLoadoutsNamespace) = true call CBA_fnc_createNamespace; + publicVariable QGVAR(sharedLoadoutsNamespace); +}; + +if (isNil {GVAR(sharedLoadoutsNamespace) getVariable QGVAR(sharedLoadoutsVars)}) then { + GVAR(sharedLoadoutsNamespace) setVariable [QGVAR(sharedLoadoutsVars), [], true]; +}; + +if (isNil QGVAR(defaultLoadoutsList)) then { + if (is3DEN) then { + GVAR(defaultLoadoutsList) = (QGVAR(DummyCategory) get3DENMissionAttribute QGVAR(DefaultLoadoutsListAttribute)); + } else { + GVAR(defaultLoadoutsList) = []; + }; +}; + +if (isNil QGVAR(virtualItems)) then { + GVAR(virtualItems) = [[[], [], []], [[], [], [], []], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]; +}; + +GVAR(currentItems) = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", [], [], [], [], [], []]; + +GVAR(currentFace) = face GVAR(center); +GVAR(currentVoice) = speaker GVAR(center); +GVAR(currentInsignia) = GVAR(center) param [0, objNull, [objNull]] getVariable ["BIS_fnc_setUnitInsignia_class", ""]; + +GVAR(currentAction) = "Stand"; +GVAR(shiftState) = false; + +// Add the items the player has to virtualItems +for "_index" from 0 to 10 do { + switch (_index) do { + // primary, secondary, handgun weapons + case 0: { + private _array = LIST_DEFAULTS select _index; + + if !((_array select 0) isEqualTo "") then { + ((GVAR(virtualItems) select _index) select 0) pushBackUnique (_array select 0); + }; + + if !((_array select 1) isEqualTo "") then { + ((GVAR(virtualItems) select _index) select 1) pushBackUnique (_array select 1); + }; + + if !((_array select 2) isEqualTo "") then { + ((GVAR(virtualItems) select _index) select 2) pushBackUnique (_array select 2); + }; + }; + + // Accs for the weapons above + case 1: { + private _array = LIST_DEFAULTS select _index; + _array params ["_accsArray", "_magsArray"]; + + { + private _subIndex = _forEachIndex; + + { + if (_x != "") then { + (GVAR(virtualItems) select _index) select ([2, 1, 0, 3] select _forEachIndex) pushBackUnique _x; + }; + } foreach _x; + } foreach _accsArray; + + { + if !(_x isEqualTo []) then { + + if (_x select 0 != "") then { + (GVAR(virtualItems) select 2) pushBackUnique (_x select 0); + }; + + if (count _x > 1 && {_x select 1 != ""}) then { + (GVAR(virtualItems) select 2) pushBackUnique (_x select 1); + }; + }; + } foreach _magsArray; + }; + + // Inventory items + case 2: { + call FUNC(updateUniqueItemsList); + }; + + // The rest + default { + private _array = (LIST_DEFAULTS select _index) select {!(_x isEqualTo "")}; + if !(_array isEqualTo []) then { + {(GVAR(virtualItems) select _index) pushBackUnique _x} foreach _array; + }; + }; + }; +}; + +// Fill current items +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))]; + }; + }; +}; + +{ + private _simulationType = getText (configFile >> "CfgWeapons" >> _x >> "simulation"); + private _index = 10 + (["itemmap", "itemcompass", "itemradio", "itemwatch", "itemgps"] find (tolower _simulationType)); + + GVAR(currentItems) set [_index, _x]; +} foreach (assignedItems GVAR(center)); + +GVAR(currentWeaponType) = switch true do { + case (currentWeapon GVAR(center) == GVAR(currentItems) select 0): {0}; + case (currentWeapon GVAR(center) == GVAR(currentItems) select 1): {1}; + case (currentWeapon GVAR(center) == GVAR(currentItems) select 2): {2}; + default {-1}; +}; + +[QGVAR(displayOpened), []] call CBA_fnc_localEvent; + +//--------------- Fade out unused elements +private _mouseBlockCtrl = _display displayCtrl IDC_mouseBlock; +_mouseBlockCtrl ctrlEnable false; + +{ + _x = _display displayCtrl _x; + + _x ctrlSetFade 1; + _x ctrlShow false; + _x ctrlCommit 0; +} foreach [ + IDC_blockRightFrame, + IDC_blockRighttBackground, + IDC_loadIndicator, + IDC_rightTabContent, + IDC_rightTabContentListnBox, + IDC_sortRightTab, + RIGHT_PANEL_ACC_BACKGROUND_IDCS, + RIGHT_PANEL_ACC_IDCS, + RIGHT_PANEL_ITEMS_BACKGROUND_IDCS, + RIGHT_PANEL_ITEMS_IDCS, + IDC_buttonRemoveAll, + IDC_rightSearchbar +]; + +//--------------- Camera prep +cutText ["","plain"]; +showCommandingMenu ""; + +GVAR(cameraView) = cameraView; +GVAR(center) switchCamera "internal"; +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 _centerOriginParent = objectParent GVAR(centerOrigin); + if !(isNull _centerOriginParent) then { + _centerOriginParent 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";}; +}; + +//--------------- Prepare the left panel +GVAR(currentLeftPanel) = nil; +GVAR(currentRightPanel) = nil; +GVAR(leftSearchbarFocus) = false; +GVAR(rightSearchbarFocus) = false; +GVAR(leftTabFocus) = false; +GVAR(rightTabFocus) = false; +GVAR(rightTabLnBFocus) = false; + +{ + private _panel = _display displayCtrl _x; + _panel ctrlSetFontHeight (GVAR(fontHeight) * GRID_H); + _panel ctrlCommit 0; +} foreach [IDC_leftTabContent, IDC_rightTabContent, IDC_rightTabContentListnBox]; + +[_display, _display displayCtrl IDC_buttonPrimaryWeapon] call FUNC(fillLeftPanel); + +//--------------- Init camera +if (isNil QGVAR(cameraPosition)) then { + GVAR(cameraPosition) = [5,0,0,[0,0,0.85]]; +}; + +GVAR(cameraHelper) = createAgent ["Logic", position GVAR(center) ,[] ,0 ,"none"]; +GVAR(cameraHelper) attachTo [GVAR(center), GVAR(cameraPosition) select 3, ""]; + +GVAR(camera) = "camera" camCreate position GVAR(center); +GVAR(camera) cameraEffect ["internal","back"]; +GVAR(camera) camPrepareFocus [-1,-1]; +GVAR(camera) camPrepareFov 0.35; +GVAR(camera) camCommitPrepared 0; + +showCinemaBorder false; +["#(argb,8,8,3)color(0,0,0,1)",false,nil,0,[0,0.5]] call bis_fnc_textTiles; + +//--------------- Reset camera pos +[nil, [controlNull,0,0]] call FUNC(handleMouse); +GVAR(camPosUpdateHandle) = addMissionEventHandler ["draw3D",{ [] call FUNC(updateCamPos) }]; diff --git a/addons/arsenal/functions/fnc_onKeyDown.sqf b/addons/arsenal/functions/fnc_onKeyDown.sqf new file mode 100644 index 0000000000..1233a5b4eb --- /dev/null +++ b/addons/arsenal/functions/fnc_onKeyDown.sqf @@ -0,0 +1,121 @@ +/* + * Author: Alganthe + * Handles keyboard inputs in arsenal. + * + * Arguments: + * 0: Arsenal display + * 1: Key being pressed + * 2: Shift state + * 3: Ctrl state + * 4: Alt state + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" +#include "\A3\ui_f\hpp\defineDIKCodes.inc" + +params ["", "_args"]; +_args params ["_display", "_keyPressed", "_shiftState", "_ctrlState", "_altState"]; + +if !((findDisplay IDD_loadouts_display) isEqualTo displayNull) exitWith {}; + +GVAR(shiftState) = _shiftState; + +private _return = true; + +if (!GVAR(leftSearchbarFocus) && {!GVAR(rightSearchbarFocus)}) then { + + switch true do { + // Close button + case (_keyPressed == DIK_ESCAPE): { + _display closeDisplay 2; + }; + // Hide button + case (_keyPressed == DIK_BACKSPACE): { + [_display] call FUNC(buttonHide); + }; + // Export button + case (_keyPressed == DIK_C && {_ctrlState}): { + [_display] call FUNC(buttonExport); + }; + // Import button + case (_keyPressed == DIK_V && {_ctrlState}): { + [_display] call FUNC(buttonImport); + }; + // Switch vision mode + case (_keyPressed in (actionkeys "nightvision")): { + if (isNil QGVAR(visionMode)) then { + GVAR(visionMode) = 0; + }; + GVAR(visionMode) = (GVAR(visionMode) + 1) % 3; + + switch GVAR(visionMode) do { + //--- Normal + case 0: { + camusenvg false; + false setCamUseTi 0; + }; + //--- NVG + case 1: { + camusenvg true; + false setCamUseTi 0; + }; + //--- TI + default { + camusenvg false; + true setCamUseTi 0; + }; + }; + + playsound ["RscDisplayCurator_visionMode",true]; + }; + }; +} else { + switch true do { + case (_keyPressed == DIK_ESCAPE): { + _display closeDisplay 2; + }; + case (_keyPressed == DIK_BACKSPACE): { + _return = false; + }; + case (_keyPressed == DIK_RETURN): { + if (GVAR(leftSearchbarFocus)) then { + [_display, _display displayCtrl IDC_leftSearchbar] call FUNC(handleSearchBar); + }; + if (GVAR(rightSearchbarFocus)) then { + [_display, _display displayCtrl IDC_rightSearchbar] call FUNC(handleSearchBar); + }; + }; + case (_keyPressed in [DIK_LEFT, DIK_RIGHT]): { + _return = false; + }; + case (_keyPressed == DIK_C && {_ctrlState}): { + _return = false; + }; + case (_keyPressed == DIK_V && {_ctrlState}): { + _return = false; + }; + }; +}; + +if (GVAR(leftTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then { + _return = false; +}; + +if (GVAR(rightTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then { + _return = false; +}; + +if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then { + _return = false; +}; + +if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_LEFT, DIK_RIGHT]}) then { + [_display, [1, 0] select (_keyPressed == DIK_LEFT)] call FUNC(buttonCargo); +}; + +_return diff --git a/addons/arsenal/functions/fnc_onLoadoutsClose.sqf b/addons/arsenal/functions/fnc_onLoadoutsClose.sqf new file mode 100644 index 0000000000..8318b4d409 --- /dev/null +++ b/addons/arsenal/functions/fnc_onLoadoutsClose.sqf @@ -0,0 +1,29 @@ +/* + * Author: Alganthe + * onUnLoad EH for arsenal loadouts display. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +GVAR(currentLoadoutsTab) = nil; + +private _arsenalDisplay = findDisplay IDD_ace_arsenal; +private _mouseBlockCtrl = _arsenalDisplay displayCtrl IDC_mouseBlock; + +GVAR(cameraPosition) = GVAR(previousCameraPos); +GVAR(previousCameraPos) = nil; + +_mouseBlockCtrl ctrlEnable false; +_mouseBlockCtrl ctrlCommit 0; + +[_arsenalDisplay] call FUNC(buttonHide); + +[_arsenalDisplay , _arsenalDisplay displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel); diff --git a/addons/arsenal/functions/fnc_onLoadoutsOpen.sqf b/addons/arsenal/functions/fnc_onLoadoutsOpen.sqf new file mode 100644 index 0000000000..6d6dd4bb76 --- /dev/null +++ b/addons/arsenal/functions/fnc_onLoadoutsOpen.sqf @@ -0,0 +1,58 @@ +/* + * Author: Alganthe + * onLoad EH for arsenal loadouts display. + * + * Arguments: + * 0: Ignored + * 1: Arguments + * 1.1: Loadouts display + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["", "_args"]; +_args params ["_display"]; + +private _arsenalDisplay = findDisplay IDD_ace_arsenal; +private _mouseBlockCtrl = _arsenalDisplay displayCtrl IDC_mouseBlock; + +_mouseBlockCtrl ctrlEnable true; +_mouseBlockCtrl ctrlCommit 0; + +[_arsenalDisplay] call FUNC(buttonHide); + +GVAR(currentLoadoutsTab) = -1; + +GVAR(previousCameraPos) = GVAR(cameraPosition); +GVAR(cameraPosition) = [5,0,20,[-0.85,0,0.85]]; + +private _panelContentCtrl = _display displayCtrl IDC_contentPanel; +_panelContentCtrl ctrlSetFontHeight (4.5 * GRID_H); +_panelContentCtrl ctrlCommit 0; + +if !(GVAR(allowDefaultLoadouts)) then { + private _buttonDefaultLoadoutsCtrl = _display displayCtrl IDC_buttonDefaultLoadouts; + _buttonDefaultLoadoutsCtrl ctrlEnable false; + _buttonDefaultLoadoutsCtrl ctrlCommit 0; + + private _buttonDefaultLoadoutsBackgroundCtrl = _display displayCtrl IDC_buttonDefaultLoadoutsBackground; + _buttonDefaultLoadoutsBackgroundCtrl ctrlShow false; + _buttonDefaultLoadoutsBackgroundCtrl ctrlCommit 0; +}; + +if !(GVAR(allowSharedLoadouts) && {isMultiplayer}) then { + private _buttonShareLoadoutsCtrl = _display displayCtrl IDC_buttonSharedLoadouts; + _buttonShareLoadoutsCtrl ctrlEnable false; + _buttonShareLoadoutsCtrl ctrlCommit 0; + + private _buttonShareLoadoutsBackgroundCtrl = _display displayCtrl IDC_buttonSharedLoadoutsBackground; + _buttonShareLoadoutsBackgroundCtrl ctrlShow false; + _buttonShareLoadoutsBackgroundCtrl ctrlCommit 0; +}; + +[_display, _display displayCtrl IDC_buttonMyLoadouts] call FUNC(loadoutsChangeTab); diff --git a/addons/arsenal/functions/fnc_onMouseButtonDown.sqf b/addons/arsenal/functions/fnc_onMouseButtonDown.sqf new file mode 100644 index 0000000000..0cb2c856a4 --- /dev/null +++ b/addons/arsenal/functions/fnc_onMouseButtonDown.sqf @@ -0,0 +1,6 @@ +#include "script_component.hpp" + +params ["", "_args"]; +_args params ["", "_buttonPressed", "_xPos", "_yPos"]; + +GVAR(mouseButtonState) set [_buttonPressed, [_xPos, _yPos]]; diff --git a/addons/arsenal/functions/fnc_onMouseButtonUp.sqf b/addons/arsenal/functions/fnc_onMouseButtonUp.sqf new file mode 100644 index 0000000000..53848a4f8e --- /dev/null +++ b/addons/arsenal/functions/fnc_onMouseButtonUp.sqf @@ -0,0 +1,6 @@ +#include "script_component.hpp" + +params ["", "_args"]; +_args params ["", "_buttonPressed"]; + +GVAR(mouseButtonState) set [_buttonPressed, []]; diff --git a/addons/arsenal/functions/fnc_onSelChangedLeft.sqf b/addons/arsenal/functions/fnc_onSelChangedLeft.sqf new file mode 100644 index 0000000000..35558be101 --- /dev/null +++ b/addons/arsenal/functions/fnc_onSelChangedLeft.sqf @@ -0,0 +1,413 @@ +/* + * Author: Alganthe + * Handles selection changes on the left panel. + * + * Arguments: + * 0: Left panel control + * 1: Left panel selection + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_control", "_curSel"]; + +if (_curSel < 0) exitwith {}; + +private _ctrlIDC = ctrlIDC _control; +private _display = ctrlParent _control; +private _item = [_control lnbData [_curSel, 0], _control lbData _curSel] select !(ctrlType _control == 102); + +private _weaponDefaultRightPanel = _display displayCtrl IDC_buttonOptic; +private _selectCorrectPanelWeapon = [_weaponDefaultRightPanel, _display displayCtrl GVAR(currentRightPanel)] select (!(isNil QGVAR(currentRightPanel)) && {GVAR(currentRightPanel) in [RIGHT_PANEL_ACC_IDCS, IDC_buttonCurrentMag, IDC_buttonCurrentMag2]}); + +private _containerDefaultRightPanel = _display displayCtrl IDC_buttonMisc; +private _selectCorrectPanelContainer = [_containerDefaultRightPanel, _display displayCtrl GVAR(currentRightPanel)] select (!(isNil QGVAR(currentRightPanel)) && {GVAR(currentRightPanel) in [RIGHT_PANEL_ITEMS_IDCS]}); + +switch (GVAR(currentLeftPanel)) do { + + case IDC_buttonPrimaryWeapon : { + private _baseWeapon = ((GVAR(currentItems) select 0) call bis_fnc_baseWeapon); + + if ((GVAR(currentItems) select 0) != _item && {_baseWeapon != _item}) then { + + private _compatibleMags = getArray (configfile >> "cfgweapons" >> _baseWeapon >> "magazines"); + { + GVAR(center) removeMagazines _x; + } foreach _compatibleMags; + + GVAR(currentItems) set [15, uniformItems GVAR(center)]; + GVAR(currentItems) set [16, vestItems GVAR(center)]; + GVAR(currentItems) set [17, backpackItems GVAR(center)]; + + if (_item == "") then { + + GVAR(center) removeWeapon (primaryWeapon GVAR(center)); + GVAR(currentItems) set [18, ["", "", "", "", "", ""]]; + GVAR(currentItems) set [0, _item]; + } else { + + private _compatibleItems = (_item call bis_fnc_compatibleItems) apply {tolower _x}; + GVAR(center) addWeapon _item; + GVAR(center) addWeaponItem [_item, [(getArray (configfile >> "cfgweapons" >> _item >> "magazines")) select 0]]; + + { + if (tolower _x in _compatibleItems || {_x in _compatibleMags}) then { + GVAR(center) addPrimaryWeaponItem _x; + }; + } foreach (GVAR(currentItems) select 18); + + private _primaryMags = primaryWeaponMagazine GVAR(center); + GVAR(currentItems) set [18, (primaryWeaponItems GVAR(center)) + ([_primaryMags + [""], _primaryMags] select (count _primaryMags > 1))]; + GVAR(currentItems) set [0, _item]; + }; + }; + + if (_item == "") then { + TOGGLE_RIGHT_PANEL_HIDE + } else { + TOGGLE_RIGHT_PANEL_WEAPON + [_display, _selectCorrectPanelWeapon] call FUNC(fillRightPanel); + }; + + call FUNC(showItem); + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonHandgun : { + private _baseWeapon = ((GVAR(currentItems) select 2) call bis_fnc_baseWeapon); + + if ((GVAR(currentItems) select 2) != _item && {_baseWeapon != _item}) then { + + private _compatibleMags = getArray (configfile >> "cfgweapons" >> _baseWeapon >> "magazines"); + { + GVAR(center) removeMagazines _x; + } foreach _compatibleMags; + + GVAR(currentItems) set [15, uniformItems GVAR(center)]; + GVAR(currentItems) set [16, vestItems GVAR(center)]; + GVAR(currentItems) set [17, backpackItems GVAR(center)]; + + if (_item == "") then { + + GVAR(center) removeWeapon (handgunWeapon GVAR(center)); + GVAR(currentItems) set [18, ["", "", "", "", "", ""]]; + GVAR(currentItems) set [2, _item]; + } else { + + private _compatibleItems = (_item call bis_fnc_compatibleItems) apply {tolower _x}; + GVAR(center) addWeapon _item; + GVAR(center) addWeaponItem [_item, [(getArray (configfile >> "cfgweapons" >> _item >> "magazines")) select 0]]; + + { + if (tolower _x in _compatibleItems || {_x in _compatibleMags}) then { + GVAR(center) addHandgunItem _x; + }; + } foreach (GVAR(currentItems) select 20); + + private _handgunMags = handgunMagazine GVAR(center); + GVAR(currentItems) set [20, (handgunItems GVAR(center)) + ([_handgunMags + [""], _handgunMags] select (count _handgunMags > 1))]; + GVAR(currentItems) set [2, _item]; + }; + }; + + if (_item == "") then { + TOGGLE_RIGHT_PANEL_HIDE + } else { + TOGGLE_RIGHT_PANEL_WEAPON + [_display, [_selectCorrectPanelWeapon, _weaponDefaultRightPanel] select (GVAR(currentRightPanel) == IDC_buttonCurrentMag2)] call FUNC(fillRightPanel); + }; + + call FUNC(showItem); + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonSecondaryWeapon : { + private _baseWeapon = ((GVAR(currentItems) select 1) call bis_fnc_baseWeapon); + + if ((GVAR(currentItems) select 1) != _item && {_baseWeapon != _item}) then { + + private _compatibleMags = getArray (configfile >> "cfgweapons" >> _baseWeapon >> "magazines"); + { + GVAR(center) removeMagazines _x; + } foreach _compatibleMags; + + GVAR(currentItems) set [15, uniformItems GVAR(center)]; + GVAR(currentItems) set [16, vestItems GVAR(center)]; + GVAR(currentItems) set [17, backpackItems GVAR(center)]; + + if (_item == "") then { + + GVAR(center) removeWeapon (secondaryWeapon GVAR(center)); + GVAR(currentItems) set [18, ["", "", "", "", "", ""]]; + GVAR(currentItems) set [1, _item]; + } else { + + private _compatibleItems = (_item call bis_fnc_compatibleItems) apply {tolower _x}; + GVAR(center) addWeapon _item; + GVAR(center) addWeaponItem [_item, [(getArray (configfile >> "cfgweapons" >> _item >> "magazines")) select 0]]; + + { + if (tolower _x in _compatibleItems || {_x in _compatibleMags}) then { + GVAR(center) addSecondaryWeaponItem _x; + }; + } foreach (GVAR(currentItems) select 19); + + private _secondaryMags = secondaryWeaponMagazine GVAR(center); + GVAR(currentItems) set [19, (secondaryWeaponItems GVAR(center)) + ([_secondaryMags + [""], _secondaryMags] select (count _secondaryMags > 1))]; + GVAR(currentItems) set [1, _item]; + }; + }; + + if (_item == "") then { + TOGGLE_RIGHT_PANEL_HIDE + } else { + TOGGLE_RIGHT_PANEL_WEAPON + [_display, [_selectCorrectPanelWeapon, _weaponDefaultRightPanel] select (GVAR(currentRightPanel) == IDC_buttonCurrentMag2)] call FUNC(fillRightPanel); + }; + + call FUNC(showItem); + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonHeadgear : { + if (_item == "") then { + removeHeadgear GVAR(center); + GVAR(currentItems) set [3, _item]; + } else { + GVAR(center) addHeadgear _item; + GVAR(currentItems) set [3, _item]; + }; + call FUNC(showItem); + TOGGLE_RIGHT_PANEL_HIDE + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonUniform : { + if (_item == "") then { + + removeuniform GVAR(center); + GVAR(currentItems) set [15, []]; + GVAR(currentItems) set [4, _item]; + TOGGLE_RIGHT_PANEL_HIDE + } else { + + GVAR(center) forceAddUniform _item; + + while {count uniformItems GVAR(center) > 0} do { + GVAR(center) removeItemFromUniform (uniformItems GVAR(center) select 0); + }; //--- Remove default config contents + + {GVAR(center) addItemtoUniform _x} foreach (GVAR(currentItems) select 15); + GVAR(currentItems) set [4, _item]; + + [GVAR(center), ""] call bis_fnc_setUnitInsignia; + [GVAR(center), GVAR(currentInsignia)] call bis_fnc_setUnitInsignia; + + TOGGLE_RIGHT_PANEL_CONTAINER + [_display, _selectCorrectPanelContainer] call FUNC(fillRightPanel); + }; + + call FUNC(showItem); + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonVest: { + if (_item == "") then { + + removeVest GVAR(center); + GVAR(currentItems) set [16, []]; + GVAR(currentItems) set [5, _item]; + TOGGLE_RIGHT_PANEL_HIDE + } else { + + GVAR(center) addVest _item; + while {count vestItems GVAR(center) > 0} do { + GVAR(center) removeItemFromVest (VestItems GVAR(center) select 0); + }; //--- Remove default config contents + {GVAR(center) addItemToVest _x} foreach (GVAR(currentItems) select 16); + + GVAR(currentItems) set [5, _item]; + + TOGGLE_RIGHT_PANEL_CONTAINER + [_display, _selectCorrectPanelContainer] call FUNC(fillRightPanel); + }; + + call FUNC(showItem); + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonBackpack : { + if (_item == "") then { + + removeBackpack GVAR(center); + GVAR(currentItems) set [17, []]; + GVAR(currentItems) set [6, _item]; + TOGGLE_RIGHT_PANEL_HIDE + } else { + + removeBackpack GVAR(center); + GVAR(center) addBackpack _item; + while {count backpackItems GVAR(center) > 0} do { + GVAR(center) removeItemFromBackpack (backpackItems GVAR(center) select 0); + }; //--- Remove default config contents + {GVAR(center) addItemToBackpack _x} foreach (GVAR(currentItems) select 17); + + GVAR(currentItems) set [6, _item]; + + TOGGLE_RIGHT_PANEL_CONTAINER + [_display, _selectCorrectPanelContainer] call FUNC(fillRightPanel); + }; + + call FUNC(showItem); + [_display, _control, _curSel, (configFile >> "CfgVehicles" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonGoggles : { + if (_item == "") then { + removeGoggles GVAR(center); + GVAR(currentItems) set [7, _item]; + } else { + GVAR(center) addGoggles _item; + GVAR(currentItems) set [7, _item]; + }; + + call FUNC(showItem); + TOGGLE_RIGHT_PANEL_HIDE + [_display, _control, _curSel, (configFile >> "CfgGlasses" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonNVG : { + if (_item == "") then { + GVAR(center) unlinkItem (GVAR(currentItems) select 8); + GVAR(currentItems) set [8, _item]; + } else { + GVAR(center) linkItem _item; + GVAR(currentItems) set [8, _item]; + }; + + call FUNC(showItem); + TOGGLE_RIGHT_PANEL_HIDE + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonBinoculars : { + if (_item == "") then { + GVAR(center) removeWeapon (binocular GVAR(center)); + GVAR(currentItems) set [9, _item]; + } else { + GVAR(center) addWeapon _item; + GVAR(currentItems) set [9, _item]; + call FUNC(showItem); + ADDBINOCULARSMAG + }; + call FUNC(showItem); + TOGGLE_RIGHT_PANEL_HIDE + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonMap : { + if (_item == "") then { + GVAR(center) unlinkItem (GVAR(currentItems) select 10) select 0; + GVAR(currentItems) set [10, _item]; + } else { + GVAR(center) linkItem _item; + GVAR(currentItems) set [10, _item]; + }; + + call FUNC(showItem); + TOGGLE_RIGHT_PANEL_HIDE + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonCompass : { + if (_item == "") then { + GVAR(center) unlinkItem (GVAR(currentItems) select 11) select 0; + GVAR(currentItems) set [11, _item]; + } else { + GVAR(center) linkItem _item; + GVAR(currentItems) set [11, _item]; + }; + + call FUNC(showItem); + TOGGLE_RIGHT_PANEL_HIDE + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonRadio : { + if (_item == "") then { + GVAR(center) unlinkItem (GVAR(currentItems) select 12) select 0; + GVAR(currentItems) set [12, _item]; + } else { + GVAR(center) linkItem _item; + GVAR(currentItems) set [12, _item]; + }; + + call FUNC(showItem); + TOGGLE_RIGHT_PANEL_HIDE + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonWatch : { + if (_item == "") then { + GVAR(center) unlinkItem (GVAR(currentItems) select 13); + GVAR(currentItems) set [13, _item]; + } else { + GVAR(center) linkItem _item; + GVAR(currentItems) set [13, _item]; + }; + + call FUNC(showItem); + TOGGLE_RIGHT_PANEL_HIDE + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonGPS : { + if (_item == "") then { + GVAR(center) unlinkItem (GVAR(currentItems) select 14) select 0; + GVAR(currentItems) set [14, _item]; + } else { + GVAR(center) linkItem _item; + GVAR(currentItems) set [14, _item]; + }; + + call FUNC(showItem); + TOGGLE_RIGHT_PANEL_HIDE + [_display, _control, _curSel, (configFile >> "CfgWeapons" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonFace : { + private _face = [_item, "Default"] select (_item == ""); + + GVAR(center) setFace _face; + GVAR(currentFace) = _face; + + call FUNC(showItem); + TOGGLE_RIGHT_PANEL_HIDE + [_display, _control, _curSel, (configFile >> "CfgFaces" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonVoice : { + GVAR(center) setSpeaker _item; + GVAR(currentVoice) = _item; + + call FUNC(showItem); + TOGGLE_RIGHT_PANEL_HIDE + [_display, _control, _curSel, (configFile >> "CfgVoice" >> _item)] call FUNC(itemInfo); + }; + + case IDC_buttonInsigna : { + [GVAR(center), _item] call bis_fnc_setUnitInsignia; + GVAR(currentInsignia) = _item; + + call FUNC(showItem); + TOGGLE_RIGHT_PANEL_HIDE + [_display, _control, _curSel, (configFile >> "CfgUnitInsignia" >> _item)] call FUNC(itemInfo); + }; +}; + +(_display displayCtrl IDC_totalWeightText) ctrlSetText ([[GVAR(center), 1] call EFUNC(common,getWeight), [GVAR(center), 2] call EFUNC(common,getWeight)] joinString " / "); diff --git a/addons/arsenal/functions/fnc_onSelChangedLoadouts.sqf b/addons/arsenal/functions/fnc_onSelChangedLoadouts.sqf new file mode 100644 index 0000000000..3f4d508ae0 --- /dev/null +++ b/addons/arsenal/functions/fnc_onSelChangedLoadouts.sqf @@ -0,0 +1,103 @@ +/* + * Author: Alganthe + * Handles selection changes on loadouts panel. + * + * Arguments: + * 0: Loadouts panel control + * 1: Loadouts panel selection + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control", "_curSel"]; + +private _shareButtonCtrl = _display displayCtrl IDC_buttonShare; +private _saveButtonCtrl = _display displayCtrl IDC_buttonSave; +private _loadButtonCtrl = _display displayCtrl IDC_buttonLoad; +private _deleteButtonCtrl = _display displayCtrl IDC_buttonDelete; +private _renameButtonCtrl = _display displayCtrl IDC_buttonRename; +private _textEditBoxCtrl= _display displayCtrl IDC_textEditBox; + +if (_curSel == -1) exitWith { + + if (GVAR(currentLoadoutsTab) == IDC_buttonSharedLoadouts) then { + _saveButtonCtrl ctrlEnable false; + _saveButtonCtrl ctrlCommit 0; + }; + + _shareButtonCtrl ctrlSetText (localize LSTRING(buttonSharePrivateText)); + + { + _x ctrlEnable false; + _x ctrlCommit 0; + } foreach [_shareButtonCtrl, _loadButtonCtrl, _deleteButtonCtrl, _renameButtonCtrl]; +}; + +switch (GVAR(currentLoadoutsTab)) do { + + case IDC_buttonMyLoadouts: { + + _shareButtonCtrl ctrlEnable (GVAR(allowSharedLoadouts) && {isMultiplayer}); + _shareButtonCtrl ctrlCommit 0; + + _loadButtonCtrl ctrlEnable true; + _loadButtonCtrl ctrlCommit 0; + + _shareButtonCtrl ctrlSetText ( [ + localize LSTRING(buttonSharePrivateText), + localize LSTRING(buttonSharePublicText) + ] select ((_control lnbValue [_curSel, 0]) == 1)); + + { + _x ctrlEnable true; + _x ctrlCommit 0; + } foreach [_renameButtonCtrl, _deleteButtonCtrl]; + + _textEditBoxCtrl ctrlSetText (_control lnbText [_curSel, 1]); + }; + + case IDC_buttonDefaultLoadouts: { + + { + _x ctrlEnable true; + _x ctrlCommit 0; + } foreach [_saveButtonCtrl, _loadButtonCtrl]; + + _shareButtonCtrl ctrlEnable false; + _shareButtonCtrl ctrlCommit 0; + + { + _x ctrlEnable (is3DEN); + _x ctrlCommit 0; + } foreach [_deleteButtonCtrl, _renameButtonCtrl]; + + _textEditBoxCtrl ctrlSetText (_control lnbText [_curSel, 1]); + }; + + case IDC_buttonSharedLoadouts: { + + { + _x ctrlEnable true; + _x ctrlCommit 0; + } foreach [_saveButtonCtrl, _loadButtonCtrl]; + + _shareButtonCtrl ctrlEnable false; + _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]); + }; +}; diff --git a/addons/arsenal/functions/fnc_onSelChangedRight.sqf b/addons/arsenal/functions/fnc_onSelChangedRight.sqf new file mode 100644 index 0000000000..a609cf8c92 --- /dev/null +++ b/addons/arsenal/functions/fnc_onSelChangedRight.sqf @@ -0,0 +1,77 @@ +/* + * Author: Alganthe + * Handles selection changes on the right panel. + * + * Arguments: + * 0: Right panel control + * 1: Right panel selection + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_control", "_curSel"]; + +if (_curSel < 0) exitwith {}; + +private _ctrlIDC = ctrlIDC _control; +private _display = ctrlParent _control; +private _item = _control lbData _curSel; + + +private _fnc_selectItem = { + params ["_item", "_currentItemsIndex", "_itemIndex"]; + + switch (_currentItemsIndex) do { + case 18: { + if (_item == "") then { + GVAR(center) removePrimaryWeaponItem ((GVAR(currentItems) select 18) select _itemIndex); + private _primaryMags = primaryWeaponMagazine GVAR(center); + GVAR(currentItems) set [18, (primaryWeaponItems GVAR(center)) + ([_primaryMags + [""], _primaryMags] select (count _primaryMags > 1))]; + } else { + GVAR(center) addPrimaryWeaponItem _item; + private _primaryMags = primaryWeaponMagazine GVAR(center); + GVAR(currentItems) set [18, (primaryWeaponItems GVAR(center)) + ([_primaryMags + [""], _primaryMags] select (count _primaryMags > 1))]; + }; + [_display, _control, _curSel, (configFile >> (["CfgWeapons", "CfgMagazines"] select (_itemIndex in [4, 5]))>> _item)] call FUNC(itemInfo); + }; + + case 19: { + if (_item == "") then { + GVAR(center) removeSecondaryWeaponItem ((GVAR(currentItems) select 19) select _itemIndex); + private _secondaryMags = secondaryWeaponMagazine GVAR(center); + GVAR(currentItems) set [19, (secondaryWeaponItems GVAR(center)) + ([_secondaryMags + [""], _secondaryMags] select (count _secondaryMags > 1))]; + } else { + GVAR(center) addSecondaryWeaponItem _item; + private _secondaryMags = secondaryWeaponMagazine GVAR(center); + GVAR(currentItems) set [19, (secondaryWeaponItems GVAR(center)) + ([_secondaryMags + [""], _secondaryMags] select (count _secondaryMags > 1))]; + }; + [_display, _control, _curSel, (configFile >> (["CfgWeapons", "CfgMagazines"] select (_itemIndex in [4, 5]))>> _item)] call FUNC(itemInfo); + }; + + case 20: { + if (_item == "") then { + GVAR(center) removeHandgunItem ((GVAR(currentItems) select 20) select _itemIndex); + private _handgunMags = handgunMagazine GVAR(center); + GVAR(currentItems) set [20, (handgunItems GVAR(center)) + ([_handgunMags + [""], _handgunMags] select (count _handgunMags > 1))]; + } else { + GVAR(center) addHandgunItem _item; + private _handgunMags = handgunMagazine GVAR(center); + GVAR(currentItems) set [20, (handgunItems GVAR(center)) + ([_handgunMags + [""], _handgunMags] select (count _handgunMags > 1))]; + }; + [_display, _control, _curSel, (configFile >> (["CfgWeapons", "CfgMagazines"] select (_itemIndex in [4, 5]))>> _item)] call FUNC(itemInfo); + }; + }; +}; + +[ + _item, + 18 + ([IDC_buttonPrimaryWeapon, IDC_buttonSecondaryWeapon, IDC_buttonHandgun] find GVAR(currentLeftPanel)), + [IDC_buttonMuzzle, IDC_buttonItemAcc, IDC_buttonOptic, IDC_buttonBipod, IDC_buttonCurrentMag, IDC_buttonCurrentMag2] find GVAR(currentRightPanel) +] call _fnc_selectItem; + +(_display displayCtrl IDC_totalWeightText) ctrlSetText ([[GVAR(center), 1] call EFUNC(common,getWeight), [GVAR(center), 2] call EFUNC(common,getWeight)] joinString " / "); diff --git a/addons/arsenal/functions/fnc_onSelChangedRightListnBox.sqf b/addons/arsenal/functions/fnc_onSelChangedRightListnBox.sqf new file mode 100644 index 0000000000..29c66a79f9 --- /dev/null +++ b/addons/arsenal/functions/fnc_onSelChangedRightListnBox.sqf @@ -0,0 +1,51 @@ +/* + * Author: Alganthe + * Handles selection changes on the right panel (listnbox). + * + * Arguments: + * 0: Right panel control + * 1: Right panel selection + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_control", "_curSel"]; + +if (_curSel < 0) exitwith {}; + +private _ctrlIDC = ctrlIDC _control; +private _display = ctrlParent _control; +private _item = [_control lnbData [_curSel, 0], _control lbData _curSel] select !(ctrlType _control == 102); + +private _fnc_selectRight = { + params ["_item", "_cfgEntry"]; + + // Load remaining + private _maxLoad = switch (GVAR(currentLeftPanel)) do { + case IDC_buttonUniform: { + gettext (configfile >> "CfgWeapons" >> uniform GVAR(center) >> "ItemInfo" >> "containerClass") + }; + case IDC_buttonVest: { + gettext (configfile >> "CfgWeapons" >> vest GVAR(center) >> "ItemInfo" >> "containerClass") + }; + case IDC_buttonBackpack: { + backpack GVAR(center) + }; + }; + + [_control, _maxLoad] call FUNC(updateRightPanel); + [_display, _control, _curSel, (configFile >> _cfgEntry >> _item)] call FUNC(itemInfo); +}; + +if (GVAR(currentLeftPanel) in [IDC_buttonUniform, IDC_buttonVest, IDC_buttonBackpack]) then { + + [ + _item, + ["CfgWeapons", "CfgMagazines"] select (GVAR(currentRightPanel) in [IDC_buttonMag, IDC_buttonMagALL, IDC_buttonThrow, IDC_buttonPut]) + ] call _fnc_selectRight; +}; diff --git a/addons/arsenal/functions/fnc_open3DEN.sqf b/addons/arsenal/functions/fnc_open3DEN.sqf new file mode 100644 index 0000000000..6bb0adcaa3 --- /dev/null +++ b/addons/arsenal/functions/fnc_open3DEN.sqf @@ -0,0 +1,17 @@ +/* + * Author: Alganthe + * Replace the 3DEN "edit loadout" menu action + * + * Arguments: + * None + * + * Return Value: + * None + * + * + * Public: No +*/ +#include "script_component.hpp" + +private _entity = (uinamespace getvariable ["bis_fnc_3DENEntityMenu_data",[]]) param [1, objnull]; +[_entity, _entity, true] call FUNC(openBox); diff --git a/addons/arsenal/functions/fnc_openBox.sqf b/addons/arsenal/functions/fnc_openBox.sqf new file mode 100644 index 0000000000..4a79f95918 --- /dev/null +++ b/addons/arsenal/functions/fnc_openBox.sqf @@ -0,0 +1,53 @@ +/* + * Author: Alganthe + * Open arsenal. + * + * Arguments: + * 0: Box + * 1: Unit to open the arsenal on + * 2: Ignore virtual items and fill arsenal + * + * Return Value: + * None + * + * Example: + * [_box, player] call ace_arsenal_fnc_openBox + * + * Public: Yes +*/ +#include "script_component.hpp" + +params [["_object", objNull, [objNull]], ["_center", objNull, [objNull]], ["_mode", false, [false]]]; + +if ( + isNull _object || + {isNull _center} || + {!(_center isKindOf "Man")} || + {!(isNull objectParent _center) && {!is3DEN}} +) exitWith {}; + +if (isNil {_object getVariable [QGVAR(virtualItems), nil]} && {!_mode}) exitWith { + [localize LSTRING(noVirtualItems), false, 5, 1] call EFUNC(common,displayText); +}; + +if (canSuspend) exitWith { + [{_this call FUNC(openBox)}, _this] call CBA_fnc_directCall; +}; + +private _displayToUse = [findDisplay 46, findDIsplay 312] select (!isNull findDisplay 312); +_displayToUse = [_displayToUse, findDisplay 313] select (is3DEN); + +if (isNil "_displayToUse" || {!isnil QGVAR(camera)}) exitWith { + [localize LSTRING(CantOpenDisplay), false, 5, 1] call EFUNC(common,displayText); +}; + +if (_mode) then { + GVAR(virtualItems) = uiNamespace getVariable QGVAR(configItems); +} else { + GVAR(virtualItems) = +(_object getVariable [QGVAR(virtualItems), [ + [[], [], []], [[], [], [], []], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [] + ]]); +}; + +GVAR(center) = _center; +_displayToUse createDisplay QGVAR(display); diff --git a/addons/arsenal/functions/fnc_removeBox.sqf b/addons/arsenal/functions/fnc_removeBox.sqf new file mode 100644 index 0000000000..43fa903ca4 --- /dev/null +++ b/addons/arsenal/functions/fnc_removeBox.sqf @@ -0,0 +1,35 @@ +/* + * Author: Alganthe + * Remove arsenal from target. + * + * Arguments: + * 0: Target + * 1: Remove globally + * + * Return Value: + * None + * + * Example: + * [_box, true] call ace_arsenal_fnc_removeBox + * + * Public: Yes +*/ +#include "script_component.hpp" + +params [["_object", objNull, [objNull]], ["_global", true, [true]]]; + +if (isNull _object || {isNil QGVAR(EHIDArray)}) exitWith {}; + +if (_global && {isMultiplayer}) then { + private _ID = (GVAR(EHIDArray) select {_x select 1 == _object}) select 0; + + if !(isNil "_ID") then { + [_ID select 0] call CBA_fnc_removeGlobalEventJIP; + GVAR(EHIDArray) deleteAt (GVAR(EHIDArray) find _ID); + publicVariable QGVAR(EHIDArray); + [QGVAR(removeBox), [_object, false]] call CBA_fnc_globalEvent; + }; +} else { + _object setVariable [QGVAR(virtualItems), nil, false]; + [_object, 0, ["ACE_MainActions", QGVAR(interaction)]] call EFUNC(interact_menu,removeActionFromObject); +}; diff --git a/addons/arsenal/functions/fnc_removeVirtualItems.sqf b/addons/arsenal/functions/fnc_removeVirtualItems.sqf new file mode 100644 index 0000000000..ad96718c6d --- /dev/null +++ b/addons/arsenal/functions/fnc_removeVirtualItems.sqf @@ -0,0 +1,80 @@ +/* + * Author: Alganthe + * Remove virtual items to the provided target. + * + * Arguments: + * 0: Target + * 1: Items + * 2: Add globally + * + * Return Value: + * None + * + * Example: + * [_box, ["item1", "item2", "itemN"]] call ace_arsenal_fnc_removeVirtualItems + * [_box, true, false] call ace_arsenal_fnc_removeVirtualItems + * + * Public: Yes +*/ +#include "script_component.hpp" + +params [ ["_object", objNull, [objNull]], ["_items", [], [true, [""]]], ["_global", false, [false]] ]; + +if (_object == objNull) exitWith {}; +if (_items isEqualType [] && {count _items == 0}) exitWith {}; + +private _cargo = _object getVariable [QGVAR(virtualItems), [ + [[], [], []], // Weapons 0, primary, handgun, secondary + [[], [], [], []], // WeaponAccessories 1, optic,side,muzzle,bipod + [ ], // Magazines 2 + [ ], // Headgear 3 + [ ], // Uniform 4 + [ ], // Vest 5 + [ ], // Backpacks 6 + [ ], // Goggles 7 + [ ], // NVGs 8 + [ ], // Binoculars 9 + [ ], // Map 10 + [ ], // Compass 11 + [ ], // Radio slot 12 + [ ], // Watch slot 13 + [ ], // Comms slot 14 + [ ], // WeaponThrow 15 + [ ], // WeaponPut 16 + [ ] // InventoryItems 17 +]]; + +if (_items isEqualType true && {_items}) then { + [_object, _global] call FUNC(removeBox); + _object setVariable [QGVAR(virtualItems), nil, _global]; +} else { + + // Make sure all items are in string form + _items = _items select {_x isEqualType "" && {_x != ""}}; + + { + if (_forEachIndex isEqualTo 0) then { + _cargo set [_forEachIndex, [(_x select 0) - _items, (_x select 1) - _items, (_x select 2) - _items]]; + } else { + if (_forEachIndex isEqualTo 1) then { + _cargo set [_forEachIndex, [(_x select 0) - _items, (_x select 1) - _items, (_x select 2) - _items, (_x select 3) - _items]]; + } else { + _cargo set [_cargo find _x, _x - _items]; + }; + }; + } foreach _cargo; + + private _itemCount = { + if (_x isEqualTo (_cargo select 0) || {_x isEqualTo (_cargo select 1)}) then { + !(_x isEqualTo [[],[],[]] || {_x isEqualTo [[],[],[],[]]}) + } else { + !(_x isEqualTo []) + }; + } count _cargo; + + if (_itemCount == 0) then { + [_object, _global] call FUNC(removeBox); + } else { + _object setVariable [QGVAR(virtualItems), _cargo, _global]; + }; +}; diff --git a/addons/arsenal/functions/fnc_scanConfig.sqf b/addons/arsenal/functions/fnc_scanConfig.sqf new file mode 100644 index 0000000000..c74a368e1a --- /dev/null +++ b/addons/arsenal/functions/fnc_scanConfig.sqf @@ -0,0 +1,184 @@ +/* + * Author: Dedmen + * Cache an array of all the compatible items for arsenal. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +private _cargo = [ + [[], [], []], // Weapons 0, primary, secondary, handgun + [[], [], [], []], // WeaponAccessories 1, optic,side,muzzle,bipod + [ ], // Magazines 2 + [ ], // Headgear 3 + [ ], // Uniform 4 + [ ], // Vest 5 + [ ], // Backpacks 6 + [ ], // Goggles 7 + [ ], // NVGs 8 + [ ], // Binoculars 9 + [ ], // Map 10 + [ ], // Compass 11 + [ ], // Radio slot 12 + [ ], // Watch slot 13 + [ ], // Comms slot 14 + [ ], // WeaponThrow 15 + [ ], // WeaponPut 16 + [ ] // InventoryItems 17 +]; + +private _configCfgWeapons = configFile >> "CfgWeapons"; //Save this lookup in variable for perf improvement +private _magazineGroups = [[],[]] call CBA_fnc_hashCreate; + +{ + private _configItemInfo = _x >> "ItemInfo"; + private _simulationType = getText (_x >> "simulation"); + private _className = configName _x; + private _hasItemInfo = isClass (_configItemInfo); + private _itemInfoType = if (_hasItemInfo) then {getNumber (_configItemInfo >> "type")} else {0}; + + switch true do { + /* Weapon acc */ + case ( + _hasItemInfo && + {_itemInfoType in [101, 201, 301, 302]} && + {!(configName _x isKindOf ["CBA_MiscItem", (_configCfgWeapons)])} + ): { + + //Convert type to array index + (_cargo select 1) select ([201,301,101,302] find _itemInfoType) pushBackUnique _className; + }; + /* Headgear */ + case (_hasItemInfo && {_itemInfoType == 605}): { + (_cargo select 3) pushBackUnique _className; + }; + /* Uniform */\ + case (_hasItemInfo && {_itemInfoType == 801}): { + (_cargo select 4) pushBackUnique _className; + }; + /* Vest */ + case (_hasItemInfo && {_itemInfoType == 701}): { + (_cargo select 5) pushBackUnique _className; + }; + /* NVgs */ + case (_simulationType == "NVGoggles"): { + (_cargo select 8) pushBackUnique _className; + }; + /* Binos */ + case (_simulationType == "Binocular" || + ((_simulationType == 'Weapon') && {(getNumber (_x >> 'type') == 4096)})): { + (_cargo select 9) pushBackUnique _className; + }; + /* Map */ + case (_simulationType == "ItemMap"): { + (_cargo select 10) pushBackUnique _className; + }; + /* Compass */ + case (_simulationType == "ItemCompass"): { + (_cargo select 11) pushBackUnique _className; + }; + /* Radio */ + case (_simulationType == "ItemRadio"): { + (_cargo select 12) pushBackUnique _className; + }; + /* Watch */ + case (_simulationType == "ItemWatch"): { + (_cargo select 13) pushBackUnique _className; + }; + /* GPS */ + case (_simulationType == "ItemGPS"): { + (_cargo select 14) pushBackUnique _className; + }; + /* UAV terminals */ + case (_hasItemInfo && {_itemInfoType == 621}): { + (_cargo select 14) pushBackUnique _className; + }; + /* Weapon, at the bottom to avoid adding binos */ + case (isClass (_x >> "WeaponSlotsInfo") && + {getNumber (_x >> 'type') != 4096}): { + switch (getNumber (_x >> "type")) do { + case 1: { + (_cargo select 0) select 0 pushBackUnique (_className call bis_fnc_baseWeapon); + }; + case 2: { + (_cargo select 0) select 2 pushBackUnique (_className call bis_fnc_baseWeapon); + }; + case 4: { + (_cargo select 0) select 1 pushBackUnique (_className call bis_fnc_baseWeapon); + }; + }; + }; + /* Misc items */ + case ( + _hasItemInfo && + (_itemInfoType in [101, 201, 301, 302] && + {(_className isKindOf ["CBA_MiscItem", (_configCfgWeapons)])}) || + {_itemInfoType in [401, 619, 620]} || + {(getText ( _x >> "simulation")) == "ItemMineDetector"} + ): { + (_cargo select 17) pushBackUnique _className; + }; + }; +} foreach configProperties [_configCfgWeapons, "isClass _x && {getNumber (_x >> 'scope') == 2} && {getNumber (_x >> 'ace_arsenal_hide') != 1}", true]; + +{ + private _className = configName _x; + private _grenadeList = []; + { + _grenadeList append getArray (_configCfgWeapons >> "Throw" >> _x >> "magazines"); + false + } count getArray (_configCfgWeapons >> "Throw" >> "muzzles"); + + private _putList = []; + { + _putList append getArray (_configCfgWeapons >> "Put" >> _x >> "magazines"); + false + } count getArray (_configCfgWeapons >> "Put" >> "muzzles"); + + + switch true do { + // Rifle, handgun, secondary weapons mags + case ( + (getNumber (_x >> "type") in [256,512,1536,16]) && + {!(_className in _grenadeList)} && + {!(_className in _putList)} + ): { + (_cargo select 2) pushBackUnique _className; + }; + // Grenades + case (_className in _grenadeList): { + (_cargo select 15) pushBackUnique _className; + }; + // Put + case (_className in _putList): { + (_cargo select 16) pushBackUnique _className; + }; + }; + + if (isArray (_x >> "magazineGroup")) then { + { + private _entry = [_magazineGroups, _x] call CBA_fnc_hashGet; + _entry pushBackUnique _className; + [_magazineGroups, _x, _entry] call CBA_fnc_hashSet; + } forEach getArray (_x >> "magazineGroup") + }; +} foreach configProperties [(configFile >> "CfgMagazines"), "isClass _x && {getNumber (_x >> 'scope') == 2} && {getNumber (_x >> 'ace_arsenal_hide') != 1}", true]; + +{ + if (getText (_x >> "vehicleClass") == "Backpacks") then { + (_cargo select 6) pushBackUnique (configName _x); + }; +} foreach configProperties [(configFile >> "CfgVehicles"), "isClass _x && {getNumber (_x >> 'scope') == 2} && {getNumber (_x >> 'ace_arsenal_hide') != 1}", true]; + +{ + (_cargo select 7) pushBackUnique (configName _x); +} foreach configProperties [(configFile >> "CfgGlasses"), "isClass _x && {getNumber (_x >> 'scope') == 2} && {getNumber (_x >> 'ace_arsenal_hide') != 1}", true]; + +uiNamespace setVariable [QGVAR(configItems), _cargo]; +uiNamespace setVariable [QGVAR(magazineGroups), _magazineGroups]; diff --git a/addons/arsenal/functions/fnc_showItem.sqf b/addons/arsenal/functions/fnc_showItem.sqf new file mode 100644 index 0000000000..e97ebd8dd5 --- /dev/null +++ b/addons/arsenal/functions/fnc_showItem.sqf @@ -0,0 +1,75 @@ +/* + * Author: Alganthe + * Change unit animation / play sound preview. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + + + +private _nextAction = switch (GVAR(currentLeftPanel)) do { + + case IDC_buttonPrimaryWeapon : { + ["Civil", "PrimaryWeapon"] select ((GVAR(currentItems) select 0) != "") + }; + case IDC_buttonSecondaryWeapon : { + ["Civil", "SecondaryWeapon"] select (GVAR(currentItems) select 1 != "") + }; + case IDC_buttonHandgun : { + ["Civil", "HandGunOn"] select (GVAR(currentItems) select 2 != "") + }; + case IDC_buttonHeadgear; + case IDC_buttonUniform; + case IDC_buttonVest; + case IDC_buttonBackpack; + case IDC_buttonGoggles; + case IDC_buttonMap; + case IDC_buttonGPS; + case IDC_buttonRadio; + case IDC_buttonCompass; + case IDC_buttonWatch; + case IDC_buttonFace; + case IDC_buttonNVG : { + "Civil" + }; + case IDC_buttonBinoculars : { + ["Civil", "Binoculars"] select (GVAR(currentItems) select 9 != "") + }; + case IDC_buttonInsigna : { + "Salute" + }; + case IDC_buttonVoice : { + GVAR(center) directSay "CuratorObjectPlaced"; + "Civil" + }; +}; + +if (_nextAction != GVAR(currentAction)) then { + switch (_nextAction) do { + case "PrimaryWeapon": { + GVAR(selectedWeaponType) = 0; + }; + case "SecondaryWeapon": { + GVAR(selectedWeaponType) = 1; + }; + case "HandGunOn": { + GVAR(selectedWeaponType) = 2; + }; + }; + + if (simulationEnabled GVAR(center)) then { + GVAR(center) playActionNow _nextAction; + } else { + GVAR(center) switchAction _nextAction; + }; + + GVAR(currentAction) = _nextAction; +}; diff --git a/addons/arsenal/functions/fnc_sortPanel.sqf b/addons/arsenal/functions/fnc_sortPanel.sqf new file mode 100644 index 0000000000..c8bf02777f --- /dev/null +++ b/addons/arsenal/functions/fnc_sortPanel.sqf @@ -0,0 +1,64 @@ +/* + * Author: Alganthe, Dedmen + * Sort arsenal panel. + * + * Arguments: + * 0: Panel's control to sort + * 1: Sorting mode + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_control", "_mode"]; + +private _display = ctrlParent _control; +private ["_panel", "_curSel", "_selected"]; + +// Right panel +if (ctrlIDC _control == 17 && {GVAR(currentLeftPanel) in [IDC_buttonUniform ,IDC_buttonVest, IDC_buttonBackpack]}) then { + _panel = _display displayCtrl IDC_rightTabContentListnBox; + _curSel = lnbCurSelRow _panel; + _selected = _panel lnbData [_curSel, 0]; + + switch (_mode) do { + case 0: { + _panel lnbSort [1, false]; + }; + + case 1: { + _panel lnbSortByValue [0, false]; + }; + + case 2: { + _panel lnbSort [2, true]; + }; + }; + + if (_cursel >= 0) then { + for '_i' from 0 to (((lnbsize _panel) select 0) - 1) do { + if ((_panel lnbdata [_i, 0]) == _selected) exitwith {_panel lnbSetCurSelRow _i}; + }; + }; +// Left panel +} else { + _panel = _display displayCtrl ([IDC_leftTabContent, IDC_rightTabContent] select (ctrlIDC _control == 17)); + _curSel = lbCurSel _panel; + _selected = _panel lbData _curSel; + + if (_mode > 0) then { + lbSortByValue _panel; + } else { + lbsort _panel; + }; + + if (_cursel >= 0) then { + for '_i' from 0 to (lbsize _panel - 1) do { + if ((_panel lbdata _i) == _selected) exitwith {_panel lbSetCurSel _i}; + }; + }; +}; diff --git a/addons/arsenal/functions/fnc_updateCamPos.sqf b/addons/arsenal/functions/fnc_updateCamPos.sqf new file mode 100644 index 0000000000..f8b6b91a15 --- /dev/null +++ b/addons/arsenal/functions/fnc_updateCamPos.sqf @@ -0,0 +1,27 @@ +/* + * Author: Karel Moricky, modified by Alganthe + * Update camera position + * Modernized a bit, modified vars to fit arsenal rewrite. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: Yes +*/ +#include "script_component.hpp" + +GVAR(cameraPosition) params ["_distance", "_dirH", "_dirV"]; +[GVAR(cameraHelper), [_dirH + 180, - _dirV, 0]] call bis_fnc_setobjectrotation; +GVAR(cameraHelper) attachTo [GVAR(center), GVAR(cameraPosition) select 3, ""]; //--- Reattach for smooth movement + +GVAR(camera) setPos (GVAR(cameraHelper) modelToWorld [0, -_distance, 0]); +GVAR(camera) setVectorDirAndUp [vectorDir GVAR(cameraHelper), vectorUp GVAR(cameraHelper)]; + +//--- Make sure the camera is not underground +if ((getPosAsl GVAR(camera) select 2) < (getPosAsl GVAR(center) select 2)) then { + private _disCoef = ((getPosAsl GVAR(cameraHelper) select 2) - (getPosAsl GVAR(center) select 2)) / ((getPosAsl GVAR(cameraHelper) select 2) - (getPosAsl GVAR(camera) select 2) + 0.001); + GVAR(camera) setPos (GVAR(cameraHelper) modelToWorldVisual [0, -_distance * _disCoef, 0]); +}; diff --git a/addons/arsenal/functions/fnc_updateRightPanel.sqf b/addons/arsenal/functions/fnc_updateRightPanel.sqf new file mode 100644 index 0000000000..aa406868b6 --- /dev/null +++ b/addons/arsenal/functions/fnc_updateRightPanel.sqf @@ -0,0 +1,57 @@ +/* + * Author: Alganthe + * Update the right panel (listnbox). + * + * Arguments: + * 0: Right panel control + * 1: Max load of the current container + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_control", "_maxLoad"]; + +private _loadIndicatorBarCtrl = _display displayCtrl IDC_loadIndicatorBar; +private _curSel = lnbCurSelRow _control; + +(lnbSize _control) params ["_rows"]; + +_maxLoad = getnumber (configfile >> "CfgVehicles" >> _maxLoad >> "maximumLoad"); +_maxLoad = _maxLoad * (1 - (progressPosition _loadIndicatorBarCtrl)); +_maxLoad = parseNumber (_maxLoad toFixed 2); // Required to avoid an issue where even though the typename returns "SCALAR" it doesn't act as one. + +// Grey out items too big +for "_r" from 0 to (_rows - 1) do { + private _mass = _control getVariable (_control lnbData [_r, 0]); + private _class = _control lnbText [_r, 1]; + + private _alpha = [0.25, 1.0] select (_mass <= _maxLoad); + private _color = [1, 1, 1, _alpha]; + _control lnbSetColor [[_r, 1],_color]; + _control lnbSetColor [[_r, 2],_color]; +}; + +// Remove all from container show / hide +private _removeAllCtrl = _display displayCtrl IDC_buttonRemoveAll; + +if (progressPosition _loadIndicatorBarCtrl > 0) then { + + _removeAllCtrl ctrlSetFade 0; + _removeAllCtrl ctrlShow true; + _removeAllCtrl ctrlEnable true; + _removeAllCtrl ctrlCommit FADE_DELAY; +}; + +(_display displayCtrl IDC_totalWeightText) ctrlSetText ([[GVAR(center), 1] call EFUNC(common,getWeight), [GVAR(center), 2] call EFUNC(common,getWeight)] joinString " / "); + +// change button color if unique or too big +if (_curSel != -1) then { + private _plusButtonCtrl = _display displayCtrl IDC_arrowPlus; + _plusButtonCtrl ctrlEnable !((_control lnbValue [_curSel, 2]) == 1 || {(_control getVariable (_control lnbData [_curSel, 0])) > _maxLoad}); + _plusButtonCtrl ctrlCommit FADE_DELAY; +}; diff --git a/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf b/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf new file mode 100644 index 0000000000..7a037d987d --- /dev/null +++ b/addons/arsenal/functions/fnc_updateUniqueItemsList.sqf @@ -0,0 +1,118 @@ +/* + * Author: Alganthe + * Update the list of unique items. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +GVAR(virtualItems) set [18, []]; +GVAR(virtualItems) set [19, []]; +GVAR(virtualItems) set [20, []]; +GVAR(virtualItems) set [21, []]; +GVAR(virtualItems) set [22, [[], [], [], []]]; +GVAR(virtualItems) set [23, []]; +GVAR(virtualItems) set [24, []]; + +private _array = LIST_DEFAULTS select 2; +private _itemsCache = uiNamespace getVariable QGVAR(configItems); + +private _configCfgWeapons = configFile >> "CfgWeapons"; +private _configMagazines = configFile >> "CfgMagazines"; +private _configVehicles = configFile >> "CfgVehicles"; +private _configGlasses = configFile >> "CfgGlasses"; + +{ + switch true do { + // Weapon mag + case ( + isClass (_configMagazines >> _x) && + {_x in (_itemsCache select 2)} && + {!(_x in (GVAR(virtualItems) select 2))} + ): { + (GVAR(virtualItems) select 19) pushBackUnique _x; + }; + + // Mag throw + case ( + isClass (_configMagazines >> _x) && + {_x in (_itemsCache select 15)} && + {!(_x in (GVAR(virtualItems) select 15))} + ): { + (GVAR(virtualItems) select 20) pushBackUnique _x; + }; + + // Mag put + case ( + isClass (_configMagazines >> _x) && + {_x in (_itemsCache select 16)} && + {!(_x in (GVAR(virtualItems) select 16))} + ): { + (GVAR(virtualItems) select 21) pushBackUnique _x; + }; + + // acc + case ( + isClass (_configCfgWeapons >> _x) && + {!(_x in ((GVAR(virtualItems) select 1) select 0))} && + {_x in ((_itemsCache select 1) select 0)} + ): { + ((GVAR(virtualItems) select 22) select 0) pushBackUnique _x; + }; + + // acc + case ( + isClass (_configCfgWeapons >> _x) && + {!(_x in ((GVAR(virtualItems) select 1) select 1))} && + {_x in ((_itemsCache select 1) select 1)} + ): { + ((GVAR(virtualItems) select 22) select 1) pushBackUnique _x; + }; + + // acc + case ( + isClass (_configCfgWeapons >> _x) && + {!(_x in ((GVAR(virtualItems) select 1) select 2))} && + {_x in ((_itemsCache select 1) select 2)} + ): { + ((GVAR(virtualItems) select 22) select 2) pushBackUnique _x; + }; + // acc + case ( + isClass (_configCfgWeapons >> _x) && + {!(_x in ((GVAR(virtualItems) select 1) select 3))} && + {_x in ((_itemsCache select 1) select 3)} + ): { + ((GVAR(virtualItems) select 22) select 3) pushBackUnique _x; + }; + + // Misc + case ( + isClass (_configCfgWeapons >> _x) && + {!(_x in (GVAR(virtualItems) select 17))} && + {!(_x in ((_itemsCache select 1) select 0))} && + {!(_x in ((_itemsCache select 1) select 1))} && + {!(_x in ((_itemsCache select 1) select 2))} && + {!(_x in ((_itemsCache select 1) select 3))} + ): { + (GVAR(virtualItems) select 18) pushBackUnique _x; + }; + + // Backpacks + case (isClass (_configVehicles >> _x)): { + (GVAR(virtualItems) select 23) pushBackUnique _x; + }; + + // Facewear + case (isClass (_configGlasses >> _x)): { + (GVAR(virtualItems) select 24) pushBackUnique _x; + }; + }; +} foreach _array; diff --git a/addons/arsenal/functions/fnc_verifyLoadout.sqf b/addons/arsenal/functions/fnc_verifyLoadout.sqf new file mode 100644 index 0000000000..e7946b8b10 --- /dev/null +++ b/addons/arsenal/functions/fnc_verifyLoadout.sqf @@ -0,0 +1,239 @@ +/* + * Author: Alganthe + * Verify the provided loadout. + * + * Arguments: + * 0: Loadout (getUnitLoadout format) + * + * Return Value: + * Verified loadout and missing / unavailable items list and count + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_loadout"]; + +private _weaponCfg = configFile >> "CfgWeapons"; +private _magCfg = configFile >> "CfgMagazines"; +private _vehcCfg = configFile >> "CfgVehicles"; +private _glassesCfg = configFile >> "CfgGlasses"; +private _weaponsArray = GVAR(virtualItems) select 0; +private _accsArray = GVAR(virtualItems) select 1; + +private _nullItemsAmount = 0; +private _unavailableItemsAmount = 0; +private _nullItemsList = []; +private _unavailableItemsList = []; + +private _fnc_weaponCheck = { + params ["_dataPath"]; + + if (count _dataPath != 0) then { + { + if (_x isEqualType "") then { + + private _item = _x; + + if (_item != "") then { + if (isClass (_weaponCfg >> _item)) then { + if !(CHECK_WEAPON_OR_ACC) then { + + _unavailableItemsList pushBackUnique _item; + _dataPath set [_forEachIndex, ""]; + _unavailableItemsAmount = _unavailableItemsAmount + 1; + }; + } else { + + _nullItemsList pushBackUnique _item; + _dataPath set [_forEachIndex, ""]; + _nullItemsAmount = _nullItemsAmount + 1; + }; + }; + + } else { + + if (count _x != 0) then { + private _mag = _x select 0; + + if (isClass (_magCfg >> _mag)) then { + if !(_mag in (GVAR(virtualItems) select 2)) then { + + _unavailableItemsList pushBackUnique _item; + _dataPath set [_forEachIndex, []]; + _unavailableItemsAmount = _unavailableItemsAmount + 1; + }; + } else { + + _nullItemsList pushBackUnique _item; + _dataPath set [_forEachIndex, []]; + _nullItemsAmount = _nullItemsAmount + 1; + }; + }; + }; + } foreach _dataPath; + }; +}; + +for "_dataIndex" from 0 to 9 do { + switch (_dataIndex) do { + case 0; + case 1; + case 2; + case 8: { + [_loadout select _dataIndex] call _fnc_weaponCheck; + }; + + case 3; + case 4; + case 5: { + private _containerArray = (_loadout select _dataIndex); + + if (count _containerArray != 0) then { + + _containerArray params ["_item", "_containerItems"]; + + if (isClass (_vehcCfg >> _item) || {isClass (_weaponCfg >> _item)}) then { + if !(CHECK_CONTAINER) then { + + _unavailableItemsList pushBackUnique _item; + _loadout set [_dataIndex, []]; + _unavailableItemsAmount = _unavailableItemsAmount + 1; + } else { + + if (count _containerItems != 0) then { + { + private _currentIndex = _forEachIndex; + + switch (count _x) do { + case 2: { + + if ((_x select 0) isEqualType "") then { + + private _item = _x select 0; + + if (CLASS_CHECK_ITEM) then { + if !(CHECK_CONTAINER_ITEMS) then { + + _unavailableItemsList pushBackUnique _item; + ((_loadout select _dataIndex) select 1) set [_currentIndex, []]; + _unavailableItemsAmount = _unavailableItemsAmount + 1; + }; + } else { + + _nullItemsList pushBackUnique _item; + ((_loadout select _dataIndex) select 1) set [_currentIndex, []]; + _nullItemsAmount = _nullItemsAmount + 1; + }; + } else { + + [(((_loadout select _dataIndex) select 1) select _currentIndex) select 0] call _fnc_weaponCheck; + }; + }; + + case 3: { + private _item = _x select 0; + + if (isClass (_magCfg >> _item)) then { + if !( + _item in (GVAR(virtualItems) select 2) || + _item in (GVAR(virtualItems) select 15) || + _item in (GVAR(virtualItems) select 16) + ) then { + + _unavailableItemsList pushBackUnique _item; + ((_loadout select _dataIndex) select 1) set [_currentIndex, []]; + _unavailableItemsAmount = _unavailableItemsAmount + 1; + }; + } else { + + _nullItemsList pushBackUnique _item; + ((_loadout select _dataIndex) select 1) set [_currentIndex, []]; + _nullItemsAmount = _nullItemsAmount + 1; + }; + }; + }; + } foreach _containerItems; + }; + }; + } else { + + _nullItemsList pushBackUnique _item; + _loadout set [_dataIndex, []]; + _nullItemsAmount = _nullItemsAmount + 1; + }; + }; + }; + + case 6: { + private _item = _loadout select _dataIndex; + + if (_item != "") then { + + if (isClass (_weaponCfg >> _item)) then { + + if !(_item in (GVAR(virtualItems) select 3)) then { + + _unavailableItemsList pushBackUnique _item; + _loadout set [_dataIndex, ""]; + _unavailableItemsAmount = _unavailableItemsAmount + 1; + }; + } else { + + _nullItemsList pushBackUnique _item; + _loadout set [_dataIndex, ""]; + _nullItemsAmount = _nullItemsAmount + 1; + }; + }; + }; + + case 7: { + private _item = _loadout select _dataIndex; + + if (_item != "") then { + + if (isClass (_glassesCfg >> _item)) then { + + if !(_item in (GVAR(virtualItems) select 7)) then { + + _unavailableItemsList pushBackUnique _item; + _loadout set [_dataIndex, ""]; + _unavailableItemsAmount = _unavailableItemsAmount + 1; + }; + } else { + + _nullItemsList pushBackUnique _item; + _loadout set [_dataIndex, ""]; + _nullItemsAmount = _nullItemsAmount + 1; + }; + }; + }; + + case 9: { + for "_subIndex" from 0 to 4 do { + private _item = (_loadout select _dataIndex) select _subIndex; + + if (_item != "") then { + + if (isClass (_weaponCfg >> _item)) then { + + if !(CHECK_ASSIGNED_ITEMS) then { + + _unavailableItemsList pushBackUnique _item; + (_loadout select _dataIndex) set [_subIndex, ""]; + _unavailableItemsAmount = _unavailableItemsAmount + 1; + }; + } else { + + _nullItemsList pushBackUnique _item; + (_loadout select _dataIndex) set [_subIndex, ""]; + _nullItemsAmount = _nullItemsAmount + 1; + }; + }; + }; + }; + }; +}; + +[_loadout, _nullItemsAmount, _unavailableItemsAmount, _nullItemsList, _unavailableItemsList] diff --git a/addons/arsenal/functions/script_component.hpp b/addons/arsenal/functions/script_component.hpp new file mode 100644 index 0000000000..523addf768 --- /dev/null +++ b/addons/arsenal/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\arsenal\script_component.hpp" \ No newline at end of file diff --git a/addons/arsenal/script_component.hpp b/addons/arsenal/script_component.hpp new file mode 100644 index 0000000000..2eb9c3f170 --- /dev/null +++ b/addons/arsenal/script_component.hpp @@ -0,0 +1,17 @@ +#define COMPONENT arsenal +#define COMPONENT_BEAUTIFIED Arsenal +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_ARSENAL + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_ARSENAL + #define DEBUG_SETTINGS DEBUG_SETTINGS_ARSENAL +#endif + +#include "\z\ace\addons\main\script_macros.hpp" diff --git a/addons/arsenal/stringtable.xml b/addons/arsenal/stringtable.xml new file mode 100644 index 0000000000..a593cc5d6b --- /dev/null +++ b/addons/arsenal/stringtable.xml @@ -0,0 +1,322 @@ + + + + + Hide + Cacher + Verstecken + Ukryj + + + Hide interface + Cache l'interface + Oberfläche verstecken + Ukryj interfejs + + + Loadouts + Équipements + Ausrüstungen + Zestawy wyposażenia + + + Export + Exporter + Exportieren + Eksportuj + + + Import + Importer + Importieren + Importuj + + + Close + Fermer + Schließen + Zamknij + + + No virtual item available + Aucun objet virtuel disponible + Kein virtuelles Objekt verfügbar + Brak dostępnych przedmiotów wirtualnych + + + Save + Enregister + Speichern + Zapisz + + + Save the current loadout + Enregistre l'équipement actuel + Ausgewählte Ausrüstung speichern + Zapisz obecny zestaw + + + Rename + Renommer + Umbenennen + Zmień nazwę + + + Rename the selected loadout + Renomme l'équipement sélectionné + Ausgewählte Ausrüstung umbenennen + Zmień nazwę wybranego zestawu + + + Load + Charger + Laden + Wczytaj + + + Load the selected loadout + Charger l'équipement sélectionné + Ausgewählte Ausrüstung laden + Wczytaj wybrany zestaw + + + Delete + Supprimer + Entfernen + Skasuj + + + Delete the selected loadout + Supprimer l'équipement sélectionné + Ausgewählte Ausrüstung entfernen + Skasuj wybrany zestaw + + + My loadouts + Mes équipements + Meine Ausrüstungen + Moje zestawy + + + Loadouts saved in your profile + Équipements enregistrés dans votre profil + Ausrüstungen, die in deinem Profil gespeichert sind + Zestawy zapisane w Twoim profilu + + + Default loadouts + Équipements de base + Standard-Ausrüstungen + Domyślne zestawy + + + Loadouts made available by the mission maker + Équipements faits par l'auteur de la mission + Ausrüstungen, die durch den Missionsersteller zur Verfügung gestellt worden sind + Zestawy udostępnione przez twórcę misji + + + Public loadouts + Équipements publics + Veröffentlichte Ausrüstungen + Publiczne zestawy + + + Loadouts shared by you and other players + Équipements mis à disposition par vous ou les autres joueurs + Ausrüstungen, die von dir und anderen Spielern geteilt wurden + Zestawy udostępnione przez Ciebie i innych graczy + + + Sort by weight + Trier par poids + Nach Gewicht sortieren + Sortuj wg wagi + + + Sort by amount + Trier par quantité + Nach Menge sortieren + Sortuj wg ilości + + + Share or stop sharing the selected loadout + Partager ou arrêter de partager cet équipement + Ausgewählte Ausrüstung teilen oder nicht mehr teilen + Udostępnij lub przestań udostępniać wybrany zestaw + + + Private + Privé + Privat + Prywatny + + + Public + Public + Öffentlich + Publiczny + + + The default loadouts list is empty! + La liste d'équipements de base est vide ! + Die Standard-Ausrüstungen-Liste ist leer! + Lista domyślnych zestawów jest pusta! + + + Default loadouts list exported to clipboard + Liste d'équipements de base exportée dans le presse papier + Standard-Ausrüstungen-Liste in die Zwischenablage exportiert + Lista domyślnych zestawów została eksportowana do schowka + + + Current loadout exported to clipboard + Équipement actuel exporté dans le presse papier + Derzeitige Ausrüstung in die Zwischenablage exportiert + Obecny zestaw został eksportowany do schowka + + + Wrong format provided + Mauvais format fourni + Falsches Format verwendet + Podano zły format + + + Default loadouts list imported from clipboard + Liste d'équipements de base importée depuis le presse papier + Standard-Ausrüstungen-Liste aus der Zwischenablage importiert + Lista domyślnych zestawów została importowana ze schowka + + + Loadout imported from clipboard + Équipement importé depuis le presse papier + Ausrüstung aus der Zwischenablage importiert + Zestaw został importowany ze schowka + + + The following loadout was deleted: + L'équipement suivant fut supprimé: + Folgende Ausrüstung wurde entfernt: + Następujący zestaw został skasowany: + + + The following loadout is not public anymore: + L'équipement suivant n'est plus public: + Folgende Ausrüstung ist nicht mehr öffentlich: + Następujący zestaw nie jest już publiczny: + + + The name field is empty! + Le champ nom est vide ! + Das Feld "Name" ist leer! + Pole nazwy jest puste! + + + You are the author of this loadout + Vous êtes l'auteur de cet équipement + Du bist der Ersteller dieser Ausrüstung + Jesteś autorem tego zestawu + + + A loadout of yours with the same name is public + Un de vos équipements avec le même nom est public + Eine deiner Ausrüstungen mit dem gleichen Namen ist öffentlich + Jeden z Twoich zestawów nazwany tak samo jest już publiczny + + + The following loadout was saved: + L'équipement suivant fut enregistré: + Folgende Ausrüstung wurde gespeichert: + Następujący zestaw został zapisany: + + + The following loadout was loaded: + L'équipement suivant fut chargé: + Folgene Ausrüstung wurde geladen: + Następujący zestaw został wczytany: + + + A loadout with the same name already exist! + Un équipement avec le même nom existe déjà ! + Eine Ausrüstung mit dem gleichen Namen existiert bereits! + Zestaw z tą nazwą już istnieje! + + + was renamed to + fut renommé en + wurde umbenannt in + zmienił nazwę na + + + Invert camera controls + Inverser les contrôles de la caméra + Kamerasteuerung invertieren + Odwróć sterowanie kamerą + + + Enable mod icons + Afficher les icônes de mod + Aktiviert Mod-Icons + Włącz ikony modów + + + Panel font height + taille de police des panneaux + Schrifthöhe für die linke und rechte Liste + Wysokość czcionki + + + Allow default loadouts + Activer l'onglet équipement de base + Erlaubt die Benutzung des Standard-Ausrüstungen-Reiters + Zezwól na użycie domyślnych zestawów + + + Allow loadout sharing + Autoriser le partage d'équipement + Erlaubt das Teilen von Ausrüstungen + Zezwól na udostępnianie zestawów + + + Log missing / unavailable items + Enregistrer les objets manquants + Aktiviert die Aufzeichnung fehlender Gegenstände in der RPT + Rejestruj brakujące / niedostępne przedmioty + + + Primary magazine + Chargeur principal + Główny magazynek + + + Secondary magazine + Chargeur secondaire + Dodatkowy magazynek + + + ACE - Arsenal + ACE - Arsenal + ACE - Arsenał + + + Allow the use of the default loadouts tab + Autorise l'usage de l'onglet équipements de base + Zezwól na użycie zakładki domyślnych zestawów + + + Show / hide mod icons for the left panel + Montrer / cacher les icones de mod pour le panneau de gauche + Pokaż / ukryj ikony modów w lewym panelu + + + Change the font height for text in the left / right panels + Change la taille de police du texte des panneaux gauche / droite + Zmień wysokość czcionki dla tekstu lewego i prawego panelu + + + Log missing / unavailable items in the RPT + Enregistre les objets manquants / indisponibles dans le RPT + Rejestruj brakujące / niedostępne przedmioty do pliku RPT + + + diff --git a/addons/arsenal/ui/RscAttributes.hpp b/addons/arsenal/ui/RscAttributes.hpp new file mode 100644 index 0000000000..b1faccfd70 --- /dev/null +++ b/addons/arsenal/ui/RscAttributes.hpp @@ -0,0 +1,898 @@ +#include "RscCommon.hpp" +#include "..\defines.hpp" + +class GVAR(display) { + idd = IDD_ace_arsenal; + enableSimulation=1; + onLoad = QUOTE([ARR_3('onLoad', _this, QQGVAR(display))] call FUNC(onArsenalOpen)); + onUnload = QUOTE([ARR_3('onUnload', _this, QQGVAR(display))] call FUNC(onArsenalClose)); + onKeyDown = QUOTE([ARR_3('onKeyDown', _this, QQGVAR(display))] call FUNC(onKeyDown)); + onKeyUp = QUOTE(GVAR(shiftState) = _this select 2); + onMouseButtonDown = QUOTE([ARR_3('onMouseButtonDown', _this, QQGVAR(display))] call FUNC(onMouseButtonDown)); + onMouseButtonUp = QUOTE([ARR_3('onMouseButtonUp', _this, QQGVAR(display))] call FUNC(onMouseButtonUp)); + icon="\A3\Ui_f\data\Logos\a_64_ca.paa"; + logo="\A3\Ui_f\data\Logos\arsenal_1024_ca.paa"; + class ControlsBackground { + class blackLeft: ctrlStatic { + colorBackground[]={0,0,0,1}; + x = QUOTE(safezoneXAbs); + y = QUOTE(safezoneY); + w = QUOTE(safezoneXAbs - safezoneX); + h = QUOTE(safezoneH); + }; + + class blackRight: blackLeft { + x = QUOTE(safezoneX + safezoneW); + }; + + class mouseArea: ctrlStatic { + idc = IDC_mouseArea; + style = 16; + onMouseMoving = QUOTE([ARR_3('onMouseMoving', _this, GVAR(display))] call FUNC(handleMouse)); + onMouseHolding = QUOTE([ARR_3('onMouseHolding', _this, GVAR(display))] call FUNC(handleMouse)); + onMouseZChanged = QUOTE([ARR_3('onMouseZChanged', _this, GVAR(display))] call FUNC(handleScrollWheel)); + x = QUOTE(safezoneX); + y = QUOTE(safezoneY); + w = QUOTE(safezoneW); + h = QUOTE(safezoneH); + }; + }; + class controls { + class ArrowLeft: ctrlButton { + idc = IDC_arrowMinus; + text = "-"; + colorBackground[]={0,0,0,0.8}; + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), -1)] call FUNC(buttonCargo)); + fade = 1; + enable = 0; + x = 0.5; + y = 0.5; + w = QUOTE(1 * GRID_W); + h = QUOTE(1 * GRID_H); + sizeEx = QUOTE(7 * GRID_H); + }; + class ArrowRight: ArrowLeft { + idc = IDC_arrowPlus; + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), 1)] call FUNC(buttonCargo)); + text="+"; + }; + class blockLeftFrame: RscFrame { + idc = IDC_blockLeftFrame; + x = QUOTE(safezoneX + 13 * GRID_W); + y = QUOTE(safezoneY + 14 * GRID_H); + w = QUOTE(80 * GRID_W); + h = QUOTE(safezoneH - 24 * GRID_H); + colorText[] = {0,0,0,1}; + }; + class blockLeftBackground: ctrlStaticBackground { + idc = IDC_blockLeftBackground; + x = QUOTE(safezoneX + 13 * GRID_W); + y = QUOTE(safezoneY + 14 * GRID_H); + w = QUOTE(80 * GRID_W); + h = QUOTE(safezoneH - 24 * GRID_H); + colorBackground[] = {0,0,0,0.5}; + }; + class blockRightFrame: blockLeftFrame { + idc = IDC_blockRightFrame; + x = QUOTE(safezoneX + safezoneW - 93 * GRID_W); + h = QUOTE(safezoneH - 34 * GRID_H); + }; + class blockRighttBackground: blockLeftBackground { + idc = IDC_blockRighttBackground; + x = QUOTE(safezoneX + safezoneW - 93 * GRID_W); + h = QUOTE(safezoneH - 34 * GRID_H); + }; + class loadIndicator: RscControlsGroupNoScrollbars { + idc = IDC_loadIndicator; + x = QUOTE(safezoneX + safezoneW - 93 * GRID_W); + y = QUOTE(safeZoneH + safezoneY - 20 * GRID_H); + w = QUOTE(80 * GRID_W); + h = QUOTE(6 * GRID_H); + class controls { + class loadIndicatorBackground: ctrlStaticBackground { + idc = -1; + colorBackground[] = {0,0,0,0.5}; + x = 0; + y = 0; + w = QUOTE(80 * GRID_W); + h = QUOTE(6 * GRID_H); + }; + class loadIndicatorBar: ctrlProgress { + idc = IDC_loadIndicatorBar; + style = 0; + texture = "#(argb,8,8,3)color(1,1,1,1)"; + colorBar[] = {1,1,1,1}; + colorFrame[] = {0,0,0,1}; + x = 0; + y = 0; + w = QUOTE(80 * GRID_W); + h = QUOTE(6 * GRID_H); + }; + }; + }; + class totalWeight: RscControlsGroupNoScrollbars { + idc = IDC_totalWeight; + x = QUOTE(safezoneX + 13 * GRID_W); + y = QUOTE(safeZoneH + safezoneY - 10 * GRID_H); + w = QUOTE(80 * GRID_W); + h = QUOTE(8 * GRID_H); + class controls { + class totalWeightBackground: ctrlStaticBackground { + idc = -1; + colorBackground[] = {0,0,0,0.8}; + x = 0; + y = 0; + w = QUOTE(80 * GRID_W); + h = QUOTE(8 * GRID_H); + }; + class totalWeightTitle: RscText { + idc = -1; + text = ECSTRING(common,Weight); + x = 0; + y = 0; + w = QUOTE(40 * GRID_W); + h = QUOTE(8 * GRID_H); + sizeEx = QUOTE(7 * GRID_H); + }; + class totalWeightText: RscText { + idc = IDC_totalWeightText; + style = ST_RIGHT; + text = ""; + x = QUOTE(40 * GRID_W); + y = 0; + w = QUOTE(40 * GRID_W); + h = QUOTE(8 * GRID_H); + sizeEx = QUOTE(7 * GRID_H); + }; + }; + }; + class message: RscText { + idc = IDC_message; + fade = 1; + style=2; + shadow=0; + colorBackground[]={0,0,0,0.69999999}; + text=""; + x = QUOTE(safezoneX + safezoneW * 0.50 - 80 * GRID_W); + y = QUOTE(safeZoneH + safezoneY - 25 * GRID_H); + w = QUOTE(160 * GRID_W); + h = QUOTE(10 * GRID_H); + sizeEx = QUOTE(5 * GRID_H); + }; + class menuBar: RscControlsGroupNoScrollbars { + idc = IDC_menuBar; + x = QUOTE((safezoneX + safezoneW * 0.50) - (105 * GRID_W)); + y = QUOTE(safezoneH + safezoneY - 9 * GRID_H); + w = QUOTE(210 * GRID_W); + h = QUOTE(7 * GRID_H); + class controls { + class buttonHide: ctrlButton { + idc = -1; + colorBackground[] = {0,0,0,0.8}; + x = QUOTE(0 * GRID_W); + y = QUOTE(0); + w = QUOTE(40 * GRID_W); + h = QUOTE(7 * GRID_H); + text = CSTRING(buttonHideText); + shortcuts[] = {"0x0E"}; + tooltip = CSTRING(buttonHideTooltip); + onButtonClick = QUOTE([ctrlparent (_this select 0)] call FUNC(buttonHide)); + }; + class buttonLoadouts: buttonHide { + idc = -1; + x = QUOTE(42.5 * GRID_W); + text = CSTRING(buttonLoadoutsText); + onButtonClick = QUOTE(createDialog QQGVAR(loadoutsDisplay)); + }; + class buttonExport: buttonHide { + idc = -1; + x = QUOTE(85 * GRID_W); + text = CSTRING(buttonExportText); + onButtonClick = QUOTE([ctrlparent (_this select 0)] call FUNC(buttonExport)); + }; + class buttonImport: buttonHide { + idc = -1; + x = QUOTE(127.5 * GRID_W); + text = CSTRING(buttonImportText); + onButtonClick = QUOTE([ctrlparent (_this select 0)] call FUNC(buttonImport)); + }; + class buttonClose: ctrlButtonClose { + idc = -1; + colorBackground[] = {0,0,0,0.8}; + x = QUOTE(170 * GRID_W); + y = QUOTE(0); + w = QUOTE(40 * GRID_W); + h = QUOTE(7 * GRID_H); + text = CSTRING(buttonCloseText); + shortcuts[]= {"0x01"}; + onButtonClick = QUOTE(ctrlparent (_this select 0) closeDisplay 2); + }; + }; + }; + class infoBox: RscControlsGroupNoScrollbars { + idc = IDC_infoBox; + fade = 1; + x = QUOTE(safezoneX + safezoneW - 93 * GRID_W); + y = QUOTE(safeZoneH + safezoneY - 14 * GRID_H); + w = QUOTE(92 * GRID_W); + h = QUOTE(12 * GRID_H); + class controls { + class infoBackground: ctrlStaticBackground { + idc = IDC_infoBackground; + x = QUOTE(0 * GRID_W); + y = QUOTE(0); + w = QUOTE(80 * GRID_W); + h = QUOTE(12 * GRID_H); + colorBackground[] = {0,0,0,0.8}; + }; + class infoName: RscText { + idc = IDC_infoName; + x = QUOTE(0 * GRID_W); + y = QUOTE(0); + w = QUOTE(80 * GRID_W); + h = QUOTE(7 * GRID_H); + sizeEx = QUOTE(5.5 * GRID_H); + }; + class infoAuthor: RscText { + idc = IDC_infoAuthor; + colorText[] = {1,1,1,0.5}; + x = QUOTE(0 * GRID_W); + y = QUOTE(6 * GRID_H); + w = QUOTE(80 * GRID_W); + h = QUOTE(5 * GRID_H); + sizeEx = QUOTE(5 * GRID_H); + }; + class DLCBackground: ctrlStaticBackground { + idc = IDC_DLCBackground; + fade = 1; + x = QUOTE(80 * GRID_W); + y = QUOTE(0); + w = QUOTE(12 * GRID_W); + h = QUOTE(12 * GRID_H); + }; + class DLCIcon: RscActivePicture { + idc = IDC_DLCIcon; + enabled = 0; + fade = 1; + color[] = {1,1,1,1}; + colorActive[] = {1,1,1,1}; + text="#(argb,8,8,3)color(1,1,1,1)"; + x = QUOTE(80 * GRID_W); + y = QUOTE(0); + w = QUOTE(12 * GRID_W); + h = QUOTE(12 * GRID_H); + }; + }; + }; + class mouseBlock: RscText { + idc = IDC_mouseBlock; + style = 16; + x = QUOTE(safezoneX); + y = QUOTE(safezoneY); + w = QUOTE(safezoneW); + h = QUOTE(safezoneH); + }; + class leftTabContent: RscListBox { + idc = IDC_leftTabContent; + colorBackground[]={0,0,0,0}; + colorSelectBackground[]={1,1,1,0.5}; + colorSelectBackground2[]={1,1,1,0.5}; + colorPictureSelected[]={1,1,1,1}; + colorSelect[]={1,1,1,1}; + colorSelect2[]={1,1,1,1}; + colorPictureRightSelected[]={1,1,1,1}; + onLBSelChanged = QUOTE(_this call FUNC(onSelChangedLeft)); + onSetFocus = QUOTE(GVAR(leftTabFocus) = true); + onKillFocus = QUOTE(GVAR(leftTabFocus) = false); + x = QUOTE(safezoneX + 13 * GRID_W); + y = QUOTE(safezoneY + 14 * GRID_H); + w = QUOTE(80 * GRID_W); + h = QUOTE(safezoneH - 24.5 * GRID_H); + sizeEx = QUOTE(7 * GRID_H); + }; + class rightTabContent: leftTabContent { + idc = IDC_rightTabContent; + drawSideArrows=1; + disableOverflow=1; + onLBSelChanged = QUOTE(_this call FUNC(onSelChangedRight)); + onSetFocus = QUOTE(GVAR(rightTabFocus) = true); + onKillFocus = QUOTE(GVAR(rightTabFocus) = false); + x = QUOTE(safezoneX + safezoneW - 93 * GRID_W); + h = QUOTE(safezoneH - 34.5 * GRID_H); + }; + class rightTabContentListnBox : RscListNBox { + idc = IDC_rightTabContentListnBox; + colorBackground[]={0,0,0,0}; + colorSelectBackground[]={1,1,1,0.5}; + colorSelectBackground2[]={1,1,1,0.5}; + colorPictureSelected[]={1,1,1,1}; + colorSelect[]={1,1,1,1}; + colorSelect2[]={1,1,1,1}; + colorPictureRightSelected[]={1,1,1,1}; + columns[]={0.07, 0.15, 0.75}; + idcLeft = IDC_arrowMinus; + idcRIght = IDC_arrowPlus; + drawSideArrows=1; + disableOverflow=1; + onLBSelChanged = QUOTE(_this call FUNC(onSelChangedRightListnBox)); + onSetFocus = QUOTE(GVAR(rightTabLnBFocus) = true); + onKillFocus = QUOTE(GVAR(rightTabLnBFocus) = false); + x = QUOTE(safezoneX + safezoneW - 93 * GRID_W); + y = QUOTE(safezoneY + 14 * GRID_H); + w = QUOTE(80 * GRID_W); + h = QUOTE(safezoneH - 34.5 * GRID_H); + sizeEx = QUOTE(7 * GRID_H); + }; + class sortLeftTab: RscCombo { + idc = IDC_sortLeftTab; + x = QUOTE(safezoneX + 13 * GRID_W); + y = QUOTE(safezoneY + 8 * GRID_H); + w = QUOTE(80 * GRID_W); + h = QUOTE(6 * GRID_H); + onLBSelChanged = QUOTE(_this call FUNC(sortPanel)); + class Items { + class Alphabet { + text="$STR_a3_rscdisplayarsenal_sort_alphabet"; + default=1; + value= 0; + }; + class Mod { + text="$STR_a3_rscdisplayarsenal_sort_mod"; + value= 1; + }; + }; + }; + class sortRightTab: sortLeftTab { + idc = IDC_sortRightTab; + x = QUOTE(safezoneX + safezoneW - 93 * GRID_W); + class Items { + class Alphabet { + text="$STR_a3_rscdisplayarsenal_sort_alphabet"; + default=1; + value= 0; + }; + class Weight { + text="$STR_a3_rscdisplayarsenal_sort_mod"; + value= 1; + }; + }; + }; + class leftSearchbar: ctrlEdit { + idc = IDC_leftSearchbar; + onSetFocus = QUOTE(GVAR(leftSearchbarFocus) = true); + onKillFocus = QUOTE(GVAR(leftSearchbarFocus) = false); + onMouseButtonClick = QUOTE([ARR_3(ctrlParent (_this select 0), _this select 0, _this select 1)] call FUNC(clearSearchbar)); + x = QUOTE(safezoneX + 13 * GRID_W); + y = QUOTE(safezoneY + 1.8 * GRID_H); + w = QUOTE(74 * GRID_W); + h = QUOTE(6 * GRID_H); + }; + class leftSearchbarButton: ctrlButtonPicture { + idc = IDC_leftSearchbarButton; + text = "\a3\Ui_f\data\GUI\RscCommon\RscButtonSearch\search_start_ca.paa"; + colorBackground[]={0,0,0,0.5}; + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), ctrlparent (_this select 0) displayCtrl IDC_leftSearchbar)] call FUNC(handleSearchbar)); + x = QUOTE(safezoneX + 87 * GRID_W); + y = QUOTE(safezoneY + 1.8 * GRID_H); + w = QUOTE(6 * GRID_W); + h = QUOTE(6 * GRID_H); + }; + class rightSearchbar: leftSearchBar { + idc = IDC_rightSearchbar; + onSetFocus = QUOTE(GVAR(rightSearchbarFocus) = true); + onKillFocus = QUOTE(GVAR(rightSearchbarFocus) = false); + x = QUOTE(safezoneX + safezoneW - 87 * GRID_W); + }; + class rightSearchbarButton: leftSearchbarButton { + idc = IDC_rightSearchbarButton; + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), ctrlparent (_this select 0) displayCtrl IDC_rightSearchbar)] call FUNC(handleSearchbar)); + x = QUOTE(safezoneX + safezoneW - 93 * GRID_W); + }; + class tabLeft: RscControlsGroupNoScrollbars { + idc = IDC_tabLeft; + x = QUOTE(safezoneX + 1 * GRID_W); + y = QUOTE(safezoneY + 8 * GRID_H); + w = QUOTE(12 * GRID_W); + h = QUOTE(200 * GRID_H); + class controls { + class iconBackgroundPrimaryWeapon: ctrlStaticBackground { + idc = IDC_iconBackgroundPrimaryWeapon; + fade=1; + enable=0; + colorBackground[]={0,0,0,1}; + x = QUOTE(0); + y = QUOTE(0 * GRID_H); + w = QUOTE(12 * GRID_W); + h = QUOTE(9 * GRID_H); + }; + class buttonPrimaryWeapon: RscButtonArsenal { + idc = IDC_buttonPrimaryWeapon; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\PrimaryWeapon_ca.paa"; + tooltip="$STR_A3_RscDisplayArsenal_tab_PrimaryWeapon"; + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), _this select 0)] call FUNC(fillLeftPanel)); + colorBackground[]={0,0,0,0.5}; + x = QUOTE(0 * GRID_W); + y = QUOTE(0 * GRID_H); + w = QUOTE(9 * GRID_W); + h = QUOTE(9 * GRID_H); + }; + class iconBackgroundHandgun: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundHandgun; + y = QUOTE(10 * GRID_H); + }; + class buttonHandgun: buttonPrimaryWeapon { + idc = IDC_buttonHandgun; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Handgun_ca.paa"; + tooltip="$STR_A3_RscDisplayArsenal_tab_Handgun"; + y = QUOTE(10 * GRID_H); + }; + class iconBackgroundSecondaryWeapon: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundSecondaryWeapon; + y = QUOTE(20 * GRID_H); + }; + class buttonSecondaryWeapon: buttonPrimaryWeapon { + idc = IDC_buttonSecondaryWeapon; + tooltip="$STR_A3_RscDisplayArsenal_tab_SecondaryWeapon"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\SecondaryWeapon_ca.paa"; + y = QUOTE(20 * GRID_H); + }; + class iconBackgroundHeadgear: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundHeadgear; + y = QUOTE(30 * GRID_H); + }; + class buttonHeadgear: buttonPrimaryWeapon { + idc = IDC_buttonHeadgear; + tooltip="$STR_A3_RscDisplayArsenal_tab_Headgear"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Headgear_ca.paa"; + y = QUOTE(30 * GRID_H); + }; + class iconBackgroundUniform: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundUniform; + y = QUOTE(40 * GRID_H); + }; + class buttonUniform: buttonPrimaryWeapon { + idc = IDC_buttonUniform; + tooltip="$STR_A3_RscDisplayArsenal_tab_Uniform"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Uniform_ca.paa"; + y = QUOTE(40 * GRID_H); + }; + class iconBackgroundVest: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundVest; + y = QUOTE(50 * GRID_H); + }; + class buttonVest: buttonPrimaryWeapon { + idc = IDC_buttonVest; + tooltip="$STR_A3_RscDisplayArsenal_tab_Vest"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Vest_ca.paa"; + y = QUOTE(50 * GRID_H); + }; + class iconBackgroundBackpack: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundBackpack; + y = QUOTE(60 * GRID_H); + }; + class buttonBackpack: buttonPrimaryWeapon { + idc = IDC_buttonBackpack; + tooltip="$STR_A3_RscDisplayArsenal_tab_Backpack"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Backpack_ca.paa"; + y = QUOTE(60 * GRID_H); + }; + class iconBackgroundGoggles: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundGoggles; + y = QUOTE(70 * GRID_H); + }; + class buttonGoggles: buttonPrimaryWeapon { + idc = IDC_buttonGoggles; + tooltip="$STR_A3_RscDisplayArsenal_tab_Goggles"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Goggles_ca.paa"; + y = QUOTE(70 * GRID_H); + }; + class iconBackgroundNVG: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundNVG; + y = QUOTE(80 * GRID_H); + }; + class buttonNVG: buttonPrimaryWeapon { + idc = IDC_buttonNVG; + tooltip="$STR_A3_RscDisplayArsenal_tab_NVGs"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\NVGs_ca.paa"; + y = QUOTE(80 * GRID_H); + }; + class iconBackgroundBinoculars: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundBinoculars; + y = QUOTE(90 * GRID_H); + }; + class buttonBinoculars: buttonPrimaryWeapon { + idc = IDC_buttonBinoculars; + tooltip="$STR_A3_RscDisplayArsenal_tab_Binoculars"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Binoculars_ca.paa"; + y = QUOTE(90 * GRID_H); + }; + class iconBackgroundMap: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundMap; + y = QUOTE(100 * GRID_H); + }; + class buttonMap: buttonPrimaryWeapon { + idc = IDC_buttonMap; + tooltip="$STR_A3_RscDisplayArsenal_tab_Map"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Map_ca.paa"; + y = QUOTE(100 * GRID_H); + }; + class iconBackgroundGPS: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundGPS; + y = QUOTE(110 * GRID_H); + }; + class buttonGPS: buttonPrimaryWeapon { + idc = IDC_buttonGPS; + tooltip="$STR_A3_RscDisplayArsenal_tab_GPS"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\GPS_ca.paa"; + y = QUOTE(110 * GRID_H); + }; + class iconBackgroundRadio: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundRadio; + y = QUOTE(120 * GRID_H); + }; + class buttonRadio: buttonPrimaryWeapon { + idc = IDC_buttonRadio; + tooltip="$STR_A3_RscDisplayArsenal_tab_Radio"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Radio_ca.paa"; + y = QUOTE(120 * GRID_H); + }; + class iconBackgroundCompass: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundCompass; + y = QUOTE(130 * GRID_H); + }; + class buttonCompass: buttonPrimaryWeapon { + idc = IDC_buttonCompass; + tooltip="$STR_A3_RscDisplayArsenal_tab_Compass"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Compass_ca.paa"; + y = QUOTE(130 * GRID_H); + }; + class iconBackgroundWatch: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundWatch; + y = QUOTE(140 * GRID_H); + }; + class buttonWatch: buttonPrimaryWeapon { + idc = IDC_buttonWatch; + tooltip="$STR_A3_RscDisplayArsenal_tab_Watch"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Watch_ca.paa"; + y = QUOTE(140 * GRID_H); + }; + class iconBackgroundFace: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundFace; + y = QUOTE(150 * GRID_H); + }; + class buttonFace: buttonPrimaryWeapon { + idc = IDC_buttonFace; + tooltip="$STR_A3_RscDisplayArsenal_tab_Face"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Face_ca.paa"; + y = QUOTE(150 * GRID_H); + }; + class iconBackgroundVoice: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundVoice; + y = QUOTE(160 * GRID_H); + }; + class buttonVoice: buttonPrimaryWeapon { + idc = IDC_buttonVoice; + tooltip="$STR_A3_RscDisplayArsenal_tab_Voice"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Voice_ca.paa"; + y = QUOTE(160 * GRID_H); + }; + class iconBackgroundInsigna: IconBackgroundPrimaryWeapon { + idc = IDC_iconBackgroundInsigna; + y = QUOTE(170 * GRID_H); + }; + class buttonInsigna: buttonPrimaryWeapon { + idc = IDC_buttonInsigna; + tooltip="$STR_A3_RscDisplayArsenal_tab_Insignia"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Insignia_ca.paa"; + y = QUOTE(170 * GRID_H); + }; + }; + }; + class iconBackgroundOptic: ctrlStaticBackground { + idc = IDC_iconBackgroundOptic; + colorBackground[]={0,0,0,1}; + fade=1; + enable=0; + x = QUOTE(safezoneW + safezoneX - 13 * GRID_W); + y = QUOTE(safezoneY + 8 * GRID_H); + w = QUOTE(12 * GRID_W); + h = QUOTE(9 * GRID_H); + }; + class buttonOptic: RscButtonArsenal { + idc = IDC_buttonOptic; + tooltip="$STR_A3_RscDisplayArsenal_tab_ItemOptic"; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\ItemOptic_ca.paa"; + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), _this select 0)] call FUNC(fillRightPanel)); + colorBackground[]={0,0,0,0.5}; + x = QUOTE(safezoneW + safezoneX - 10 * GRID_W); + y = QUOTE(safezoneY + 8 * GRID_H); + w = QUOTE(9 * GRID_W); + h = QUOTE(9 * GRID_H); + }; + class iconBackgroundItemAcc: iconBackgroundOptic { + idc = IDC_iconBackgroundItemAcc; + y = QUOTE(safezoneY + 18 * GRID_H); + }; + class buttonItemAcc: buttonOptic { + idc = IDC_buttonItemAcc; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\ItemAcc_ca.paa"; + tooltip="$STR_A3_RscDisplayArsenal_tab_ItemAcc"; + y = QUOTE(safezoneY + 18 * GRID_H); + }; + class iconBackgroundMuzzle: iconBackgroundOptic { + idc = IDC_iconBackgroundMuzzle; + y = QUOTE(safezoneY + 28 * GRID_H); + }; + class buttonMuzzle: buttonOptic { + idc = IDC_buttonMuzzle; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\ItemMuzzle_ca.paa"; + tooltip="$STR_A3_RscDisplayArsenal_tab_ItemMuzzle"; + y = QUOTE(safezoneY + 28 * GRID_H); + }; + class iconBackgroundBipod: iconBackgroundOptic { + idc = IDC_iconBackgroundBipod; + y = QUOTE(safezoneY + 38 * GRID_H); + }; + class buttonBipod: buttonOptic { + idc = IDC_buttonBipod; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\ItemBipod_ca.paa"; + tooltip="$STR_A3_RscDisplayArsenal_tab_ItemBipod"; + y = QUOTE(safezoneY + 38 * GRID_H); + }; + class iconBackgroundCurrentMag: iconBackgroundOptic { + idc = IDC_iconBackgroundCurrentMag; + y = QUOTE(safezoneY + 48 * GRID_H); + }; + class buttonCurrentMag: buttonOptic { + idc = IDC_buttonCurrentMag; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\CargoMag_ca.paa"; + tooltip= CSTRING(buttonCurrentMagTooltip); + y = QUOTE(safezoneY + 48 * GRID_H); + }; + class iconBackgroundCurrentMag2: iconBackgroundOptic { + idc = IDC_iconBackgroundCurrentMag2; + y = QUOTE(safezoneY + 58 * GRID_H); + }; + class buttonCurrentMag2: buttonOptic { + idc = IDC_buttonCurrentMag2; + text= QPATHTOF(data\iconSecondaryMuzzle); + tooltip= CSTRING(buttonCurrentMag2Tooltip); + y = QUOTE(safezoneY + 58 * GRID_H); + }; + class iconBackgroundMag: iconBackgroundOptic { + idc = IDC_iconBackgroundMag; + y = QUOTE(safezoneY + 48 * GRID_H); + }; + class buttonMag: buttonOptic { + idc = IDC_buttonMag; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\CargoMag_ca.paa"; + tooltip="$STR_A3_RscDisplayArsenal_tab_CargoMag"; + y = QUOTE(safezoneY + 48 * GRID_H); + }; + class iconBackgroundMagALL: iconBackgroundOptic { + idc = IDC_iconBackgroundMagALL; + y = QUOTE(safezoneY + 58 * GRID_H); + }; + class buttonMagALL: buttonOptic { + idc = IDC_buttonMagALL; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\CargoMagAll_ca.paa"; + tooltip="$STR_A3_RscDisplayArsenal_tab_CargoMagAll"; + y = QUOTE(safezoneY + 58 * GRID_H); + }; + class iconBackgroundThrow: iconBackgroundOptic { + idc = IDC_iconBackgroundThrow; + y = QUOTE(safezoneY + 68 * GRID_H); + }; + class buttonThrow: buttonOptic { + idc = IDC_buttonThrow; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\CargoThrow_ca.paa"; + tooltip="$STR_A3_RscDisplayArsenal_tab_CargoThrow"; + y = QUOTE(safezoneY + 68 * GRID_H); + }; + class iconBackgroundPut: iconBackgroundOptic { + idc = IDC_iconBackgroundPut; + y = QUOTE(safezoneY + 78 * GRID_H); + }; + class buttonPut: buttonOptic { + idc = IDC_buttonPut; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\CargoPut_ca.paa"; + tooltip="$STR_A3_RscDisplayArsenal_tab_CargoPut"; + y = QUOTE(safezoneY + 78 * GRID_H); + }; + class iconBackgroundMisc: iconBackgroundOptic { + idc = IDC_iconBackgroundMisc; + y = QUOTE(safezoneY + 88 * GRID_H); + }; + class buttonMisc: buttonOptic { + idc = IDC_buttonMisc; + text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\CargoMisc_ca.paa"; + tooltip="$STR_A3_RscDisplayArsenal_tab_CargoMisc"; + y = QUOTE(safezoneY + 88 * GRID_H); + }; + class buttonRemoveAll: ctrlButtonPicture { + idc = IDC_buttonRemoveAll; + text = QPATHTOF(data\iconClearContainer.paa); + colorBackground[]={0,0,0,0.5}; + onButtonClick = QUOTE(ctrlParent (_this select 0) call FUNC(buttonClearAll)); + fade=1; + enable=0; + x = QUOTE(safezoneW + safezoneX - 11 * GRID_W); + y = QUOTE(safeZoneH + safezoneY - 29 * GRID_H); + w = QUOTE(9 * GRID_W); + h = QUOTE(9 * GRID_H); + }; + }; +}; + +class GVAR(loadoutsDisplay) { + idd = IDD_loadouts_display; + onLoad = QUOTE([ARR_3('onLoad', _this, QQGVAR(loadoutsDisplay))] call FUNC(onLoadoutsOpen)); + onUnload = QUOTE([ARR_3('onUnload', _this, QQGVAR(loadoutsDisplay))] call FUNC(onLoadoutsClose)); + class controls { + class centerBox: ctrlControlsGroupNoScrollbars { + idc = IDC_centerBox; + x = QUOTE(safezoneW + safezoneX - (180 * GRID_W)); + y = QUOTE(safezoneY + (5 * GRID_H)); + w = QUOTE(160 * GRID_W); + h = QUOTE(safezoneH - (34 * GRID_H)); + class controls { + class centerFrame: RscFrame { + idc = -1; + x = QUOTE(0 * GRID_W); + y = QUOTE(0 * GRID_H); + w = QUOTE(160 * GRID_W); + h = QUOTE(safezoneH - (45 * GRID_H)); + colorText[] = {0,0,0,1}; + }; + class centerBackground: ctrlStaticBackground { + idc = -1; + x = QUOTE(0); + y = QUOTE(0); + w = QUOTE(160 * GRID_W); + h = QUOTE(safezoneH - (45 * GRID_H)); + colorBackground[] = {0.13,0.13,0.13,0.9}; + }; + class centerTitle: ctrlStaticTitle { + idc = IDC_centerTitle; + style = ST_CENTER; + text = ""; + x = QUOTE(0); + y = QUOTE(0); + w = QUOTE(160 * GRID_W); + h = QUOTE(5 * GRID_H); + }; + class contentPanel: RscListnBox { + idc = IDC_contentPanel; + columns[]={0, 0.05, 0.40, 0.50, 0.60, 0.70, 0.75, 0.80, 0.85, 0.90}; + drawSideArrows=0; + disableOverflow=1; + onLBSelChanged = QUOTE([ARR_3(ctrlParent (_this select 0), _this select 0, _this select 1)] call FUNC(onSelChangedLoadouts)); + onLBDblClick = QUOTE([ARR_2(ctrlparent (_this select 0), (ctrlParent (_this select 0)) displayCtrl IDC_buttonLoad)] call FUNC(buttonLoadoutsLoad)); + x = QUOTE(0); + y = QUOTE(5 * GRID_H); + w = QUOTE(160 * GRID_W); + h = QUOTE(safezoneH - (57 * GRID_H)); + sizeEx = QUOTE(7 * GRID_H); + }; + class textTitle: RscText { + idc= -1; + text="$STR_DISP_GAME_NAME"; + x = QUOTE(1 * GRID_W); + y = QUOTE(safezoneH - (51 * GRID_H)); + w = QUOTE(15 * GRID_W); + h = QUOTE(5 * GRID_H); + colorBackground[]={0,0,0,0.2}; + }; + class textEditBox: ctrlEdit { + idc= IDC_textEditBox; + x = QUOTE(16 * GRID_W); + y = QUOTE(safezoneH - (51 * GRID_H)); + w = QUOTE(80 * GRID_W); + h = QUOTE(5 * GRID_H); + }; + class buttonSave: ctrlButton { + idc = IDC_buttonSave; + x = QUOTE(0 * GRID_W); + y = QUOTE(safezoneH - (44 * GRID_H)); + w = QUOTE(30 * GRID_W); + h = QUOTE(10 * GRID_H); + text= CSTRING(buttonSaveText); + tooltip= CSTRING(buttonSaveTooltip); + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), _this select 0)] call FUNC(buttonLoadoutsSave)); + colorBackground[] = {0,0,0,0.8}; + }; + class buttonRename: buttonSave { + idc = IDC_buttonRename; + x = QUOTE(32.5 * GRID_W); + text= CSTRING(buttonRenameText); + tooltip= CSTRING(buttonRenameTooltip); + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), _this select 0)] call FUNC(buttonLoadoutsRename)); + }; + class buttonLoad: buttonSave { + idc = IDC_buttonLoad; + x = QUOTE(65 * GRID_W); + text= CSTRING(buttonLoadText); + tooltip= CSTRING(buttonLoadTooltip); + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), _this select 0)] call FUNC(buttonLoadoutsLoad)); + }; + class buttonShare: buttonSave { + idc = IDC_buttonShare; + x = QUOTE(97.5 * GRID_W); + text= CSTRING(buttonSharePrivateText); + tooltip= CSTRING(buttonShareTooltip); + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), _this select 0)] call FUNC(buttonLoadoutsShare)); + }; + class buttonDelete: buttonSave { + idc = IDC_buttonDelete; + x = QUOTE(130 * GRID_W); + text= CSTRING(buttonDeleteText); + tooltip= CSTRING(buttonDeleteTooltip); + colorBackgroundActive[] = {0.5,0,0,1}; + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), _this select 0)] call FUNC(buttonLoadoutsDelete)); + }; + }; + }; + + class buttonClose: ctrlButton { + idc = -1; + x = QUOTE(safezoneW + safezoneX - 32 * GRID_W); + y = QUOTE(safezoneH + safezoneY - 9 * GRID_H); + w = QUOTE(30 * GRID_W); + h = QUOTE(7 * GRID_H); + sizeEx = QUOTE(4 * GRID_H); + text= CSTRING(buttonCloseText); + shortcuts[]= {"0x01"}; + tooltip= ""; + onButtonClick = QUOTE(ctrlparent (_this select 0) closeDisplay 2); + }; + class buttonBar: ctrlControlsGroupNoScrollbars { + idc = -1; + x = QUOTE((safezoneW * 0.5) + safezoneX - (80.5 * GRID_W)); + y = QUOTE(safezoneH + safezoneY - 9 * GRID_H); + w = QUOTE(161 * GRID_W); + h = QUOTE(7 * GRID_H); + class controls { + class buttonMyLoadoutsBackground: ctrlStaticBackground { + idc = IDC_buttonMyLoadoutsBackground; + x = QUOTE(0); + y = QUOTE(0); + w = QUOTE(52 * GRID_W); + h = QUOTE(7 * GRID_H); + colorBackground[] = {0,0,0,0.7}; + }; + class buttonMyLoadouts: ctrlButton { + idc = IDC_buttonMyLoadouts; + colorBackground[] = {0,0,0,0}; + x = QUOTE(0 * GRID_W); + y = QUOTE(0 * GRID_H); + w = QUOTE(52 * GRID_W); + h = QUOTE(7 * GRID_H); + sizeEx = QUOTE(4 * GRID_H); + text= CSTRING(tabMyLoadoutsText); + tooltip= CSTRING(tabMyLoadoutsTooltip); + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), _this select 0)] call FUNC(loadoutsChangeTab)); + }; + class buttonDefaultLoadoutsBackground: buttonMyLoadoutsBackground { + idc = IDC_buttonDefaultLoadoutsBackground; + x = QUOTE(54.5 * GRID_W); + }; + class buttonDefaultLoadouts: buttonMyLoadouts { + idc = IDC_buttonDefaultLoadouts; + x = QUOTE(54.5 * GRID_W); + text= CSTRING(tabDefaultLoadoutsText); + tooltip= CSTRING(tabDefaultLoadoutsTooltip); + }; + class buttonSharedLoadoutsBackground: buttonMyLoadoutsBackground { + idc = IDC_buttonSharedLoadoutsBackground; + x = QUOTE(109 * GRID_W); + }; + class buttonSharedLoadouts: buttonMyLoadouts { + idc = IDC_buttonSharedLoadouts; + x = QUOTE(109 * GRID_W); + text= CSTRING(tabSharedLoadoutsText); + tooltip= CSTRING(tabSharedLoadoutsTooltip); + }; + }; + }; + }; +}; diff --git a/addons/arsenal/ui/RscCommon.hpp b/addons/arsenal/ui/RscCommon.hpp new file mode 100644 index 0000000000..2a88204d7b --- /dev/null +++ b/addons/arsenal/ui/RscCommon.hpp @@ -0,0 +1,278 @@ +// Control types +#define CT_STATIC 0 +#define CT_BUTTON 1 +#define CT_EDIT 2 +#define CT_SLIDER 3 +#define CT_COMBO 4 +#define CT_LISTBOX 5 +#define CT_TOOLBOX 6 +#define CT_CHECKBOXES 7 +#define CT_PROGRESS 8 +#define CT_HTML 9 +#define CT_STATIC_SKEW 10 +#define CT_ACTIVETEXT 11 +#define CT_TREE 12 +#define CT_STRUCTURED_TEXT 13 +#define CT_CONTEXT_MENU 14 +#define CT_CONTROLS_GROUP 15 +#define CT_SHORTCUTBUTTON 16 +#define CT_HITZONES 17 +#define CT_XKEYDESC 40 +#define CT_XBUTTON 41 +#define CT_XLISTBOX 42 +#define CT_XSLIDER 43 +#define CT_XCOMBO 44 +#define CT_ANIMATED_TEXTURE 45 +#define CT_OBJECT 80 +#define CT_OBJECT_ZOOM 81 +#define CT_OBJECT_CONTAINER 82 +#define CT_OBJECT_CONT_ANIM 83 +#define CT_LINEBREAK 98 +#define CT_USER 99 +#define CT_MAP 100 +#define CT_MAP_MAIN 101 +#define CT_LISTNBOX 102 +#define CT_ITEMSLOT 103 +#define CT_CHECKBOX 77 + +// Static styles +#define ST_POS 0x0F +#define ST_HPOS 0x03 +#define ST_VPOS 0x0C +#define ST_LEFT 0x00 +#define ST_RIGHT 0x01 +#define ST_CENTER 0x02 +#define ST_DOWN 0x04 +#define ST_UP 0x08 +#define ST_VCENTER 0x0C + +#define ST_TYPE 0xF0 +#define ST_SINGLE 0x00 +#define ST_MULTI 0x10 +#define ST_TITLE_BAR 0x20 +#define ST_PICTURE 0x30 +#define ST_FRAME 0x40 +#define ST_BACKGROUND 0x50 +#define ST_GROUP_BOX 0x60 +#define ST_GROUP_BOX2 0x70 +#define ST_HUD_BACKGROUND 0x80 +#define ST_TILE_PICTURE 0x90 +#define ST_WITH_RECT 0xA0 +#define ST_LINE 0xB0 +#define ST_UPPERCASE 0xC0 +#define ST_LOWERCASE 0xD0 + +#define ST_SHADOW 0x100 +#define ST_NO_RECT 0x200 +#define ST_KEEP_ASPECT_RATIO 0x800 + +// Slider styles +#define SL_DIR 0x400 +#define SL_VERT 0 +#define SL_HORZ 0x400 + +#define SL_TEXTURES 0x10 + +// progress bar +#define ST_VERTICAL 0x01 +#define ST_HORIZONTAL 0 + +// Listbox styles +#define LB_TEXTURES 0x10 +#define LB_MULTI 0x20 + +// Tree styles +#define TR_SHOWROOT 1 +#define TR_AUTOCOLLAPSE 2 + +// Default grid +#define GUI_GRID_WAbs ((safezoneW / safezoneH) min 1.2) +#define GUI_GRID_HAbs (GUI_GRID_WAbs / 1.2) +#define GUI_GRID_W (GUI_GRID_WAbs / 40) +#define GUI_GRID_H (GUI_GRID_HAbs / 25) +#define GUI_GRID_X (safezoneX) +#define GUI_GRID_Y (safezoneY + safezoneH - GUI_GRID_HAbs) + +// Default text sizes +#define GUI_TEXT_SIZE_SMALL (GUI_GRID_H * 0.8) +#define GUI_TEXT_SIZE_MEDIUM (GUI_GRID_H * 1) +#define GUI_TEXT_SIZE_LARGE (GUI_GRID_H * 1.2) + +class ScrollBar; +class RscObject; +class RscText; +class RscTextSmall; +class RscTitle; +class RscProgress; +class RscProgressNotFreeze; +class RscPicture; +class RscLadderPicture; +class RscPictureKeepAspect; +class RscHTML; +class RscButton; +class RscShortcutButton; +class RscButtonSmall; +class RscEdit; +class RscCombo; +class RscListBox; +class RscListNBox; +class RscXListBox; +class RscTree; +class RscSlider; +class RscSliderH; +class RscXSliderH; +class RscActiveText; +class RscStructuredText; +class RscControlsGroup; +class RscToolbox; +class RscMapControl; +class RscCheckBox; +class RscFrame; +class ctrlDefault; +class ctrlControlsGroup; +class ctrlDefaultText; +class ctrlDefaultButton; +class RscBackgroundStripeTop; +class RscBackgroundStripeBottom; +class RscIGText; +class RscIGProgress; +class RscListBoxKeys; +class RscControlsGroupNoScrollbars; +class RscControlsGroupNoHScrollbars; +class RscControlsGroupNoVScrollbars; +class RscLine; +class RscActivePicture; +class RscButtonTextOnly; +class RscShortcutButtonMain; +class RscButtonEditor; +class RscIGUIShortcutButton; +class RscGearShortcutButton; +class RscButtonMenu; +class RscButtonMenuOK; +class RscButtonMenuCancel; +class RscButtonMenuSteam; +class RscLoadingText; +class RscIGUIListBox; +class RscIGUIListNBox; +class RscBackground; +class RscBackgroundGUI; +class RscBackgroundGUILeft; +class RscBackgroundGUIRight; +class RscBackgroundGUIBottom; +class RscBackgroundGUITop; +class RscBackgroundGUIDark; +class RscBackgroundLogo; +class RscMapControlEmpty; +class RscVignette; +class CA_Mainback; +class CA_Back; +class CA_Title_Back; +class CA_Black_Back; +class CA_Title; +class CA_Logo; +class CA_Logo_Small; +class CA_RscButton; +class CA_RscButton_dialog; +class CA_Ok; +class CA_Ok_image; +class CA_Ok_image2; +class CA_Ok_text; +class ctrlCheckbox; +class ctrlCheckboxBaseline; +class ctrlStatic; +class ctrlControlsGroupNoScrollbars; +class ctrlStructuredText; +class RscTextMulti; +class RscTreeSearch; +class RscVideo; +class RscVideoKeepAspect; +class RscActivePictureKeepAspect; +class RscEditMulti; +class RscMapSignalBackground; +class RscMapSignalPicture; +class RscMapSignalText; +class RscColorPicker; +class RscInterlacingScreen; +class RscFeedback; +class RscTrafficLight; +class RscButtonSearch; +class RscIGUIText; +class RscOpticsText; +class RscOpticsValue; +class RscIGUIValue; +class RscButtonMenuMain; +class RscButtonTestCentered; +class RscDisplaySingleMission_ChallengeOverviewGroup; +class RscDisplayDebriefing_RscTextMultiline; +class RscDisplayDebriefing_ListGroup; +class RscButtonArsenal; +class RscTextNoShadow; +class RscButtonNoColor; +class RscToolboxButton; +class ctrlStaticPicture; +class ctrlStaticPictureKeepAspect; +class ctrlStaticPictureTile; +class ctrlStaticFrame; +class ctrlStaticLine; +class ctrlStaticMulti; +class ctrlStaticBackground; +class ctrlStaticOverlay; +class ctrlStaticTitle; +class ctrlStaticFooter; +class ctrlStaticBackgroundDisable; +class ctrlStaticBackgroundDisableTiles; +class ctrlButton; +class ctrlButtonPicture; +class ctrlButtonPictureKeepAspect; +class ctrlButtonOK; +class ctrlButtonCancel; +class ctrlButtonClose; +class ctrlButtonToolbar; +class ctrlButtonSearch; +class ctrlButtonExpandAll; +class ctrlButtonCollapseAll; +class ctrlButtonFilter; +class ctrlEdit; +class ctrlEditMulti; +class ctrlSliderV; +class ctrlSliderH; +class ctrlCombo; +class ctrlComboToolbar; +class ctrlListbox; +class ctrlToolbox; +class ctrlToolboxPicture; +class ctrlToolboxPictureKeepAspect; +class ctrlCheckboxes; +class ctrlCheckboxesCheckbox; +class ctrlProgress; +class ctrlHTML; +class ctrlActiveText; +class ctrlActivePicture; +class ctrlActivePictureKeepAspect; +class ctrlTree; +class ctrlControlsGroupNoHScrollbars; +class ctrlControlsGroupNoVScrollbars; +class ctrlShortcutButton; +class ctrlShortcutButtonOK; +class ctrlShortcutButtonCancel; +class ctrlShortcutButtonSteam; +class ctrlXListbox; +class ctrlXSliderV; +class ctrlXSliderH; +class ctrlMenu; +class ctrlMenuStrip; +class ctrlMap; +class ctrlMapEmpty; +class ctrlMapMain; +class ctrlListNBox; +class ctrlCheckboxToolbar; + +class Display3DEN { + class ContextMenu :ctrlMenu { + class Items { + class Arsenal { + action= QUOTE(call FUNC(open3DEN)); + }; + }; + }; +}; diff --git a/addons/arsenal/ui/script_component.hpp b/addons/arsenal/ui/script_component.hpp new file mode 100644 index 0000000000..523addf768 --- /dev/null +++ b/addons/arsenal/ui/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\arsenal\script_component.hpp" \ No newline at end of file diff --git a/addons/chemlights/CfgWeapons.hpp b/addons/chemlights/CfgWeapons.hpp index 5214c7e689..de6f3920f5 100644 --- a/addons/chemlights/CfgWeapons.hpp +++ b/addons/chemlights/CfgWeapons.hpp @@ -57,6 +57,7 @@ class CfgWeapons { descriptionShort = CSTRING(Shield_Green_DescriptionShort); model = "\A3\weapons_F\ammo\mag_univ.p3d"; picture = QPATHTOF(UI\ace_chemlight_shield_green_x_ca.paa); + ace_arsenal_uniqueBase = "ACE_Chemlight_Shield"; scope = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 1; diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 5a89f4b3b2..f90bef3a9c 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -87,6 +87,7 @@ PREP(getVersion); PREP(getWeaponAzimuthAndInclination); PREP(getWeaponIndex); PREP(getWeaponState); +PREP(getWeight); PREP(getWindDirection); PREP(getZoom); PREP(goKneeling); diff --git a/addons/common/functions/fnc_getWeight.sqf b/addons/common/functions/fnc_getWeight.sqf new file mode 100644 index 0000000000..186e10c638 --- /dev/null +++ b/addons/common/functions/fnc_getWeight.sqf @@ -0,0 +1,40 @@ +/* + * Author: commy2 + * Returns the weight (from the loadAbs command) in lbs/kg (based on user option) + * + * Arguments: + * 0: The Unit (usually the player) + * 0: Force a return type (0: useImperial setting; 1: Metric; 2: Imperial) + * + * Return Value: + * The return value + * + * Example: + * [player] call ace_common_fnc_getWeight + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", ["_returnFormat", 0, [0]]]; + +private _virtualLoad = 0; +private _useImperial = (!isNil QEGVAR(movement,useImperial) && {EGVAR(movement,useImperial)}); + +{ + _virtualLoad = _virtualLoad + (_x getVariable [QEGVAR(movement,vLoad), 0]); +} forEach [ + _unit, + uniformContainer _unit, + vestContainer _unit, + backpackContainer _unit +]; + +private _weight = (loadAbs _unit + _virtualLoad) * 0.1; + +//Return +if ([_useImperial, (_returnFormat == 1)] select (_returnFormat != 0)) then { + format ["%1lb", (round (_weight * 100)) / 100] +} else { + format ["%1kg", (round (_weight * (1/2.2046) * 100)) / 100] +}; diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index ac3309604d..1d415ff7de 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -1131,5 +1131,21 @@ 切換 切换 + + Weight: + Gewicht: + Peso: + Poids : + Waga: + Váha: + Peso: + Peso: + Súly: + Вес: + 重量: + 무게: + 重量: + 重量: + diff --git a/addons/dogtags/XEH_postInit.sqf b/addons/dogtags/XEH_postInit.sqf index 6a50ce61cf..02d2db862b 100644 --- a/addons/dogtags/XEH_postInit.sqf +++ b/addons/dogtags/XEH_postInit.sqf @@ -46,5 +46,35 @@ if (["ACE_Medical"] call EFUNC(common,isModLoaded)) then { }; }; +if (["ACE_Arsenal"] call EFUNC(common,isModLoaded)) then { + [QEGVAR(arsenal,rightPanelFilled), { + + params ["_display", "_leftPanelIDC", "_rightPanelIDC"]; + + if (_leftPanelIDC in [2010, 2012, 2014] && {_rightPanelIDC == 38}) then { + LOG("passed"); + private _rightPanel = _display displayCtrl 15; + (lnbSize _rightPanel) params ["_rows", "_columns"]; + + private _allDogtags = missionNameSpace getVariable [QGVAR(allDogtags), []]; + private _allDogtagDatas = missionNameSpace getVariable [QGVAR(allDogtagDatas), []]; + + for "_r" from 0 to (_rows - 1) do { + private _data = _rightPanel lnbData [_r, 0]; + + if (_data isKindOf ["ACE_dogtag", (configFile >> "CfgWeapons")]) then { + + private _dogtagData = []; + private _index = _allDogtags find _data; + _dogtagData = _allDogtagDatas select _index; + private _dogtagString = [localize LSTRING(itemName), ": ", (_dogtagData select 0)] joinString ""; + + _rightPanel lnbSetText [[_r, 1], _dogtagString]; + }; + }; + }; + }] call CBA_fnc_addEventHandler; +}; + // disable dogtags for civilians "CIV_F" call FUNC(disableFactionDogtags); diff --git a/addons/medical/CfgWeapons.hpp b/addons/medical/CfgWeapons.hpp index 13e0517865..7260452bc4 100644 --- a/addons/medical/CfgWeapons.hpp +++ b/addons/medical/CfgWeapons.hpp @@ -8,12 +8,14 @@ class CfgWeapons { // ITEMS class FirstAidKit: ItemCore { type = 0; + ace_arsenal_hide = 1; class ItemInfo: InventoryFirstAidKitItem_Base_F { mass = 4; }; }; class Medikit: ItemCore { type = 0; + ace_arsenal_hide = 1; class ItemInfo: MedikitItem { mass = 60; }; diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index fab2a2a607..991124fcb1 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -305,3 +305,9 @@ if (hasInterface) then { [player] call FUNC(init); }] call CBA_fnc_addEventHandler; }; + +if (["ACE_Arsenal"] call EFUNC(common,isModLoaded)) then { + [QEGVAR(arsenal,displayOpened), { + EGVAR(arsenal,virtualItems) set [17, (EGVAR(arsenal,virtualItems) select 17) - ["FirstAidKit", "Medikit"]]; + }] call CBA_fnc_addEventHandler; +}; diff --git a/addons/movement/XEH_PREP.hpp b/addons/movement/XEH_PREP.hpp index 609908450c..74074d8f08 100644 --- a/addons/movement/XEH_PREP.hpp +++ b/addons/movement/XEH_PREP.hpp @@ -1,6 +1,5 @@ PREP(addLoadToUnitContainer); -PREP(getWeight); PREP(canClimb); PREP(climb); PREP(handleClimb); diff --git a/addons/movement/functions/fnc_getWeight.sqf b/addons/movement/functions/fnc_getWeight.sqf deleted file mode 100644 index b64abc3623..0000000000 --- a/addons/movement/functions/fnc_getWeight.sqf +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Author: commy2 - * Returns the weight (from the loadAbs command) in lbs/kg (based on user option) - * - * Arguments: - * 0: The Unit (usually the player) - * - * Return Value: - * The return value - * - * Example: - * [player] call ace_movement_fnc_getWeight - * - * Public: No - */ -#include "script_component.hpp" - -params ["_unit"]; - -private _virtualLoad = 0; - -{ - _virtualLoad = _virtualLoad + (_x getVariable [QGVAR(vLoad), 0]); -} forEach [ - _unit, - uniformContainer _unit, - vestContainer _unit, - backpackContainer _unit -]; - -private _weight = (loadAbs _unit + _virtualLoad) * 0.1; - -if (GVAR(useImperial)) then { - _weight = format ["%1lb", (round (_weight * 100)) / 100]; -} else { - _weight = format ["%1kg", (round (_weight * FACTOR_POUND_TO_KILOGRAMM * 100)) / 100]; -}; - -_weight diff --git a/addons/movement/functions/fnc_inventoryDisplayLoad.sqf b/addons/movement/functions/fnc_inventoryDisplayLoad.sqf index bc48d4d09c..88e148fd6a 100644 --- a/addons/movement/functions/fnc_inventoryDisplayLoad.sqf +++ b/addons/movement/functions/fnc_inventoryDisplayLoad.sqf @@ -25,5 +25,5 @@ disableSerialization; [_this select 1] call CBA_fnc_removePerFrameHandler; }; - (_dialog displayCtrl 111) ctrlSetText format ["%1 - %2 %3", [ACE_player, false, true] call EFUNC(common,getName), localize LSTRING(Weight), [ACE_player] call FUNC(getWeight)]; + (_dialog displayCtrl 111) ctrlSetText format ["%1 - %2 %3", [ACE_player, false, true] call EFUNC(common,getName), localize ELSTRING(common,Weight), [ACE_player] call EFUNC(common,getWeight)]; }, 0, _this select 0] call CBA_fnc_addPerFrameHandler; diff --git a/addons/movement/stringtable.xml b/addons/movement/stringtable.xml index 0eb4434b42..2d587ce3d2 100644 --- a/addons/movement/stringtable.xml +++ b/addons/movement/stringtable.xml @@ -17,22 +17,6 @@ 使用磅来显示重量 使用磅來顯示重量 - - Weight: - Gewicht: - Peso: - Poids : - Waga: - Váha: - Peso: - Peso: - Súly: - Вес: - 重量: - 무게: - 重量: - 重量: - Climb Grimper diff --git a/addons/zeus/CfgVehicles.hpp b/addons/zeus/CfgVehicles.hpp index 8b85b7540d..49fcb9532a 100644 --- a/addons/zeus/CfgVehicles.hpp +++ b/addons/zeus/CfgVehicles.hpp @@ -266,4 +266,7 @@ class CfgVehicles { displayName = CSTRING(ModuleRemoveArsenal_DisplayName); function = QFUNC(moduleRemoveArsenal); }; + class ModuleArsenal_F: Module_F { + function=QFUNC(bi_moduleArsenal); + }; }; diff --git a/addons/zeus/XEH_PREP.hpp b/addons/zeus/XEH_PREP.hpp index bb842edaf3..aba07e7114 100644 --- a/addons/zeus/XEH_PREP.hpp +++ b/addons/zeus/XEH_PREP.hpp @@ -1,5 +1,6 @@ PREP(addObjectToCurator); +PREP(bi_moduleArsenal); PREP(bi_moduleCurator); PREP(bi_moduleMine); PREP(bi_moduleProjectile); diff --git a/addons/zeus/functions/fnc_bi_moduleArsenal.sqf b/addons/zeus/functions/fnc_bi_moduleArsenal.sqf new file mode 100644 index 0000000000..2990d42633 --- /dev/null +++ b/addons/zeus/functions/fnc_bi_moduleArsenal.sqf @@ -0,0 +1,66 @@ +/* + * Author: Bohemia Interactive + * Module function to open a full arsenal on a unit + * Edited to use ACE arsenal when present, moved isPlayer check + * + * Arguments: + * 0: The module logic + * 1: Not used + * 2: activated + * + * Return Value: + * None + * + * Example: + * [LOGIC, nil, true] call ace_zeus_fnc_bi_moduleArsenal + * + * Public: No +*/ + +#include "script_component.hpp" + +params ["_logic", "", "_activated"]; + +if (_activated && local _logic) then { + _unit = _logic getvariable ["bis_fnc_curatorAttachObject_object",objnull]; + + //--- Check if the unit is suitable + _error = ""; + switch true do { + case (isnull _unit): {_error = localize "str_a3_BIS_fnc_showCuratorFeedbackMessage_506";}; + case !(alive _unit): {_error = localize "str_a3_BIS_fnc_moduleArsenal_errorDead";}; + case (isnull group _unit || !(side group _unit in [east,west,resistance,civilian])): {_error = localize "str_a3_BIS_fnc_moduleArsenal_errorBrain";}; + case (vehicle _unit != _unit || effectivecommander _unit != _unit): {_error = localize "str_a3_BIS_fnc_moduleArsenal_errorVehicle";}; + }; + + if (_error == "") then { + if (["ACE_Arsenal"] call EFUNC(common,isModLoaded)) then { + if (!isPlayer _unit || {player == _unit}) then { + + [{ + params ["_unit"]; + + [_unit, _unit, true] call EFUNC(arsenal,openBox); + }, [_unit]] call CBA_fnc_directCall; + } else { + + [objNull, localize "str_a3_BIS_fnc_moduleArsenal_errorDead"] call bis_fnc_showCuratorFeedbackMessage; + }; + } else { + if !(isPlayer _unit) then { + + ([] call bis_fnc_rscLayer) cuttext ["","black out",0.5]; + ["#(argb,8,8,3)color(0,0,0,1)",false,nil,0,[0.5,0]] call bis_fnc_textTiles; + ["Open",[true,nil,_unit]] call bis_fnc_arsenal; + ([] call bis_fnc_rscLayer) cuttext ["","plain"]; + } else { + + [objNull, localize "str_a3_BIS_fnc_moduleArsenal_errorDead"] call bis_fnc_showCuratorFeedbackMessage; + }; + }; + } else { + + [objNull,_error] call bis_fnc_showCuratorFeedbackMessage; + }; + deleteVehicle _logic; +}; diff --git a/addons/zeus/functions/fnc_moduleAddArsenal.sqf b/addons/zeus/functions/fnc_moduleAddArsenal.sqf index b8eed64d76..68b5148521 100644 --- a/addons/zeus/functions/fnc_moduleAddArsenal.sqf +++ b/addons/zeus/functions/fnc_moduleAddArsenal.sqf @@ -29,9 +29,15 @@ switch (true) do { [LSTRING(OnlyAlive)] call FUNC(showMessage); }; default { - TRACE_1("BIS_fnc_arsenal: AmmoboxInit",_object); - // Global Effects: "Action to access the Arsenal will be added automatically on all clients." - ["AmmoboxInit", [_object, true]] call BIS_fnc_arsenal; + if (["ACE_Arsenal"] call EFUNC(common,isModLoaded)) then { + + [_object, true, true] call EFUNC(arsenal,initBox); + } else { + + TRACE_1("BIS_fnc_arsenal: AmmoboxInit",_object); + // Global Effects: "Action to access the Arsenal will be added automatically on all clients." + ["AmmoboxInit", [_object, true]] call BIS_fnc_arsenal; + }; }; }; diff --git a/addons/zeus/functions/fnc_moduleRemoveArsenal.sqf b/addons/zeus/functions/fnc_moduleRemoveArsenal.sqf index 9e267e4cf5..b14509c272 100644 --- a/addons/zeus/functions/fnc_moduleRemoveArsenal.sqf +++ b/addons/zeus/functions/fnc_moduleRemoveArsenal.sqf @@ -30,11 +30,18 @@ switch (true) do { [LSTRING(OnlyAlive)] call FUNC(showMessage); }; default { - TRACE_1("Calling removeVirtualXXXCargo functions",_object); - [_object, (_object call BIS_fnc_getVirtualItemCargo), true] call BIS_fnc_removeVirtualItemCargo; - [_object, (_object call BIS_fnc_getVirtualWeaponCargo), true] call BIS_fnc_removeVirtualWeaponCargo; - [_object, (_object call BIS_fnc_getVirtualMagazineCargo), true] call BIS_fnc_removeVirtualMagazineCargo; - [_object, (_object call BIS_fnc_getVirtualBackpackCargo), true] call BIS_fnc_removeVirtualBackpackCargo; + + if (["ACE_Arsenal"] call EFUNC(common,isModLoaded)) then { + + [_object, true, true] call EFUNC(arsenal,removeBox); + } else { + + TRACE_1("Calling removeVirtualXXXCargo functions",_object); + [_object, (_object call BIS_fnc_getVirtualItemCargo), true] call BIS_fnc_removeVirtualItemCargo; + [_object, (_object call BIS_fnc_getVirtualWeaponCargo), true] call BIS_fnc_removeVirtualWeaponCargo; + [_object, (_object call BIS_fnc_getVirtualMagazineCargo), true] call BIS_fnc_removeVirtualMagazineCargo; + [_object, (_object call BIS_fnc_getVirtualBackpackCargo), true] call BIS_fnc_removeVirtualBackpackCargo; + }; }; };