From d2c4bdb453f2db5b4eabd3088c3b559b38cd05c3 Mon Sep 17 00:00:00 2001 From: amsteadrayle Date: Tue, 10 Oct 2023 16:18:43 -0400 Subject: [PATCH 1/5] Warn if tourniquet will interfere with medical action --- addons/medical_gui/functions/fnc_collectActions.sqf | 3 ++- addons/medical_gui/functions/fnc_updateActions.sqf | 12 +++++++++++- addons/medical_gui/stringtable.xml | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/addons/medical_gui/functions/fnc_collectActions.sqf b/addons/medical_gui/functions/fnc_collectActions.sqf index 7a9902ad719..818decb0170 100644 --- a/addons/medical_gui/functions/fnc_collectActions.sqf +++ b/addons/medical_gui/functions/fnc_collectActions.sqf @@ -24,8 +24,9 @@ GVAR(actions) = []; private _category = getText (_x >> "category"); private _condition = compile format [QUOTE([ARR_4(ACE_player, GVAR(target), %1 select GVAR(selectedBodyPart), '%2')] call DEFUNC(medical_treatment,canTreatCached)), ALL_BODY_PARTS, _configName]; private _statement = compile format [QUOTE([ARR_4(ACE_player, GVAR(target), %1 select GVAR(selectedBodyPart), '%2')] call DEFUNC(medical_treatment,treatment)), ALL_BODY_PARTS, _configName]; + private _items = getArray (_x >> "items"); - GVAR(actions) pushBack [_displayName, _category, _condition, _statement]; + GVAR(actions) pushBack [_displayName, _category, _condition, _statement, _items]; } forEach configProperties [configFile >> QEGVAR(medical_treatment,actions), "isClass _x"]; diff --git a/addons/medical_gui/functions/fnc_updateActions.sqf b/addons/medical_gui/functions/fnc_updateActions.sqf index 43141b9c105..44b90b795cf 100644 --- a/addons/medical_gui/functions/fnc_updateActions.sqf +++ b/addons/medical_gui/functions/fnc_updateActions.sqf @@ -38,7 +38,7 @@ if (_showTriage) exitWith { // Show treatment options on action buttons private _shownIndex = 0; { - _x params ["_displayName", "_category", "_condition", "_statement"]; + _x params ["_displayName", "_category", "_condition", "_statement", "_items"]; // Check action category and condition if (_category == _selectedCategory && {call _condition}) then { @@ -50,6 +50,16 @@ private _shownIndex = 0; _ctrl ctrlSetPositionY POS_H(1.1 * _shownIndex); _ctrl ctrlCommit 0; + // Show warning if tourniquet will interfere with action + if (((_category in ["examine", "medication"]) || (_items findIf {"IV" in _x}) > -1) + && HAS_TOURNIQUET_APPLIED_ON(GVAR(target),GVAR(selectedBodyPart))) then { + _ctrl ctrlSetTooltipColorText [1, 1, 0, 1]; + _ctrl ctrlSetTooltip localize LSTRING(TourniquetWarning); + } else { + _ctrl ctrlSetTooltipColorText [1, 1, 1, 1]; + _ctrl ctrlSetTooltip ""; + }; + _ctrl ctrlSetText _displayName; _ctrl ctrlShow true; diff --git a/addons/medical_gui/stringtable.xml b/addons/medical_gui/stringtable.xml index c2eb8c8e735..0ab956d6ab5 100644 --- a/addons/medical_gui/stringtable.xml +++ b/addons/medical_gui/stringtable.xml @@ -1304,5 +1304,8 @@ Chronisches Trauma 심각한 외상 + + No effect while tourniqeted + From 64a30267124f4451bfb62f6b7fb7108d4149324d Mon Sep 17 00:00:00 2001 From: amsteadrayle Date: Fri, 13 Oct 2023 01:47:35 -0400 Subject: [PATCH 2/5] Add setting to enable, default to off --- addons/medical_gui/functions/fnc_updateActions.sqf | 5 +++-- addons/medical_gui/initSettings.sqf | 9 +++++++++ addons/medical_gui/stringtable.xml | 6 ++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/addons/medical_gui/functions/fnc_updateActions.sqf b/addons/medical_gui/functions/fnc_updateActions.sqf index 44b90b795cf..711fa3ef38f 100644 --- a/addons/medical_gui/functions/fnc_updateActions.sqf +++ b/addons/medical_gui/functions/fnc_updateActions.sqf @@ -51,8 +51,9 @@ private _shownIndex = 0; _ctrl ctrlCommit 0; // Show warning if tourniquet will interfere with action - if (((_category in ["examine", "medication"]) || (_items findIf {"IV" in _x}) > -1) - && HAS_TOURNIQUET_APPLIED_ON(GVAR(target),GVAR(selectedBodyPart))) then { + if (GVAR(tourniquetWarning) + && {(_category in ["examine", "medication"]) || (_items findIf {"IV" in _x}) > -1} + && {HAS_TOURNIQUET_APPLIED_ON(GVAR(target),GVAR(selectedBodyPart))}) then { _ctrl ctrlSetTooltipColorText [1, 1, 0, 1]; _ctrl ctrlSetTooltip localize LSTRING(TourniquetWarning); } else { diff --git a/addons/medical_gui/initSettings.sqf b/addons/medical_gui/initSettings.sqf index c1d02d7131d..307e8344b76 100644 --- a/addons/medical_gui/initSettings.sqf +++ b/addons/medical_gui/initSettings.sqf @@ -126,3 +126,12 @@ private _categoryColors = [ELSTRING(medical,Category), format ["| %1 |", LELSTRI true, true // isGlobal ] call CBA_fnc_addSetting; + +[ + QGVAR(tourniquetWarning), + "CHECKBOX", + [LSTRING(TourniquetWarning_DisplayName), LSTRING(TourniquetWarning_Description)], + [ELSTRING(medical,Category), LSTRING(SubCategory)], + false, + false +] call CBA_fnc_addSetting; diff --git a/addons/medical_gui/stringtable.xml b/addons/medical_gui/stringtable.xml index 0ab956d6ab5..17b4fd13c14 100644 --- a/addons/medical_gui/stringtable.xml +++ b/addons/medical_gui/stringtable.xml @@ -1307,5 +1307,11 @@ No effect while tourniqeted + + Show Tourniquet Warning + + + Show a warning tooltip when a tourniquet will interfere with a medical action. + From 8d602dd51676c840e5304649dbacea00a9ae22ef Mon Sep 17 00:00:00 2001 From: amsteadrayle Date: Fri, 13 Oct 2023 19:06:13 -0400 Subject: [PATCH 3/5] Tweak tooltip message --- addons/medical_gui/stringtable.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical_gui/stringtable.xml b/addons/medical_gui/stringtable.xml index e9504f0a299..52c73071461 100644 --- a/addons/medical_gui/stringtable.xml +++ b/addons/medical_gui/stringtable.xml @@ -1349,7 +1349,7 @@ in vehicle's inventory - No effect while tourniqeted + No effect until tourniquet removed Show Tourniquet Warning From 86ff46b0119986fa0d32b52764a89b56d80a87ae Mon Sep 17 00:00:00 2001 From: amsteadrayle <2516219+amsteadrayle@users.noreply.github.com> Date: Sat, 14 Oct 2023 00:13:08 -0400 Subject: [PATCH 4/5] Tweak code style, missing semicolon Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> --- addons/medical_gui/functions/fnc_updateActions.sqf | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/medical_gui/functions/fnc_updateActions.sqf b/addons/medical_gui/functions/fnc_updateActions.sqf index 1e448934256..5e8951a08b3 100644 --- a/addons/medical_gui/functions/fnc_updateActions.sqf +++ b/addons/medical_gui/functions/fnc_updateActions.sqf @@ -62,12 +62,14 @@ private _shownIndex = 0; _ctrl ctrlSetTooltip _countText; // Show warning if tourniquet will interfere with action - if (GVAR(tourniquetWarning) - && {(_category in ["examine", "medication"]) || (_items findIf {"IV" in _x}) > -1} - && {HAS_TOURNIQUET_APPLIED_ON(GVAR(target),GVAR(selectedBodyPart))}) then { + if ( + GVAR(tourniquetWarning) && + {(_category in ["examine", "medication"]) || (_items findIf {"IV" in _x}) > -1} && + {HAS_TOURNIQUET_APPLIED_ON(GVAR(target),GVAR(selectedBodyPart))} + ) then { _ctrl ctrlSetTooltipColorText [1, 1, 0, 1]; _ctrl ctrlSetTooltip localize LSTRING(TourniquetWarning); - } + }; _ctrl ctrlSetText _displayName; _ctrl ctrlShow true; From 46473601d60a674f9d6c8ff8d02b1b535d1aea01 Mon Sep 17 00:00:00 2001 From: amsteadrayle <2516219+amsteadrayle@users.noreply.github.com> Date: Sat, 14 Oct 2023 00:13:21 -0400 Subject: [PATCH 5/5] Use localize macro Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> --- addons/medical_gui/functions/fnc_updateActions.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical_gui/functions/fnc_updateActions.sqf b/addons/medical_gui/functions/fnc_updateActions.sqf index 5e8951a08b3..6d52b8ccdf2 100644 --- a/addons/medical_gui/functions/fnc_updateActions.sqf +++ b/addons/medical_gui/functions/fnc_updateActions.sqf @@ -68,7 +68,7 @@ private _shownIndex = 0; {HAS_TOURNIQUET_APPLIED_ON(GVAR(target),GVAR(selectedBodyPart))} ) then { _ctrl ctrlSetTooltipColorText [1, 1, 0, 1]; - _ctrl ctrlSetTooltip localize LSTRING(TourniquetWarning); + _ctrl ctrlSetTooltip LLSTRING(TourniquetWarning); }; _ctrl ctrlSetText _displayName;