From dd7e7463686ed731af9468726fbe7cc8716be089 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sat, 11 Apr 2015 19:52:30 +0200 Subject: [PATCH 1/3] formatting --- .../common/functions/fnc_disableUserInput.sqf | 132 ++++++++++-------- 1 file changed, 73 insertions(+), 59 deletions(-) diff --git a/addons/common/functions/fnc_disableUserInput.sqf b/addons/common/functions/fnc_disableUserInput.sqf index 57be44fe43..a1486438b6 100644 --- a/addons/common/functions/fnc_disableUserInput.sqf +++ b/addons/common/functions/fnc_disableUserInput.sqf @@ -1,14 +1,16 @@ /* * Author: commy2 - * * Disables key input. ESC can still be pressed to open the menu. * - * Argument: - * 0: True to disable key inputs, false to re-enable them (Bool) + * Arguments: + * 0: True to disable key inputs, false to re-enable them * * Return value: * Nothing + * + * Public: Yes */ + #include "script_component.hpp" private ["_state", "_dlg"]; @@ -16,76 +18,88 @@ private ["_state", "_dlg"]; _state = _this select 0; if (_state) then { - disableSerialization; + disableSerialization; - if (!isNull (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull])) exitWith {}; - if ("ACE_DisableUserInput" in ([BIS_stackedEventHandlers_onEachFrame, {_this select 0}] call FUNC(map))) exitWith {}; + if (!isNull (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull])) exitWith {}; + if ("ACE_DisableUserInput" in ([BIS_stackedEventHandlers_onEachFrame, {_this select 0}] call FUNC(map))) exitWith {}; - // end TFAR and ACRE2 radio transmissions - 0 spawn FUNC(endRadioTransmission); + // end TFAR and ACRE2 radio transmissions + call FUNC(endRadioTransmission); - // Close map - if (visibleMap && {!(player getVariable ["ACE_canSwitchUnits", false])}) then {openMap false}; + // Close map + if (visibleMap && {!(player getVariable ["ACE_canSwitchUnits", false])}) then { + openMap false; + }; - closeDialog 0; - createDialog QGVAR(DisableMouse_Dialog); + closeDialog 0; + createDialog QGVAR(DisableMouse_Dialog); - _dlg = uiNamespace getVariable QGVAR(dlgDisableMouse); + _dlg = uiNamespace getVariable QGVAR(dlgDisableMouse); - _dlg displayAddEventHandler ["KeyDown", { - _key = _this select 1; - - if (_key == 1 && {alive player}) then { - createDialog (["RscDisplayInterrupt", "RscDisplayMPInterrupt"] select isMultiplayer); - - disableSerialization; - _dlg = finddisplay 49; - _dlg displayAddEventHandler ["KeyDown", { + _dlg displayAddEventHandler ["KeyDown", { _key = _this select 1; - !(_key == 1) - }]; - for "_index" from 100 to 2000 do { - (_dlg displayCtrl _index) ctrlEnable false; - }; + if (_key == 1 && {alive player}) then { + createDialog (["RscDisplayInterrupt", "RscDisplayMPInterrupt"] select isMultiplayer); - _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."; + disableSerialization; + _dlg = finddisplay 49; + _dlg displayAddEventHandler ["KeyDown", { + _key = _this select 1; + !(_key == 1) + }]; - _ctrl = _dlg displayctrl ([104, 1010] select isMultiplayer); - _ctrl ctrlSetEventHandler ["buttonClick", QUOTE(closeDialog 0; player setDamage 1; [false] call DFUNC(disableUserInput);)]; - _ctrl ctrlEnable (call {_config = missionConfigFile >> "respawnButton"; !isNumber _config || {getNumber _config == 1}}); - _ctrl ctrlSetText "RESPAWN"; - _ctrl ctrlSetTooltip "Respawn."; - }; + for "_index" from 100 to 2000 do { + (_dlg displayCtrl _index) ctrlEnable false; + }; - if (_key in actionKeys "TeamSwitch" && {teamSwitchEnabled}) then {(uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0; teamSwitch};//_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}; + _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."; - if (serverCommandAvailable "#missions" || {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; - }; - }; + _ctrl = _dlg displayctrl ([104, 1010] select isMultiplayer); + _ctrl ctrlSetEventHandler ["buttonClick", QUOTE(closeDialog 0; player setDamage 1; [false] call DFUNC(disableUserInput);)]; + _ctrl ctrlEnable (call {_config = missionConfigFile >> "respawnButton"; !isNumber _config || {getNumber _config == 1}}); + _ctrl ctrlSetText "RESPAWN"; + _ctrl ctrlSetTooltip "Respawn."; + }; - _key > 0 - }]; - _dlg displayAddEventHandler ["KeyUp", {true}]; + if (_key in actionKeys "TeamSwitch" && {teamSwitchEnabled}) then { + (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0; teamSwitch + };//_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 (serverCommandAvailable "#missions" || {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}]; + + ["ACE_DisableUserInput", "onEachFrame", { + if (isNull (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) && {!visibleMap && isNull findDisplay 49 && isNull findDisplay 312 && isNull findDisplay 632}) then { + ["ACE_DisableUserInput", "onEachFrame"] call BIS_fnc_removeStackedEventHandler; + [true] call FUNC(disableUserInput); + }; + }] call BIS_fnc_addStackedEventHandler; - ["ACE_DisableUserInput", "onEachFrame", { - if (isNull (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) && {!visibleMap && isNull findDisplay 49 && isNull findDisplay 312 && isNull findDisplay 632}) then { - ["ACE_DisableUserInput", "onEachFrame"] call BIS_fnc_removeStackedEventHandler; - [true] call FUNC(disableUserInput); - }; - }] call BIS_fnc_addStackedEventHandler; } else { - if ("ACE_DisableUserInput" in ([BIS_stackedEventHandlers_onEachFrame, {_this select 0}] call FUNC(map))) then { - ["ACE_DisableUserInput", "onEachFrame"] call BIS_fnc_removeStackedEventHandler; - }; + if ("ACE_DisableUserInput" in ([BIS_stackedEventHandlers_onEachFrame, {_this select 0}] call FUNC(map))) then { + ["ACE_DisableUserInput", "onEachFrame"] call BIS_fnc_removeStackedEventHandler; + }; - (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0; + (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0; }; From 24765741ab3c9cacb0ad3e0aec9e6af4030311a8 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sat, 11 Apr 2015 20:05:22 +0200 Subject: [PATCH 2/3] Enabled setAccTime fix from commy --- addons/common/functions/fnc_disableUserInput.sqf | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/common/functions/fnc_disableUserInput.sqf b/addons/common/functions/fnc_disableUserInput.sqf index a1486438b6..0b1275e9cf 100644 --- a/addons/common/functions/fnc_disableUserInput.sqf +++ b/addons/common/functions/fnc_disableUserInput.sqf @@ -67,15 +67,20 @@ if (_state) then { }; if (_key in actionKeys "TeamSwitch" && {teamSwitchEnabled}) then { - (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0; teamSwitch - };//_acc = accTime; teamSwitch; setAccTime _acc}; + (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0; + _acc = accTime; + teamSwitch; + setAccTime _acc; + }; if (_key in actionKeys "CuratorInterface" && {getAssignedCuratorLogic player in allCurators}) then { - (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0; openCuratorInterface; + (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 + (uiNamespace getVariable [QGVAR(dlgDisableMouse), displayNull]) closeDisplay 0; + openMap true; }; if (serverCommandAvailable "#missions" || {player getVariable ["ACE_isUnconscious", false] && {(call FUNC(player)) getVariable [QEGVAR(medical,AllowChatWhileUnconscious), missionNamespace getVariable [QEGVAR(medical,AllowChatWhileUnconscious), false]]}}) then { From 1df42b17c201521bbf3a15529809a1c206093087 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Mon, 20 Apr 2015 22:22:09 +0200 Subject: [PATCH 3/3] close all dialogs --- addons/medical/functions/fnc_setUnconscious.sqf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_setUnconscious.sqf b/addons/medical/functions/fnc_setUnconscious.sqf index e527215c51..c5809f8c8e 100644 --- a/addons/medical/functions/fnc_setUnconscious.sqf +++ b/addons/medical/functions/fnc_setUnconscious.sqf @@ -37,7 +37,9 @@ _unit setUnconscious true; if (_unit == ACE_player) then { if (visibleMap) then {openMap false}; - closeDialog 0; + while {dialog} do { + closeDialog 0; + }; }; // if we have unconsciousness for AI disabled, we will kill the unit instead