diff --git a/addons/medical_menu/CfgVehicles.hpp b/addons/medical_menu/CfgVehicles.hpp index 1918511566..dceb042752 100644 --- a/addons/medical_menu/CfgVehicles.hpp +++ b/addons/medical_menu/CfgVehicles.hpp @@ -44,6 +44,15 @@ class CfgVehicles { class Man; class CAManBase: Man { class ACE_SelfActions { + class Medical { + displayName = CSTRING(Actions_Medical); + runOnHover = 1; + exceptions[] = {"isNotInside", "isNotSitting"}; + statement = QUOTE([ARR_3(_target, true, 0)] call EFUNC(medical,displayPatientInformation)); + condition = "true"; + icon = QPATHTOEF(medical,UI\icons\medical_cross.paa); + #include "InteractionBodyParts.hpp" + }; class Medical_Menu { displayName = CSTRING(OpenMenu); runOnHover = 0; @@ -55,6 +64,7 @@ class CfgVehicles { }; class ACE_Actions { + #include "InteractionBodyParts.hpp" // Create a consolidates medical menu for treatment while boarded class ACE_MainActions { class Medical_Menu { diff --git a/addons/medical_menu/InteractionBodyParts.hpp b/addons/medical_menu/InteractionBodyParts.hpp new file mode 100644 index 0000000000..4814917df1 --- /dev/null +++ b/addons/medical_menu/InteractionBodyParts.hpp @@ -0,0 +1,57 @@ +class ACE_Head { + displayName = ECSTRING(interaction,Head); + icon = QPATHTOEF(medical,UI\icons\medical_cross.paa); + exceptions[] = {"isNotInside", "isNotSitting"}; + statement = QUOTE([ARR_3(_target, true, 0)] call EFUNC(medical,displayPatientInformation)); + modifierFunction = QUOTE([ARR_4(_target,_player,0,_this select 3)] call EFUNC(medical_treatment,modifyMedicalAction)); + condition = "true"; + runOnHover = 1; +}; +class ACE_Torso { + displayName = ECSTRING(interaction,Torso); + distance = 5.0; + condition = "true"; + runOnHover = 1; + exceptions[] = {"isNotInside", "isNotSitting"}; + statement = QUOTE([ARR_3(_target, true, 1)] call EFUNC(medical,displayPatientInformation)); + modifierFunction = QUOTE([ARR_4(_target,_player,1,_this select 3)] call EFUNC(medical_treatment,modifyMedicalAction)); + showDisabled = 1; + priority = 2; + icon = QPATHTOEF(medical,UI\icons\medical_cross.paa); +}; +class ACE_ArmLeft { + displayName = ECSTRING(interaction,ArmLeft); + runOnHover = 1; + exceptions[] = {"isNotInside", "isNotSitting"}; + statement = QUOTE([ARR_3(_target, true, 2)] call EFUNC(medical,displayPatientInformation)); + modifierFunction = QUOTE([ARR_4(_target,_player,2,_this select 3)] call EFUNC(medical_treatment,modifyMedicalAction)); + condition = "true"; + icon = QPATHTOEF(medical,UI\icons\medical_cross.paa); +}; +class ACE_ArmRight { + displayName = ECSTRING(interaction,ArmRight); + runOnHover = 1; + exceptions[] = {"isNotInside", "isNotSitting"}; + statement = QUOTE([ARR_3(_target, true, 3)] call EFUNC(medical,displayPatientInformation)); + modifierFunction = QUOTE([ARR_4(_target,_player,3,_this select 3)] call EFUNC(medical_treatment,modifyMedicalAction)); + condition = "true"; + icon = QPATHTOEF(medical,UI\icons\medical_cross.paa); +}; +class ACE_LegLeft { + displayName = ECSTRING(interaction,LegLeft); + runOnHover = 1; + exceptions[] = {"isNotInside", "isNotSitting"}; + statement = QUOTE([ARR_3(_target, true, 4)] call EFUNC(medical,displayPatientInformation)); + modifierFunction = QUOTE([ARR_4(_target,_player,4,_this select 3)] call EFUNC(medical_treatment,modifyMedicalAction)); + condition = "true"; + icon = QPATHTOEF(medical,UI\icons\medical_cross.paa); +}; +class ACE_LegRight { + displayName = ECSTRING(interaction,LegRight); + runOnHover = 1; + exceptions[] = {"isNotInside", "isNotSitting"}; + statement = QUOTE([ARR_3(_target, true, 5)] call EFUNC(medical,displayPatientInformation)); + modifierFunction = QUOTE([ARR_4(_target,_player,5,_this select 3)] call EFUNC(medical_treatment,modifyMedicalAction)); + condition = "true"; + icon = QPATHTOEF(medical,UI\icons\medical_cross.paa); +}; diff --git a/addons/medical_menu/XEH_PREP.hpp b/addons/medical_menu/XEH_PREP.hpp index 8a44bd2bdc..187eea2c08 100644 --- a/addons/medical_menu/XEH_PREP.hpp +++ b/addons/medical_menu/XEH_PREP.hpp @@ -1,18 +1,17 @@ - -PREP(onMenuOpen); -PREP(onMenuClose); -PREP(openMenu); - PREP(canOpenMenu); -PREP(updateIcons); -PREP(updateUIInfo); +PREP(collectActions); +PREP(collectActions3D); +PREP(getTreatmentOptions); PREP(handleUI_DisplayOptions); PREP(handleUI_dropDownTriageCard); -PREP(getTreatmentOptions); -PREP(updateActivityLog); -PREP(updateQuickViewLog); -PREP(updateBodyImage); -PREP(updateInformationLists); -PREP(setTriageStatus); -PREP(collectActions); PREP(module); +PREP(onMenuClose); +PREP(onMenuOpen); +PREP(openMenu); +PREP(setTriageStatus); +PREP(updateActivityLog); +PREP(updateBodyImage); +PREP(updateIcons); +PREP(updateInformationLists); +PREP(updateQuickViewLog); +PREP(updateUIInfo); diff --git a/addons/medical_menu/XEH_postInit.sqf b/addons/medical_menu/XEH_postInit.sqf index b028a16e75..dff5817c77 100644 --- a/addons/medical_menu/XEH_postInit.sqf +++ b/addons/medical_menu/XEH_postInit.sqf @@ -6,6 +6,12 @@ GVAR(MenuPFHID) = -1; GVAR(lastOpenedOn) = -1; GVAR(pendingReopen) = false; +["ace_settingsInitialized", { + if (EGVAR(medical,level) > 0 && {EGVAR(medical,menuTypeStyle) == 0}) then { + [] call FUNC(collectActions3D); + }; +}] call CBA_fnc_addEventHandler; + ["ace_treatmentSucceded", { if (GVAR(openAfterTreatment) && {GVAR(pendingReopen)}) then { GVAR(pendingReopen) = false; @@ -15,8 +21,7 @@ GVAR(pendingReopen) = false; }; }] call CBA_fnc_addEventHandler; -["ACE3 Common", QGVAR(displayMenuKeyPressed), localize LSTRING(DisplayMenuKey), -{ +["ACE3 Common", QGVAR(displayMenuKeyPressed), localize LSTRING(DisplayMenuKey), { private _target = cursorTarget; if (!((_target isKindOf "CAManBase") && {[ACE_player, _target] call FUNC(canOpenMenu)})) then {_target = ACE_player}; @@ -27,11 +32,9 @@ GVAR(pendingReopen) = false; // Statement [_target] call FUNC(openMenu); false -}, -{ +}, { if (CBA_missionTime - GVAR(lastOpenedOn) > 0.5) exitWith { [objNull] call FUNC(openMenu); }; false -}, -[35, [false, false, false]], false, 0] call CBA_fnc_addKeybind; +}, [35, [false, false, false]], false, 0] call CBA_fnc_addKeybind; diff --git a/addons/medical_menu/config.cpp b/addons/medical_menu/config.cpp index ff78ca384a..6207d6c7da 100644 --- a/addons/medical_menu/config.cpp +++ b/addons/medical_menu/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_medical_treatment"}; + requiredAddons[] = {"ace_medical_treatment", "ace_interact_menu"}; author = ECSTRING(common,ACETeam); authors[] = {"Glowbal"}; url = ECSTRING(main,URL); diff --git a/addons/medical_menu/functions/fnc_collectActions3D.sqf b/addons/medical_menu/functions/fnc_collectActions3D.sqf new file mode 100644 index 0000000000..5ab1a354b0 --- /dev/null +++ b/addons/medical_menu/functions/fnc_collectActions3D.sqf @@ -0,0 +1,62 @@ +/* + * Author: BaerMitUmlaut + * Creates actions for the given treatments and adds them to the interaction menu. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_medical_menu_fnc_collectActions3D + * + * Public: No + */ +#include "script_component.hpp" + +private _actionsConfig = [nil, configFile >> "ACE_Medical_Treatment_Actions" >> "Basic", configFile >> "ACE_Medical_Treatment_Actions" >> "Advanced"] select EGVAR(medical,level); +private _allAllowedSelections = ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"]; +private _actionPaths = ["ACE_Head", "ACE_Torso", "ACE_ArmLeft", "ACE_ArmRight", "ACE_LegLeft", "ACE_LegRight"]; +private _actionPathTexts = [ + localize ELSTRING(interaction,Head), localize ELSTRING(interaction,Torso), + localize ELSTRING(interaction,ArmLeft), localize ELSTRING(interaction,ArmRight), + localize ELSTRING(interaction,LegLeft), localize ELSTRING(interaction,LegRight) +]; +private _actionPathPositions = ["spine3", "pilot", "LeftForeArm", "RightForeArm", "LKnee", "RKnee"]; + +// - Create treatment actions ------------------------------------------------- +{ + private _config = _x; + private _actionName = QUOTE(ADDON) + "_" + configName _config; + private _displayName = getText (_config >> "displayName"); + private _icon = switch (getText (_config >> "category")) do { + case "bandage": {QPATHTOEF(medical,UI\icons\bandage.paa)}; + case "medication": {QPATHTOEF(medical,UI\icons\autoInjector.paa)}; + // Currently category advanced which includes body bag :/ + // case "iv": {QPATHTOF(UI\icons\iv.paa)}; + default {""}; + }; + + private _allowedSelections = getArray (_config >> "allowedSelections"); + _allowedSelections = _allowedSelections apply {toLower _x}; + + if (_allowedSelections isEqualTo ["all"]) then { + _allowedSelections = _allAllowedSelections; + }; + + { + private _selection = _x; + private _actionPath = _actionPaths select (_allAllowedSelections find _selection); + + private _statement = {[_player, _target, _selection, _this select 2] call EFUNC(medical_treatment,treatment)}; + private _condition = {[_player, _target, _selection, _this select 2] call EFUNC(medical_treatment,canTreatCached)}; + + private _action = [ + _actionName, _displayName, _icon, _statement, _condition, {}, configName _config, [0, 0, 0], 2, [false, true, false, false, false] + ] call EFUNC(interact_menu,createAction); + diag_log formatText ["ACTIONS LOL: %1", [_actionName, _displayName, _icon, _statement, _condition]]; + ["CAManBase", 0, [_actionPath], _action, true] call EFUNC(interact_menu,addActionToClass); + ["CAManBase", 1, ["ACE_SelfActions", "Medical", _actionPath], _action, true] call EFUNC(interact_menu,addActionToClass); + } forEach _allowedSelections; +} forEach configProperties [_actionsConfig, "isClass _x"]; diff --git a/addons/medical_menu/script_component.hpp b/addons/medical_menu/script_component.hpp index cb437060a3..cdea3a2c90 100644 --- a/addons/medical_menu/script_component.hpp +++ b/addons/medical_menu/script_component.hpp @@ -3,7 +3,7 @@ #include "\z\ace\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE +#define DISABLE_COMPILE_CACHE // #define CBA_DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS