From 0e26755b88bb5141594320cf9292fe02a05eedc7 Mon Sep 17 00:00:00 2001 From: Grim <69561145+LinkIsGrim@users.noreply.github.com> Date: Fri, 7 Jul 2023 07:14:44 +0300 Subject: [PATCH] Medical - Add arsenal category (#9220) * add medical category to arsenal * function header Co-authored-by: PabstMirror * move to preinit, protect list * improve macro * documentation * add config property * add CfgMagazines * Revert "add CfgMagazines" Arsenal doesn't support magazines in custom categories --------- Co-authored-by: GhostIsSpooky <69561145+Salluci@users.noreply.github.com> Co-authored-by: PabstMirror --- addons/medical_treatment/CfgWeapons.hpp | 19 +++++++++++ addons/medical_treatment/XEH_PREP.hpp | 1 + addons/medical_treatment/XEH_preInit.sqf | 7 ++++ addons/medical_treatment/XEH_preStart.sqf | 2 ++ .../functions/fnc_scanMedicalItems.sqf | 34 +++++++++++++++++++ addons/medical_treatment/script_component.hpp | 2 ++ .../framework/medical-treatment-framework.md | 18 ++++++++++ 7 files changed, 83 insertions(+) create mode 100644 addons/medical_treatment/functions/fnc_scanMedicalItems.sqf diff --git a/addons/medical_treatment/CfgWeapons.hpp b/addons/medical_treatment/CfgWeapons.hpp index fed3184a59..e285697cc1 100644 --- a/addons/medical_treatment/CfgWeapons.hpp +++ b/addons/medical_treatment/CfgWeapons.hpp @@ -8,12 +8,14 @@ class CfgWeapons { class FirstAidKit: ItemCore { type = 0; + ACE_isMedicalItem = 1; class ItemInfo: InventoryFirstAidKitItem_Base_F { mass = 4; }; }; class Medikit: ItemCore { type = 0; + ACE_isMedicalItem = 1; class ItemInfo: MedikitItem { mass = 60; }; @@ -27,6 +29,7 @@ class CfgWeapons { displayName = CSTRING(Bandage_Basic_Display); descriptionShort = CSTRING(Bandage_Basic_Desc_Short); descriptionUse = CSTRING(Bandage_Basic_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 1; }; @@ -39,6 +42,7 @@ class CfgWeapons { model = QPATHTOF(data\packingbandage.p3d); descriptionShort = CSTRING(Packing_Bandage_Desc_Short); descriptionUse = CSTRING(Packing_Bandage_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 1; }; @@ -51,6 +55,7 @@ class CfgWeapons { model = "\A3\Structures_F_EPA\Items\Medical\Bandage_F.p3d"; descriptionShort = CSTRING(Bandage_Elastic_Desc_Short); descriptionUse = CSTRING(Bandage_Elastic_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 1; }; @@ -63,6 +68,7 @@ class CfgWeapons { model = QPATHTOF(data\tourniquet.p3d); descriptionShort = CSTRING(Tourniquet_Desc_Short); descriptionUse = CSTRING(Tourniquet_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 1; }; @@ -74,6 +80,7 @@ class CfgWeapons { picture = QPATHTOF(ui\splint_ca.paa); model = QPATHTOF(data\splint.p3d); descriptionShort = CSTRING(splint_Desc_Short); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 2; }; @@ -86,6 +93,7 @@ class CfgWeapons { model = QPATHTOF(data\morphine.p3d); descriptionShort = CSTRING(Morphine_Desc_Short); descriptionUse = CSTRING(Morphine_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 1; }; @@ -98,6 +106,7 @@ class CfgWeapons { model = QPATHTOF(data\adenosine.p3d); descriptionShort = CSTRING(adenosine_Desc_Short); descriptionUse = CSTRING(adenosine_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 1; }; @@ -110,6 +119,7 @@ class CfgWeapons { model = QPATHTOF(data\atropine.p3d); descriptionShort = CSTRING(Atropine_Desc_Short); descriptionUse = CSTRING(Atropine_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 1; }; @@ -122,6 +132,7 @@ class CfgWeapons { model = QPATHTOF(data\epinephrine.p3d); descriptionShort = CSTRING(Epinephrine_Desc_Short); descriptionUse = CSTRING(Epinephrine_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 1; }; @@ -137,6 +148,7 @@ class CfgWeapons { picture = QPATHTOF(ui\plasmaIV_ca.paa); descriptionShort = CSTRING(Plasma_IV_Desc_Short); descriptionUse = CSTRING(Plasma_IV_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 10; }; @@ -167,6 +179,7 @@ class CfgWeapons { hiddenSelectionsTextures[] = {QPATHTOF(data\IVBag_blood_1000ml_ca.paa)}; descriptionShort = CSTRING(Blood_IV_Desc_Short); descriptionUse = CSTRING(Blood_IV_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 10; }; @@ -197,6 +210,7 @@ class CfgWeapons { picture = QPATHTOF(ui\salineIV_ca.paa); descriptionShort = CSTRING(Saline_IV_Desc_Short); descriptionUse = CSTRING(Saline_IV_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 10; }; @@ -225,6 +239,7 @@ class CfgWeapons { picture = QPATHTOF(ui\quickclot_ca.paa); descriptionShort = CSTRING(QuikClot_Desc_Short); descriptionUse = CSTRING(QuikClot_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 1; }; @@ -236,6 +251,7 @@ class CfgWeapons { picture = QPATHTOF(ui\personal_aid_kit_ca.paa); descriptionShort = CSTRING(Aid_Kit_Desc_Short); descriptionUse = CSTRING(Aid_Kit_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 10; }; @@ -248,6 +264,7 @@ class CfgWeapons { picture = QPATHTOF(ui\surgicalKit_ca.paa); descriptionShort = CSTRING(SurgicalKit_Desc_Short); descriptionUse = CSTRING(SurgicalKit_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 15; }; @@ -260,6 +277,7 @@ class CfgWeapons { picture = QPATHTOF(ui\suture_ca.paa); descriptionShort = CSTRING(Suture_Desc_Short); descriptionUse = CSTRING(Suture_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 1; }; @@ -272,6 +290,7 @@ class CfgWeapons { picture = QPATHTOF(ui\bodybag_ca.paa); descriptionShort = CSTRING(Bodybag_Desc_Short); descriptionUse = CSTRING(Bodybag_Desc_Use); + ACE_isMedicalItem = 1; class ItemInfo: CBA_MiscItem_ItemInfo { mass = 7; }; diff --git a/addons/medical_treatment/XEH_PREP.hpp b/addons/medical_treatment/XEH_PREP.hpp index be64563857..ab128aa49c 100644 --- a/addons/medical_treatment/XEH_PREP.hpp +++ b/addons/medical_treatment/XEH_PREP.hpp @@ -48,6 +48,7 @@ PREP(medicationLocal); PREP(onMedicationUsage); PREP(placeInBodyBag); PREP(removeBody); +PREP(scanMedicalItems); PREP(setTriageStatus); PREP(splint); PREP(splintLocal); diff --git a/addons/medical_treatment/XEH_preInit.sqf b/addons/medical_treatment/XEH_preInit.sqf index dfb6bf6518..30bf875291 100644 --- a/addons/medical_treatment/XEH_preInit.sqf +++ b/addons/medical_treatment/XEH_preInit.sqf @@ -8,6 +8,8 @@ PREP_RECOMPILE_END; #include "initSettings.sqf" +#define ARSENAL_CATEGORY_ICON (["\A3\ui_f\data\igui\cfg\actions\heal_ca.paa", QPATHTOEF(medical_gui,data\categories\bandage_fracture.paa)] select (["ace_medical_gui"] call EFUNC(common,isModLoaded))) + // config to determine animation acceleration coefficient // adjusting these is trail and error // if the animation is cut of ingame, increase these values @@ -44,4 +46,9 @@ GVAR(facilityClasses) = []; } forEach getArray _x; } forEach configProperties [configFile >> QEGVAR(medical,facilities), "isArray _x"]; +// Custom Arsenal tab +if (["ace_arsenal"] call EFUNC(common,isModLoaded)) then { + [MEDICAL_TREATMENT_ITEMS, LELSTRING(medical,Category), ARSENAL_CATEGORY_ICON] call EFUNC(arsenal,addRightPanelButton); +}; + ADDON = true; diff --git a/addons/medical_treatment/XEH_preStart.sqf b/addons/medical_treatment/XEH_preStart.sqf index 022888575e..27f8f2d9c2 100644 --- a/addons/medical_treatment/XEH_preStart.sqf +++ b/addons/medical_treatment/XEH_preStart.sqf @@ -1,3 +1,5 @@ #include "script_component.hpp" #include "XEH_PREP.hpp" + +call FUNC(scanMedicalItems) diff --git a/addons/medical_treatment/functions/fnc_scanMedicalItems.sqf b/addons/medical_treatment/functions/fnc_scanMedicalItems.sqf new file mode 100644 index 0000000000..17b2456c42 --- /dev/null +++ b/addons/medical_treatment/functions/fnc_scanMedicalItems.sqf @@ -0,0 +1,34 @@ +#include "script_component.hpp" +/* + * Author: Salluci + * Caches all item classnames used in ACE_Medical_Treatment_Actions + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call ace_medical_treatment_fnc_scanMedicalItems + * + * Public: No + */ + +private _list = []; +private _cfgActions = configFile >> QGVAR(actions); + +private _fnc_isMedicalItem = toString { + getNumber (_x >> "ACE_isMedicalItem") isEqualTo 1 +}; + +// get items in ACE_Medical_Treament_Actions, fallback for items without API config property +{ + _list append (getArray (_x >> "items")); +} forEach ("true" configClasses _cfgActions); + +{ + _list pushBack (configName _x); +} forEach (_fnc_isMedicalItem configClasses (configFile >> "CfgWeapons")); + +uiNamespace setVariable [QGVAR(treatmentItems), compileFinal str (_list arrayIntersect _list)] diff --git a/addons/medical_treatment/script_component.hpp b/addons/medical_treatment/script_component.hpp index 682e8a471c..36173d4ac1 100644 --- a/addons/medical_treatment/script_component.hpp +++ b/addons/medical_treatment/script_component.hpp @@ -54,3 +54,5 @@ // Animations that would be played faster than this are instead skipped. (= Progress bar too quick for animation). #define ANIMATION_SPEED_MAX_COEFFICIENT 2.5 + +#define MEDICAL_TREATMENT_ITEMS (call (uiNamespace getVariable [QGVAR(treatmentItems), {[]}])) diff --git a/docs/wiki/framework/medical-treatment-framework.md b/docs/wiki/framework/medical-treatment-framework.md index a3f5d04de1..adb9cd485d 100644 --- a/docs/wiki/framework/medical-treatment-framework.md +++ b/docs/wiki/framework/medical-treatment-framework.md @@ -38,3 +38,21 @@ class CfgVehicles { }; }; ``` +### 1.3 Treatment Items + +Items in `CfgWeapons` with `ACE_isMedicalItem` property will be added to the ACE Medical category in the ACE Arsenal. +```cpp +class CfgWeapons { + class MyMedicalItem { + ACE_isMedicalItem = 1; + }; +}; +``` +Required items in `ACE_Medical_Treatment_Actions` will also be added as a fallback. +```cpp +class ACE_Medical_Treatment_Actions { + class MyCustomTreatment { + items[] = {"MyMedicalItem"}; + }; +}; +```