Added a second set of binds for small keyboards

Also changed the key lock key to L, as the "switch binds" key is now K
This commit is contained in:
Dan
2020-02-25 14:23:31 +00:00
parent a3a1d93b3b
commit 5580cc8745
6 changed files with 136 additions and 42 deletions

View File

@@ -104,14 +104,14 @@ function READER:GetCamLocked( cam )
end
-- Locks the given reader
function READER:LockCam( cam, playAudio )
function READER:LockCam( cam, playAudio, isBolo )
-- Check that plate readers can actually be locked
if ( PLY:VehicleStateValid() and self:CanPerformMainTask() ) then
-- Toggle the lock state
self.vars.cams[cam].locked = not self.vars.cams[cam].locked
-- Tell the NUI side to show/hide the lock icon
SendNUIMessage( { _type = "lockPlate", cam = cam, state = self:GetCamLocked( cam ) } )
SendNUIMessage( { _type = "lockPlate", cam = cam, state = self:GetCamLocked( cam ), isBolo = isBolo } )
-- Play a beep
if ( self:GetCamLocked( cam ) ) then
@@ -199,7 +199,7 @@ function READER:Main()
-- Automatically lock the plate if the scanned plate matches the BOLO
if ( plate == self:GetBoloPlate() ) then
self:LockCam( cam, false )
self:LockCam( cam, false, true )
SendNUIMessage( { _type = "audio", name = "plate_hit", vol = RADAR:GetSettingValue( "plateAudio" ) } )
end

View File

