From be23ae7ecdd516edf18c782cf9a6f999ae59d3bf Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sun, 11 Aug 2024 23:24:01 +0200 Subject: [PATCH] Medical GUI - Make separate file for keybinds (#10190) * Make separate file for keybinds * Add missing ; --- addons/medical_gui/XEH_postInit.sqf | 60 +------------------------ addons/medical_gui/initKeybinds.inc.sqf | 55 +++++++++++++++++++++++ 2 files changed, 57 insertions(+), 58 deletions(-) create mode 100644 addons/medical_gui/initKeybinds.inc.sqf diff --git a/addons/medical_gui/XEH_postInit.sqf b/addons/medical_gui/XEH_postInit.sqf index 2b7fb8ce52..6d18696b0e 100644 --- a/addons/medical_gui/XEH_postInit.sqf +++ b/addons/medical_gui/XEH_postInit.sqf @@ -2,6 +2,8 @@ if (!hasInterface) exitWith {}; +#include "initKeybinds.inc.sqf" + GVAR(target) = objNull; GVAR(previousTarget) = objNull; GVAR(selectedBodyPart) = 0; @@ -35,64 +37,6 @@ GVAR(selfInteractionActions) = []; }; }] call CBA_fnc_addEventHandler; -["ACE3 Common", QGVAR(openMedicalMenuKey), localize LSTRING(OpenMedicalMenu), { - // Get target (cursorTarget, cursorObject, and lineIntersectsSurfaces along camera to maxDistance), if not valid then target is ACE_player - TRACE_3("Open menu key",cursorTarget,cursorObject,ACE_player); - private _target = cursorTarget; - if !(_target isKindOf "CAManBase" && {[ACE_player, _target] call FUNC(canOpenMenu)}) then { - _target = cursorObject; - if !(_target isKindOf "CAManBase" && {[ACE_player, _target] call FUNC(canOpenMenu)}) then { - private _start = AGLToASL positionCameraToWorld [0, 0, 0]; - private _end = AGLToASL positionCameraToWorld [0, 0, GVAR(maxDistance)]; - private _intersections = lineIntersectsSurfaces [_start, _end, ACE_player, objNull, true, -1, "FIRE"]; - { - _x params ["", "", "_intersectObject"]; - // Only look "through" player and player's vehicle - if (!(_intersectObject isKindOf "CAManBase") && {_intersectObject != vehicle ACE_player}) exitWith {}; - if (_intersectObject != ACE_player && {_intersectObject isKindOf "CAManBase" && {[ACE_player, _intersectObject] call FUNC(canOpenMenu)}}) exitWith { - _target =_intersectObject - }; - } forEach _intersections; - if (!(_target isKindOf "CAManBase") || {!([ACE_player, _target] call FUNC(canOpenMenu))}) then { - _target = ACE_player; - }; - }; - }; - - // Check conditions: canInteract and canOpenMenu - if !([ACE_player, _target, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false}; - if !([ACE_player, _target] call FUNC(canOpenMenu)) exitWith {false}; - - // Statement - [_target] call FUNC(openMenu); - false -}, { - // Close menu if enough time passed from opening - if (CBA_missionTime - GVAR(lastOpenedOn) > 0.5) exitWith { - [objNull] call FUNC(openMenu); - }; - false -}, [DIK_H, [false, false, false]], false, 0] call CBA_fnc_addKeybind; - -["ACE3 Common", QGVAR(peekMedicalInfoKey), localize LSTRING(PeekMedicalInfo), -{ - // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; - - // Statement - [ACE_player, -1] call FUNC(displayPatientInformation); - false -}, { - if (CBA_missionTime - GVAR(peekLastOpenedOn) > GVAR(peekMedicalInfoReleaseDelay)) then { - [{ - CBA_missionTime - GVAR(peekLastOpenedOn) > GVAR(peekMedicalInfoReleaseDelay) - }, {QGVAR(RscPatientInfo) cutFadeOut 0.3}] call CBA_fnc_waitUntilAndExecute; - }; - GVAR(peekLastOpenedOn) = CBA_missionTime; - false -}, [DIK_H, [false, true, false]], false, 0] call CBA_fnc_addKeybind; - - // Close patient information display when interaction menu is closed ["ace_interactMenuClosed", { QGVAR(RscPatientInfo) cutFadeOut 0.3; diff --git a/addons/medical_gui/initKeybinds.inc.sqf b/addons/medical_gui/initKeybinds.inc.sqf new file mode 100644 index 0000000000..53c577084e --- /dev/null +++ b/addons/medical_gui/initKeybinds.inc.sqf @@ -0,0 +1,55 @@ +["ACE3 Common", QGVAR(openMedicalMenuKey), LLSTRING(OpenMedicalMenu), { + // Get target (cursorTarget, cursorObject, and lineIntersectsSurfaces along camera to maxDistance), if not valid then target is ACE_player + TRACE_3("Open menu key",cursorTarget,cursorObject,ACE_player); + private _target = cursorTarget; + if !(_target isKindOf "CAManBase" && {[ACE_player, _target] call FUNC(canOpenMenu)}) then { + _target = cursorObject; + if !(_target isKindOf "CAManBase" && {[ACE_player, _target] call FUNC(canOpenMenu)}) then { + private _start = AGLToASL positionCameraToWorld [0, 0, 0]; + private _end = AGLToASL positionCameraToWorld [0, 0, GVAR(maxDistance)]; + private _intersections = lineIntersectsSurfaces [_start, _end, ACE_player, objNull, true, -1, "FIRE"]; + { + _x params ["", "", "_intersectObject"]; + // Only look "through" player and player's vehicle + if (!(_intersectObject isKindOf "CAManBase") && {_intersectObject != vehicle ACE_player}) exitWith {}; + if (_intersectObject != ACE_player && {_intersectObject isKindOf "CAManBase" && {[ACE_player, _intersectObject] call FUNC(canOpenMenu)}}) exitWith { + _target = _intersectObject; + }; + } forEach _intersections; + if (!(_target isKindOf "CAManBase") || {!([ACE_player, _target] call FUNC(canOpenMenu))}) then { + _target = ACE_player; + }; + }; + }; + + // Check conditions: canInteract and canOpenMenu + if !([ACE_player, _target, ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, _target] call FUNC(canOpenMenu)) exitWith {false}; + + // Statement + [_target] call FUNC(openMenu); + false +}, { + // Close menu if enough time passed from opening + if (CBA_missionTime - GVAR(lastOpenedOn) > 0.5) exitWith { + [objNull] call FUNC(openMenu); + }; +}, [DIK_H, [false, false, false]], false, 0] call CBA_fnc_addKeybind; + +["ACE3 Common", QGVAR(peekMedicalInfoKey), LLSTRING(PeekMedicalInfo), { + // Conditions: canInteract + if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + + // Statement + [ACE_player, -1] call FUNC(displayPatientInformation); + false +}, { + if (CBA_missionTime - GVAR(peekLastOpenedOn) > GVAR(peekMedicalInfoReleaseDelay)) then { + [{ + CBA_missionTime - GVAR(peekLastOpenedOn) > GVAR(peekMedicalInfoReleaseDelay) + }, { + QGVAR(RscPatientInfo) cutFadeOut 0.3; + }] call CBA_fnc_waitUntilAndExecute; + }; + GVAR(peekLastOpenedOn) = CBA_missionTime; +}, [DIK_H, [false, true, false]], false, 0] call CBA_fnc_addKeybind;