Fixed xmit and mode working when powering up

This commit is contained in:
Dan
2020-02-28 22:51:45 +00:00
parent e8d6ab1689
commit b3e7e87a25

View File

@@ -1351,53 +1351,59 @@ end )
-- Runs when the user presses any of the antenna mode buttons on the remote -- Runs when the user presses any of the antenna mode buttons on the remote
RegisterNUICallback( "setAntennaMode", function( data ) RegisterNUICallback( "setAntennaMode", function( data )
-- As the mode buttons are used to exit the menu, we check for that -- Only run the codw if the radar has power and is not powering up
if ( RADAR:IsPowerOn() and RADAR:IsMenuOpen() ) then if ( RADAR:IsPowerOn() and not RADAR:IsPoweringUp() ) then
-- Set the internal menu state to be closed (false) -- As the mode buttons are used to exit the menu, we check for that
RADAR:SetMenuState( false ) if ( RADAR:IsMenuOpen() ) then
-- Set the internal menu state to be closed (false)
RADAR:SetMenuState( false )
-- Send a setting update to the NUI side -- Send a setting update to the NUI side
RADAR:SendSettingUpdate() RADAR:SendSettingUpdate()
-- Play a menu done beep -- Play a menu done beep
SendNUIMessage( { _type = "audio", name = "done", vol = RADAR:GetSettingValue( "beep" ) } ) SendNUIMessage( { _type = "audio", name = "done", vol = RADAR:GetSettingValue( "beep" ) } )
else else
-- Change the mode for the designated antenna, pass along a callback which contains data from this NUI callback -- Change the mode for the designated antenna, pass along a callback which contains data from this NUI callback
RADAR:SetAntennaMode( data.value, tonumber( data.mode ), function() RADAR:SetAntennaMode( data.value, tonumber( data.mode ), function()
-- Update the interface with the new mode -- Update the interface with the new mode
SendNUIMessage( { _type = "antennaMode", ant = data.value, mode = tonumber( data.mode ) } ) SendNUIMessage( { _type = "antennaMode", ant = data.value, mode = tonumber( data.mode ) } )
-- Play a beep -- Play a beep
SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } ) SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } )
end ) end )
end end
end
end ) end )
-- Runs when the user presses either of the XMIT/HOLD buttons on the remote -- Runs when the user presses either of the XMIT/HOLD buttons on the remote
RegisterNUICallback( "toggleAntenna", function( data ) RegisterNUICallback( "toggleAntenna", function( data )
-- As the xmit/hold buttons are used to change settings in the menu, we check for that -- Only run the codw if the radar has power and is not powering up
if ( RADAR:IsPowerOn() and RADAR:IsMenuOpen() ) then if ( RADAR:IsPowerOn() and not RADAR:IsPoweringUp() ) then
-- Change the menu option based on which button is pressed -- As the xmit/hold buttons are used to change settings in the menu, we check for that
RADAR:ChangeMenuOption( data.value ) if ( RADAR:IsMenuOpen() ) then
-- Change the menu option based on which button is pressed
RADAR:ChangeMenuOption( data.value )
-- Play a beep noise -- Play a beep noise
SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } ) SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } )
else else
-- Toggle the transmit state for the designated antenna, pass along a callback which contains data from this NUI callback -- Toggle the transmit state for the designated antenna, pass along a callback which contains data from this NUI callback
RADAR:ToggleAntenna( data.value, function() RADAR:ToggleAntenna( data.value, function()
-- Update the interface with the new antenna transmit state -- Update the interface with the new antenna transmit state
SendNUIMessage( { _type = "antennaXmit", ant = data.value, on = RADAR:IsAntennaTransmitting( data.value ) } ) SendNUIMessage( { _type = "antennaXmit", ant = data.value, on = RADAR:IsAntennaTransmitting( data.value ) } )
-- Play some audio specific to the transmit state -- Play some audio specific to the transmit state
SendNUIMessage( { _type = "audio", name = RADAR:IsAntennaTransmitting( data.value ) and "xmit_on" or "xmit_off", vol = RADAR:GetSettingValue( "beep" ) } ) SendNUIMessage( { _type = "audio", name = RADAR:IsAntennaTransmitting( data.value ) and "xmit_on" or "xmit_off", vol = RADAR:GetSettingValue( "beep" ) } )
end ) end )
end end
end
end ) end )
-- Runs when the user presses the menu button on the remote control -- Runs when the user presses the menu button on the remote control
RegisterNUICallback( "menu", function() RegisterNUICallback( "menu", function()
-- Only run the codw if the radar has power -- Only run the codw if the radar has power and is not powering up
if ( RADAR:IsPowerOn() ) then if ( RADAR:IsPowerOn() and not RADAR:IsPoweringUp() ) then
-- As the menu button is a multipurpose button, we first check to see if the menu is already open -- As the menu button is a multipurpose button, we first check to see if the menu is already open
if ( RADAR:IsMenuOpen() ) then if ( RADAR:IsMenuOpen() ) then
-- As the menu is already open, we then iterate to the next option in the settings list -- As the menu is already open, we then iterate to the next option in the settings list