local lg = assert( love.graphics ) local scene = assert( require 'client.scene' ) local textInput = assert( require 'client.ui.textinput' ) local button = assert( require 'client.ui.button' ) local browser = {} local ti = textInput.new{ width = 300, length = 20, x = 15, y = 165 } function browser.draw() lg.setColor( 1, 1, 1, 1 ) lg.print( "Server Browser", 15, 115 ) ti:draw() end function browser.update( dt ) end function browser.onLoad( ) lg.setColor( 1, 1, 1, 1 ) end function browser.mousepressed(x, y, button, istouch, pressed) if ti:contains( x, y ) then return ti:enterText( browser.joinIPString ) end end function browser.joinIPString( s ) --Parse IP address and port from string. If it's valid, join the server. if not s then return end ti:clear() local valid, ip, port if valid then return browser.joinIP( ip, port ) end end function browser.joinIP( ip, port ) return scene.game{ serverIP = ip, serverPort = port } end function browser.keypressed( key, code, isRepeat ) if code == "escape" then return scene.mainmenu() end if code == "return" then return ti:enterText( browser.joinIPString ) end end scene.browser = browser return browser