mirror of
https://github.com/acemod/ACE3.git
synced 2025-07-25 04:42:48 +00:00
Medical GUI - Add sound and conditional switching to Medical Menu keybinds (#9487)
* add sound and condition to category switch * improve conditional switching * better toggle handling * playSound * header * Update addons/medical_gui/functions/fnc_onKeyDown.sqf Co-authored-by: PabstMirror <pabstmirror@gmail.com> --------- Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
@ -5,20 +5,25 @@
|
|||||||
* Handles keyboard inputs in medical menu.
|
* Handles keyboard inputs in medical menu.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Menu display <DISPLAY>
|
* 1: Args <ARRAY>
|
||||||
* 1: Key being pressed <NUMBER>
|
* - 0: Menu display <DISPLAY>
|
||||||
* 2: Shift state <BOOL>
|
* - 1: Key being pressed <NUMBER>
|
||||||
* 3: Ctrl state <BOOL>
|
* - 2: Shift state <BOOL>
|
||||||
* 4: Alt state <BOOL>
|
* - 3: Ctrl state <BOOL>
|
||||||
|
* - 4: Alt state <BOOL>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
|
* Example:
|
||||||
|
* ["", [displayNull, 5, false, false, false]] call ace_medical_gui_fnc_onKeyDown
|
||||||
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
// TODO: Is the airway category ever visible? Can the dynamic category stuff be removed?
|
// TODO: Is the airway category ever visible? Can the dynamic category stuff be removed?
|
||||||
|
|
||||||
#define NUMBER_KEYS [DIK_1, DIK_2, DIK_3, DIK_4, DIK_5, DIK_6, DIK_7, DIK_8, DIK_9, DIK_0]
|
#define NUMBER_KEYS [DIK_1, DIK_2, DIK_3, DIK_4, DIK_5, DIK_6, DIK_7, DIK_8, DIK_9, DIK_0]
|
||||||
|
#define ALL_CATEGORIES ["triage", "examine", "bandage", "medication", "airway", "advanced", "drag", "toggle"]
|
||||||
|
|
||||||
params ["", "_args"];
|
params ["", "_args"];
|
||||||
_args params ["_display", "_keyPressed", "_shiftState", "_ctrlState", "_altState"];
|
_args params ["_display", "_keyPressed", "_shiftState", "_ctrlState", "_altState"];
|
||||||
@ -40,16 +45,23 @@ private _allCategories = ["triage", "examine"] + _visibleCategories + ["toggle"]
|
|||||||
private _keyCategoryPairs = _allCategories createHashMapFromArray NUMBER_KEYS;
|
private _keyCategoryPairs = _allCategories createHashMapFromArray NUMBER_KEYS;
|
||||||
|
|
||||||
private _temp_category = "";
|
private _temp_category = "";
|
||||||
|
private _temp_idc = 0;
|
||||||
|
|
||||||
switch (true) do {
|
switch (true) do {
|
||||||
// Dynamically assign number keys to visible categories
|
// Dynamically assign number keys to visible categories
|
||||||
{
|
{
|
||||||
_temp_category = _x; // _x does not exist inside case code
|
_temp_category = _x; // _x does not exist inside case code
|
||||||
case (_keyPressed == _y): {
|
_temp_idc = IDC_TRIAGE + (ALL_CATEGORIES find _temp_category) * 10;
|
||||||
GVAR(selectedCategory) = _temp_category;
|
case (_keyPressed == _y && {GVAR(selectedCategory) != _temp_category}): {
|
||||||
|
if (ctrlEnabled _temp_idc) then {
|
||||||
if (_temp_category == "toggle") then {
|
if (_temp_category == "toggle") then {
|
||||||
call FUNC(handleToggle);
|
call FUNC(handleToggle);
|
||||||
}
|
} else {
|
||||||
|
GVAR(selectedCategory) = _temp_category;
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
_return = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
} forEach _keyCategoryPairs;
|
} forEach _keyCategoryPairs;
|
||||||
|
|
||||||
@ -57,22 +69,22 @@ switch (true) do {
|
|||||||
// w
|
// w
|
||||||
// a s d
|
// a s d
|
||||||
// z x
|
// z x
|
||||||
case (_keyPressed == DIK_W): {
|
case (_keyPressed == DIK_W && {GVAR(selectedBodyPart) != 0}): {
|
||||||
GVAR(selectedBodyPart) = 0;
|
GVAR(selectedBodyPart) = 0;
|
||||||
};
|
};
|
||||||
case (_keyPressed == DIK_S): {
|
case (_keyPressed == DIK_S && {GVAR(selectedBodyPart != 1)}): {
|
||||||
GVAR(selectedBodyPart) = 1;
|
GVAR(selectedBodyPart) = 1;
|
||||||
};
|
};
|
||||||
case (_keyPressed == DIK_D): {
|
case (_keyPressed == DIK_D && {GVAR(selectedBodyPart) != 2}): {
|
||||||
GVAR(selectedBodyPart) = 2;
|
GVAR(selectedBodyPart) = 2;
|
||||||
};
|
};
|
||||||
case (_keyPressed == DIK_A): {
|
case (_keyPressed == DIK_A && {GVAR(selectedBodyPart) != 3}): {
|
||||||
GVAR(selectedBodyPart) = 3;
|
GVAR(selectedBodyPart) = 3;
|
||||||
};
|
};
|
||||||
case (_keyPressed == DIK_X): {
|
case (_keyPressed == DIK_X && {GVAR(selectedBodyPart) != 4}): {
|
||||||
GVAR(selectedBodyPart) = 4;
|
GVAR(selectedBodyPart) = 4;
|
||||||
};
|
};
|
||||||
case (_keyPressed == DIK_Z): {
|
case (_keyPressed == DIK_Z && {GVAR(selectedBodyPart) != 5}): {
|
||||||
GVAR(selectedBodyPart) = 5;
|
GVAR(selectedBodyPart) = 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,4 +93,8 @@ switch (true) do {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (_return) then {
|
||||||
|
playSound ["SoundClick", true]
|
||||||
|
};
|
||||||
|
|
||||||
_return
|
_return
|
||||||
|
Reference in New Issue
Block a user