diff --git a/addons/medical_menu/functions/fnc_collectActions.sqf b/addons/medical_menu/functions/fnc_collectActions.sqf index 6f106aca91..8e8f7cd10d 100644 --- a/addons/medical_menu/functions/fnc_collectActions.sqf +++ b/addons/medical_menu/functions/fnc_collectActions.sqf @@ -3,38 +3,40 @@ * Collect treatment actions from medical config * * Arguments: + * None * * Return Value: - * NONE + * None + * + * Example: + * [] call ace_medical_menu_fnc_collectActions * * Public: No */ - #include "script_component.hpp" -private ["_configBasic", "_configAdvanced", "_compileActionsLevel"]; +private ["_configBasic", "_configAdvanced", "_fnc_compileActionsLevel"]; _configBasic = (configFile >> "ACE_Medical_Actions" >> "Basic"); _configAdvanced = (configFile >> "ACE_Medical_Actions" >> "Advanced"); - -_compileActionsLevel = { - private [ "_config", "_entryCount", "_actions", "_action", "_displayName","_condition", "_category", "_statement"]; - _config = _this select 0; - _entryCount = (count _config) - 1; +_fnc_compileActionsLevel = { + private ["_entryCount", "_actions", "_displayName", "_condition", "_category", "_statement"]; + params ["_config"]; _actions = []; - for "_i" from 0 to _entryCount /* step +1 */ do { - _action = _config select _i; - if (isClass _action) then { - _displayName = getText (_action >> "displayName"); - _category = getText (_action >> "category"); - _condition = format[QUOTE([ARR_4(ACE_player, GVAR(INTERACTION_TARGET), EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart), '%1')] call DEFUNC(medical,canTreatCached)), configName _action]; - _statement = format[QUOTE([ARR_4(ACE_player, GVAR(INTERACTION_TARGET), EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart), '%1')] call DEFUNC(medical,treatment)), configName _action]; - _actions pushback [_displayName, _category, compile _condition, compile _statement]; + { + if (isClass _x) then { + _displayName = getText (_x >> "displayName"); + _category = getText (_x >> "category"); + _condition = format[QUOTE([ARR_4(ACE_player, GVAR(INTERACTION_TARGET), EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart), '%1')] call DEFUNC(medical,canTreatCached)), configName _x]; + _statement = format[QUOTE([ARR_4(ACE_player, GVAR(INTERACTION_TARGET), EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart), '%1')] call DEFUNC(medical,treatment)), configName _x]; + _actions pushBack [_displayName, _category, compile _condition, compile _statement]; }; - }; - _actions; + nil + } count _config; + + _actions // return }; -GVAR(actionsBasic) = [_configBasic] call _compileActionsLevel; -GVAR(actionsAdvanced) = [_configAdvanced] call _compileActionsLevel; +GVAR(actionsBasic) = [_configBasic] call _fnc_compileActionsLevel; +GVAR(actionsAdvanced) = [_configAdvanced] call _fnc_compileActionsLevel; diff --git a/addons/medical_menu/functions/fnc_getTreatmentOptions.sqf b/addons/medical_menu/functions/fnc_getTreatmentOptions.sqf index b317f539c8..4b03d27970 100644 --- a/addons/medical_menu/functions/fnc_getTreatmentOptions.sqf +++ b/addons/medical_menu/functions/fnc_getTreatmentOptions.sqf @@ -10,16 +10,17 @@ * Return Value: * Available actions * + * Exmaple: + * [ACE_player, poor_dude, "some category"] call ace_medical_menu_fnc_getTreatmentOptions + * * Public: No */ - #include "script_component.hpp" -private ["_player", "_target", "_name", "_actions"]; -_player = _this select 0; -_target = _this select 1; -_name = _this select 2; -if !([ACE_player, _target, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitwith {[]}; +private "_actions"; +params ["_player", "_target", "_name"]; + +if (!([ACE_player, _target, ["isNotInside"]] call EFUNC(common,canInteractWith))) exitwith {[]}; _actions = if (EGVAR(medical,level) == 2) then { GVAR(actionsAdvanced); @@ -31,9 +32,11 @@ _collectedActions = []; _bodyPart = EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart); { - if (_name == (_x select 1) && {call (_x select 2)}) then { - _collectedActions pushback _x; + _x params ["", "_currentCategory", "_currentCondition"]; + if (_name == _currentCategory && {call _currentCondition}) then { + _collectedActions pushBack _x; }; -}foreach _actions; + nil +} count _actions; -_collectedActions; +_collectedActions // return diff --git a/addons/medical_menu/functions/fnc_handleUI_DisplayOptions.sqf b/addons/medical_menu/functions/fnc_handleUI_DisplayOptions.sqf index 621ef0e702..b156435839 100644 --- a/addons/medical_menu/functions/fnc_handleUI_DisplayOptions.sqf +++ b/addons/medical_menu/functions/fnc_handleUI_DisplayOptions.sqf @@ -6,27 +6,31 @@ * 0: Category name * * Return Value: - * NONE + * None + * + * Example: + * ["some category"] call ace_medical_menu_handleUI_DisplayOptions * * Public: No */ - #include "script_component.hpp" -#define START_IDC 20 -#define END_IDC 27 -#define AMOUNT_OF_ENTRIES (count _entries) +#define START_IDC 20 +#define END_IDC 27 +#define AMOUNT_OF_ENTRIES (count _entries) -private ["_name","_entries","_display","_newTarget","_counter","_card","_ctrl","_code"]; -_name = _this select 0; if (!hasInterface) exitwith{}; +private ["_entries", "_display", "_newTarget", "_card", "_ctrl", "_code"]; + +params ["_name"]; + disableSerialization; + _display = uiNamespace getVariable QGVAR(medicalMenu); if (isNil "_display") exitwith {}; // no valid dialog present -if ((_name == "toggle")) exitwith { - +if (_name isEqualTo "toggle") exitwith { if (GVAR(INTERACTION_TARGET) != ACE_player) then { _newTarget = ACE_player; } else { @@ -42,7 +46,7 @@ if ((_name == "toggle")) exitwith { }; // Clean the dropdown options list from all actions -for [{_x=START_IDC},{_x <= END_IDC},{_x=_x+1}] do { +for [{_x = START_IDC}, {_x <= END_IDC}, {_x = _x + 1}] do { _ctrl = (_display displayCtrl (_x)); _ctrl ctrlSetText ""; _ctrl ctrlShow false; @@ -55,34 +59,34 @@ GVAR(LatestDisplayOptionMenu) = _name; // The triage card has no options available lbClear 212; -if (_name == "triage") exitwith { - ctrlEnable[212,true]; - _card = ([GVAR(INTERACTION_TARGET)] call FUNC(getTriageList)); +if (_name isEqualTo "triage") exitwith { + ctrlEnable [212, true]; + _card = [GVAR(INTERACTION_TARGET)] call FUNC(getTriageList); { - lbadd[212,format["%1 x%2", getText(configFile >> "CfgWeapons" >> (_x select 0) >> "displayName"), _x select 1]]; - }foreach _card; + lbAdd [212, format["%1 x%2", getText(configFile >> "CfgWeapons" >> (_x select 0) >> "displayName"), _x select 1]]; + } forEach _card; if (count _card == 0) then { - lbadd[212,"No Entries"]; + lbAdd [212, "No Entries"]; }; }; -ctrlEnable[212,false]; +ctrlEnable [212, false]; _entries = [ACE_player, GVAR(INTERACTION_TARGET), _name] call FUNC(getTreatmentOptions); { //player sidechat format["TRIGGERED: %1",_x]; - if (_foreachIndex > END_IDC) exitwith {}; - _ctrl = (_display displayCtrl (START_IDC + _foreachIndex)); - if (!(_foreachIndex > AMOUNT_OF_ENTRIES)) then { + if (_forEachIndex > END_IDC) exitwith {}; + _ctrl = (_display displayCtrl (START_IDC + _forEachIndex)); + if (!(_forEachIndex > AMOUNT_OF_ENTRIES)) then { _ctrl ctrlSetText (_x select 0); - _code = format["ace_medical_menu_pendingReopen = true; call %1;",(_x select 3)]; + _code = format ["ace_medical_menu_pendingReopen = true; call %1;", (_x select 3)]; _ctrl ctrlSetEventHandler ["ButtonClick", _code]; _ctrl ctrlSetTooltip (_x select 0); // TODO implement _ctrl ctrlShow true; } else { _ctrl ctrlSetText ""; - _ctrl ctrlSetEventHandler ["ButtonClick",""]; + _ctrl ctrlSetEventHandler ["ButtonClick", ""]; }; _ctrl ctrlCommit 0; -}foreach _entries; +} forEach _entries; diff --git a/addons/medical_menu/functions/fnc_handleUI_dropDownTriageCard.sqf b/addons/medical_menu/functions/fnc_handleUI_dropDownTriageCard.sqf index 844fc20051..fb924fc40b 100644 --- a/addons/medical_menu/functions/fnc_handleUI_dropDownTriageCard.sqf +++ b/addons/medical_menu/functions/fnc_handleUI_dropDownTriageCard.sqf @@ -3,28 +3,33 @@ * Handle the triage card display * * Arguments: + * None * * Return Value: - * NONE + * None + * + * Example: + * [] call ace_medical_menu_handleUI_dropDownTriageCard * * Public: No */ - #include "script_component.hpp" -private ["_display","_pos","_ctrl","_curPos","_idc"]; +private ["_display", "_pos", "_ctrl", "_currentPos", "_idc"]; + disableSerialization; + _display = uiNamespace getVariable QGVAR(medicalMenu); -_pos = [ 0,0,0,0]; -_curPos = ctrlPosition (_display displayCtrl 2002); -if ((_curPos select 0) == 0 && (_curPos select 1) == 0) then { +_pos = [0, 0, 0, 0]; +_currentPos = ctrlPosition (_display displayCtrl 2002); +_currentPos params ["_currentPosX", "_currentPosY"]; +if (_currentPosX == 0 && _currentPosY == 0) then { _pos = ctrlPosition (_display displayCtrl 2001); }; for "_idc" from 2002 to 2006 step 1 do { _pos set [1, (_pos select 1) + (_pos select 3)]; - _ctrl = (_display displayCtrl _idc); + _ctrl = _display displayCtrl _idc; _ctrl ctrlSetPosition _pos; _ctrl ctrlCommit 0; }; - diff --git a/addons/medical_menu/functions/fnc_onMenuOpen.sqf b/addons/medical_menu/functions/fnc_onMenuOpen.sqf index 26f3392cb1..52a957ae93 100644 --- a/addons/medical_menu/functions/fnc_onMenuOpen.sqf +++ b/addons/medical_menu/functions/fnc_onMenuOpen.sqf @@ -3,17 +3,25 @@ * Handle medical menu opened * * Arguments: + * 0: Medical Menu display * * Return Value: - * NONE + * None + * + * Example: + * [medical_menu] call ace_medical_menu_onMenuOpen * * Public: No */ - - #include "script_component.hpp" -if (isnil QGVAR(LatestDisplayOptionMenu)) then { +private "_target"; + +params ["_display"]; + +if (isNil "_display") exitwith {}; + +if (isNil QGVAR(LatestDisplayOptionMenu)) then { GVAR(LatestDisplayOptionMenu) = "triage"; } else { if (GVAR(LatestDisplayOptionMenu) == "toggle") then { @@ -22,52 +30,48 @@ if (isnil QGVAR(LatestDisplayOptionMenu)) then { }; }; -private ["_display","_target"]; _target = GVAR(INTERACTION_TARGET); -if (isnil QGVAR(INTERACTION_TARGET_PREVIOUS)) then { +if (isNil QGVAR(INTERACTION_TARGET_PREVIOUS)) then { GVAR(INTERACTION_TARGET_PREVIOUS) = _target; }; [GVAR(LatestDisplayOptionMenu)] call FUNC(handleUI_DisplayOptions); - -// 11 till 18 disableSerialization; -_display = _this select 0; //uiNamespace getVariable QGVAR(medicalMenu); -if (isnil "_display") exitwith {}; + [_target, _display] call FUNC(updateUIInfo); -(_display displayCtrl 11) ctrlSetTooltip localize "STR_ACE_Medical_Menu_VIEW_TRIAGE_CARD"; -(_display displayCtrl 12) ctrlSetTooltip localize "STR_ACE_Medical_Menu_EXAMINE_PATIENT"; -(_display displayCtrl 13) ctrlSetTooltip localize "STR_ACE_Medical_Menu_BANDAGE_FRACTURES"; -(_display displayCtrl 14) ctrlSetTooltip localize "STR_ACE_Medical_Menu_MEDICATION"; -(_display displayCtrl 15) ctrlSetTooltip localize "STR_ACE_Medical_Menu_AIRWAY_MANAGEMENT"; -(_display displayCtrl 16) ctrlSetTooltip localize "STR_ACE_Medical_Menu_ADVANCED_TREATMENT"; -(_display displayCtrl 17) ctrlSetTooltip localize "STR_ACE_Medical_Menu_DRAG_CARRY"; -(_display displayCtrl 18) ctrlSetTooltip localize "STR_ACE_Medical_Menu_TOGGLE_SELF"; +(_display displayCtrl 11) ctrlSetTooltip localize LSTRING(VIEW_TRIAGE_CARD); +(_display displayCtrl 12) ctrlSetTooltip localize LSTRING(EXAMINE_PATIENT); +(_display displayCtrl 13) ctrlSetTooltip localize LSTRING(BANDAGE_FRACTURES); +(_display displayCtrl 14) ctrlSetTooltip localize LSTRING(MEDICATION); +(_display displayCtrl 15) ctrlSetTooltip localize LSTRING(AIRWAY_MANAGEMENT); +(_display displayCtrl 16) ctrlSetTooltip localize LSTRING(ADVANCED_TREATMENT); +(_display displayCtrl 17) ctrlSetTooltip localize LSTRING(DRAG_CARRY); +(_display displayCtrl 18) ctrlSetTooltip localize LSTRING(TOGGLE_SELF); -(_display displayCtrl 301) ctrlSetTooltip localize "STR_ACE_Medical_Menu_SELECT_HEAD"; -(_display displayCtrl 302) ctrlSetTooltip localize "STR_ACE_Medical_Menu_SELECT_TORSO"; -(_display displayCtrl 303) ctrlSetTooltip localize "STR_ACE_Medical_Menu_SELECT_ARM_R"; -(_display displayCtrl 304) ctrlSetTooltip localize "STR_ACE_Medical_Menu_SELECT_ARM_L"; -(_display displayCtrl 305) ctrlSetTooltip localize "STR_ACE_Medical_Menu_SELECT_LEG_R"; -(_display displayCtrl 306) ctrlSetTooltip localize "STR_ACE_Medical_Menu_SELECT_LEG_L"; -(_display displayCtrl 2001) ctrlSetTooltip localize "STR_ACE_Medical_Menu_SELECT_TRIAGE_STATUS"; +(_display displayCtrl 301) ctrlSetTooltip localize LSTRING(SELECT_HEAD); +(_display displayCtrl 302) ctrlSetTooltip localize LSTRING(SELECT_TORSO); +(_display displayCtrl 303) ctrlSetTooltip localize LSTRING(SELECT_ARM_R); +(_display displayCtrl 304) ctrlSetTooltip localize LSTRING(SELECT_ARM_L); +(_display displayCtrl 305) ctrlSetTooltip localize LSTRING(SELECT_LEG_R); +(_display displayCtrl 306) ctrlSetTooltip localize LSTRING(SELECT_LEG_L); +(_display displayCtrl 2001) ctrlSetTooltip localize LSTRING(SELECT_TRIAGE_STATUS); -(_display displayCtrl 1) ctrlSetText format["%1",[_target] call EFUNC(common,getName)]; -setMousePosition [ 0.4, 0.4]; +(_display displayCtrl 1) ctrlSetText format ["%1", [_target] call EFUNC(common,getName)]; +setMousePosition [0.4, 0.4]; [QGVAR(onMenuOpen), "onEachFrame", { + params ["_display"]; if (isNull GVAR(INTERACTION_TARGET)) then { GVAR(INTERACTION_TARGET) = ACE_player; }; - [GVAR(INTERACTION_TARGET), _this select 0] call FUNC(updateUIInfo); + [GVAR(INTERACTION_TARGET), _display] call FUNC(updateUIInfo); [GVAR(INTERACTION_TARGET)] call FUNC(updateIcons); [GVAR(LatestDisplayOptionMenu)] call FUNC(handleUI_DisplayOptions); _status = [GVAR(INTERACTION_TARGET)] call FUNC(getTriageStatus); - ((_this select 0) displayCtrl 2000) ctrlSetText (_status select 0); - ((_this select 0) displayCtrl 2000) ctrlSetBackgroundColor (_status select 2); - + (_display displayCtrl 2000) ctrlSetText (_status select 0); + (_display displayCtrl 2000) ctrlSetBackgroundColor (_status select 2); }, [_display]] call BIS_fnc_addStackedEventHandler; - ["Medical_onMenuOpen", [ACE_player, _interactionTarget]] call ace_common_fnc_localEvent; + ["Medical_onMenuOpen", [ACE_player, _interactionTarget]] call EFUNC(common,localEvent); diff --git a/addons/medical_menu/functions/fnc_openMenu.sqf b/addons/medical_menu/functions/fnc_openMenu.sqf index 8803c99ef2..3bc67f0028 100644 --- a/addons/medical_menu/functions/fnc_openMenu.sqf +++ b/addons/medical_menu/functions/fnc_openMenu.sqf @@ -6,22 +6,23 @@ * 0: Target * * Return Value: - * NONE + * None + * + * Example: + * [some_player] call ace_medical_menu_openMenu * * Public: No */ - #include "script_component.hpp" -private ["_interactionTarget"]; -_interactionTarget = _this select 0; +params ["_interactionTarget"]; if (dialog || isNull _interactionTarget) exitwith { disableSerialization; private "_display"; _display = uiNamespace getVariable QGVAR(medicalMenu); - if (!isnil "_display") then { + if (!isNil "_display") then { closeDialog 314412; }; }; diff --git a/addons/medical_menu/functions/fnc_setTriageStatus.sqf b/addons/medical_menu/functions/fnc_setTriageStatus.sqf index 468a044f91..7e7c764aee 100644 --- a/addons/medical_menu/functions/fnc_setTriageStatus.sqf +++ b/addons/medical_menu/functions/fnc_setTriageStatus.sqf @@ -7,15 +7,12 @@ * 1: Status * * Return Value: - * NONE + * None * * Public: No */ - #include "script_component.hpp" -private ["_target", "_status"]; -_target = _this select 0; -_status = _this select 1; +params ["_target", "_status"]; _target setvariable [QEGVAR(medical,triageLevel), _status, true]; diff --git a/addons/medical_menu/functions/fnc_updateActivityLog.sqf b/addons/medical_menu/functions/fnc_updateActivityLog.sqf index 2e1fddcf2a..392359064a 100644 --- a/addons/medical_menu/functions/fnc_updateActivityLog.sqf +++ b/addons/medical_menu/functions/fnc_updateActivityLog.sqf @@ -7,26 +7,25 @@ * 1: log collection * * Return Value: - * NONE + * None + * + * Example: + * [some_display, log] call ace_medical_menu_updateActivityLog * * Public: No */ - #include "script_component.hpp" -private ["_display", "_logs", "_logCtrl"]; -_display = _this select 0; -_logs = _this select 1; +private "_logCtrl"; -_logCtrl = (_display displayCtrl 214); +params ["_display", "_logs"]; + +_logCtrl = _display displayCtrl 214; lbClear _logCtrl; -private ["_message", "_moment", "_arguments"]; { - // [_message,_moment,_type, _arguments] - _message = _x select 0; - _moment = _x select 1; - _arguments = _x select 3; + _x params ["_message", "_moment", "_arguments"]; + if (isLocalized _message) then { _message = localize _message; }; @@ -35,7 +34,9 @@ private ["_message", "_moment", "_arguments"]; if (typeName _x == "STRING" && {isLocalized _x}) then { _arguments set [_foreachIndex, localize _x]; }; - }foreach _arguments; - _message = format([_message] + _arguments); - _logCtrl lbAdd format["%1 %2", _moment, _message]; -}foreach _logs; + } forEach _arguments; + + _message = format ([_message] + _arguments); + _logCtrl lbAdd format ["%1 %2", _moment, _message]; + nil +} count _logs; diff --git a/addons/medical_menu/functions/fnc_updateBodyImage.sqf b/addons/medical_menu/functions/fnc_updateBodyImage.sqf index 707cd3e87e..34b2f450c8 100644 --- a/addons/medical_menu/functions/fnc_updateBodyImage.sqf +++ b/addons/medical_menu/functions/fnc_updateBodyImage.sqf @@ -7,35 +7,36 @@ * 1: display * * Return Value: - * NONE + * None + * + * Example: + * [0.3, some_display] call ace_medical_menu_updateBodyImage * * Public: No */ - #include "script_component.hpp" -private ["_selectionBloodLoss", "_display"]; -_selectionBloodLoss = _this select 0; -_display = _this select 1; +params ["_selectionBloodLoss", "_display"]; // Handle the body image coloring -_availableSelections = [50,51,52,53,54,55]; +_availableSelections = [50, 51, 52, 53, 54, 55]; { private ["_red", "_green", "_blue"]; - _total = _x; _red = 1; _green = 1; _blue = 1; - if (_total > 0) then { + + if (_x > 0) then { if (_damaged select _forEachIndex) then { - _green = (0.9 - _total) max 0; + _green = (0.9 - _x) max 0; _blue = _green; } else { - _green = (0.9 - _total) max 0; + _green = (0.9 - _x) max 0; _red = _green; //_blue = _green; }; }; - (_display displayCtrl (_availableSelections select _foreachIndex)) ctrlSetTextColor [_red, _green, _blue, 1.0]; -}foreach _selectionBloodLoss; + + (_display displayCtrl (_availableSelections select _forEachIndex)) ctrlSetTextColor [_red, _green, _blue, 1.0]; +} forEach _selectionBloodLoss; diff --git a/addons/medical_menu/functions/fnc_updateIcons.sqf b/addons/medical_menu/functions/fnc_updateIcons.sqf index 02570f1355..f9d3fc5ab4 100644 --- a/addons/medical_menu/functions/fnc_updateIcons.sqf +++ b/addons/medical_menu/functions/fnc_updateIcons.sqf @@ -3,27 +3,33 @@ * Update the category icons * * Arguments: + * None * * Return Value: - * NONE + * None + * + * Example: + * [] call ace_medical_menu_updateIcons * * Public: No */ - #include "script_component.hpp" -private ["_display","_startIDC","_idc","_options","_name","_amount"]; +#define START_IDC 111 +#define END_IDC 118 + +private ["_display", "_idc", "_options", "_name", "_amount"]; + disableSerialization; + _display = uiNamespace getVariable QGVAR(medicalMenu); -_startIDC = 111; - _options = ["triage" , "examine", "bandage", "medication", "airway", "advanced", "drag", "toggle"]; -for "_idc" from _startIDC to 118 step 1 do { - _amount = [ACE_player, GVAR(INTERACTION_TARGET), _options select (_idc - 111)] call FUNC(getTreatmentOptions); - if ((count _amount) > 0 || _idc == 111 || _idc == 118) then { - (_display displayCtrl _idc) ctrlSettextColor [1,1,1,1]; +for "_idc" from START_IDC to END_IDC step 1 do { + _amount = [ACE_player, GVAR(INTERACTION_TARGET), _options select (_idc - START_IDC)] call FUNC(getTreatmentOptions); + if ((count _amount) > 0 || _idc == START_IDC || _idc == END_IDC) then { + (_display displayCtrl _idc) ctrlSettextColor [1, 1, 1, 1]; } else { - (_display displayCtrl _idc) ctrlSettextColor [0.4,0.4,0.4,1]; + (_display displayCtrl _idc) ctrlSettextColor [0.4, 0.4, 0.4, 1]; }; -}; \ No newline at end of file +}; diff --git a/addons/medical_menu/functions/fnc_updateInformationLists.sqf b/addons/medical_menu/functions/fnc_updateInformationLists.sqf index f96e8c9943..c8388b2bd3 100644 --- a/addons/medical_menu/functions/fnc_updateInformationLists.sqf +++ b/addons/medical_menu/functions/fnc_updateInformationLists.sqf @@ -8,30 +8,31 @@ * 2: injury collection * * Return Value: - * NONE + * None * * Public: No */ - #include "script_component.hpp" -private ["_display", "_genericMessages", "_allInjuryTexts", "_lbCtrl"]; -_display = _this select 0; -_genericMessages = _this select 1; -_allInjuryTexts = _this select 2; +private "_lbCtrl"; -_lbCtrl = (_display displayCtrl 213); +params["_display", "_genericMessages", "_allInjuryTexts"]; + +_lbCtrl = _display displayCtrl 213; lbClear _lbCtrl; { _lbCtrl lbAdd (_x select 0); - _lbCtrl lbSetColor [_foreachIndex, _x select 1]; -}foreach _genericMessages; + _lbCtrl lbSetColor [_forEachIndex, _x select 1]; + nil +} count _genericMessages; _amountOfGeneric = count _genericMessages; { _lbCtrl lbAdd (_x select 0); - _lbCtrl lbSetColor [_foreachIndex + _amountOfGeneric, _x select 1]; -}foreach _allInjuryTexts; + _lbCtrl lbSetColor [_forEachIndex + _amountOfGeneric, _x select 1]; + nil +} count _allInjuryTexts; + if (count _allInjuryTexts == 0) then { - _lbCtrl lbAdd (localize ELSTRING(medical,NoInjuriesBodypart)); + _lbCtrl lbAdd localize ELSTRING(medical,NoInjuriesBodypart); }; diff --git a/addons/medical_menu/functions/fnc_updateUIInfo.sqf b/addons/medical_menu/functions/fnc_updateUIInfo.sqf index cf8e868827..d5c3b9eed6 100644 --- a/addons/medical_menu/functions/fnc_updateUIInfo.sqf +++ b/addons/medical_menu/functions/fnc_updateUIInfo.sqf @@ -7,16 +7,18 @@ * 1: display * * Return Value: - * NONE + * None + * + * Example: + * [some_player, some_display] call ace_medical_menu_updateUIInfo * * Public: No */ - #include "script_component.hpp" -private ["_targeT", "_display", "_genericMessages", "_totalIvVolume", "_damaged", "_selectionBloodLoss", "_allInjuryTexts"]; -_target = _this select 0; -_display = _this select 1; +private ["_genericMessages", "_totalIvVolume", "_damaged", "_selectionBloodLoss", "_allInjuryTexts"]; + +params ["_target", "_display"]; _selectionN = GVAR(selectedBodyPart); if (_selectionN < 0 || _selectionN > 5) exitwith {}; @@ -24,89 +26,91 @@ if (_selectionN < 0 || _selectionN > 5) exitwith {}; _genericMessages = []; if (EGVAR(medical,level) >= 2) then { _partText = [ELSTRING(medical,Head), ELSTRING(medical,Torso), ELSTRING(medical,LeftArm) ,ELSTRING(medical,RightArm) ,ELSTRING(medical,LeftLeg), ELSTRING(medical,RightLeg)] select _selectionN; - _genericMessages pushback [localize _partText, [1, 1, 1, 1]]; + _genericMessages pushBack [localize _partText, [1, 1, 1, 1]]; }; -if (_target getvariable[QGVAR(isBleeding), false]) then { - _genericMessages pushback [localize ELSTRING(medical,Status_Bleeding), [1, 0.1, 0.1, 1]]; -}; -if (_target getvariable[QGVAR(hasLostBlood), 0] > 1) then { - _genericMessages pushback [localize ELSTRING(medical,Status_Lost_Blood), [1, 0.1, 0.1, 1]]; +if (_target getVariable [QGVAR(isBleeding), false]) then { + _genericMessages pushBack [localize ELSTRING(medical,Status_Bleeding), [1, 0.1, 0.1, 1]]; }; -if (((_target getvariable [QGVAR(tourniquets), [0,0,0,0,0,0]]) select _selectionN) > 0) then { - _genericMessages pushback [localize ELSTRING(medical,Status_Tourniquet_Applied), [0.77, 0.51, 0.08, 1]]; +if (_target getVariable [QGVAR(hasLostBlood), 0] > 1) then { + _genericMessages pushBack [localize ELSTRING(medical,Status_Lost_Blood), [1, 0.1, 0.1, 1]]; }; -if (_target getvariable[QGVAR(hasPain), false]) then { - _genericMessages pushback [localize ELSTRING(medical,Status_Pain), [1, 1, 1, 1]]; + +if (((_target getVariable [QGVAR(tourniquets), [0, 0, 0, 0, 0, 0]]) select _selectionN) > 0) then { + _genericMessages pushBack [localize ELSTRING(medical,Status_Tourniquet_Applied), [0.77, 0.51, 0.08, 1]]; +}; + +if (_target getVariable [QGVAR(hasPain), false]) then { + _genericMessages pushBack [localize ELSTRING(medical,Status_Pain), [1, 1, 1, 1]]; }; _totalIvVolume = 0; { private "_value"; - _value = _target getvariable _x; - if !(isnil "_value") then { - _totalIvVolume = _totalIvVolume + (_target getvariable [_x, 0]); + _value = _target getVariable _x; + if (!isNil "_value") then { + _totalIvVolume = _totalIvVolume + (_target getVariable [_x, 0]); }; -}foreach GVAR(IVBags); +} count GVAR(IVBags); + if (_totalIvVolume >= 1) then { - _genericMessages pushback [format[localize ELSTRING(medical,receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]]; + _genericMessages pushBack [format [localize ELSTRING(medical,receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]]; }; _damaged = [false, false, false, false, false, false]; -_selectionBloodLoss = [0,0,0,0,0,0]; - +_selectionBloodLoss = [0, 0, 0, 0, 0, 0]; _allInjuryTexts = []; if (EGVAR(medical,level) >= 2) then { - _openWounds = _target getvariable [QEGVAR(medical,openWounds), []]; + _openWounds = _target getVariable [QEGVAR(medical,openWounds), []]; private "_amountOf"; { _amountOf = _x select 3; // Find how much this bodypart is bleeding if (_amountOf > 0) then { - _damaged set[_x select 2, true]; - _selectionBloodLoss set [(_x select 2), (_selectionBloodLoss select (_x select 2)) + (20 * ((_x select 4) * _amountOf))]; + _damaged set [_x select 2, true]; + _selectionBloodLoss set [_x select 2, (_selectionBloodLoss select (_x select 2)) + (20 * ((_x select 4) * _amountOf))]; if (_selectionN == (_x select 2)) then { // Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this] if (_amountOf >= 1) then { // TODO localization - _allInjuryTexts pushback [format["%2x %1", (EGVAR(medical,AllWoundInjuryTypes) select (_x select 1)) select 6, _amountOf], [1,1,1,1]]; + _allInjuryTexts pushBack [format["%2x %1", (EGVAR(medical,AllWoundInjuryTypes) select (_x select 1)) select 6, _amountOf], [1,1,1,1]]; } else { // TODO localization - _allInjuryTexts pushback [format["Partial %1", (EGVAR(medical,AllWoundInjuryTypes) select (_x select 1)) select 6], [1,1,1,1]]; + _allInjuryTexts pushBack [format["Partial %1", (EGVAR(medical,AllWoundInjuryTypes) select (_x select 1)) select 6], [1,1,1,1]]; }; }; }; - }foreach _openWounds; + } forEach _openWounds; - _bandagedwounds = _target getvariable [QEGVAR(medical,bandagedWounds), []]; + _bandagedwounds = _target getVariable [QEGVAR(medical,bandagedWounds), []]; { _amountOf = _x select 3; // Find how much this bodypart is bleeding if !(_damaged select (_x select 2)) then { - _selectionBloodLoss set [(_x select 2), (_selectionBloodLoss select (_x select 2)) + (20 * ((_x select 4) * _amountOf))]; + _selectionBloodLoss set [_x select 2, (_selectionBloodLoss select (_x select 2)) + (20 * ((_x select 4) * _amountOf))]; }; if (_selectionN == (_x select 2)) then { // Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this] if (_amountOf > 0) then { if (_amountOf >= 1) then { // TODO localization - _allInjuryTexts pushback [format["[B] %2x %1", (EGVAR(medical,AllWoundInjuryTypes) select (_x select 1)) select 6, _amountOf], [0.88,0.7,0.65,1]]; + _allInjuryTexts pushBack [format ["[B] %2x %1", (EGVAR(medical,AllWoundInjuryTypes) select (_x select 1)) select 6, _amountOf], [0.88,0.7,0.65,1]]; } else { // TODO localization - _allInjuryTexts pushback [format["[B] Partial %1", (EGVAR(medical,AllWoundInjuryTypes) select (_x select 1)) select 6], [0.88,0.7,0.65,1]]; + _allInjuryTexts pushBack [format ["[B] Partial %1", (EGVAR(medical,AllWoundInjuryTypes) select (_x select 1)) select 6], [0.88,0.7,0.65,1]]; }; }; }; - }foreach _bandagedwounds; + } forEach _bandagedwounds; } else { _damaged = [true, true, true, true, true, true]; { _selectionBloodLoss set [_forEachIndex, _target getHitPointDamage _x]; - if (_target getHitPointDamage _x > 0 && {_forEachIndex == _selectionN}) then { + if (_target getHitPointDamage _x > 0 && _forEachIndex == _selectionN) then { _pointDamage = _target getHitPointDamage _x; _severity = switch (true) do { case (_pointDamage > 0.5): {localize ELSTRING(medical,HeavilyWounded)}; @@ -129,7 +133,7 @@ if (EGVAR(medical,level) >= 2) then { [_selectionBloodLoss, _display] call FUNC(updateBodyImage); [_display, _genericMessages, _allInjuryTexts] call FUNC(updateInformationLists); -_logs = _target getvariable [QEGVAR(medical,logFile_Activity), []]; +_logs = _target getVariable [QEGVAR(medical,logFile_Activity), []]; [_display, _logs] call FUNC(updateActivityLog); _triageStatus = [_target] call EFUNC(medical,getTriageStatus);