ACE3/addons/medical/functions/fnc_displayTriageCard.sqf

80 lines
2.3 KiB
Plaintext
Raw Normal View History

2015-03-10 20:12:35 +00:00
/*
* Author: Glowbal
* Display triage card for a unit
*
* Arguments:
* 0: The unit <OBJECT>
2015-08-22 14:25:10 +00:00
* 1: Show <BOOL> (default: true)
2015-03-10 20:12:35 +00:00
*
* Return Value:
2015-08-22 14:25:10 +00:00
* None
2015-03-10 20:12:35 +00:00
*
* Public: Yes
*/
#include "script_component.hpp"
2015-08-22 14:25:10 +00:00
private ["_amount", "_item", "_log", "_message", "_triageCardTexts", "_triageStatus"];
params ["_target", ["_show", true]];
2015-03-10 20:12:35 +00:00
GVAR(TriageCardTarget) = if (_show) then {_target} else {ObjNull};
if (_show) then {
//("ACE_MedicalTriageCard" call BIS_fnc_rscLayer) cutRsc [QGVAR(triageCard),"PLAIN"];
createDialog QGVAR(triageCard);
[{
2015-04-30 06:17:26 +00:00
private ["_target", "_display", "_alphaLevel", "_alphaLevel", "_lbCtrl"];
2015-08-22 14:25:10 +00:00
params ["_args", "_idPFH"];
_args params ["_target"];
2015-11-30 16:14:05 +00:00
if (GVAR(TriageCardTarget) != _target) exitWith {
2015-08-22 14:25:10 +00:00
[_idPFH] call CBA_fnc_removePerFrameHandler;
2015-03-10 20:12:35 +00:00
};
disableSerialization;
_display = uiNamespace getVariable QGVAR(triageCard);
2015-11-30 16:22:16 +00:00
if (isNil "_display") exitWith {
2015-08-22 14:25:10 +00:00
[_idPFH] call CBA_fnc_removePerFrameHandler;
2015-03-10 20:12:35 +00:00
};
_triageCardTexts = [];
// TODO fill the lb with the appropiate information for the patient
_lbCtrl = (_display displayCtrl 200);
lbClear _lbCtrl;
_log = _target getVariable [QGVAR(triageCard), []];
2015-03-10 20:12:35 +00:00
{
2015-08-22 14:25:10 +00:00
_x params ["_item", "_amount"];
2015-04-05 20:07:38 +00:00
_message = _item;
if (isClass(configFile >> "CfgWeapons" >> _item)) then {
_message = getText(configFile >> "CfgWeapons" >> _item >> "DisplayName");
} else {
if (isLocalized _message) then {
_message = localize _message;
2015-03-10 20:12:35 +00:00
};
2015-04-05 20:07:38 +00:00
};
2015-11-30 16:21:28 +00:00
_triageCardTexts pushBack format["%1x - %2", _amount, _message];
2015-11-30 16:23:48 +00:00
} forEach _log;
2015-03-10 20:12:35 +00:00
if (count _triageCardTexts == 0) then {
2015-05-28 19:59:04 +00:00
_lbCtrl lbAdd (localize LSTRING(TriageCard_NoEntry));
2015-03-10 20:12:35 +00:00
};
2015-04-05 20:07:38 +00:00
{
_lbCtrl lbAdd _x;
2015-11-30 16:23:48 +00:00
} forEach _triageCardTexts;
2015-03-10 20:12:35 +00:00
_triageStatus = [_target] call FUNC(getTriageStatus);
2015-08-22 14:25:10 +00:00
2015-09-03 16:30:29 +00:00
_triageStatus params ["_text", "", "_color"];
2015-08-22 14:25:10 +00:00
(_display displayCtrl 2000) ctrlSetText _text;
(_display displayCtrl 2000) ctrlSetBackgroundColor _color;
2015-03-10 20:12:35 +00:00
}, 0, [_target]] call CBA_fnc_addPerFrameHandler;
} else {
//("ACE_MedicalTriageCard" call BIS_fnc_rscLayer) cutText ["","PLAIN"];
closeDialog 7010;
};