2015-08-06 21:51:17 +00:00
/*
* Author: Glowbal
* Update all UI information in the medical menu
2015-08-02 14:56:27 +00:00
*
2015-08-06 21:51:17 +00:00
* Arguments:
* 0: target <OBJECT>
* 1: display <DISPLAY>
*
* Return Value:
2015-08-07 03:37:41 +00:00
* None
*
* Example:
2015-10-13 07:01:59 +00:00
* [some_player, some_display] call ace_medical_menu_fnc_updateUIInfo
2015-08-06 21:51:17 +00:00
*
* Public: No
2015-08-02 14:56:27 +00:00
*/
#include "script_component.hpp"
2015-08-07 03:37:41 +00:00
params ["_target", "_display"];
2015-08-02 14:56:27 +00:00
2015-10-13 18:40:16 +00:00
if (isNil "_display" || {isNull _display}) exitWith {ERROR("No display");};
2015-10-13 07:01:59 +00:00
2017-10-10 14:39:59 +00:00
private _selectionN = GVAR(selectedBodyPart);
2015-11-30 16:14:05 +00:00
if (_selectionN < 0 || {_selectionN > 5}) exitWith {};
2015-08-02 14:56:27 +00:00
2017-10-10 14:39:59 +00:00
private _genericMessages = [];
private _partText = [ELSTRING(medical,Head), ELSTRING(medical,Torso), ELSTRING(medical,LeftArm) ,ELSTRING(medical,RightArm) ,ELSTRING(medical,LeftLeg), ELSTRING(medical,RightLeg)] select _selectionN;
2015-08-09 18:08:45 +00:00
_genericMessages pushBack [localize _partText, [1, 1, 1, 1]];
2015-08-02 14:56:27 +00:00
2015-08-09 18:07:06 +00:00
if (_target getVariable [QEGVAR(medical,isBleeding), false]) then {
2015-08-07 03:37:41 +00:00
_genericMessages pushBack [localize ELSTRING(medical,Status_Bleeding), [1, 0.1, 0.1, 1]];
2015-08-02 14:56:27 +00:00
};
2015-08-07 03:37:41 +00:00
2015-08-09 18:07:06 +00:00
if (_target getVariable [QEGVAR(medical,hasLostBlood), 0] > 1) then {
2015-08-07 03:37:41 +00:00
_genericMessages pushBack [localize ELSTRING(medical,Status_Lost_Blood), [1, 0.1, 0.1, 1]];
2015-08-02 14:56:27 +00:00
};
2015-08-09 18:07:06 +00:00
if (((_target getVariable [QEGVAR(medical,tourniquets), [0, 0, 0, 0, 0, 0]]) select _selectionN) > 0) then {
2015-08-07 03:37:41 +00:00
_genericMessages pushBack [localize ELSTRING(medical,Status_Tourniquet_Applied), [0.77, 0.51, 0.08, 1]];
2015-08-02 14:56:27 +00:00
};
2015-08-07 03:37:41 +00:00
2015-08-09 18:07:06 +00:00
if (_target getVariable [QEGVAR(medical,hasPain), false]) then {
2015-08-07 03:37:41 +00:00
_genericMessages pushBack [localize ELSTRING(medical,Status_Pain), [1, 1, 1, 1]];
2015-08-02 14:56:27 +00:00
};
2017-10-10 14:39:59 +00:00
private _totalIvVolume = 0;
2016-09-06 19:52:22 +00:00
private _bloodBags = _target getVariable [QEGVAR(medical,ivBags), []];
2015-08-02 14:56:27 +00:00
{
2016-09-06 19:52:22 +00:00
_x params ["_bagVolumeRemaining"];
_totalIvVolume = _totalIvVolume + _bagVolumeRemaining;
} foreach _bloodBags;
2015-08-07 03:37:41 +00:00
2015-08-06 21:51:17 +00:00
if (_totalIvVolume >= 1) then {
2015-08-07 03:37:41 +00:00
_genericMessages pushBack [format [localize ELSTRING(medical,receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]];
2015-08-06 21:51:17 +00:00
};
2015-08-02 14:56:27 +00:00
2017-10-10 14:39:59 +00:00
private _damaged = [false, false, false, false, false, false];
private _selectionBloodLoss = [0, 0, 0, 0, 0, 0];
2015-08-06 21:51:17 +00:00
2017-10-10 14:39:59 +00:00
private _allInjuryTexts = [];
2015-11-06 07:05:25 +00:00
if ((EGVAR(medical,level) >= 2) && {([_target] call EFUNC(medical,hasMedicalEnabled))}) then {
2017-10-10 14:39:59 +00:00
private _openWounds = _target getVariable [QEGVAR(medical,openWounds), []];
2015-08-06 21:51:17 +00:00
{
2017-10-10 14:39:59 +00:00
private _amountOf = _x select 3;
2015-08-06 21:51:17 +00:00
// Find how much this bodypart is bleeding
if (_amountOf > 0) then {
2015-08-07 03:37:41 +00:00
_damaged set [_x select 2, true];
_selectionBloodLoss set [_x select 2, (_selectionBloodLoss select (_x select 2)) + (20 * ((_x select 4) * _amountOf))];
2015-08-06 21:51:17 +00:00
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
2015-12-06 01:57:21 +00:00
_allInjuryTexts pushBack [format["%2x %1", (EGVAR(medical,AllWoundInjuryTypes) select (_x select 1)) select 6, ceil _amountOf], [1,1,1,1]];
2015-08-06 21:51:17 +00:00
} else {
// TODO localization
2015-08-07 03:37:41 +00:00
_allInjuryTexts pushBack [format["Partial %1", (EGVAR(medical,AllWoundInjuryTypes) select (_x select 1)) select 6], [1,1,1,1]];
2015-08-06 21:51:17 +00:00
};
};
2015-08-02 14:56:27 +00:00
};
2015-08-07 03:37:41 +00:00
} forEach _openWounds;
2015-08-06 21:51:17 +00:00
2017-10-10 14:39:59 +00:00
private _bandagedwounds = _target getVariable [QEGVAR(medical,bandagedWounds), []];
2015-08-06 21:51:17 +00:00
{
2017-10-10 14:39:59 +00:00
private _amountOf = _x select 3;
2015-08-06 21:51:17 +00:00
// Find how much this bodypart is bleeding
if !(_damaged select (_x select 2)) then {
2015-08-07 03:37:41 +00:00
_selectionBloodLoss set [_x select 2, (_selectionBloodLoss select (_x select 2)) + (20 * ((_x select 4) * _amountOf))];
2015-08-06 21:51:17 +00:00
};
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
2015-12-06 01:57:21 +00:00
_allInjuryTexts pushBack [format ["[B] %2x %1", (EGVAR(medical,AllWoundInjuryTypes) select (_x select 1)) select 6, ceil _amountOf], [0.88,0.7,0.65,1]];
2015-08-06 21:51:17 +00:00
} else {
// TODO localization
2015-08-07 03:37:41 +00:00
_allInjuryTexts pushBack [format ["[B] Partial %1", (EGVAR(medical,AllWoundInjuryTypes) select (_x select 1)) select 6], [0.88,0.7,0.65,1]];
2015-08-06 21:51:17 +00:00
};
2015-08-02 14:56:27 +00:00
};
};
2015-08-07 03:37:41 +00:00
} forEach _bandagedwounds;
2015-08-06 21:51:17 +00:00
} else {
2015-09-05 09:57:17 +00:00
2016-06-13 10:19:19 +00:00
// Add all bleeding from wounds on selection
2017-10-10 14:39:59 +00:00
private _openWounds = _target getVariable [QEGVAR(medical,openWounds), []];
2015-08-06 21:51:17 +00:00
{
2017-10-10 14:39:59 +00:00
private _amountOf = _x select 3;
2016-06-13 10:19:19 +00:00
// 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))];
};
} forEach _openWounds;
2017-10-10 14:39:59 +00:00
private _bandagedwounds = _target getVariable [QEGVAR(medical,bandagedWounds), []];
2016-06-13 10:19:19 +00:00
{
2017-10-10 14:39:59 +00:00
private _amountOf = _x select 3;
2016-06-13 10:19:19 +00:00
// 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))];
2015-08-06 21:51:17 +00:00
};
2016-06-13 10:19:19 +00:00
} forEach _bandagedwounds;
private _bloodLossOnSelection = _selectionBloodLoss select _selectionN;
if (_bloodLossOnSelection > 0) then {
private _severity = switch (true) do {
case (_bloodLossOnSelection > 0.5): {localize ELSTRING(medical,HeavilyWounded)};
case (_bloodLossOnSelection > 0.1): {localize ELSTRING(medical,LightlyWounded)};
default {localize ELSTRING(medical,VeryLightlyWounded)};
};
private _part = localize ([
ELSTRING(medical,Head),
ELSTRING(medical,Torso),
ELSTRING(medical,LeftArm),
ELSTRING(medical,RightArm),
ELSTRING(medical,LeftLeg),
ELSTRING(medical,RightLeg)
] select _selectionN);
_allInjuryTexts pushBack [format ["%1 %2", _severity, toLower _part], [1,1,1,1]];
};
2015-08-06 21:51:17 +00:00
};
2015-08-02 14:56:27 +00:00
2015-10-13 07:01:59 +00:00
[_selectionBloodLoss, _damaged, _display] call FUNC(updateBodyImage);
2015-08-06 21:51:17 +00:00
[_display, _genericMessages, _allInjuryTexts] call FUNC(updateInformationLists);
2015-08-02 14:56:27 +00:00
2016-06-13 10:19:19 +00:00
[_display, _target getVariable [QEGVAR(medical,logFile_activity_view), []]] call FUNC(updateActivityLog);
[_display, _target getVariable [QEGVAR(medical,logFile_quick_view), []]] call FUNC(updateQuickViewLog);
2015-08-07 17:11:27 +00:00
2016-06-13 10:19:19 +00:00
private _triageStatus = [_target] call EFUNC(medical,getTriageStatus);
2015-08-06 21:51:17 +00:00
(_display displayCtrl 2000) ctrlSetText (_triageStatus select 0);
(_display displayCtrl 2000) ctrlSetBackgroundColor (_triageStatus select 2);