From 21e9fc9b6b5940497bf5ed9fd7e4a08f8b2010f8 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 26 Nov 2019 10:56:52 +0000 Subject: [PATCH] Remote opens on F5, closes on Esc, updated functions and other stuff --- cl_radar.lua | 29 +++++++++++++++----- nui/radar.css | 3 +++ nui/radar.html | 4 +-- nui/radar.js | 73 ++++++++++++++++++++++++++++++++++++-------------- 4 files changed, 81 insertions(+), 28 deletions(-) diff --git a/cl_radar.lua b/cl_radar.lua index 8e63ed0..6d35ea9 100644 --- a/cl_radar.lua +++ b/cl_radar.lua @@ -17,15 +17,14 @@ local pairs = pairs Resource Rename Fix - for those muppets who rename the resource and complain that the NUI aspect doesn't work! ------------------------------------------------------------------------]]-- -Citizen.CreateThread( function() - -- Wait for a short period of time to give the resource time to load - Citizen.Wait( 10000 ) - +Citizen.SetTimeout( 5000, function() -- Get the name of the resource, for example the default name is 'wk_wrs2' - local resourceName = GetCurrentResourceName() + local name = GetCurrentResourceName() + + print( "WK_WARS2X: Sending resource name (" .. name .. ") to JavaScript side." ) -- Send a message through the NUI system to the JavaScript file to give the name of the resource - SendNUIMessage( { resourcename = resourceName } ) + SendNUIMessage( { pathName = name } ) end ) @@ -640,10 +639,16 @@ end -- Num7 = 117 - INPUT_VEH_FLY_SELECT_TARGET_LEFT -- Num8 = 111 - INPUT_VEH_FLY_PITCH_UP_ONLY -- Num9 = 118 - INPUT_VEH_FLY_SELECT_TARGET_RIGHT +-- F5 = 166 - INPUT_SELECT_CHARACTER_MICHAEL function RADAR:RunControlManager() -- 'Z' key, toggles debug mode if ( IsDisabledControlJustPressed( 1, 20 ) ) then self.config.debug_mode = not self.config.debug_mode + end + + if ( IsDisabledControlJustPressed( 1, 166 ) ) then + SendNUIMessage( { activateRemote = true } ) + SetNuiFocus( true, true ) end -- 'X' key, change the sort mode @@ -675,6 +680,16 @@ function RADAR:RunControlManager() end +--[[------------------------------------------------------------------------ + NUI callback +------------------------------------------------------------------------]]-- +RegisterNUICallback( "remote", function( data, cb ) + if ( data == "close" ) then + SetNuiFocus( false, false ) + end +end ) + + --[[------------------------------------------------------------------------ Main function ------------------------------------------------------------------------]]-- @@ -738,6 +753,8 @@ end ) -- Main thread Citizen.CreateThread( function() + SetNuiFocus( false, false ) + while ( true ) do RADAR:Main() diff --git a/nui/radar.css b/nui/radar.css index 7a4e822..68ced45 100644 --- a/nui/radar.css +++ b/nui/radar.css @@ -19,6 +19,9 @@ box-sizing: border-box; } +/* Removes the outline when buttons have been clicked */ +button:focus { outline: none; } + .unit_frame { width: 715px; height: 230px; diff --git a/nui/radar.html b/nui/radar.html index a94b025..2d261ef 100644 --- a/nui/radar.html +++ b/nui/radar.html @@ -4,7 +4,7 @@ - -