From 27c55981358383e00ad0a6b4774005c896a98f6d Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 24 Apr 2016 11:26:13 -0500 Subject: [PATCH] vehicle inventory lock - compatibility with acre --- addons/vehiclelock/CfgEventHandlers.hpp | 8 ----- addons/vehiclelock/XEH_postInit.sqf | 10 +++++++ .../functions/fnc_onOpenInventory.sqf | 29 ++++++++++--------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/addons/vehiclelock/CfgEventHandlers.hpp b/addons/vehiclelock/CfgEventHandlers.hpp index 705415e65d..712cc2be1c 100644 --- a/addons/vehiclelock/CfgEventHandlers.hpp +++ b/addons/vehiclelock/CfgEventHandlers.hpp @@ -17,14 +17,6 @@ class Extended_PostInit_EventHandlers { }; }; -class Extended_InventoryOpened_EventHandlers { - class CAManBase { - class ADDON { - clientInventoryOpened = QUOTE(_this call FUNC(onOpenInventory);); - }; - }; -}; - class Extended_InitPost_EventHandlers { class Car { class ADDON { diff --git a/addons/vehiclelock/XEH_postInit.sqf b/addons/vehiclelock/XEH_postInit.sqf index c635de2bd3..93d8bd6426 100644 --- a/addons/vehiclelock/XEH_postInit.sqf +++ b/addons/vehiclelock/XEH_postInit.sqf @@ -3,3 +3,13 @@ //Add Event Handlers ["VehicleLock_SetupCustomKey", {_this call FUNC(serverSetupCustomKeyEH)}] call EFUNC(common,addEventHandler); ["VehicleLock_SetVehicleLock", {_this call FUNC(setVehicleLockEH)}] call EFUNC(common,addEventHandler); + +if (!hasInterface) exitwith {}; + +["SettingsInitialized", { + TRACE_1("SettingsInitialized eh",GVAR(LockVehicleInventory)); + + if (GVAR(LockVehicleInventory)) then { + ["CAManBase", "InventoryOpened", {_this call FUNC(onOpenInventory);}] call CBA_fnc_addClassEventHandler; + }; +}] call EFUNC(common,addEventHandler); diff --git a/addons/vehiclelock/functions/fnc_onOpenInventory.sqf b/addons/vehiclelock/functions/fnc_onOpenInventory.sqf index 17682c72de..5ac9ee427e 100644 --- a/addons/vehiclelock/functions/fnc_onOpenInventory.sqf +++ b/addons/vehiclelock/functions/fnc_onOpenInventory.sqf @@ -7,7 +7,7 @@ * 1: Container * * Return Value: - * Handeled + * None * * Example: * [player, car] call ACE_VehicleLock_fnc_onOpenInventory; @@ -20,10 +20,7 @@ params ["_unit", "_container"]; TRACE_2("params",_unit,_container); //Only check for player: -if (_unit != ace_player) exitWith {false}; - -private "_handeled"; -_handeled = false; +if (_unit != ace_player) exitWith {}; if (GVAR(LockVehicleInventory) && //if setting not enabled {(vehicle ace_player) == ace_player} && //Player dismounted @@ -33,15 +30,19 @@ if (GVAR(LockVehicleInventory) && //if setting not enabled ) then { //Give feedback that vehicle is locked playSound "ACE_Sound_Click"; - //don't open the vehicles inventory - _handeled = true; - // As of 1.54 the action needs to be delayed a frame to work, which used not to be the case + //For compatibiltiy with ACRE, wait until the display is open, close it and then reopen the player's own inventory + //ref: http://gitlab.idi-systems.com/idi-systems/acre2-public/issues/70 [{ - TRACE_1("delaying a frame", ace_player); - //Just opens a dummy groundContainer (so the player can still see their own inventory) - ACE_player action ["Gear", objNull]; - }, []] call EFUNC(common,execNextFrame); + !isNull (findDisplay 602) + }, + { + TRACE_1("car display open: closing", _this); + (findDisplay 602) closeDisplay 0; + [{ + TRACE_1("Opening Player Inventory", _this); + ACE_player action ["Gear", objNull] + }, []] call EFUNC(common,execNextFrame); + }, + []] call EFUNC(common,waitUntilAndExecute); }; - -_handeled