mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Medical GUI - Dynamically create any number of action buttons (#9332)
* Medical Gui - Dynamically create any number of action buttons * Fix right alignment, add h-spacing, fix 2.14 select
This commit is contained in:
@ -48,3 +48,8 @@ if ("ace_dragging" call EFUNC(common,isModLoaded)) then {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// testing code for multi-line
|
||||||
|
// for "_i" from 0 to 12 do {
|
||||||
|
// GVAR(actions) pushBack [format ["Example %1", _i], "medication", {true}, compile format ['systemChat "%1"', _i]]
|
||||||
|
// };
|
||||||
|
@ -19,39 +19,45 @@ params ["_display"];
|
|||||||
|
|
||||||
private _selectedCategory = GVAR(selectedCategory);
|
private _selectedCategory = GVAR(selectedCategory);
|
||||||
|
|
||||||
// Clear all action buttons
|
private _group = _display displayCtrl IDC_ACTION_BUTTON_GROUP;
|
||||||
{
|
private _actionButons = allControls _group;
|
||||||
private _ctrl = _display displayCtrl _x;
|
|
||||||
_ctrl ctrlRemoveAllEventHandlers "ButtonClick";
|
|
||||||
_ctrl ctrlShow false;
|
|
||||||
} forEach IDCS_ACTION_BUTTONS;
|
|
||||||
|
|
||||||
// Handle triage list (no actions shown)
|
// Handle triage list (no actions shown)
|
||||||
private _ctrlTriage = _display displayCtrl IDC_TRIAGE_CARD;
|
private _ctrlTriage = _display displayCtrl IDC_TRIAGE_CARD;
|
||||||
private _showTriage = _selectedCategory == "triage";
|
private _showTriage = _selectedCategory == "triage";
|
||||||
_ctrlTriage ctrlEnable _showTriage;
|
_ctrlTriage ctrlEnable _showTriage;
|
||||||
|
_group ctrlEnable !_showTriage;
|
||||||
|
|
||||||
lbClear _ctrlTriage;
|
lbClear _ctrlTriage;
|
||||||
|
|
||||||
if (_showTriage) exitWith {
|
if (_showTriage) exitWith {
|
||||||
|
{ ctrlDelete _x } forEach _actionButons;
|
||||||
[_ctrlTriage, GVAR(target)] call FUNC(updateTriageCard);
|
[_ctrlTriage, GVAR(target)] call FUNC(updateTriageCard);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Show treatment options on action buttons
|
// Show treatment options on action buttons
|
||||||
private _idcIndex = 0;
|
private _shownIndex = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
_x params ["_displayName", "_category", "_condition", "_statement"];
|
_x params ["_displayName", "_category", "_condition", "_statement"];
|
||||||
|
|
||||||
// Check action category and condition
|
// Check action category and condition
|
||||||
if (_category == _selectedCategory && {call _condition}) then {
|
if (_category == _selectedCategory && {call _condition}) then {
|
||||||
private _ctrl = _display displayCtrl (IDCS_ACTION_BUTTONS select _idcIndex);
|
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;
|
||||||
|
|
||||||
_ctrl ctrlSetText _displayName;
|
_ctrl ctrlSetText _displayName;
|
||||||
_ctrl ctrlShow true;
|
_ctrl ctrlShow true;
|
||||||
|
|
||||||
_ctrl ctrlAddEventHandler ["ButtonClick", _statement];
|
_ctrl ctrlAddEventHandler ["ButtonClick", _statement];
|
||||||
_ctrl ctrlAddEventHandler ["ButtonClick", {GVAR(pendingReopen) = true}];
|
_ctrl ctrlAddEventHandler ["ButtonClick", {GVAR(pendingReopen) = true}];
|
||||||
|
|
||||||
_idcIndex = _idcIndex + 1;
|
_shownIndex = _shownIndex + 1;
|
||||||
};
|
};
|
||||||
} forEach GVAR(actions);
|
} forEach GVAR(actions);
|
||||||
|
|
||||||
|
{ ctrlDelete _x } forEach (_actionButons select [_shownIndex, 9999]);
|
||||||
|
@ -4,6 +4,7 @@ class RscPicture;
|
|||||||
class RscListBox;
|
class RscListBox;
|
||||||
class RscActivePicture;
|
class RscActivePicture;
|
||||||
class RscButtonMenu;
|
class RscButtonMenu;
|
||||||
|
class RscControlsGroup;
|
||||||
class RscControlsGroupNoScrollbars;
|
class RscControlsGroupNoScrollbars;
|
||||||
|
|
||||||
class GVAR(BodyImage): RscControlsGroupNoScrollbars {
|
class GVAR(BodyImage): RscControlsGroupNoScrollbars {
|
||||||
@ -157,6 +158,22 @@ class GVAR(TriageSelect): RscControlsGroupNoScrollbars {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ACE_Medical_Menu_ActionButton: RscButtonMenu {
|
||||||
|
idc = -1;
|
||||||
|
style = ST_LEFT;
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
w = QUOTE(POS_W(11.833));
|
||||||
|
h = QUOTE(POS_H(1));
|
||||||
|
size = QUOTE(POS_H(0.9));
|
||||||
|
class Attributes {
|
||||||
|
align = "center";
|
||||||
|
color = "#E5E5E5";
|
||||||
|
font = "RobotoCondensed";
|
||||||
|
shadow = "false";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
class ACE_Medical_Menu {
|
class ACE_Medical_Menu {
|
||||||
idd = IDD_MEDICAL_MENU;
|
idd = IDD_MEDICAL_MENU;
|
||||||
movingEnable = 1;
|
movingEnable = 1;
|
||||||
@ -283,7 +300,7 @@ class ACE_Medical_Menu {
|
|||||||
idc = IDC_TRIAGE_CARD;
|
idc = IDC_TRIAGE_CARD;
|
||||||
x = QUOTE(POS_X(1.5));
|
x = QUOTE(POS_X(1.5));
|
||||||
y = QUOTE(POS_Y(4.4));
|
y = QUOTE(POS_Y(4.4));
|
||||||
w = QUOTE(POS_W(12));
|
w = QUOTE(POS_W(11.833));
|
||||||
h = QUOTE(POS_H(10));
|
h = QUOTE(POS_H(10));
|
||||||
sizeEx = QUOTE(POS_H(0.7));
|
sizeEx = QUOTE(POS_H(0.7));
|
||||||
colorSelect[] = {1, 1, 1, 1};
|
colorSelect[] = {1, 1, 1, 1};
|
||||||
@ -293,52 +310,12 @@ class ACE_Medical_Menu {
|
|||||||
colorSelectBackground2[] = {0, 0, 0, 0};
|
colorSelectBackground2[] = {0, 0, 0, 0};
|
||||||
colorScrollbar[] = {0.9, 0.9, 0.9, 1};
|
colorScrollbar[] = {0.9, 0.9, 0.9, 1};
|
||||||
};
|
};
|
||||||
class Action1: RscButtonMenu {
|
class ActionButtonGroup: RscControlsGroup {
|
||||||
idc = IDC_ACTION_1;
|
idc = IDC_ACTION_BUTTON_GROUP;
|
||||||
style = ST_LEFT;
|
|
||||||
x = QUOTE(POS_X(1.5));
|
x = QUOTE(POS_X(1.5));
|
||||||
y = QUOTE(POS_Y(4.4));
|
y = QUOTE(POS_Y(4.4));
|
||||||
w = QUOTE(POS_W(12));
|
w = QUOTE(POS_W(11.833));
|
||||||
h = QUOTE(POS_H(1));
|
h = QUOTE(POS_H(10));
|
||||||
size = QUOTE(POS_H(0.9));
|
|
||||||
class Attributes {
|
|
||||||
align = "center";
|
|
||||||
color = "#E5E5E5";
|
|
||||||
font = "RobotoCondensed";
|
|
||||||
shadow = "false";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
class Action2: Action1 {
|
|
||||||
idc = IDC_ACTION_2;
|
|
||||||
y = QUOTE(POS_Y(5.5));
|
|
||||||
};
|
|
||||||
class Action3: Action1 {
|
|
||||||
idc = IDC_ACTION_3;
|
|
||||||
y = QUOTE(POS_Y(6.6));
|
|
||||||
};
|
|
||||||
class Action4: Action1 {
|
|
||||||
idc = IDC_ACTION_4;
|
|
||||||
y = QUOTE(POS_Y(7.7));
|
|
||||||
};
|
|
||||||
class Action5: Action1 {
|
|
||||||
idc = IDC_ACTION_5;
|
|
||||||
y = QUOTE(POS_Y(8.8));
|
|
||||||
};
|
|
||||||
class Action6: Action1 {
|
|
||||||
idc = IDC_ACTION_6;
|
|
||||||
y = QUOTE(POS_Y(9.9));
|
|
||||||
};
|
|
||||||
class Action7: Action1 {
|
|
||||||
idc = IDC_ACTION_7;
|
|
||||||
y = QUOTE(POS_Y(11));
|
|
||||||
};
|
|
||||||
class Action8: Action1 {
|
|
||||||
idc = IDC_ACTION_8;
|
|
||||||
y = QUOTE(POS_Y(12.1));
|
|
||||||
};
|
|
||||||
class Action9: Action1 {
|
|
||||||
idc = IDC_ACTION_9;
|
|
||||||
y = QUOTE(POS_Y(13.2));
|
|
||||||
};
|
};
|
||||||
class BodyImage: GVAR(BodyImage) {};
|
class BodyImage: GVAR(BodyImage) {};
|
||||||
class SelectHead: RscButton {
|
class SelectHead: RscButton {
|
||||||
|
@ -51,17 +51,7 @@
|
|||||||
#define IDC_ACTIVITY 1420
|
#define IDC_ACTIVITY 1420
|
||||||
#define IDC_QUICKVIEW 1430
|
#define IDC_QUICKVIEW 1430
|
||||||
|
|
||||||
#define IDC_ACTION_1 1500
|
#define IDC_ACTION_BUTTON_GROUP 1599
|
||||||
#define IDC_ACTION_2 1510
|
|
||||||
#define IDC_ACTION_3 1520
|
|
||||||
#define IDC_ACTION_4 1530
|
|
||||||
#define IDC_ACTION_5 1540
|
|
||||||
#define IDC_ACTION_6 1550
|
|
||||||
#define IDC_ACTION_7 1560
|
|
||||||
#define IDC_ACTION_8 1570
|
|
||||||
#define IDC_ACTION_9 1580
|
|
||||||
|
|
||||||
#define IDCS_ACTION_BUTTONS [IDC_ACTION_1, IDC_ACTION_2, IDC_ACTION_3, IDC_ACTION_4, IDC_ACTION_5, IDC_ACTION_6, IDC_ACTION_7, IDC_ACTION_8, IDC_ACTION_9]
|
|
||||||
|
|
||||||
#define IDC_BODY_GROUP 6000
|
#define IDC_BODY_GROUP 6000
|
||||||
#define IDC_BODY_HEAD 6005
|
#define IDC_BODY_HEAD 6005
|
||||||
|
Reference in New Issue
Block a user