From 1994e301fdc95935ba16262eac0a5e65bf996be1 Mon Sep 17 00:00:00 2001 From: Josuan Albin Date: Thu, 12 Apr 2018 17:44:23 +0200 Subject: [PATCH] More various ace arsenal fixes (#6192) * Compile stats on preInit * Remove uneeded check in add/removeStat * Remove perf profiler vars They aren't required anymore * Fix case issue in verifyLoadout, remove uneeded line * Fix ace arsenal cam not working porperly underwater By removing those checks the cam is allowed to clip through objects and work properly underwater, sounds like features to me :D * Fix gunbag behavior in ace arsenal Switching between gunbags will keep the weapon, switching to another backpack then back to a gunbag will also keep the weapon. * Fix text scaling in the searchbars and loadout name edit boxes Also made the text bigger by default --- addons/arsenal/XEH_preInit.sqf | 2 + addons/arsenal/defines.hpp | 70 +++++++++---------- addons/arsenal/functions/fnc_addStat.sqf | 1 + .../arsenal/functions/fnc_fillLeftPanel.sqf | 4 -- .../arsenal/functions/fnc_fillRightPanel.sqf | 4 -- addons/arsenal/functions/fnc_handleMouse.sqf | 5 -- addons/arsenal/functions/fnc_handleStats.sqf | 5 -- addons/arsenal/functions/fnc_itemInfo.sqf | 4 -- .../arsenal/functions/fnc_onArsenalOpen.sqf | 5 -- .../functions/fnc_onSelChangedLeft.sqf | 4 -- .../functions/fnc_onSelChangedRight.sqf | 4 -- .../fnc_onSelChangedRightListnBox.sqf | 4 -- addons/arsenal/functions/fnc_showItem.sqf | 4 -- addons/arsenal/functions/fnc_sortPanel.sqf | 4 -- addons/arsenal/functions/fnc_updateCamPos.sqf | 6 -- .../functions/fnc_updateRightPanel.sqf | 4 -- addons/arsenal/script_component.hpp | 1 - addons/arsenal/ui/RscAttributes.hpp | 3 + addons/gunbag/XEH_preInit.sqf | 18 +++++ 19 files changed, 59 insertions(+), 93 deletions(-) diff --git a/addons/arsenal/XEH_preInit.sqf b/addons/arsenal/XEH_preInit.sqf index 1919941139..41f5f4cf88 100644 --- a/addons/arsenal/XEH_preInit.sqf +++ b/addons/arsenal/XEH_preInit.sqf @@ -58,4 +58,6 @@ GVAR(modList) = ["","curator","kart","heli","mark","expansion","expansionpremium _this call FUNC(handleStats); }] call CBA_fnc_addEventHandler; +call FUNC(compileStats); + ADDON = true; diff --git a/addons/arsenal/defines.hpp b/addons/arsenal/defines.hpp index 42c0e70536..1a3c94d1ca 100644 --- a/addons/arsenal/defines.hpp +++ b/addons/arsenal/defines.hpp @@ -339,27 +339,27 @@ _buttonCurrentMag2Ctrl ctrlCommit FADE_DELAY;\ ] #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)} + (_weaponsArray select 0) findIf {_x == _item} > -1 ||\ + {(_weaponsArray select 1) findIf {_x == _item} > -1} ||\ + {(_weaponsArray select 2) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 9) findIf {_x == _item} > -1} ||\ + {(_accsArray select 0) findIf {_x == _item} > -1} ||\ + {(_accsArray select 1 findIf {_x == _item} > -1)} ||\ + {(_accsArray select 2) findIf {_x == _item} > -1} ||\ + {(_accsArray select 3) findIf {_x == _item} > -1} #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)} + (GVAR(virtualItems) select 10) findIf {_x == _item} > -1 ||\ + {(GVAR(virtualItems) select 11) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 12) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 13) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 14) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 8) findIf {_x == _item} > -1} #define CHECK_CONTAINER\ - _item in (GVAR(virtualItems) select 4) ||\ - {_item in (GVAR(virtualItems) select 5)} ||\ - {_item in (GVAR(virtualItems) select 6)} + (GVAR(virtualItems) select 4) findIf {_x == _item} > -1 ||\ + {(GVAR(virtualItems) select 5) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 6) findIf {_x == _item} > -1} #define CLASS_CHECK_ITEM\ isClass (_weaponCfg >> _item) ||\ @@ -368,24 +368,24 @@ _buttonCurrentMag2Ctrl ctrlCommit FADE_DELAY;\ {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)} + (GVAR(virtualItems) select 3) findIf {_x == _item} > -1 ||\ + {(_accsArray select 0) findIf {_x == _item} > -1} ||\ + {(_accsArray select 1) findIf {_x == _item} > -1} ||\ + {(_accsArray select 2) findIf {_x == _item} > -1} ||\ + {(_accsArray select 3) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 4) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 5) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 6) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 7) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 8) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 10) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 11) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 12) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 13) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 14) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 15) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 16) findIf {_x == _item} > -1} ||\ + {(GVAR(virtualItems) select 17) findIf {_x == _item} > -1} #define ADD_LOADOUTS_LIST_PICTURES\ _contentPanelCtrl lnbSetPicture [[_newRow, 2], getText (configFile >> "cfgWeapons" >> ((_loadout select 0) select 0) >> "picture")];\ diff --git a/addons/arsenal/functions/fnc_addStat.sqf b/addons/arsenal/functions/fnc_addStat.sqf index 88b732df93..d51c0ff13d 100644 --- a/addons/arsenal/functions/fnc_addStat.sqf +++ b/addons/arsenal/functions/fnc_addStat.sqf @@ -54,6 +54,7 @@ _statements params [ ]; call FUNC(compileStats); + private _returnArray = []; private _fnc_addToTabs = { diff --git a/addons/arsenal/functions/fnc_fillLeftPanel.sqf b/addons/arsenal/functions/fnc_fillLeftPanel.sqf index 46dbd86e83..83a4336ea0 100644 --- a/addons/arsenal/functions/fnc_fillLeftPanel.sqf +++ b/addons/arsenal/functions/fnc_fillLeftPanel.sqf @@ -14,10 +14,6 @@ #include "script_component.hpp" #include "..\defines.hpp" -#ifdef ENABLE_PERF_PROFILING - private _scopeFillLeftPanel = createProfileScope QFUNC(fillLeftPanel); -#endif - params ["_display", "_control"]; private _ctrlIDC = ctrlIDC _control; diff --git a/addons/arsenal/functions/fnc_fillRightPanel.sqf b/addons/arsenal/functions/fnc_fillRightPanel.sqf index 52d91cf20c..c62ea3cab8 100644 --- a/addons/arsenal/functions/fnc_fillRightPanel.sqf +++ b/addons/arsenal/functions/fnc_fillRightPanel.sqf @@ -14,10 +14,6 @@ #include "script_component.hpp" #include "..\defines.hpp" -#ifdef ENABLE_PERF_PROFILING - private _scopeFillRightPanel = createProfileScope QFUNC(fillRightPanel); -#endif - params ["_display", "_control"]; private _ctrlIDC = ctrlIDC _control; diff --git a/addons/arsenal/functions/fnc_handleMouse.sqf b/addons/arsenal/functions/fnc_handleMouse.sqf index 16548f3985..071eb1f94d 100644 --- a/addons/arsenal/functions/fnc_handleMouse.sqf +++ b/addons/arsenal/functions/fnc_handleMouse.sqf @@ -44,11 +44,6 @@ if (count _LMB > 0) then { _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]; }; diff --git a/addons/arsenal/functions/fnc_handleStats.sqf b/addons/arsenal/functions/fnc_handleStats.sqf index f9180f372d..ec22b6055d 100644 --- a/addons/arsenal/functions/fnc_handleStats.sqf +++ b/addons/arsenal/functions/fnc_handleStats.sqf @@ -16,10 +16,6 @@ #include "script_component.hpp" #include "..\defines.hpp" -#ifdef ENABLE_PERF_PROFILING - private _scopeHandleStats = createProfileScope QFUNC(handleStats); -#endif - params ["_display", "_control", "_curSel", "_itemCfg"]; private _statsBoxCtrl = _display displayCtrl IDC_statsBox; @@ -50,7 +46,6 @@ private _hideUnusedFnc = { } forEach _numbers; }; -call FUNC(compileStats); if !(isNil "_itemCfg") then { private _handleStatsFnc = { diff --git a/addons/arsenal/functions/fnc_itemInfo.sqf b/addons/arsenal/functions/fnc_itemInfo.sqf index 45d5d03164..546158fa7e 100644 --- a/addons/arsenal/functions/fnc_itemInfo.sqf +++ b/addons/arsenal/functions/fnc_itemInfo.sqf @@ -16,10 +16,6 @@ #include "script_component.hpp" #include "..\defines.hpp" -#ifdef ENABLE_PERF_PROFILING - private _scopeItemInfo = createProfileScope QFUNC(itemInfo); -#endif - params ["_display", "_control", "_curSel" ,"_itemCfg"]; private _ctrlInfo = _display displayCtrl IDC_infoBox; diff --git a/addons/arsenal/functions/fnc_onArsenalOpen.sqf b/addons/arsenal/functions/fnc_onArsenalOpen.sqf index 23e03561a8..b67bd4173a 100644 --- a/addons/arsenal/functions/fnc_onArsenalOpen.sqf +++ b/addons/arsenal/functions/fnc_onArsenalOpen.sqf @@ -15,11 +15,6 @@ #include "script_component.hpp" #include "..\defines.hpp" -#ifdef ENABLE_PERF_PROFILING - private _scopeArsenal = createProfileScope QFUNC(onArsenalOpen); - profilerTrigger; -#endif - params ["", "_args"]; _args params ["_display"]; diff --git a/addons/arsenal/functions/fnc_onSelChangedLeft.sqf b/addons/arsenal/functions/fnc_onSelChangedLeft.sqf index b70f7b00e6..5c4d49b5d1 100644 --- a/addons/arsenal/functions/fnc_onSelChangedLeft.sqf +++ b/addons/arsenal/functions/fnc_onSelChangedLeft.sqf @@ -14,10 +14,6 @@ #include "script_component.hpp" #include "..\defines.hpp" -#ifdef ENABLE_PERF_PROFILING - private _scopeOnSelChangedLeft = createProfileScope QFUNC(onSelChangedLeft); -#endif - params ["_control", "_curSel"]; if (_curSel < 0) exitwith {}; diff --git a/addons/arsenal/functions/fnc_onSelChangedRight.sqf b/addons/arsenal/functions/fnc_onSelChangedRight.sqf index ce40ef87f6..7a565cd14d 100644 --- a/addons/arsenal/functions/fnc_onSelChangedRight.sqf +++ b/addons/arsenal/functions/fnc_onSelChangedRight.sqf @@ -14,10 +14,6 @@ #include "script_component.hpp" #include "..\defines.hpp" -#ifdef ENABLE_PERF_PROFILING - private _scopeOnSelChangedRight = createProfileScope QFUNC(onSelChangedRight); -#endif - params ["_control", "_curSel"]; if (_curSel < 0) exitwith {}; diff --git a/addons/arsenal/functions/fnc_onSelChangedRightListnBox.sqf b/addons/arsenal/functions/fnc_onSelChangedRightListnBox.sqf index 531c0817c8..29c66a79f9 100644 --- a/addons/arsenal/functions/fnc_onSelChangedRightListnBox.sqf +++ b/addons/arsenal/functions/fnc_onSelChangedRightListnBox.sqf @@ -14,10 +14,6 @@ #include "script_component.hpp" #include "..\defines.hpp" -#ifdef ENABLE_PERF_PROFILING - private _scopeOnSelChangedRightLNB = createProfileScope QFUNC(onSelChangedRightListnBox); -#endif - params ["_control", "_curSel"]; if (_curSel < 0) exitwith {}; diff --git a/addons/arsenal/functions/fnc_showItem.sqf b/addons/arsenal/functions/fnc_showItem.sqf index fddfbe1a3a..478ae4218d 100644 --- a/addons/arsenal/functions/fnc_showItem.sqf +++ b/addons/arsenal/functions/fnc_showItem.sqf @@ -13,10 +13,6 @@ #include "script_component.hpp" #include "..\defines.hpp" -#ifdef ENABLE_PERF_PROFILING - private _scopeShowItem = createProfileScope QFUNC(showItem); -#endif - if (GVAR(centerNotPlayer)) exitWith {}; private _nextAction = switch (GVAR(currentLeftPanel)) do { diff --git a/addons/arsenal/functions/fnc_sortPanel.sqf b/addons/arsenal/functions/fnc_sortPanel.sqf index a81b31bd82..c8bf02777f 100644 --- a/addons/arsenal/functions/fnc_sortPanel.sqf +++ b/addons/arsenal/functions/fnc_sortPanel.sqf @@ -14,10 +14,6 @@ #include "script_component.hpp" #include "..\defines.hpp" -#ifdef ENABLE_PERF_PROFILING - private _scopeSortPanel = createProfileScope QFUNC(sortPanel); -#endif - params ["_control", "_mode"]; private _display = ctrlParent _control; diff --git a/addons/arsenal/functions/fnc_updateCamPos.sqf b/addons/arsenal/functions/fnc_updateCamPos.sqf index f8b6b91a15..41b7399e61 100644 --- a/addons/arsenal/functions/fnc_updateCamPos.sqf +++ b/addons/arsenal/functions/fnc_updateCamPos.sqf @@ -19,9 +19,3 @@ GVAR(cameraHelper) attachTo [GVAR(center), GVAR(cameraPosition) select 3, ""]; / 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 index 42a0275fbb..41c7c68483 100644 --- a/addons/arsenal/functions/fnc_updateRightPanel.sqf +++ b/addons/arsenal/functions/fnc_updateRightPanel.sqf @@ -14,10 +14,6 @@ #include "script_component.hpp" #include "..\defines.hpp" -#ifdef ENABLE_PERF_PROFILING - private _scopeUpdateRightPanel = createProfileScope QFUNC(updateRightPanel); -#endif - params ["_control", "_maxLoad"]; private _loadIndicatorBarCtrl = _display displayCtrl IDC_loadIndicatorBar; diff --git a/addons/arsenal/script_component.hpp b/addons/arsenal/script_component.hpp index 791b9663dc..2eb9c3f170 100644 --- a/addons/arsenal/script_component.hpp +++ b/addons/arsenal/script_component.hpp @@ -5,7 +5,6 @@ // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS -// #define ENABLE_PERF_PROFILING // This requires https://forums.bohemia.net/forums/topic/211626-arma-script-profiler/ do not uncomment otherwise. #ifdef DEBUG_ENABLED_ARSENAL #define DEBUG_MODE_FULL diff --git a/addons/arsenal/ui/RscAttributes.hpp b/addons/arsenal/ui/RscAttributes.hpp index 7f485fb9e6..50a1d7f93c 100644 --- a/addons/arsenal/ui/RscAttributes.hpp +++ b/addons/arsenal/ui/RscAttributes.hpp @@ -559,6 +559,7 @@ class GVAR(display) { y = QUOTE(safezoneY + 1.8 * GRID_H); w = QUOTE(74 * GRID_W); h = QUOTE(6 * GRID_H); + sizeEx = QUOTE(6 * GRID_H); }; class leftSearchbarButton: ctrlButtonPicture { idc = IDC_leftSearchbarButton; @@ -987,6 +988,7 @@ class GVAR(loadoutsDisplay) { y = QUOTE(safezoneH - (51 * GRID_H)); w = QUOTE(65 * GRID_W); h = QUOTE(5 * GRID_H); + sizeEx = QUOTE(6 * GRID_H); }; class loadoutsSearchbar: ctrlEdit { idc = IDC_loadoutsSearchbar; @@ -997,6 +999,7 @@ class GVAR(loadoutsDisplay) { y = QUOTE(safezoneH - (51 * GRID_H)); w = QUOTE(72 * GRID_W); h = QUOTE(5 * GRID_H); + sizeEx = QUOTE(6 * GRID_H); }; class loadoutsSearchbarButton: ctrlButtonPicture { idc = -1; diff --git a/addons/gunbag/XEH_preInit.sqf b/addons/gunbag/XEH_preInit.sqf index cac548d134..8f313ba472 100644 --- a/addons/gunbag/XEH_preInit.sqf +++ b/addons/gunbag/XEH_preInit.sqf @@ -24,4 +24,22 @@ PREP_RECOMPILE_END; }, _this] call CBA_fnc_execNextFrame; }] call CBA_fnc_addClassEventHandler; +[QEGVAR(arsenal,displayOpened), { + + private _center = EGVAR(arsenal,center); + + if (_center call FUNC(hasGunBag)) then { + GVAR(arsenalCache) = (backpackContainer _center) getVariable [QGVAR(gunbagWeapon), []]; + }; +}] call CBA_fnc_addEventHandler; + +[QEGVAR(arsenal,displayClosed), { + + if !(isNil QGVAR(arsenalCache)) then { + (backpackContainer EGVAR(arsenal,center)) setVariable [QGVAR(gunbagWeapon),GVAR(arsenalCache), true]; + }; + + GVAR(arsenalCache) = nil; +}] call CBA_fnc_addEventHandler; + ADDON = true;