2015-03-01 15:04:53 +00:00
/*
* Author: Glowbal
* Displays the patient information for given unit.
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: Show <BOOL> <OPTIONAL>
*
* ReturnValue:
* nil
*
* Public: No
*/
#include "script_component.hpp"
private ["_target", "_show"];
_target = _this select 0;
_show = if (count _this > 1) then {_this select 1} else {true};
2015-03-03 22:34:44 +00:00
GVAR(currentSelectedSelectionN) = if (count _this > 2) then {_this select 2} else {0};
2015-03-01 15:04:53 +00:00
GVAR(displayPatientInformationTarget) = if (_show) then {_target} else {ObjNull};
if (_show) then {
("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutRsc [QGVAR(DisplayInformation),"PLAIN"];
[{
2015-03-05 17:43:44 +00:00
private ["_target", "_display", "_alphaLevel", "_damaged", "_availableSelections", "_openWounds", "_selectionBloodLoss", "_red", "_green", "_blue", "_alphaLevel", "_allInjuryTexts", "_lbCtrl", "_genericMessages"];
2015-03-01 15:04:53 +00:00
_target = (_this select 0) select 0;
if (GVAR(displayPatientInformationTarget) != _target) exitwith {
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
disableSerialization;
_display = uiNamespace getvariable QGVAR(DisplayInformation);
if (isnil "_display") exitwith {
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
2015-03-03 22:34:44 +00:00
_allInjuryTexts = [];
2015-03-05 17:43:44 +00:00
_genericMessages = [];
if (_target getvariable[QGVAR(isBleeding), false]) then {
_genericMessages pushback [localize "STR_ACE_MEDICAL_STATUS_BLEEDING", [1, 1, 1, 1]];
};
if (_target getvariable[QGVAR(hasLostBlood), false]) then {
_genericMessages pushback [localize "STR_ACE_MEDICAL_STATUS_LOST_BLOOD", [1, 0.1, 0.1, 1]];
};
if (((_target getvariable [QGVAR(tourniquets), [0,0,0,0,0,0]]) select GVAR(currentSelectedSelectionN)) > 0) then {
_genericMessages pushback [localize "STR_ACE_MEDICAL_STATUS_TOURNIQUET_APPLIED", [0.5, 0.5, 0, 1]];
};
2015-03-03 22:34:44 +00:00
2015-03-01 15:04:53 +00:00
_selectionBloodLoss = [0,0,0,0,0,0];
2015-03-06 21:54:44 +00:00
if (GVAR(level) >= 2) then {
2015-03-05 17:43:44 +00:00
_openWounds = _target getvariable [QGVAR(openWounds), []];
private "_amountOf";
{
_amountOf = _x select 3;
// Find how much this bodypart is bleeding
_selectionBloodLoss set [(_x select 2), (_selectionBloodLoss select (_x select 2)) + (15 * ((_x select 4) * _amountOf))];
if (GVAR(currentSelectedSelectionN) == (_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 {
2015-03-05 17:53:38 +00:00
// TODO localization
2015-03-05 17:43:44 +00:00
_allInjuryTexts pushback format["%2x %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6, _amountOf];
} else {
// TODO localization
_allInjuryTexts pushback format["Partial %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6];
};
};
2015-03-03 22:34:44 +00:00
};
2015-03-05 17:43:44 +00:00
}foreach _openWounds;
} else {
// TODO handle basic medical colors for body part selections here
};
2015-03-01 15:04:53 +00:00
2015-03-05 17:43:44 +00:00
// Handle the body image coloring
_damaged = [false, false, false, false, false, false];
_availableSelections = [50,51,52,53,54,55];
2015-03-01 15:04:53 +00:00
{
private ["_red", "_green", "_blue"];
_total = _x;
_red = 1;
_green = 1;
_blue = 1;
if (_total >0) then {
2015-03-05 17:43:44 +00:00
_green = 0.9 - _total;
2015-03-01 15:04:53 +00:00
if (_green < 0.0) then {
_green = 0.0;
};
_blue = _green;
_damaged set[_foreachIndex, true];
};
2015-03-05 17:43:44 +00:00
(_display displayCtrl (_availableSelections select _foreachIndex)) ctrlSetTextColor [_red, _green, _blue, 1.0];
2015-03-01 15:04:53 +00:00
}foreach _selectionBloodLoss;
// TODO fill the lb with the appropiate information for the patient
2015-03-03 22:34:44 +00:00
_lbCtrl = (_display displayCtrl 200);
lbClear _lbCtrl;
2015-03-05 17:43:44 +00:00
{
_lbCtrl lbAdd (_x select 0);
_lbCtrl lbSetColor [_foreachIndex, _x select 1];
}foreach _genericMessages;
2015-03-03 22:34:44 +00:00
{
_lbCtrl lbAdd _x;
}foreach _allInjuryTexts;
2015-03-05 17:43:44 +00:00
if (count _genericMessages == 0 && {count _allInjuryTexts == 0}) then {
2015-03-03 22:34:44 +00:00
_lbCtrl lbAdd "No injuries on this bodypart..";
};
2015-03-01 15:04:53 +00:00
2015-03-05 17:53:38 +00:00
_logCtrl = (_display displayCtrl 302);
lbClear _logCtrl;
private ["_logs", "_log", "_message", "_moment", "_arguments", "_lbCtrl"];
_logs = _unit getvariable [QGVAR(allLogs), []];
{
_log = _unit getvariable [_x, []];
{
// [_message,_moment,_type, _arguments]
_message = _x select 0;
_moment = _x select 1;
_arguments = _x select 3;
if (isLocalized _message) then {
_message = localize _message;
};
{
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 _log;
}foreach _logs;
2015-03-05 19:55:38 +00:00
_triageStatus = [_target] call FUNC(getTriageStatus);
(_display displayCtrl 303) ctrlSetText (_triageStatus select 0);
(_display displayCtrl 303) ctrlSetBackgroundColor (_triageStatus select 2);
2015-03-01 15:04:53 +00:00
}, 0, [_target]] call CBA_fnc_addPerFrameHandler;
} else {
2015-03-05 17:43:44 +00:00
("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutText ["","PLAIN"];
2015-03-01 15:04:53 +00:00
};