@@ -204,7 +204,11 @@ RADAR.vars =
threadWaitTime = 500,
-- Key lock, when true, prevents any of the radar's key events from working, like the ELS key lock
keyLock = false
keyLock = false,
-- Full keyboard, when true, the keybinds for the radar will be set to the keys on the numpad, when false, the
-- keybinds for the radar will be set to the number keys above WASD
fullKeyboard = true
}
-- Speed conversion values
@@ -434,6 +438,32 @@ function RADAR:GetKeyLockState()
return self.vars.keyLock
end
-- Toggles between the full and small keybinds
function RADAR:ToggleFullKeyboard()
-- Check the player state is valid
if ( PLY:VehicleStateValid() ) then
-- Toggle the full keyboard state
self.vars.fullKeyboard = not self.vars.fullKeyboard
-- Tell the NUI side to display the keybind message
SendNUIMessage( { _type = "displayKeybindChange", state = self:GetFullKeyboardState() } )
end
end
-- Returns the full keyboard state
function RADAR:GetFullKeyboardState()
return self.vars.fullKeyboard
end
-- Returns which keybind set to use
function RADAR:GetKeybindType()
if ( self:GetFullKeyboardState() ) then
return "full"
else
return "small"
end
end
--[[----------------------------------------------------------------------------------
Radar menu functions
@@ -1612,36 +1642,43 @@ function RunControlManager()
-- Make sure only the keyboard works
if ( IsInputDisabled( 0 ) ) then
if ( not RADAR:GetKeyLockState() ) then
local keyType = RADAR:GetKeybindType()
-- Opens the remote control
if ( IsDisabledControlJustPressed( 1, CONFIG.remote_control_key ) ) then
if ( IsDisabledControlJustPressed( 1, CONFIG.keys.remote_control ) ) then
RADAR:OpenRemote()
end
-- Locks speed from front antenna
if ( IsDisabledControlJustPressed( 1, CONFIG.front_lock_key ) ) then
if ( IsDisabledControlJustPressed( 1, CONFIG.keys[keyType].front_lock ) ) then
RADAR:LockAntennaSpeed( "front" )
end
-- Locks speed from rear antenna
if ( IsDisabledControlJustPressed( 1, CONFIG.rear_lock_key ) ) then
if ( IsDisabledControlJustPressed( 1, CONFIG.keys[keyType].rear_lock ) ) then
RADAR:LockAntennaSpeed( "rear" )
end
-- Locks front plate reader
if ( IsDisabledControlJustPressed( 1, CONFIG.plate_front_lock_key ) ) then
READER:LockCam( "front", true )
if ( IsDisabledControlJustPressed( 1, CONFIG.keys[keyType].plate_front_lock ) ) then
READER:LockCam( "front", true, false )
end
-- Locks front plate reader
if ( IsDisabledControlJustPressed( 1, CONFIG.plate_rear_lock_key ) ) then
READER:LockCam( "rear", true )
if ( IsDisabledControlJustPressed( 1, CONFIG.keys[keyType].plate_rear_lock ) ) then
READER:LockCam( "rear", true, false )
end
end
-- Toggles the key lock state
if ( IsDisabledControlJustPressed( 1, CONFIG.key_lock_key ) ) then
if ( IsDisabledControlJustPressed( 1, CONFIG.keys.key_lock ) ) then
RADAR:ToggleKeyLock()
end
-- Toggles between the keybind types
if ( IsDisabledControlJustPressed( 1, CONFIG.keys.switch_keys ) ) then
RADAR:ToggleFullKeyboard()
end
end
-- Shortcut to restart the resource

View File

@@ -8,29 +8,58 @@
-- Do not touch this
CONFIG = {}
CONFIG.keys =
{
-- Remote control key
-- The default key to open the remote control is 166 (F5 - INPUT_SELECT_CHARACTER_MICHAEL)
CONFIG.remote_control_key = 166
-- Radar front antenna lock/unlock Key
-- The default key to lock/unlock the front antenna is 111 (Numpad 8 - INPUT_VEH_FLY_PITCH_UP_ONLY)
CONFIG.front_lock_key = 111
-- Radar rear antenna lock/unlock Key
-- The default key to lock/unlock the rear antenna is 112 (Numpad 5 - INPUT_VEH_FLY_PITCH_DOWN_ONLY)
CONFIG.rear_lock_key = 112
remote_control = 166,
-- Radar key lock key
-- The default key to enable/disable the radar key lock is 311 (K - INPUT_REPLAY_SHOWHOTKEY)
CONFIG.key_lock_key = 311
-- The default key to enable/disable the radar key lock is 182 (L - INPUT_CELLPHONE_CAMERA_FOCUS_LOCK)
key_lock = 182,
-- Radar keybinds switch
-- The default to key to switch the bind set is (K - INPUT_REPLAY_SHOWHOTKEY)
switch_keys = 311,
-- Keys for a full size keyboard
[ "full" ] = {
-- Radar front antenna lock/unlock Key
-- The default full keyboard key to lock/unlock the front antenna is 111 (Numpad 8 - INPUT_VEH_FLY_PITCH_UP_ONLY)
front_lock = 111,
-- Radar rear antenna lock/unlock Key
-- The default full keyboard key to lock/unlock the rear antenna is 112 (Numpad 5 - INPUT_VEH_FLY_PITCH_DOWN_ONLY)
rear_lock = 112,
-- Plate reader front lock/unlock Key
-- The default key to lock/unlock the front plate reader is 118 (Numpad 9 - INPUT_VEH_FLY_SELECT_TARGET_RIGHT)
CONFIG.plate_front_lock_key = 118
-- The default full keyboard key to lock/unlock the front plate reader is 118 (Numpad 9 - INPUT_VEH_FLY_SELECT_TARGET_RIGHT)
plate_front_lock = 118,
-- Plate reader rear lock/unlock Key
-- The default key to lock/unlock the rear plate reader is 109 (Numpad 6 - INPUT_VEH_FLY_ROLL_RIGHT_ONLY)
CONFIG.plate_rear_lock_key = 109
-- The default full keyboard key to lock/unlock the rear plate reader is 109 (Numpad 6 - INPUT_VEH_FLY_ROLL_RIGHT_ONLY)
plate_rear_lock = 109
},
-- Keys for smaller keyboards
[ "small" ] = {
-- Radar front antenna lock/unlock Key
-- The default small keyboard key to lock/unlock the front antenna is 157 (1 - INPUT_SELECT_WEAPON_UNARMED)
front_lock = 157,
-- Radar rear antenna lock/unlock Key
-- The default small keyboard key to lock/unlock the rear antenna is 158 (2 - INPUT_SELECT_WEAPON_MELEE)
rear_lock = 158,
-- Plate reader front lock/unlock Key
-- The default small keyboard key to lock/unlock the front plate reader is 160 (3 - INPUT_SELECT_WEAPON_SHOTGUN)
plate_front_lock = 160,
-- Plate reader rear lock/unlock Key
-- The default small keyboard key to lock/unlock the rear plate reader is 164 (4 - INPUT_SELECT_WEAPON_HEAVY)
plate_rear_lock = 164
}
}
-- Radar fast limit locking
-- When enabled, the player will be able to define a fast limit within the radar's menu, when a vehicle

View File

@@ -958,7 +958,7 @@ button:focus { outline: none; }
padding: 0;
}
#keyLockLabel {
#keyLockLabel, #keyBindsLabel {
position: absolute;
left: 0;
right: 0;
@@ -967,12 +967,12 @@ button:focus { outline: none; }
text-align: center;
font-size: 30px;
color: rgb( 200, 200, 200 );
color: rgb(255, 255, 255);
text-shadow: 3px 2px 5px rgb( 0, 0, 0 );
z-index: 5;
}
#keyLockLabel span {
#keyLockLabel span, #keyBindsLabel span {
font-size: 30px;
}

