add keyboard control to server browser
This commit is contained in:
parent
aa64929f8e
commit
08c27ba610
|
@ -2,7 +2,7 @@ local scene = assert( require 'client.scene' )
|
|||
local lg = assert( love.graphics )
|
||||
local server = assert( require 'client.udp' )
|
||||
local button = assert( require 'client.ui.button' )
|
||||
local strings = assert( require 'client.assets.strings.strings' )
|
||||
local strings = assert( require 'client.strings' )
|
||||
local connecting = {}
|
||||
|
||||
local time, ip, port, attempts = 0, 0, 0, 0
|
||||
|
|
|
@ -4,7 +4,7 @@ local textInput = assert( require 'client.ui.textinput' )
|
|||
local button = assert( require 'client.ui.button' )
|
||||
local packet = assert( require 'shared.packet' )
|
||||
local menu = assert( require 'client.ui.menu' )
|
||||
local strings = assert( require 'client.assets.strings.strings' )
|
||||
local strings = assert( require 'client.strings' )
|
||||
local fonts = assert( require 'client.ui.fonts' )
|
||||
local utf8 = assert( require 'utf8' )
|
||||
|
||||
|
@ -120,7 +120,7 @@ function serverList.refresh( serverInfo )
|
|||
b.w = lg.getWidth()
|
||||
b.y = 27 * i + 145
|
||||
b.h = 24
|
||||
b.color = { 0.3 + 0.1 * (n % 2), 0.3 + 0.1 * (n % 2), 0.8, 0.5 }
|
||||
b.color = { 0.3 + 0.1 * (n % 2), 0.3 + 0.1 * (n % 2), 0.8, 0.3 }
|
||||
b.callback = joinServerCallback
|
||||
b.serverInfo = server
|
||||
b.ip = tostring( server.ip )
|
||||
|
@ -160,7 +160,7 @@ function serverList.scroll( up )
|
|||
if up and serverButtons[ #headerButtons + 1 ].y > minY then return end
|
||||
if ( not up ) and serverButtons[ #serverButtons ].y < maxY then return end
|
||||
|
||||
up = 10 * ( up and 1 or -1 )
|
||||
up = ( 27 / 3 ) * ( up and 1 or -1 )
|
||||
for i = #headerButtons + 1, #serverButtons do
|
||||
local sb = serverButtons[i]
|
||||
sb.y = sb.y + up
|
||||
|
@ -219,8 +219,21 @@ function browser.joinIP( ip, port )
|
|||
end
|
||||
|
||||
function browser.keypressed( key, code, isRepeat )
|
||||
|
||||
local y = serverList.getSelectedButton()
|
||||
|
||||
if code == "escape" then return scene.mainmenu() end
|
||||
|
||||
if y and code == "down" and y.y > lg.getHeight() - 100 then
|
||||
for i = 1, 3 do serverList.scroll( false ) end
|
||||
end
|
||||
|
||||
if y and code == "up" and y.y > 180 and y.y < 250 then
|
||||
for i = 1, 3 do serverList.scroll( true ) end
|
||||
end
|
||||
|
||||
return serverList.keypressed( key, code, isRepeat )
|
||||
|
||||
end
|
||||
|
||||
scene.browser = browser
|
||||
|
|
|
@ -5,5 +5,5 @@ local lgnf = love.graphics.newFont
|
|||
return {
|
||||
font = lgnf( "client/assets/fonts/Montserrat-Bold.ttf", 14 ),
|
||||
midFont = lgnf( "client/assets/fonts/Montserrat-Bold.ttf", 24 ),
|
||||
headerFont = lgnf( "client/assets/fonts/Montserrat-Bold.ttf", 36 )
|
||||
headerFont = lgnf( "client/assets/fonts/Montserrat-Bold.ttf", 48 )
|
||||
}
|
|
@ -15,23 +15,12 @@ local svInfo = packet.serverInfo{ version = 13,
|
|||
|
||||
local server = {
|
||||
tick = 0,
|
||||
logFile = assert( io.open( "../logs/serverLog.txt", "a" ) ),
|
||||
}
|
||||
|
||||
local msIP, msPort = socket.dns.toip(socket.dns.gethostname()), 42069
|
||||
|
||||
local clients = {}
|
||||
|
||||
do
|
||||
local _print = print
|
||||
function server.Print(...)
|
||||
_print( os.date("!%Y-%m-%d %X"), ... )
|
||||
--server.logFile:write( table.concat({ ... }, "\t"), "\n" )
|
||||
end
|
||||
end
|
||||
local print = server.Print
|
||||
|
||||
|
||||
--Developer convenience function: start the local client program.
|
||||
function server.StartLocalClient()
|
||||
os.execute( "start vision.bat" )
|
||||
|
@ -78,7 +67,7 @@ function server.Start()
|
|||
udp:settimeout(0)
|
||||
server.SetIP( socket.dns.toip(socket.dns.gethostname()), 51312 )
|
||||
assert( udp:setsockname( tostring( svInfo.ip ), svInfo.port ))
|
||||
print( "Start." )
|
||||
print( "Server started:", udp:getsockname() )
|
||||
repeat
|
||||
server.Parse( udp:receivefrom() )
|
||||
server.Advance()
|
||||
|
|
Loading…
Reference in New Issue