Compare commits
No commits in common. "4a7be75dfa2a895abbc6441b86bb46603785d434" and "dc6cdf123e25bfa0b02a80f4b840b1e1937860a2" have entirely different histories.
4a7be75dfa
...
dc6cdf123e
25
build.sh
25
build.sh
|
@ -1,33 +1,10 @@
|
||||||
#get locations of scripts, libraries, engine
|
|
||||||
SRC_DIR="src"
|
SRC_DIR="src"
|
||||||
LIB_DIR="lib"
|
|
||||||
LOVE_DIR="../../love"
|
LOVE_DIR="../../love"
|
||||||
BUILD_DIR="build"
|
BUILD_DIR="build"
|
||||||
|
|
||||||
#build LuaJIT for target platform
|
|
||||||
|
|
||||||
|
|
||||||
#build LuaSocket shared library for target platform
|
|
||||||
|
|
||||||
|
|
||||||
#get appropriate copy of love
|
|
||||||
|
|
||||||
|
|
||||||
#zip client scripts into .love file
|
|
||||||
cp -r $SRC_DIR/ $BUILD_DIR/
|
cp -r $SRC_DIR/ $BUILD_DIR/
|
||||||
cd $BUILD_DIR/
|
cd $BUILD_DIR/
|
||||||
zip -9 -r vision.love
|
zip -9 -r vision.love
|
||||||
|
|
||||||
#zip .love file with LOVE and dependencies (and license!)
|
|
||||||
|
|
||||||
|
|
||||||
#zip server scripts with LuaJIT and dependencies
|
|
||||||
|
|
||||||
|
|
||||||
#zip metaserver with LuaJIT and dependencies
|
|
||||||
|
|
||||||
|
|
||||||
#WINDOWS: make fused client executable
|
|
||||||
cat ../../love/love.exe vision.love > vision.exe
|
cat ../../love/love.exe vision.love > vision.exe
|
||||||
|
|
||||||
#LINUX: get official LOVE AppImage
|
|
|
@ -8,13 +8,4 @@ return setmetatable({
|
||||||
["option_pron"] = "Player Pronouns",
|
["option_pron"] = "Player Pronouns",
|
||||||
["option_tint"] = "Player Colour",
|
["option_tint"] = "Player Colour",
|
||||||
["option_keybinds"] = "Edit Keybindings",
|
["option_keybinds"] = "Edit Keybindings",
|
||||||
["utf8_error"] = "??? what is this",
|
|
||||||
["server_browser"] = "Server Browser",
|
|
||||||
["ip_button"] = "Enter IP:",
|
|
||||||
["svinfo_name"] = "Server Name",
|
|
||||||
["svinfo_map"] = "Current Map",
|
|
||||||
["svinfo_players"] = "In",
|
|
||||||
["svinfo_capacity"] = "Max",
|
|
||||||
["svinfo_ip"] = "IP",
|
|
||||||
["svinfo_port"] = "Port",
|
|
||||||
}, {__index = function( t, k ) return k end } )
|
}, {__index = function( t, k ) return k end } )
|
|
@ -1,3 +0,0 @@
|
||||||
--TODO: check config option for current language, dynamically change it?
|
|
||||||
local utf8 = assert( require 'utf8' )
|
|
||||||
return require 'client.assets.strings.english'
|
|
|
@ -11,7 +11,7 @@ return {
|
||||||
chat = "t",
|
chat = "t",
|
||||||
love = "q",
|
love = "q",
|
||||||
hate = "e",
|
hate = "e",
|
||||||
},
|
}
|
||||||
serverIP = "192.168.2.15",
|
serverIP = "192.168.2.15",
|
||||||
serverPort = 51312,
|
serverPort = 51312,
|
||||||
}
|
}
|
|
@ -3,18 +3,13 @@ local lg = assert( love.graphics )
|
||||||
local server = assert( require 'client.udp' )
|
local server = assert( require 'client.udp' )
|
||||||
local connecting = {}
|
local connecting = {}
|
||||||
|
|
||||||
local time, ip, port
|
local time, ip, port = 0
|
||||||
|
|
||||||
function connecting.draw()
|
function connecting.draw()
|
||||||
lg.setColor( 1,1,1,1 )
|
lg.print( "Connecting to server:\t"..time, 0, 0, 0 )
|
||||||
lg.print( ("CONNECTING:\nTIME: %1.1fs\nADDRESS: %s:%d"):format(time, ip, port), 0, 0, 0 )
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function connecting.keypressed(key, code, isrepeat)
|
|
||||||
if code == "escape" then return scene.browser() end
|
|
||||||
end
|
|
||||||
|
|
||||||
function connecting.update(dt)
|
function connecting.update(dt)
|
||||||
time = time + dt
|
time = time + dt
|
||||||
|
|
||||||
|
@ -25,12 +20,8 @@ function connecting.update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function connecting:onLoad( params )
|
function connecting:onLoad( params )
|
||||||
lg.setCanvas()
|
params = params or { ip = "127.0.0.0", port = 8 }
|
||||||
time = 0
|
local ip, port = params.ip, params.port
|
||||||
print( "connecting:", params, self.ip, self.port )
|
|
||||||
for k, v in pairs( self ) do print( k,v ) end
|
|
||||||
params = params or { ip = "8.8.8.8", port = 8 }
|
|
||||||
ip, port = params.ip, params.port
|
|
||||||
return server.connect( ip, port )
|
return server.connect( ip, port )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ function game.disconnect( )
|
||||||
end
|
end
|
||||||
|
|
||||||
function game.onLoad( params )
|
function game.onLoad( params )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function game.keypressed( key, code, isRepeat )
|
function game.keypressed( key, code, isRepeat )
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
local packet = assert( require 'shared.packet' )
|
|
||||||
local ipString = assert( require 'shared.ipstring' )
|
|
||||||
local utf8 = assert( require 'utf8' )
|
|
||||||
local r = math.random
|
|
||||||
local rand = function() return r( 1, 255 ) end
|
|
||||||
local rs = function()
|
|
||||||
local t = {}
|
|
||||||
for i = 1, r( 0, 64 ) do t[i] = rand() end
|
|
||||||
return string.char( unpack( t ) )
|
|
||||||
end
|
|
||||||
local rutf8 = function()
|
|
||||||
local t = {}
|
|
||||||
for i = 1, r( 0, 64 ) do t[i] = r( 30, 1234 ) end
|
|
||||||
|
|
||||||
local s = utf8.char( unpack( t ) )
|
|
||||||
return s
|
|
||||||
end
|
|
||||||
local randserver = function()
|
|
||||||
local str = rutf8
|
|
||||||
return packet.serverInfo{
|
|
||||||
players = rand(),
|
|
||||||
capacity = rand(),
|
|
||||||
ip = ipString.new{ rand(), rand(), rand(), rand() },
|
|
||||||
port = r( 1, 65535 ),
|
|
||||||
version = 25,
|
|
||||||
svname = str(),
|
|
||||||
map = str(),
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
|
||||||
|
|
||||||
--Simulate getting server info from the metaserver.
|
|
||||||
getTestServers = function()
|
|
||||||
packet.get()
|
|
||||||
for i = 1, r( 1, 128 ) do randserver() end
|
|
||||||
return packet.deserialise( packet.get() )
|
|
||||||
end
|
|
||||||
}
|
|
|
@ -3,84 +3,94 @@ local scene = assert( require 'client.scene' )
|
||||||
local textInput = assert( require 'client.ui.textinput' )
|
local textInput = assert( require 'client.ui.textinput' )
|
||||||
local button = assert( require 'client.ui.button' )
|
local button = assert( require 'client.ui.button' )
|
||||||
local packet = assert( require 'shared.packet' )
|
local packet = assert( require 'shared.packet' )
|
||||||
local menu = assert( require 'client.ui.menu' )
|
local ipString = assert( require 'shared.ipstring' )
|
||||||
local strings = assert( require 'client.assets.strings.strings' )
|
|
||||||
local utf8 = assert( require 'utf8' )
|
|
||||||
local gs = function( d )
|
|
||||||
local s = packet.getString( d )
|
|
||||||
local valid, trip = utf8.len( s )
|
|
||||||
return valid and s or --Regurgitate name.
|
|
||||||
( trip > 1 ) and s:sub( 1, trip - 1 ) or --Attempt truncation to initial valid utf8 sequence.
|
|
||||||
strings.utf8_error --Return fallback string indicating garbled mess.
|
|
||||||
end
|
|
||||||
local browser = {}
|
local browser = {}
|
||||||
|
|
||||||
local test = assert( require 'client.test.browser' )
|
local font = lg.newFont( "client/assets/fonts/Montserrat-Bold.ttf", 20 )
|
||||||
|
|
||||||
local font = lg.newFont( "client/assets/fonts/Montserrat-Bold.ttf", 12 )
|
local function populateTestServers()
|
||||||
local headerFont = lg.newFont( "client/assets/fonts/Montserrat-Bold.ttf", 36 )
|
packet.get()
|
||||||
local midFont = lg.newFont( "client/assets/fonts/Montserrat-Bold.ttf", 24 )
|
packet.serverInfo{
|
||||||
|
players = 24,
|
||||||
local function joinServerCallback( button )
|
capacity = 255,
|
||||||
if button.ip and button.port then
|
ip = ipString.new{ 123, 456, 789, 101 },
|
||||||
return browser.joinIP( button.ip, button.port )
|
port = 51312,
|
||||||
end
|
version = 25,
|
||||||
|
svname = "test server",
|
||||||
|
map = "testMap_01",
|
||||||
|
}
|
||||||
|
packet.serverInfo{
|
||||||
|
players = 24,
|
||||||
|
capacity = 255,
|
||||||
|
ip = ipString.new{ 123, 456, 789, 101 },
|
||||||
|
port = 51312,
|
||||||
|
version = 25,
|
||||||
|
svname = "test server",
|
||||||
|
map = "testMap_02",
|
||||||
|
}
|
||||||
|
packet.serverInfo{
|
||||||
|
players = 24,
|
||||||
|
capacity = 255,
|
||||||
|
ip = ipString.new{ 150, 645, 151, 67 },
|
||||||
|
port = 51312,
|
||||||
|
version = 25,
|
||||||
|
svname = "test server",
|
||||||
|
map = "testMap_03",
|
||||||
|
}
|
||||||
|
packet.serverInfo{
|
||||||
|
players = 24,
|
||||||
|
capacity = 255,
|
||||||
|
ip = ipString.new{ 123, 456, 789, 101 },
|
||||||
|
port = 51312,
|
||||||
|
version = 25,
|
||||||
|
svname = "test server",
|
||||||
|
map = "testMap_01",
|
||||||
|
}
|
||||||
|
return packet.deserialise( packet.get() )
|
||||||
end
|
end
|
||||||
|
local serverList = {}
|
||||||
local serverButtons = test.getTestServers()
|
serverList.servers = populateTestServers()
|
||||||
do
|
serverList.offsets = {
|
||||||
local cw = font:getWidth( "w" )
|
15,
|
||||||
|
50,
|
||||||
|
150,
|
||||||
local headerText = lg.newText( font )
|
100,
|
||||||
headerText:add( strings.svinfo_name, 0 )
|
100,
|
||||||
headerText:add( strings.svinfo_map, cw * 16 )
|
50,
|
||||||
headerText:add( strings.svinfo_ip, cw * 32 )
|
50
|
||||||
headerText:add( strings.svinfo_port, cw * ( 32 + 12 ) )
|
|
||||||
headerText:add( strings.svinfo_players, cw * ( 32 + 12 + 6 ) )
|
|
||||||
headerText:add( strings.svinfo_capacity, cw * ( 32 + 12 + 9 ) )
|
|
||||||
local headerButton = button{
|
|
||||||
space = 15, y = 135, text = headerText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, server in ipairs( serverButtons ) do
|
|
||||||
local text = lg.newText( font )
|
|
||||||
text:add( gs( server.svname ), 0 )
|
|
||||||
text:add( gs( server.map ), cw * 16 )
|
|
||||||
text:add( tostring( server.ip ), cw * 32 )
|
|
||||||
text:add( server.port, cw * ( 32 + 12 ) )
|
|
||||||
text:add( server.players, cw * ( 32 + 12 + 6 ) )
|
|
||||||
text:add( server.capacity, cw * ( 32 + 12 + 9 ) )
|
|
||||||
|
|
||||||
serverButtons[i] = button{ space = 0,
|
|
||||||
ip = tostring( server.ip ),
|
|
||||||
port = server.port,
|
|
||||||
text = text,
|
|
||||||
callback = joinServerCallback,
|
|
||||||
color = { 0.3 + 0.1 * (i % 2), 0.3 + 0.1 * (i % 2), 0.8, 0.5 }}
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert( serverButtons, 1, headerButton )
|
|
||||||
|
|
||||||
end
|
|
||||||
local serverList = menu.new{
|
|
||||||
name = "serverList",
|
|
||||||
buttons = serverButtons,
|
|
||||||
fg = nil,
|
|
||||||
bg = lg.newMesh{
|
|
||||||
{ 0, 0, 0, 0, 0.4, 0.05, 0.0, 0.1 },
|
|
||||||
{ 1, 0, 1, 0, 0.8, 0.3, 0.1, 0.8 },
|
|
||||||
{ 1, 1, 1, 1, 0.7, 0.4, 0.1, 0.8 },
|
|
||||||
{ 0, 1, 0, 1, 0.4, 0.05, 0.05, 0.1 },
|
|
||||||
},
|
|
||||||
|
|
||||||
font = font,
|
|
||||||
subScene = true }
|
|
||||||
serverList.selected = false
|
serverList.selected = false
|
||||||
serverList.x = 25
|
serverList.x = 25
|
||||||
serverList.y = 0
|
serverList.y = 220
|
||||||
serverList.h = 36
|
serverList.h = 36
|
||||||
|
|
||||||
|
function serverList.draw()
|
||||||
|
local gs = packet.getString
|
||||||
|
local x, y, h = serverList.x, serverList.y, serverList.h
|
||||||
|
local oldFont = lg.getFont()
|
||||||
|
lg.setFont( font )
|
||||||
|
for i, svInfo in ipairs( serverList.servers ) do
|
||||||
|
lg.setColor( 0.7, 0.7, 0.7, 0.7 )
|
||||||
|
lg.rectangle( "fill", x, y, 800, h, 5, 5 )
|
||||||
|
|
||||||
|
x = x + 15
|
||||||
|
y = y + 9
|
||||||
|
lg.setColor( 0, 0, 0, 0.7 )
|
||||||
|
lg.print( svInfo.version, x, y )
|
||||||
|
lg.print( gs( svInfo.svname ), 50 + x, y )
|
||||||
|
lg.print( tostring( svInfo.ip ), 200 + x, y )
|
||||||
|
lg.print( svInfo.port, 300 + x, y )
|
||||||
|
lg.print( svInfo.players, 400 + x, y )
|
||||||
|
lg.print( svInfo.capacity, 450 + x, y )
|
||||||
|
lg.print( gs( svInfo.map ), 500 + x, y )
|
||||||
|
y = y - 12
|
||||||
|
x = x - 15
|
||||||
|
y = y + h + 5
|
||||||
|
end
|
||||||
|
lg.setFont( oldFont )
|
||||||
|
end
|
||||||
|
|
||||||
function serverList.select()
|
function serverList.select()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -96,21 +106,15 @@ end
|
||||||
local ti = textInput.new{
|
local ti = textInput.new{
|
||||||
width = 300,
|
width = 300,
|
||||||
length = 20,
|
length = 20,
|
||||||
x = 150,
|
x = 15,
|
||||||
y = 75,
|
y = 175
|
||||||
str = "8.8.8.8:1234"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.selected = false
|
|
||||||
|
|
||||||
function browser.draw()
|
function browser.draw()
|
||||||
serverList.draw()
|
|
||||||
lg.setColor( 1, 1, 1, 1 )
|
lg.setColor( 1, 1, 1, 1 )
|
||||||
lg.setFont( headerFont )
|
lg.print( "Server Browser", 15, 115 )
|
||||||
lg.print( strings.server_browser, 15, 15 )
|
|
||||||
lg.setFont( midFont )
|
|
||||||
lg.print( strings.ip_button, 15, 85 )
|
|
||||||
ti:draw()
|
ti:draw()
|
||||||
|
serverList.draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
function browser.update( dt )
|
function browser.update( dt )
|
||||||
|
@ -118,43 +122,31 @@ function browser.update( dt )
|
||||||
end
|
end
|
||||||
|
|
||||||
function browser.onLoad( )
|
function browser.onLoad( )
|
||||||
serverList:onLoad()
|
|
||||||
lg.setColor( 1, 1, 1, 1 )
|
lg.setColor( 1, 1, 1, 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
function browser.mousemoved( x, y, dx, dy, istouch )
|
|
||||||
return serverList.mousemoved( x, y, dx, dy, istouch )
|
|
||||||
end
|
|
||||||
|
|
||||||
function browser.resize( x, y )
|
|
||||||
return serverList.resize( x, y )
|
|
||||||
end
|
|
||||||
|
|
||||||
function browser.mousepressed(x, y, button, istouch, pressed)
|
function browser.mousepressed(x, y, button, istouch, pressed)
|
||||||
if ti:contains( x, y ) then return ti:enterText( browser.joinIPString ) end
|
if ti:contains( x, y ) then return ti:enterText( browser.joinIPString ) end
|
||||||
return serverList.mousepressed( x, y, button, istouch, pressed )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function browser.joinIPString( s )
|
function browser.joinIPString( s )
|
||||||
--Parse IP address and port from string. If it's valid, join the server.
|
--Parse IP address and port from string. If it's valid, join the server.
|
||||||
print( "browser: entered IP and port", s )
|
print( "browser: Attempting to join server", s )
|
||||||
if not s then return end
|
if not s then return end
|
||||||
ti:clear()
|
ti:clear()
|
||||||
local ip, port = s:match '(%d+%.%d+%.%d+%.%d+)', s:match ':(%d+)'
|
local valid, ip, port
|
||||||
print( "browser:", "ip:", ip, port )
|
|
||||||
|
|
||||||
if ip and port then return browser.joinIP( ip, port ) end
|
if valid then return browser.joinIP( ip, port ) end
|
||||||
end
|
end
|
||||||
|
|
||||||
function browser.joinIP( ip, port )
|
function browser.joinIP( ip, port )
|
||||||
print( "Joining server:", ip, port )
|
print( "Joining server:", ip, port )
|
||||||
return scene.loadScene( scene.connecting, { ip = ip, port = port } )
|
return scene.game{ serverIP = ip, serverPort = port }
|
||||||
end
|
end
|
||||||
|
|
||||||
function browser.keypressed( key, code, isRepeat )
|
function browser.keypressed( key, code, isRepeat )
|
||||||
if code == "escape" then return scene.mainmenu() end
|
if code == "escape" then return scene.mainmenu() end
|
||||||
if code == "return" then return ti:enterText( browser.joinIPString ) end
|
if code == "return" then return ti:enterText( browser.joinIPString ) end
|
||||||
return serverList.keypressed( key, code, isRepeat )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scene.browser = browser
|
scene.browser = browser
|
||||||
|
|
|
@ -16,13 +16,12 @@ function button:new( t )
|
||||||
if t.h then button.h = t.h end
|
if t.h then button.h = t.h end
|
||||||
if t.w then button.w = t.w end
|
if t.w then button.w = t.w end
|
||||||
if t.x then button.x = t.x end
|
if t.x then button.x = t.x end
|
||||||
if t.space then button.space = t.space end
|
|
||||||
|
|
||||||
t.x = t.x or button.x
|
t.x = t.x or button.x
|
||||||
t.y = t.y or button.y
|
t.y = t.y or button.y
|
||||||
t.w = t.w or button.w
|
t.w = t.w or button.w
|
||||||
t.h = t.h or button.h
|
t.h = t.h or button.h
|
||||||
t.text = t.text or lg.newText( lg.getFont(), "button" )
|
t.text = t.text or ""
|
||||||
t.color = t.color or { 0.5, 0.5, 0.5, 0.5 }
|
t.color = t.color or { 0.5, 0.5, 0.5, 0.5 }
|
||||||
t.callback = t.callback or function() print( "Clicked button:", t.text ) end
|
t.callback = t.callback or function() print( "Clicked button:", t.text ) end
|
||||||
t.selected = t.selected or false
|
t.selected = t.selected or false
|
||||||
|
@ -48,9 +47,9 @@ function button:draw( )
|
||||||
end
|
end
|
||||||
|
|
||||||
lg.setColor( 0, 0, 0, 0.8 )
|
lg.setColor( 0, 0, 0, 0.8 )
|
||||||
lg.draw( self.text, self.x + 15, self.y + 6)
|
lg.print( self.text, self.x + 15, self.y + 6)
|
||||||
lg.setColor( 0, 0, 0, 0.2 )
|
lg.setColor( 0, 0, 0, 0.2 )
|
||||||
lg.draw( self.text, self.x + 18, self.y + 8)
|
lg.print( self.text, self.x + 18, self.y + 8)
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable( button, { __call = button.new } )
|
return setmetatable( button, { __call = button.new } )
|
|
@ -5,49 +5,47 @@ local strings = strings or assert( require 'client.assets.strings.english' )
|
||||||
local button = assert( require 'client.ui.button' )
|
local button = assert( require 'client.ui.button' )
|
||||||
local menu = assert( require 'client.ui.menu' )
|
local menu = assert( require 'client.ui.menu' )
|
||||||
|
|
||||||
local font = lg.newFont( "client/assets/fonts/Montserrat-Bold.ttf", 48 )
|
return menu.new(
|
||||||
|
"mainmenu",
|
||||||
|
|
||||||
return menu.new{
|
{
|
||||||
name = "mainmenu",
|
|
||||||
|
|
||||||
buttons = {
|
|
||||||
|
|
||||||
button{
|
button{
|
||||||
x = 15, w = lg.getWidth(), y = 115, h = 72, space = 15,
|
x = 15, w = lg.getWidth(), y = 115, h = 72,
|
||||||
text = lg.newText( font, strings.newgame_button ),
|
text = strings.newgame_button,
|
||||||
color = { 0.6, 0.6, 0.6, 0.9 },
|
color = { 0.6, 0.6, 0.6, 0.9 },
|
||||||
callback = function() return scene.connecting{ip = "127.0.0.0", port = 8} end },
|
callback = function() return scene.connecting() end },
|
||||||
|
|
||||||
button{
|
button{
|
||||||
text = lg.newText( font, strings.join_button ),
|
text = strings.join_button,
|
||||||
color = { 0.6, 0.6, 0.6, 0.9 },
|
color = { 0.6, 0.6, 0.6, 0.9 },
|
||||||
callback = function() return scene.browser() end },
|
callback = function() return scene.browser() end },
|
||||||
|
|
||||||
button{
|
button{
|
||||||
text = lg.newText( font, strings.option_button ),
|
text = strings.option_button,
|
||||||
color = { 0.6, 0.6, 0.6, 0.9 },
|
color = { 0.6, 0.6, 0.6, 0.9 },
|
||||||
callback = function() return scene.options() end },
|
callback = function() return scene.options() end },
|
||||||
|
|
||||||
button{
|
button{
|
||||||
text = lg.newText( font, strings.quit_button ),
|
text = strings.quit_button,
|
||||||
color = { 0.6, 0.6, 0.6, 0.9 },
|
color = { 0.6, 0.6, 0.6, 0.9 },
|
||||||
callback = love.event.quit },
|
callback = love.event.quit },
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
fg = lg.newMesh{
|
lg.newMesh{
|
||||||
{ 0, 0, 0, 0, 0.4, 0.1, 0.05, 0.0 },
|
{ 0, 0, 0, 0, 0.4, 0.1, 0.05, 0.0 },
|
||||||
{ 1, 0, 1, 0, 0.8, 0.3, 0.1, 0.8 },
|
{ 1, 0, 1, 0, 0.8, 0.3, 0.1, 0.8 },
|
||||||
{ 1, 1, 1, 1, 0.7, 0.4, 0.1, 0.8 },
|
{ 1, 1, 1, 1, 0.7, 0.4, 0.1, 0.8 },
|
||||||
{ 0, 1, 0, 1, 0.4, 0.1, 0.03, 0.0 },
|
{ 0, 1, 0, 1, 0.4, 0.1, 0.03, 0.0 },
|
||||||
},
|
},
|
||||||
|
|
||||||
bg = lg.newMesh{
|
lg.newMesh{
|
||||||
{ 0, 0, 0, 0, 0.4, 0.05, 0.0, 0.1 },
|
{ 0, 0, 0, 0, 0.4, 0.05, 0.0, 0.1 },
|
||||||
{ 1, 0, 1, 0, 0.8, 0.3, 0.1, 0.8 },
|
{ 1, 0, 1, 0, 0.8, 0.3, 0.1, 0.8 },
|
||||||
{ 1, 1, 1, 1, 0.7, 0.4, 0.1, 0.8 },
|
{ 1, 1, 1, 1, 0.7, 0.4, 0.1, 0.8 },
|
||||||
{ 0, 1, 0, 1, 0.4, 0.05, 0.05, 0.1 },
|
{ 0, 1, 0, 1, 0.4, 0.05, 0.05, 0.1 },
|
||||||
},
|
},
|
||||||
|
|
||||||
font = lg.newFont( "client/assets/fonts/Montserrat-Bold.ttf", 48 )
|
lg.newFont( "client/assets/fonts/Montserrat-Bold.ttf", 48 )
|
||||||
}
|
)
|
|
@ -10,16 +10,10 @@ local canvas
|
||||||
local wWidth, wHeight
|
local wWidth, wHeight
|
||||||
local currentMenu
|
local currentMenu
|
||||||
|
|
||||||
function menu.getSelectedButton()
|
function menu.new( name, buttons, fg, bg, font )
|
||||||
return currentMenu.buttons[selectedButtonIdx]
|
local t = { buttons = buttons, fg = fg, bg = bg, font = font or lg.getFont() }
|
||||||
end
|
scene[name] = t
|
||||||
|
|
||||||
function menu.new( t )
|
|
||||||
if t.subScene then setmetatable( t, t )
|
|
||||||
else
|
|
||||||
scene[t.name] = t
|
|
||||||
print( 'scene', scene )
|
print( 'scene', scene )
|
||||||
end
|
|
||||||
getmetatable( t ).__index = menu
|
getmetatable( t ).__index = menu
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
@ -27,7 +21,7 @@ end
|
||||||
function menu:onLoad()
|
function menu:onLoad()
|
||||||
print( 'loading:', self.name )
|
print( 'loading:', self.name )
|
||||||
currentMenu = self
|
currentMenu = self
|
||||||
if self.font then lg.setFont( self.font ) end
|
lg.setFont( self.font )
|
||||||
return menu.resize( lg.getDimensions() )
|
return menu.resize( lg.getDimensions() )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -123,9 +117,7 @@ function menu:paint()
|
||||||
|
|
||||||
--bg
|
--bg
|
||||||
lg.setColor( 1, 1, 1, 1 )
|
lg.setColor( 1, 1, 1, 1 )
|
||||||
if self.bg then
|
|
||||||
lg.draw( self.bg, 0, 0, 0, wWidth, wHeight )
|
lg.draw( self.bg, 0, 0, 0, wWidth, wHeight )
|
||||||
end
|
|
||||||
|
|
||||||
--buttons
|
--buttons
|
||||||
for i = #self.buttons, 1, -1 do self.buttons[i]:draw( ) end
|
for i = #self.buttons, 1, -1 do self.buttons[i]:draw( ) end
|
||||||
|
@ -135,14 +127,12 @@ function menu:paint()
|
||||||
local r = math.random
|
local r = math.random
|
||||||
local v = r() * 0.4 + 0.6
|
local v = r() * 0.4 + 0.6
|
||||||
|
|
||||||
if self.fg then
|
|
||||||
local fg = self.fg
|
local fg = self.fg
|
||||||
fg:setVertexAttribute( 2, 3, v * (0.7 + 0.2 * r()), v * (0.1 + 0.4 * r()), v * (0.1 * r()), 1 )
|
fg:setVertexAttribute( 2, 3, v * (0.7 + 0.2 * r()), v * (0.1 + 0.4 * r()), v * (0.1 * r()), 1 )
|
||||||
fg:setVertexAttribute( 1, 3, 0.3 * ( 1 - v ), 0, 0, 0.4 * (1 - v) )
|
fg:setVertexAttribute( 1, 3, 0.3 * ( 1 - v ), 0, 0, 0.4 * (1 - v) )
|
||||||
fg:setVertexAttribute( 4, 3, 0.3 * ( 1 - v ), 0, 0, 0.4 * (1 - v) )
|
fg:setVertexAttribute( 4, 3, 0.3 * ( 1 - v ), 0, 0, 0.4 * (1 - v) )
|
||||||
fg:setVertexAttribute( 3, 3, v * (0.7 + 0.2 * r()), v * (0.1 + 0.4 * r()), v * (0.1 * r()), 1 )
|
fg:setVertexAttribute( 3, 3, v * (0.7 + 0.2 * r()), v * (0.1 + 0.4 * r()), v * (0.1 * r()), 1 )
|
||||||
lg.draw( fg, 0, 0, 0, wWidth, wHeight )
|
lg.draw( fg, 0, 0, 0, wWidth, wHeight )
|
||||||
end
|
|
||||||
lg.setCanvas()
|
lg.setCanvas()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,47 +5,45 @@ local strings = strings or assert( require 'client.assets.strings.english' )
|
||||||
local button = assert( require 'client.ui.button' )
|
local button = assert( require 'client.ui.button' )
|
||||||
local menu = assert( require 'client.ui.menu' )
|
local menu = assert( require 'client.ui.menu' )
|
||||||
|
|
||||||
local font = lg.newFont( "client/assets/fonts/Montserrat-Bold.ttf", 18 )
|
return menu.new(
|
||||||
|
"options",
|
||||||
|
|
||||||
return menu.new{
|
{
|
||||||
name = "options",
|
|
||||||
|
|
||||||
buttons = {
|
|
||||||
|
|
||||||
button{
|
button{
|
||||||
x = 15, y = 115, w = 800, h = 30, space = 8,
|
x = 15, y = 115, w = 800, h = 30,
|
||||||
text = lg.newText( font, strings.mainmenu_button ),
|
text = strings.mainmenu_button,
|
||||||
color = { 0.6, 0.6, 0.6, 0.8 },
|
color = { 0.6, 0.6, 0.6, 0.8 },
|
||||||
callback = function() return scene.mainmenu() end },
|
callback = function() return scene.mainmenu() end },
|
||||||
|
|
||||||
button{
|
button{
|
||||||
option = 'name',
|
option = 'name',
|
||||||
text = lg.newText( font, strings.option_name ),
|
text = strings.option_name,
|
||||||
color = { 0.6, 0.6, 0.6, 0.8 },
|
color = { 0.6, 0.6, 0.6, 0.8 },
|
||||||
callback = menu.textOption },
|
callback = menu.textOption },
|
||||||
|
|
||||||
button{
|
button{
|
||||||
option = 'pronoun',
|
option = 'pronoun',
|
||||||
text = lg.newText( font, strings.option_pron ),
|
text = strings.option_pron,
|
||||||
color = { 0.6, 0.6, 0.6, 0.8 },
|
color = { 0.6, 0.6, 0.6, 0.8 },
|
||||||
callback = menu.textOption },
|
callback = menu.textOption },
|
||||||
|
|
||||||
button{
|
button{
|
||||||
option = 'colour',
|
option = 'colour',
|
||||||
text = lg.newText( font, strings.option_tint ),
|
text = strings.option_tint,
|
||||||
color = { 0.6, 0.6, 0.6, 0.8 },
|
color = { 0.6, 0.6, 0.6, 0.8 },
|
||||||
callback = menu.colourOption },
|
callback = menu.colourOption },
|
||||||
|
|
||||||
|
|
||||||
button{
|
button{
|
||||||
option = 'keybinds',
|
option = 'keybinds',
|
||||||
text = lg.newText( font, strings.option_keybinds ),
|
text = strings.option_keybinds,
|
||||||
color = { 0.6, 0.6, 0.6, 0.8 },
|
color = { 0.6, 0.6, 0.6, 0.8 },
|
||||||
callback = menu.editKeybinds,
|
callback = menu.editKeybinds,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
fg = lg.newMesh{
|
lg.newMesh{
|
||||||
{ 0, 0, 0, 0, 0.4, 0.1, 0.05, 0.0 },
|
{ 0, 0, 0, 0, 0.4, 0.1, 0.05, 0.0 },
|
||||||
{ 1, 0, 1, 0, 0.8, 0.3, 0.1, 0.8 },
|
{ 1, 0, 1, 0, 0.8, 0.3, 0.1, 0.8 },
|
||||||
{ 1, 1, 1, 1, 0.7, 0.4, 0.1, 0.8 },
|
{ 1, 1, 1, 1, 0.7, 0.4, 0.1, 0.8 },
|
||||||
|
@ -53,11 +51,12 @@ return menu.new{
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
bg = lg.newMesh{
|
lg.newMesh{
|
||||||
{ 0, 0, 0, 0, 1, 1, 1, 0.01 },
|
{ 0, 0, 0, 0, 1, 1, 1, 0.01 },
|
||||||
{ 1, 0, 1, 0, 1, 1, 1, 0.1 },
|
{ 1, 0, 1, 0, 1, 1, 1, 0.1 },
|
||||||
{ 1, 1, 1, 1, 0, 0, 0, 0.1 },
|
{ 1, 1, 1, 1, 0, 0, 0, 0.1 },
|
||||||
{ 0, 1, 0, 1, 0, 0, 0, 0.01 },
|
{ 0, 1, 0, 1, 0, 0, 0, 0.01 },
|
||||||
}
|
},
|
||||||
|
|
||||||
}
|
lg.newFont( "client/assets/fonts/Montserrat-Bold.ttf", 18 )
|
||||||
|
)
|
|
@ -28,8 +28,8 @@ textInput.y = 0
|
||||||
|
|
||||||
function textInput.new( t )
|
function textInput.new( t )
|
||||||
t = t or {}
|
t = t or {}
|
||||||
t.str = t.str or ""
|
t.text = lg.newText( font, "")
|
||||||
t.text = lg.newText( font, t.str )
|
t.str = ""
|
||||||
return setmetatable( t, __mt )
|
return setmetatable( t, __mt )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ function server.Start()
|
||||||
udp:settimeout(0)
|
udp:settimeout(0)
|
||||||
server.SetIP( socket.dns.toip(socket.dns.gethostname()), 51312 )
|
server.SetIP( socket.dns.toip(socket.dns.gethostname()), 51312 )
|
||||||
assert( udp:setsockname( tostring( svInfo.ip ), svInfo.port ))
|
assert( udp:setsockname( tostring( svInfo.ip ), svInfo.port ))
|
||||||
|
server.StartLocalClient()
|
||||||
print( socket.gettime(), "Start." )
|
print( socket.gettime(), "Start." )
|
||||||
repeat
|
repeat
|
||||||
server.Parse( udp:receivefrom() )
|
server.Parse( udp:receivefrom() )
|
||||||
|
|
|
@ -127,12 +127,6 @@ function packet.getString( member )
|
||||||
return ffi.string( member, ffi.sizeof( member ) )
|
return ffi.string( member, ffi.sizeof( member ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
--Slow!
|
|
||||||
function packet.luaString( member )
|
|
||||||
local s = packet.getString( member )
|
|
||||||
return s:sub( 1, ( s:find( "\0" ) or s:len() ) - 1 )
|
|
||||||
end
|
|
||||||
|
|
||||||
local writeBuffer = buffer.new( 1024 )
|
local writeBuffer = buffer.new( 1024 )
|
||||||
function packet.add( struct, data )
|
function packet.add( struct, data )
|
||||||
local str = ffi.new( struct.ct, data or 0 )
|
local str = ffi.new( struct.ct, data or 0 )
|
||||||
|
|
Loading…
Reference in New Issue