From 52c9c7ceda5cb913cc3049264e4243b50eb8d341 Mon Sep 17 00:00:00 2001 From: icomrade Date: Sat, 26 Nov 2016 18:48:11 -0500 Subject: [PATCH] Somewhat better VON Block Not perfect, occasionally the player can double tap a button to lock VON on - which now they cannot turn off unless they open the escape menu and double tap to turn off. Chat channel changes are now blocked when VON is active. ActionKeys are now recalculated on key binding change, but it is important to note that double tap bindings DO NOT work with the ActionKeys command. This is why inputAction check is neccesary Summary: Double tapping a key to lock von on (VoiceOverNet) is not reliably blocked, nor is it blocked at all in secondary displays/dialogs. otherwise, this works pretty well. --- SQF/dayz_code/Configs/rscTitles.hpp | 9 +++++++ SQF/dayz_code/compile/keyboard.sqf | 4 ++-- SQF/dayz_code/compile/ui_updateControls.sqf | 5 ++++ SQF/dayz_code/init/compiles.sqf | 26 ++++++++++++++------- SQF/dayz_code/init/variables.sqf | 6 +++-- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/SQF/dayz_code/Configs/rscTitles.hpp b/SQF/dayz_code/Configs/rscTitles.hpp index b0f2b510a..88817df04 100644 --- a/SQF/dayz_code/Configs/rscTitles.hpp +++ b/SQF/dayz_code/Configs/rscTitles.hpp @@ -40,6 +40,7 @@ class RscDisplayMission: RscDisplayEmpty onKeyDown = "if (!isNil 'DZ_KeyDown_EH') then {_this call DZ_KeyDown_EH;};"; //assigned much quicker than spawning init_keyboard }; class RscDisplayConfigure { + idd = 4; onUnload = "if (!isNil 'updateControlsHandle') then {terminate updateControlsHandle;}; if (!isNil 'ui_updateControls') then {updateControlsHandle = true spawn ui_updateControls;};"; class controlsBackground; class controls; @@ -103,6 +104,13 @@ class RscDisplayChannel onMouseButtonDown = "_handle = if (!isNil 'DZE_FilterCheats') then {[0,(_this select 1),false] call DZE_FilterCheats} else {false}; _handle"; class controls; }; +class RscDisplayVoiceChat +{ + idd = 55; + onKeyDown = "_handle = if (!isNil 'DZE_FilterCheats') then {_this call DZE_FilterCheats} else {false}; _handle"; + onMouseButtonDown = "_handle = if (!isNil 'DZE_FilterCheats') then {[0,(_this select 1),false] call DZE_FilterCheats} else {false}; _handle"; + class controls; +}; class RscPictureGUI { access = 0; @@ -434,6 +442,7 @@ class RscDisplayMPInterrupt : RscStandardDisplay { //onLoad = "_dummy = ['Init', _this] execVM '\ca\ui\scripts\pauseLoadinit.sqf'; [(_this select 0)] execVM '\z\addons\dayz_code\compile\player_onPause.sqf';"; _respawn = (_this select 0) displayCtrl 1010); _respawn ctrlEnable false; _abort = (_this select 0) displayCtrl 104); _abort ctrlEnable false; onLoad = "uiNamespace setVariable ['RscDisplayMPInterrupt', _this select 0]; _this call fn_pauseMenuChecks; [] spawn player_onPause; _dummy = ['Init', _this] execVM '\ca\ui\scripts\pauseLoadinit.sqf';"; /*diag_log[diag_tickTime,'RscDisplayMPInterrupt'];*/ onUnload = "uiNamespace setVariable ['RscDisplayMPInterrupt', nil];['Unload', _this] execVM '\ca\ui\scripts\pauseOnUnload.sqf';"; + onKeyDown = "_handle = if (!isNil 'DZE_FilterCheats') then {_this call DZE_FilterCheats} else {false}; _handle"; class controlsBackground { class Mainback : RscPicture { diff --git a/SQF/dayz_code/compile/keyboard.sqf b/SQF/dayz_code/compile/keyboard.sqf index 0e57f5a90..fabbdf6c4 100644 --- a/SQF/dayz_code/compile/keyboard.sqf +++ b/SQF/dayz_code/compile/keyboard.sqf @@ -310,7 +310,7 @@ if (isNil "keyboard_keys") then { if (!isNil "bis_fnc_halo_keydown_eh") then {bis_fnc_halo_keydown_eh = (finddisplay 46) displayaddeventhandler ["keydown","_this call bis_fnc_halo_keydown;"];}; // halo in progress }; -_this call DZE_FilterCheats; +_CheatHandled = _this call DZE_FilterCheats; if (r_player_unconsciousInputDisabled) exitWith {true}; _code = keyboard_keys select _dikCode; @@ -318,4 +318,4 @@ if (!isNil "_code") then { call _code; }; -_handled \ No newline at end of file +(_handled || _CheatHandled); \ No newline at end of file diff --git a/SQF/dayz_code/compile/ui_updateControls.sqf b/SQF/dayz_code/compile/ui_updateControls.sqf index 91cea6209..761a2b6c3 100644 --- a/SQF/dayz_code/compile/ui_updateControls.sqf +++ b/SQF/dayz_code/compile/ui_updateControls.sqf @@ -3,6 +3,11 @@ private ["_holdBreath","_turboKey"]; //Sleep required for actionKeys to update after controls dialog closes uiSleep 1; +dayz_voiceControls = []; +DayZ_channelChangeKeys = []; +{dayz_voiceControls = dayz_voiceControls + (actionKeys _x)} count ["voiceOverNet","PushToTalk","PushToTalkAll","PushToTalkCommand","PushToTalkDirect","PushToTalkGroup","PushToTalkSide","PushToTalkVehicle"]; +{DayZ_channelChangeKeys = DayZ_channelChangeKeys + (actionKeys _x)} count ["NextChannel","PrevChannel"]; + //Refresh keyboard_keys after controls change if (_this) then { keyboard_keys = nil; diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index d39595687..20b834499 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -694,19 +694,29 @@ dayz_EjectPlayer = compile preprocessFileLineNumbers "\z\addons\dayz_code\compil dayz_groupInvite = compile preprocessFileLineNumbers "\z\addons\dayz_code\groups\handleInvite.sqf"; DZE_FilterCheats = { - #define DIK_NUMPADMINUS 0x4A + #include "\ca\editor\Data\Scripts\dikCodes.h" _dik = _this select 1; _shift = _this select 2; - - _isVoiceChat = (_dik in dayz_voiceControls && {ctrlText (findDisplay 63 displayCtrl 101) in DZE_DisabledChannels}); //getting display directly from _this select 0 isn't reliable for chat channels! - if ((_dik == DIK_NUMPADMINUS && _shift) || _isVoiceChat) then { + _voiceLocked = (ctrlShown ((FindDisplay 55) displayCtrl 101)); + _textBoxShown = (ctrlShown ((FindDisplay 24) displayCtrl 101)); + //we need to check inputAction as well since ArmA is soooooo reliable that dik codes don't work with double tap or combination ActionKey mappings... + // Additionally inputAction does not work in dialogs, such as the escape menu, that are not the main display. + _channelChange = ((_dik in DayZ_channelChangeKeys) || {(inputAction "PrevChannel") > 0} || {(inputAction "NextChannel") > 0}); + _inputActionCheck = ({(inputAction _x) > 0} count ["voiceOverNet","PushToTalk","PushToTalkAll","PushToTalkCommand","PushToTalkDirect","PushToTalkGroup","PushToTalkSide","PushToTalkVehicle"]) > 0; + _isVoiceChat = ((_dik in dayz_voiceControls || _inputActionCheck) && {ctrlText (findDisplay 63 displayCtrl 101) in DZE_DisabledChannels}); //getting display directly from _this select 0 isn't reliable for chat channels! + _ChannelChangeWithVoice = ((_voiceLocked && _channelChange) || {_voiceLocked && _textBoxShown && ((_dik == DIK_DOWN) || (_dik == DIK_UP))}); + if ((_dik == DIK_NUMPADMINUS && _shift) || _isVoiceChat || _ChannelChangeWithVoice) then { if (!_isVoiceChat) then {call player_forceSave;}; disableUserInput true;disableUserInput true; - _isVoiceChat spawn { //disable input, this is unfortunately the only way to stop cheat input + [_isVoiceChat, _ChannelChangeWithVoice] spawn { //disable input, this is unfortunately the only way to stop cheat input _testTime = diag_tickTime; CheatsDisabled = _testTime; - if (_this) then { - titleText [(Format ["No voice chat in: %1", DZE_DisabledChannels]), "PLAIN", 1]; + if (_this select 0 || _this select 1) then { + if (_this select 0) then { + titleText [(Format ["No voice chat in: %1", DZE_DisabledChannels]), "PLAIN", 1]; + } else { + titleText ["You may not change chat channels while VON is active!", "PLAIN", 1]; + }; uiSleep 2; } else { titleText ["DO NOT ENTER CHEATS, WAIT 5 SECONDS TO CONTINUE!", "PLAIN", 1]; @@ -718,7 +728,7 @@ DZE_FilterCheats = { }; }; }; - _isVoiceChat + (_isVoiceChat || _ChannelChangeWithVoice); }; player_sumMedical = { diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index 3dafbf4fa..483cf0ed8 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -685,8 +685,10 @@ if (!isDedicated) then { dayz_getoutTime = 0; dayz_HitBy = objNull; dayz_voiceControls = []; - {dayz_voiceControls = dayz_voiceControls + (actionKeys _x)} count ["VoiceOverNet","PushToTalk","PushToTalkAll","PushToTalkCommand","PushToTalkDirect","PushToTalkGroup","PushToTalkSide","PushToTalkVehicle"]; - + DayZ_channelChangeKeys = []; + {dayz_voiceControls = dayz_voiceControls + (actionKeys _x)} count ["voiceOverNet","PushToTalk","PushToTalkAll","PushToTalkCommand","PushToTalkDirect","PushToTalkGroup","PushToTalkSide","PushToTalkVehicle"]; + {DayZ_channelChangeKeys = DayZ_channelChangeKeys + (actionKeys _x)} count ["NextChannel","PrevChannel"]; + // EPOCH ADDITIONS if (isNil "DZE_BackpackAntiTheft") then {DZE_BackpackAntiTheft = false;}; if (isNil "DZE_requireplot") then {DZE_requireplot = 1;};