View File

@@ -268,6 +268,8 @@
<p id="keyLockLabel">Radar key lock <span id="keyLockStateLabel"></span></p>
<p id="keyBindsLabel">Radar keybinds set for a <span id="keyBindsStateLabel"></span></p>
<div id="helpWindow">
<iframe id="helpWeb" src="about:blank"></iframe>
<button id="closeHelp" class="close">CLOSE HELP</button>

View File

@@ -118,6 +118,11 @@ const elements =
stateLabel: $( "#keyLockStateLabel" )
},
keyBinds: {
label: $( "#keyBindsLabel" ),
stateLabel: $( "#keyBindsStateLabel" )
},
patrolSpeed: $( "#patrolSpeed" ),
antennas: {
@@ -196,6 +201,7 @@ elements.plateReader.hide();
elements.plateReaderBox.hide();
elements.uiSettingsBox.hide();
elements.keyLock.label.hide();
elements.keyBinds.label.hide();
elements.helpWindow.hide();
// Sets the action for the "UI SETTINGS" button on the remote to open the UI settings box
@@ -304,7 +310,7 @@ function setAntennaDirs( ant, dir, fastDir )
}
// sets the plate lock light for the given plate reader
function setPlateLock( cam, state )
function setPlateLock( cam, state, isBolo )
{
// Get the plate reader lock object
let obj = elements.plates[cam];
@@ -313,12 +319,15 @@ function setPlateLock( cam, state )
if ( state ) {
obj.lock.addClass( "active" );
// Only flash the plate if it was a BOLO plate
if ( isBolo ) {
// Make the hit plate flash for 3 seconds, acts as a visual aid
obj.plate.addClass( "plate_hit" );
setTimeout( function() {
obj.plate.removeClass( "plate_hit" );
}, 3000 );
}
} else {
obj.lock.removeClass( "active" );
}
@@ -563,6 +572,20 @@ function displayKeyLock( state )
}, 2000 );
}
function displayKeybindState( state )
{
// Set the state label text to enabled or disabled
elements.keyBinds.stateLabel.html( state ? "full keyboard" : "small keyboard" );
// Fade in the label
elements.keyBinds.label.fadeIn();
// Make the label fade out after 2 seconds
setTimeout( function() {
elements.keyBinds.label.fadeOut();
}, 2000 );
}
// This function is used to send data back through to the LUA side
function sendData( name, data ) {
$.post( "http://" + resourceName + "/" + name, JSON.stringify( data ), function( datab ) {
@@ -981,6 +1004,9 @@ window.addEventListener( "message", function( event ) {
case "displayKeyLock":
displayKeyLock( item.state );
break;
case "displayKeybindChange":
displayKeybindState( item.state );
return;
// Radar events
case "openRemote":
@@ -1026,7 +1052,7 @@ window.addEventListener( "message", function( event ) {
setPlate( item.cam, item.plate, item.index );
break;
case "lockPlate":
setPlateLock( item.cam, item.state );
setPlateLock( item.cam, item.state, item.isBolo );
break;
// Audio events