mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 00:16:27 +02:00
Directional arrows now work
This commit is contained in:
@@ -721,11 +721,17 @@ function RADAR:Main()
|
|||||||
data.antennas[ant] = {}
|
data.antennas[ant] = {}
|
||||||
|
|
||||||
for i = 1, 2 do
|
for i = 1, 2 do
|
||||||
data.antennas[ant][i] = { speed = "¦¦¦" }
|
data.antennas[ant][i] = { speed = "¦¦¦", dir = 0 }
|
||||||
|
|
||||||
-- The vehicle data exists for this slot
|
-- The vehicle data exists for this slot
|
||||||
if ( av[ant][i] ~= nil ) then
|
if ( av[ant][i] ~= nil ) then
|
||||||
|
-- We already have the vehicle speed as we needed it earlier on for filtering
|
||||||
data.antennas[ant][i].speed = UTIL:FormatSpeed( self:GetVehSpeedFormatted( av[ant][i].speed ) )
|
data.antennas[ant][i].speed = UTIL:FormatSpeed( self:GetVehSpeedFormatted( av[ant][i].speed ) )
|
||||||
|
|
||||||
|
-- Work out if the vehicle is closing or away
|
||||||
|
local ownH = GetEntityHeading( PLY.veh )
|
||||||
|
local tarH = GetEntityHeading( av[ant][i].veh )
|
||||||
|
data.antennas[ant][i].dir = UTIL:GetEntityRelativeDirection( ownH, tarH, 120 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
34
nui/radar.js
34
nui/radar.js
@@ -25,8 +25,10 @@ const elements =
|
|||||||
targetSpeed: $( "#frontSpeed" ),
|
targetSpeed: $( "#frontSpeed" ),
|
||||||
|
|
||||||
dirs: {
|
dirs: {
|
||||||
forward: $( "#frontDirAway" ),
|
fwd: $( "#frontDirAway" ),
|
||||||
backward: $( "#frontDirTowards" )
|
bwd: $( "#frontDirTowards" ),
|
||||||
|
fwdFast: $( "#frontFastDirAway" ),
|
||||||
|
bwdFast: $( "#frontFastDirTowards" )
|
||||||
},
|
},
|
||||||
|
|
||||||
modes: {
|
modes: {
|
||||||
@@ -46,8 +48,10 @@ const elements =
|
|||||||
targetSpeed: $( "#rearSpeed" ),
|
targetSpeed: $( "#rearSpeed" ),
|
||||||
|
|
||||||
dirs: {
|
dirs: {
|
||||||
forward: $( "#rearDirTowards" ),
|
fwd: $( "#rearDirTowards" ),
|
||||||
backward: $( "#rearDirAway" )
|
bwd: $( "#rearDirAway" ),
|
||||||
|
fwdFast: $( "#rearFastDirTowards" ),
|
||||||
|
bwdFast: $( "#rearFastDirAway" )
|
||||||
},
|
},
|
||||||
|
|
||||||
modes: {
|
modes: {
|
||||||
@@ -96,6 +100,13 @@ const antennaModes =
|
|||||||
both: 3
|
both: 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const dirs =
|
||||||
|
{
|
||||||
|
none: 0,
|
||||||
|
closing: 1,
|
||||||
|
away: 2
|
||||||
|
}
|
||||||
|
|
||||||
// Hide the radar and remote, this way we can bypass setting a style of 'display: none;' in the HTML file
|
// Hide the radar and remote, this way we can bypass setting a style of 'display: none;' in the HTML file
|
||||||
// elements.radar.hide();
|
// elements.radar.hide();
|
||||||
elements.remote.hide();
|
elements.remote.hide();
|
||||||
@@ -115,9 +126,9 @@ function setLight( ant, cat, item, state )
|
|||||||
let obj = elements.antennas[ant][cat][item];
|
let obj = elements.antennas[ant][cat][item];
|
||||||
|
|
||||||
if ( state ) {
|
if ( state ) {
|
||||||
obj.addClass( "active" );
|
if ( cat == "dirs" ) { obj.addClass( "active_arrow" ) } else { obj.addClass( "active" ) };
|
||||||
} else {
|
} else {
|
||||||
obj.removeClass( "active" );
|
if ( cat == "dirs" ) { obj.removeClass( "active_arrow" ) } else { obj.removeClass( "active" ) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +144,15 @@ function setAntennaXmit( ant, state )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setAntennaDirs( ant, dir, fastDir )
|
||||||
|
{
|
||||||
|
setLight( ant, "dirs", "fwd", dir == dirs.closing );
|
||||||
|
setLight( ant, "dirs", "bwd", dir == dirs.away );
|
||||||
|
|
||||||
|
setLight( ant, "dirs", "fwdFast", fastDir == dirs.closing );
|
||||||
|
setLight( ant, "dirs", "bwdFast", fastDir == dirs.away );
|
||||||
|
}
|
||||||
|
|
||||||
function updateDisplays( ps, ants )
|
function updateDisplays( ps, ants )
|
||||||
{
|
{
|
||||||
elements.patrolSpeed.html( ps );
|
elements.patrolSpeed.html( ps );
|
||||||
@@ -142,6 +162,8 @@ function updateDisplays( ps, ants )
|
|||||||
if ( ants[ant] != null ) {
|
if ( ants[ant] != null ) {
|
||||||
elements.antennas[ant].targetSpeed.html( ants[ant][0].speed );
|
elements.antennas[ant].targetSpeed.html( ants[ant][0].speed );
|
||||||
elements.antennas[ant].fast.speed.html( ants[ant][1].speed );
|
elements.antennas[ant].fast.speed.html( ants[ant][1].speed );
|
||||||
|
|
||||||
|
setAntennaDirs( ant, ants[ant][0].dir, ants[ant][1].dir );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user