From 03636463c6912bda27e39c8249f90cbbde884f5e Mon Sep 17 00:00:00 2001 From: A Man Date: Tue, 12 Apr 2022 19:59:07 +0200 Subject: [PATCH] Add snap switch left-handed option with F6 Made by @Victor-the-Cleaner --- SQF/dayz_code/compile/dze_snap_building.sqf | 3 +- SQF/dayz_code/compile/keyboard.sqf | 58 ++++++++++++++++----- SQF/dayz_code/init/variables.sqf | 1 + SQF/dayz_code/stringtable.xml | 16 ++++++ 4 files changed, 63 insertions(+), 15 deletions(-) diff --git a/SQF/dayz_code/compile/dze_snap_building.sqf b/SQF/dayz_code/compile/dze_snap_building.sqf index e283c0955..5eb061784 100644 --- a/SQF/dayz_code/compile/dze_snap_building.sqf +++ b/SQF/dayz_code/compile/dze_snap_building.sqf @@ -47,12 +47,13 @@ local _hpsp = _hyphen + _PgUp + _slash + _PgDn + _BRW; local _degKeys = toArray (localize "STR_EPOCH_TUT_ADJ_DEGREES_KEYS"); local _decrease = toString [_degKeys select 0]; local _increase = toString [_degKeys select 1]; +local _handedness = ["STR_EPOCH_TUT_KEY_ARROWS","STR_EPOCH_TUT_KEY_NUMPAD_ARROWS"] select DZE_LEFT_HANDED; local _HK = _OBR + _tab + _DBR + localize "STR_EPOCH_TUT_KEY_SHIFT" + _hyphen + _tab + _BRW + localize "STR_EPOCH_TUT_SNAP_NEXT_PREV" + _NL; _HK = _HK + _OBR + _PgUp + _DBR + _PgDn + _BRW + localize "STR_EPOCH_TUT_HEIGHT10" + _NL; _HK = _HK + _OBR + localize "STR_EPOCH_TUT_KEY_CTRL" + _hpsp + localize "STR_EPOCH_TUT_HEIGHT1" + _NL; _HK = _HK + _OBR + localize "STR_EPOCH_TUT_KEY_ALT" + _hpsp + localize "STR_EPOCH_TUT_HEIGHT100" + _NL; -_HK = _HK + _OBR + localize "STR_EPOCH_TUT_KEY_ARROWS" + _BRW + _strPitch + " / " + _strBank + _NL; +_HK = _HK + _OBR + localize _handedness + _BRW + _strPitch + " / " + _strBank + _NL; _HK = _HK + _ORA + "[Q] [E] " + _WHT + _strRotate + _NL; _HK = _HK + _OBR + _decrease + _DBR + _increase + _BRW + localize "STR_EPOCH_TUT_ADJ_DEGREES" + _NL; _HK = _HK + _spacing; diff --git a/SQF/dayz_code/compile/keyboard.sqf b/SQF/dayz_code/compile/keyboard.sqf index 0800fd3ed..9cfa02764 100644 --- a/SQF/dayz_code/compile/keyboard.sqf +++ b/SQF/dayz_code/compile/keyboard.sqf @@ -70,30 +70,38 @@ if (isNil "keyboard_keys") then { }; }; local _dze_up = { - if (!isNil "DZE_buildItem") then { // pitch object forward while base building (Up Arrow Only) - DZE_UP = true; - _handled = true; // prevent move forward + if (!isNil "DZE_buildItem") then { // pitch object forward while base building (Up Arrow or Numpad 8) + if ((DZE_LEFT_HANDED && (_dikCode == 72)) || (!DZE_LEFT_HANDED && (_dikCode == 200))) then { + DZE_UP = true; + _handled = true; + }; }; r_interrupt = true; }; local _dze_down = { - if (!isNil "DZE_buildItem") then { // pitch object back while base building (Down Arrow Only) - DZE_DOWN = true; - _handled = true; // prevent move back + if (!isNil "DZE_buildItem") then { // pitch object back while base building (Down Arrow or Numpad 2) + if ((DZE_LEFT_HANDED && (_dikCode == 80)) || (!DZE_LEFT_HANDED && (_dikCode == 208))) then { + DZE_DOWN = true; + _handled = true; + }; }; r_interrupt = true; }; local _dze_left = { - if (!isNil "DZE_buildItem") then { // bank object left while base building - DZE_LEFT = true; - _handled = true; // prevent move left + if (!isNil "DZE_buildItem") then { // bank object left while base building (Left Arrow or Numpad 4) + if ((DZE_LEFT_HANDED && (_dikCode == 75)) || (!DZE_LEFT_HANDED && (_dikCode == 203))) then { + DZE_LEFT = true; + _handled = true; + }; }; r_interrupt = true; }; local _dze_right = { - if (!isNil "DZE_buildItem") then { // bank object right while base building - DZE_RIGHT = true; - _handled = true; // prevent move right + if (!isNil "DZE_buildItem") then { // bank object right while base building (Right Arrow or Numpad 6) + if ((DZE_LEFT_HANDED && (_dikCode == 77)) || (!DZE_LEFT_HANDED && (_dikCode == 205))) then { + DZE_RIGHT = true; + _handled = true; + }; }; r_interrupt = true; }; @@ -168,6 +176,19 @@ if (isNil "keyboard_keys") then { call ui_changeDisplay; _handled = true; }; + local _handedness = { + if (isNil "DZE_buildItem") then { // only allow switching outside of base building + DZE_LEFT_HANDED = !DZE_LEFT_HANDED; + local _handed = ""; + if (DZE_LEFT_HANDED) then { + _handed = "STR_EPOCH_LEFT_HANDED"; + } else { + _handed = "STR_EPOCH_RIGHT_HANDED"; + }; + systemChat format [localize "STR_EPOCH_KEYBOARD_HANDEDNESS", localize _handed]; + }; + _handled = true; + }; local _rifle = { 2 call dz_fn_switchWeapon; _handled = true; @@ -313,11 +334,19 @@ if (isNil "keyboard_keys") then { [actionKeys "MoveBack", _interrupt] call _addArray; // S / Down Arrow Keys [actionKeys "TurnLeft", _interrupt] call _addArray; // A / Left Arrow Keys [actionKeys "TurnRight", _interrupt] call _addArray; // D / Right Arrow Keys - // keep these arrow keys directly below the move/turn action key entries + /////////////////////////////////////////////////////////////////////////////////////////// + // Keep these arrow keys directly below the move/turn action key entries, + // and keep them in exactly this order. + /////////////////////////////////////////////////////////////////////////////////////////// + [[DIK_NUMPAD8], _dze_up] call _addArray; + [[DIK_NUMPAD2], _dze_down] call _addArray; + [[DIK_NUMPAD4], _dze_left] call _addArray; + [[DIK_NUMPAD6], _dze_right] call _addArray; [[DIK_UP], _dze_up] call _addArray; [[DIK_DOWN], _dze_down] call _addArray; [[DIK_LEFT], _dze_left] call _addArray; [[DIK_RIGHT], _dze_right] call _addArray; + /////////////////////////////////////////////////////////////////////////////////////////// [actionKeys "PushToTalk", _noise] call _addArray; [actionKeys "PushToTalkAll", _noise] call _addArray; [actionKeys "PushToTalkCommand", _noise] call _addArray; @@ -335,6 +364,7 @@ if (isNil "keyboard_keys") then { [actionKeys "SelectAll", _block] call _addArray; [[DIK_F1], _muteSound] call _addArray; [[DIK_F3], _statusUI] call _addArray; + [[DIK_F6], _handedness] call _addArray; [[DIK_F5], {if (diag_tickTime - dayz_lastSave > 10) then {call player_forceSave;};_handled = true;}] call _addArray; [[DIK_TAB], _dze_tab] call _addArray; [actionKeys "LeanLeft", {DZE_4 = true; dayz_dodge = true;}] call _addArray; @@ -343,7 +373,7 @@ if (isNil "keyboard_keys") then { [[DIK_E], _dze_e] call _addArray; [actionKeys "GetOver", _bunnyhop] call _addArray; // V [actionKeys "ForceCommandingMode", {DZE_5 = true; _handled = true;}] call _addArray; - [[DIK_F2, DIK_F4, DIK_F6, DIK_F7, DIK_F8, DIK_F9, DIK_F10, DIK_F11, DIK_F12, DIK_4, DIK_5, DIK_6, DIK_7, DIK_8, DIK_9], _block] call _addArray; + [[DIK_F2, DIK_F4, DIK_F7, DIK_F8, DIK_F9, DIK_F10, DIK_F11, DIK_F12, DIK_4, DIK_5, DIK_6, DIK_7, DIK_8, DIK_9], _block] call _addArray; if (dayz_groupSystem) then { [[DIK_F5], _openGroups] call _addArray; diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index 9fdfc67e4..81755a9d5 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -431,6 +431,7 @@ if (!isDedicated) then { DZE_myHaloVehicle = objNull; dayz_myLiftVehicle = objNull; DZE_Friends = []; + DZE_LEFT_HANDED = false; DZE_Q = false; DZE_Z = false; DZE_Q_alt = false; diff --git a/SQF/dayz_code/stringtable.xml b/SQF/dayz_code/stringtable.xml index 9a63bd481..dc598fef8 100644 --- a/SQF/dayz_code/stringtable.xml +++ b/SQF/dayz_code/stringtable.xml @@ -33772,6 +33772,22 @@ Pfeiltasten Стрелки + + Numpad Arrow Keys + Nummernpad-Pfeiltasten + + + ** Keyboard is now configured: %1 ** + ** Tastatur is eingestellt auf: %1 ** + + + Left-handed + Linkshändig + + + Right-handed + Rechtshändig + Esc