Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Medical GUI - Make separate file for keybinds #10190

Merged
merged 2 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 2 additions & 58 deletions addons/medical_gui/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

if (!hasInterface) exitWith {};

#include "initKeybinds.inc.sqf"

GVAR(target) = objNull;
GVAR(previousTarget) = objNull;
GVAR(selectedBodyPart) = 0;
Expand Down Expand Up @@ -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;
Expand Down
55 changes: 55 additions & 0 deletions addons/medical_gui/initKeybinds.inc.sqf
Original file line number Diff line number Diff line change
@@ -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;