ACE3/addons/medical_menu/functions/fnc_handleUI_DisplayOptions.sqf

93 lines
2.5 KiB
Plaintext
Raw Normal View History

/*
* Author: Glowbal
* Display the available treatment options in category
2015-08-02 14:56:27 +00:00
*
* Arguments:
* 0: Category name <STRING>
*
* Return Value:
2015-08-07 03:37:41 +00:00
* None
*
* Example:
* ["some category"] call ace_medical_menu_handleUI_DisplayOptions
*
* 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
if (!hasInterface) exitwith{};
2015-08-07 03:37:41 +00:00
private ["_entries", "_display", "_newTarget", "_card", "_ctrl", "_code"];
params ["_name"];
2015-08-02 14:56:27 +00:00
disableSerialization;
2015-08-07 03:37:41 +00:00
2015-08-02 14:56:27 +00:00
_display = uiNamespace getVariable QGVAR(medicalMenu);
if (isNil "_display") exitwith {}; // no valid dialog present
2015-08-07 03:37:41 +00:00
if (_name isEqualTo "toggle") exitwith {
2015-08-02 14:56:27 +00:00
if (GVAR(INTERACTION_TARGET) != ACE_player) then {
_newTarget = ACE_player;
} else {
_newTarget = GVAR(INTERACTION_TARGET_PREVIOUS);
};
GVAR(INTERACTION_TARGET_PREVIOUS) = GVAR(INTERACTION_TARGET);
[_newTarget] spawn {
closeDialog 0;
sleep 0.1;
[_this select 0] call FUNC(openMenu);
};
};
// 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 {
2015-08-02 14:56:27 +00:00
_ctrl = (_display displayCtrl (_x));
_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-08-07 03:37:41 +00:00
if (_name isEqualTo "triage") exitwith {
ctrlEnable [212, true];
_card = [GVAR(INTERACTION_TARGET)] call FUNC(getTriageList);
2015-08-02 14:56:27 +00:00
{
2015-08-07 03:37:41 +00:00
lbAdd [212, format["%1 x%2", getText(configFile >> "CfgWeapons" >> (_x select 0) >> "displayName"), _x select 1]];
} forEach _card;
2015-08-02 14:56:27 +00:00
if (count _card == 0) then {
2015-08-07 03:37:41 +00:00
lbAdd [212, "No Entries"];
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
_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-08-07 03:37:41 +00:00
if (_forEachIndex > END_IDC) exitwith {};
_ctrl = (_display displayCtrl (START_IDC + _forEachIndex));
if (!(_forEachIndex > AMOUNT_OF_ENTRIES)) then {
_ctrl ctrlSetText (_x select 0);
2015-08-07 03:37:41 +00:00
_code = format ["ace_medical_menu_pendingReopen = true; call %1;", (_x select 3)];
2015-08-02 14:56:27 +00:00
_ctrl ctrlSetEventHandler ["ButtonClick", _code];
_ctrl ctrlSetTooltip (_x select 0); // TODO implement
2015-08-02 14:56:27 +00:00
_ctrl ctrlShow true;
} else {
_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;