ACE3/addons/common/functions/fnc_disableUserInput.sqf
Dedmen Miller e2ac18a05d [WIP] Fix script errors reporting wrong line numbers (#6407)
* advanced_ballistics

* advanced_fatigue

* advanced_throwing

* ai

* aircraft

* arsenal

* atragmx

* attach

* backpacks

* ballistics

* captives

* cargo

* chemlights

* common

* concertina_wire

* cookoff

* dagr

* disarming

* disposable

* dogtags

* dragging

* explosives

* fastroping

* fcs

* finger

* frag

* gestures

* gforces

* goggles

* grenades

* gunbag

* hearing

* hitreactions

* huntir

* interact_menu

* interaction

* inventory

* kestrel4500

* laser

* laserpointer

* logistics_uavbattery

* logistics_wirecutter

* magazinerepack

* map

* map_gestures

* maptools

* markers

* medical

* medical_ai

* medical_blood

* medical_menu

* microdagr

* minedetector

* missileguidance

* missionmodules

* mk6mortar

* modules

* movement

* nametags

* nightvision

* nlaw

* optics

* optionsmenu

* overheating

* overpressure

* parachute

* pylons

* quickmount

* rangecard

* rearm

* recoil

* refuel

* reload

* reloadlaunchers

* repair

* respawn

* safemode

* sandbag

* scopes

* slideshow

* spectator

* spottingscope

* switchunits

* tacticalladder

* tagging

* trenches

* tripod

* ui

* vector

* vehiclelock

* vehicles

* viewdistance

* weaponselect

* weather

* winddeflection

* yardage450

* zeus

* arsenal defines.hpp

* optionals

* DEBUG_MODE_FULL 1

* DEBUG_MODE_FULL 2

* Manual fixes

* Add SQF Validator check for #include after block comment

* explosives fnc_openTimerUI

* fix uniqueItems
2018-09-17 14:19:29 -05:00

110 lines
4.1 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: commy2
* Disables key input. ESC can still be pressed to open the menu.
*
* Arguments:
* 0: True to disable key inputs, false to re-enable them <BOOL>
*
* Return Value:
* None
*
* Example:
* [true] call ace_common_fnc_disableUserInput
*
* Public: No
*/
params ["_state"];
if (_state) then {
disableSerialization;
if (!isNull (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull])) exitWith {};
if (!isNil QGVAR(disableInputPFH)) exitWith {};
// end TFAR and ACRE2 radio transmissions
call FUNC(endRadioTransmission);
// Close map
if (visibleMap && {!(player getVariable ["ACE_canSwitchUnits", false])}) then {
openMap false;
};
closeDialog 0;
createDialog QGVAR(DisableMouse_Dialog);
private _dlg = uiNamespace getVariable QGVAR(dlgDisableMouse);
_dlg displayAddEventHandler ["KeyDown", {
params ["", "_key"];
if (_key == 1 && {alive player}) then {
createDialog (["RscDisplayInterrupt", "RscDisplayMPInterrupt"] select isMultiplayer);
disableSerialization;
private _dlg = findDisplay 49;
for "_index" from 100 to 2000 do {
(_dlg displayCtrl _index) ctrlEnable false;
};
private _ctrl = _dlg displayctrl 103;
_ctrl ctrlSetEventHandler ["buttonClick", QUOTE(while {!isNull (uiNamespace getVariable [ARR_2(QUOTE(QGVAR(dlgDisableMouse)),displayNull)])} do {closeDialog 0}; failMission 'LOSER'; [false] call DFUNC(disableUserInput);)];
_ctrl ctrlEnable true;
_ctrl ctrlSetText "ABORT";
_ctrl ctrlSetTooltip "Abort.";
_ctrl = _dlg displayctrl ([104, 1010] select isMultiplayer);
_ctrl ctrlSetEventHandler ["buttonClick", QUOTE(closeDialog 0; player setDamage 1; [false] call DFUNC(disableUserInput);)];
_ctrl ctrlEnable (call {private _config = missionConfigFile >> "respawnButton"; !isNumber _config || {getNumber _config == 1}});
_ctrl ctrlSetText "RESPAWN";
_ctrl ctrlSetTooltip "Respawn.";
};
if (_key in actionKeys "TeamSwitch" && {teamSwitchEnabled}) then {
(uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0;
private _acc = accTime;
teamSwitch;
setAccTime _acc;
};
if (_key in actionKeys "CuratorInterface" && {getAssignedCuratorLogic player in allCurators}) then {
(uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0;
openCuratorInterface;
};
if (_key in actionKeys "ShowMap" && {player getVariable ["ACE_canSwitchUnits", false]}) then {
(uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0;
openMap true;
};
if (isServer || {serverCommandAvailable "#kick"} || {player getVariable ["ACE_isUnconscious", false] && {(call FUNC(player)) getVariable [QEGVAR(medical,AllowChatWhileUnconscious), missionNamespace getVariable [QEGVAR(medical,AllowChatWhileUnconscious), false]]}}) then {
if (!(_key in (actionKeys "DefaultAction" + actionKeys "Throw")) && {_key in (actionKeys "Chat" + actionKeys "PrevChannel" + actionKeys "NextChannel")}) then {
_key = 0;
};
};
_key > 0
}];
_dlg displayAddEventHandler ["KeyUp", {true}];
GVAR(disableInputPFH) = [{
if (isNull (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) && {!visibleMap && isNull findDisplay 49 && isNull findDisplay 312 && isNull findDisplay 632}) then {
[GVAR(disableInputPFH)] call CBA_fnc_removePerFrameHandler;
GVAR(disableInputPFH) = nil;
[true] call FUNC(disableUserInput);
};
}, 0, []] call CBA_fnc_addPerFrameHandler;
} else {
if (!isNil QGVAR(disableInputPFH)) then {
[GVAR(disableInputPFH)] call CBA_fnc_removePerFrameHandler;
GVAR(disableInputPFH) = nil;
};
(uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0;
};