2015-08-06 21:51:17 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Display the available treatment options in category
|
2015-08-02 14:56:27 +00:00
|
|
|
*
|
2015-08-06 21:51:17 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Category name <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-07 03:37:41 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2015-10-13 07:01:59 +00:00
|
|
|
* ["some category"] call ace_medical_menu_fnc_handleUI_DisplayOptions
|
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
|
|
|
#define START_IDC 20
|
|
|
|
#define END_IDC 27
|
|
|
|
#define AMOUNT_OF_ENTRIES (count _entries)
|
2015-08-02 14:56:27 +00:00
|
|
|
|
2015-11-30 16:14:05 +00:00
|
|
|
if (!hasInterface) exitWith{};
|
2015-08-02 14:56:27 +00:00
|
|
|
|
2015-08-07 03:37:41 +00:00
|
|
|
params ["_name"];
|
|
|
|
|
2015-08-02 14:56:27 +00:00
|
|
|
disableSerialization;
|
2015-08-07 03:37:41 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _display = uiNamespace getVariable QGVAR(medicalMenu);
|
2015-11-30 16:14:05 +00:00
|
|
|
if (isNil "_display") exitWith {}; // no valid dialog present
|
2015-08-02 14:56:27 +00:00
|
|
|
|
2015-11-30 16:14:05 +00:00
|
|
|
if (_name isEqualTo "toggle") exitWith {
|
2017-10-10 14:39:59 +00:00
|
|
|
private _newTarget = ACE_player;
|
2015-10-13 07:01:59 +00:00
|
|
|
//If we are on the player, and only if our old target is still valid, switch to it:
|
|
|
|
if ((GVAR(INTERACTION_TARGET) == ACE_player) &&
|
2017-08-22 18:30:56 +00:00
|
|
|
{[ACE_player, GVAR(INTERACTION_TARGET_PREVIOUS), ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)} &&
|
2015-10-13 07:01:59 +00:00
|
|
|
{[ACE_player, GVAR(INTERACTION_TARGET_PREVIOUS)] call FUNC(canOpenMenu)}) then {
|
2015-08-02 14:56:27 +00:00
|
|
|
_newTarget = GVAR(INTERACTION_TARGET_PREVIOUS);
|
|
|
|
};
|
|
|
|
|
|
|
|
GVAR(INTERACTION_TARGET_PREVIOUS) = GVAR(INTERACTION_TARGET);
|
2015-08-22 20:33:15 +00:00
|
|
|
|
|
|
|
closeDialog 0;
|
|
|
|
[{
|
2015-08-02 14:56:27 +00:00
|
|
|
[_this select 0] call FUNC(openMenu);
|
2016-05-22 13:27:24 +00:00
|
|
|
}, [_newTarget], 0.1] call CBA_fnc_waitAndExecute;
|
2015-08-02 14:56:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Clean the dropdown options list from all actions
|
2015-08-07 03:37:41 +00:00
|
|
|
for [{_x = START_IDC}, {_x <= END_IDC}, {_x = _x + 1}] do {
|
2017-10-10 14:39:59 +00:00
|
|
|
private _ctrl = (_display displayCtrl (_x));
|
2015-08-02 14:56:27 +00:00
|
|
|
_ctrl ctrlSetText "";
|
|
|
|
_ctrl ctrlShow false;
|
|
|
|
_ctrl ctrlSetEventHandler ["ButtonClick",""];
|
|
|
|
_ctrl ctrlSetTooltip "";
|
|
|
|
_ctrl ctrlCommit 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
GVAR(LatestDisplayOptionMenu) = _name;
|
|
|
|
|
|
|
|
// The triage card has no options available
|
|
|
|
lbClear 212;
|
2015-11-30 16:14:05 +00:00
|
|
|
if (_name isEqualTo "triage") exitWith {
|
2015-08-08 16:29:30 +00:00
|
|
|
|
2015-08-07 03:37:41 +00:00
|
|
|
ctrlEnable [212, true];
|
2017-10-10 14:39:59 +00:00
|
|
|
private _log = GVAR(INTERACTION_TARGET) getVariable [QEGVAR(medical,triageCard), []];
|
|
|
|
private _triageCardTexts = [];
|
2015-08-02 14:56:27 +00:00
|
|
|
{
|
2015-08-08 16:29:30 +00:00
|
|
|
_x params ["_item", "_amount", "_time"];
|
2017-10-10 14:39:59 +00:00
|
|
|
private _message = _item;
|
2015-08-08 16:29:30 +00:00
|
|
|
if (isClass(configFile >> "CfgWeapons" >> _item)) then {
|
|
|
|
_message = getText(configFile >> "CfgWeapons" >> _item >> "DisplayName");
|
|
|
|
} else {
|
|
|
|
if (isLocalized _message) then {
|
|
|
|
_message = localize _message;
|
|
|
|
};
|
|
|
|
};
|
2016-03-02 10:01:39 +00:00
|
|
|
_triageCardTexts pushBack format["%1x - %2 (%3m)", _amount, _message, round((CBA_missionTime - _time) / 60)];
|
2015-08-08 16:29:30 +00:00
|
|
|
nil;
|
2015-08-22 20:33:15 +00:00
|
|
|
} count _log;
|
2015-08-08 16:29:30 +00:00
|
|
|
|
2015-11-30 16:14:05 +00:00
|
|
|
if (count _triageCardTexts == 0) exitWith {
|
2015-08-08 16:29:30 +00:00
|
|
|
lbAdd [212,(localize ELSTRING(medical,TriageCard_NoEntry))];
|
2015-08-02 14:56:27 +00:00
|
|
|
};
|
2015-08-08 16:29:30 +00:00
|
|
|
{
|
|
|
|
lbAdd [212,_x];
|
|
|
|
nil;
|
|
|
|
}count _triageCardTexts;
|
2015-08-02 14:56:27 +00:00
|
|
|
};
|
|
|
|
|
2015-08-07 03:37:41 +00:00
|
|
|
ctrlEnable [212, false];
|
2015-08-02 14:56:27 +00:00
|
|
|
|
2015-08-06 21:51:17 +00:00
|
|
|
_entries = [ACE_player, GVAR(INTERACTION_TARGET), _name] call FUNC(getTreatmentOptions);
|
2015-08-02 14:56:27 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
//player sidechat format["TRIGGERED: %1",_x];
|
2015-11-30 16:14:05 +00:00
|
|
|
if (_forEachIndex > END_IDC) exitWith {};
|
2015-08-07 03:37:41 +00:00
|
|
|
_ctrl = (_display displayCtrl (START_IDC + _forEachIndex));
|
|
|
|
if (!(_forEachIndex > AMOUNT_OF_ENTRIES)) then {
|
2015-08-06 21:51:17 +00:00
|
|
|
_ctrl ctrlSetText (_x select 0);
|
2017-10-10 14:39:59 +00:00
|
|
|
private _code = format ["ace_medical_menu_pendingReopen = true; call %1;", (_x select 3)];
|
2015-08-02 14:56:27 +00:00
|
|
|
_ctrl ctrlSetEventHandler ["ButtonClick", _code];
|
2015-08-06 21:51:17 +00:00
|
|
|
_ctrl ctrlSetTooltip (_x select 0); // TODO implement
|
2015-08-02 14:56:27 +00:00
|
|
|
_ctrl ctrlShow true;
|
|
|
|
} else {
|
2015-08-06 21:51:17 +00:00
|
|
|
_ctrl ctrlSetText "";
|
2015-08-07 03:37:41 +00:00
|
|
|
_ctrl ctrlSetEventHandler ["ButtonClick", ""];
|
2015-08-02 14:56:27 +00:00
|
|
|
};
|
|
|
|
_ctrl ctrlCommit 0;
|
2015-08-07 03:37:41 +00:00
|
|
|
} forEach _entries;
|