-
Notifications
You must be signed in to change notification settings - Fork 737
/
Copy pathfnc_updateActions.sqf
84 lines (70 loc) · 2.71 KB
/
fnc_updateActions.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "..\script_component.hpp"
/*
* 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);
private _group = _display displayCtrl IDC_ACTION_BUTTON_GROUP;
private _actionButons = allControls _group;
// Handle triage list (no actions shown)
private _ctrlTriage = _display displayCtrl IDC_TRIAGE_CARD;
private _showTriage = _selectedCategory == "triage";
_ctrlTriage ctrlEnable _showTriage;
_group ctrlEnable !_showTriage;
lbClear _ctrlTriage;
if (_showTriage) exitWith {
{ ctrlDelete _x } forEach _actionButons;
[_ctrlTriage, GVAR(target)] call FUNC(updateTriageCard);
};
// Show treatment options on action buttons
private _shownIndex = 0;
{
_x params ["_displayName", "_category", "_condition", "_statement", "_items"];
// Check action category and condition
if (_category == _selectedCategory && {call _condition}) then {
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;
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 ctrlSetTooltipColorText [1, 1, 1, 1];
_ctrl ctrlSetTooltip _countText;
// Show warning if tourniquet will interfere with action
if (
GVAR(tourniquetWarning) &&
{(_category in ["examine", "medication"]) || (_items findIf {"IV" in _x}) > -1} &&
{HAS_TOURNIQUET_APPLIED_ON(GVAR(target),GVAR(selectedBodyPart))}
) then {
_ctrl ctrlSetTooltipColorText [1, 1, 0, 1];
_ctrl ctrlSetTooltip LLSTRING(TourniquetWarning);
};
_ctrl ctrlSetText _displayName;
_ctrl ctrlShow true;
_ctrl ctrlAddEventHandler ["ButtonClick", _statement];
_ctrl ctrlAddEventHandler ["ButtonClick", {GVAR(pendingReopen) = true}];
_shownIndex = _shownIndex + 1;
};
} forEach GVAR(actions);
{ ctrlDelete _x } forEach (_actionButons select [_shownIndex, 9999]);