2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2019-03-24 22:17:48 +00:00
|
|
|
/*
|
|
|
|
* Author: mharis001
|
|
|
|
* Updates the action buttons based currently avaiable treatments.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Medical Menu display <DISPLAY>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [_display] call ace_medical_gui_fnc_updateActions
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_display"];
|
|
|
|
|
|
|
|
private _selectedCategory = GVAR(selectedCategory);
|
|
|
|
|
2023-08-25 15:32:39 +00:00
|
|
|
private _group = _display displayCtrl IDC_ACTION_BUTTON_GROUP;
|
|
|
|
private _actionButons = allControls _group;
|
2019-03-24 22:17:48 +00:00
|
|
|
|
|
|
|
// Handle triage list (no actions shown)
|
|
|
|
private _ctrlTriage = _display displayCtrl IDC_TRIAGE_CARD;
|
|
|
|
private _showTriage = _selectedCategory == "triage";
|
|
|
|
_ctrlTriage ctrlEnable _showTriage;
|
2023-08-25 15:32:39 +00:00
|
|
|
_group ctrlEnable !_showTriage;
|
2019-03-24 22:17:48 +00:00
|
|
|
|
|
|
|
lbClear _ctrlTriage;
|
|
|
|
|
|
|
|
if (_showTriage) exitWith {
|
2023-08-25 15:32:39 +00:00
|
|
|
{ ctrlDelete _x } forEach _actionButons;
|
2019-03-24 22:17:48 +00:00
|
|
|
[_ctrlTriage, GVAR(target)] call FUNC(updateTriageCard);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Show treatment options on action buttons
|
2023-08-25 15:32:39 +00:00
|
|
|
private _shownIndex = 0;
|
2019-03-24 22:17:48 +00:00
|
|
|
{
|
2023-10-13 02:39:23 +00:00
|
|
|
_x params ["_displayName", "_category", "_condition", "_statement", "_items"];
|
2019-03-24 22:17:48 +00:00
|
|
|
|
|
|
|
// Check action category and condition
|
|
|
|
if (_category == _selectedCategory && {call _condition}) then {
|
2023-08-25 15:32:39 +00:00
|
|
|
private _ctrl = if (_shownIndex >= count _actionButons) then {
|
|
|
|
_actionButons pushBack (_display ctrlCreate ["ACE_Medical_Menu_ActionButton", -1, _group]);
|
|
|
|
};
|
|
|
|
_ctrl = _actionButons # _shownIndex;
|
|
|
|
_ctrl ctrlRemoveAllEventHandlers "ButtonClick";
|
|
|
|
_ctrl ctrlSetPositionY POS_H(1.1 * _shownIndex);
|
|
|
|
_ctrl ctrlCommit 0;
|
|
|
|
|
2023-10-13 02:39:23 +00:00
|
|
|
private _countText = "";
|
|
|
|
if (_items isNotEqualTo []) then {
|
|
|
|
if ("ACE_surgicalKit" in _items && {EGVAR(medical_treatment,consumeSurgicalKit) == 2}) then {
|
|
|
|
_items = ["ACE_suture"];
|
|
|
|
};
|
|
|
|
private _counts = [_items] call FUNC(countTreatmentItems);
|
|
|
|
_countText = _counts call FUNC(formatItemCounts);
|
|
|
|
};
|
|
|
|
_ctrl ctrlSetTooltip _countText;
|
|
|
|
|
2019-03-24 22:17:48 +00:00
|
|
|
_ctrl ctrlSetText _displayName;
|
|
|
|
_ctrl ctrlShow true;
|
|
|
|
|
|
|
|
_ctrl ctrlAddEventHandler ["ButtonClick", _statement];
|
|
|
|
_ctrl ctrlAddEventHandler ["ButtonClick", {GVAR(pendingReopen) = true}];
|
|
|
|
|
2023-08-25 15:32:39 +00:00
|
|
|
_shownIndex = _shownIndex + 1;
|
2019-03-24 22:17:48 +00:00
|
|
|
};
|
|
|
|
} forEach GVAR(actions);
|
2023-08-25 15:32:39 +00:00
|
|
|
|
|
|
|
{ ctrlDelete _x } forEach (_actionButons select [_shownIndex, 9999]);
|