Compare commits
6 Commits
126ae0e127
...
d6015ef155
Author | SHA1 | Date |
---|---|---|
Pascal Abresch | d6015ef155 | |
Pascal Abresch | 761fa00cbd | |
Pascal Abresch | 388964b2c3 | |
Pascal Abresch | a5649210a5 | |
Pascal Abresch | 2306586af4 | |
Pascal Abresch | 03f18b8c8a |
4
conf.lua
4
conf.lua
|
@ -1,7 +1,7 @@
|
||||||
love.conf = function(conf)
|
love.conf = function(conf)
|
||||||
conf.window.height = 1000
|
conf.window.height = 612
|
||||||
conf.window.minheight = 480
|
conf.window.minheight = 480
|
||||||
conf.window.width = 1000
|
conf.window.width = 1024
|
||||||
conf.window.minwidth = 640
|
conf.window.minwidth = 640
|
||||||
conf.window.resizable = true
|
conf.window.resizable = true
|
||||||
conf.window.vsync = -1
|
conf.window.vsync = -1
|
||||||
|
|
|
@ -9,7 +9,9 @@ local altPressed, enterPressed = false, false
|
||||||
function camera.keypressed(key, _)
|
function camera.keypressed(key, _)
|
||||||
if key == "return" then enterPressed = true end
|
if key == "return" then enterPressed = true end
|
||||||
if key == "lalt" then altPressed = true end
|
if key == "lalt" then altPressed = true end
|
||||||
if key == "f11" or (altPressed and key == "return") or (enterPressed and key == "lalt") then
|
if key == "f11"
|
||||||
|
or (altPressed and key == "return")
|
||||||
|
or (enterPressed and key == "lalt") then
|
||||||
fullscreen = not fullscreen
|
fullscreen = not fullscreen
|
||||||
love.window.setFullscreen(fullscreen, "desktop")
|
love.window.setFullscreen(fullscreen, "desktop")
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,8 @@ local sharedCommands = require("lua.sharedCommands")
|
||||||
|
|
||||||
commands.commandsInit = sharedCommands.commandsInit
|
commands.commandsInit = sharedCommands.commandsInit
|
||||||
|
|
||||||
|
commands.commandsWorldInit = sharedCommands.commandsWorldInit
|
||||||
|
|
||||||
commands.init = function(clientID, args)
|
commands.init = function(clientID, args)
|
||||||
local nickname, args = utils.nextStringRecord(args)
|
local nickname, args = utils.nextStringRecord(args)
|
||||||
local avatarEncoded, args = utils.nextStringRecord(args)
|
local avatarEncoded, args = utils.nextStringRecord(args)
|
||||||
|
|
|
@ -24,16 +24,16 @@ end
|
||||||
|
|
||||||
|
|
||||||
function drawing.fillCanvas(layer, hash)
|
function drawing.fillCanvas(layer, hash)
|
||||||
love.graphics.setCanvas(gameloop.Canvas[layer])
|
love.graphics.setCanvas(gameloop.Canvas[layer])
|
||||||
love.graphics.clear()
|
love.graphics.clear()
|
||||||
for x = 0, gameloop.world.x -gameloop.textures[hash].image:getPixelWidth(),
|
for x = 0, gameloop.world.x -gameloop.textures[hash].image:getPixelWidth(),
|
||||||
gameloop.textures[hash].image:getPixelWidth() do
|
gameloop.textures[hash].image:getPixelWidth() do
|
||||||
for y = 0, gameloop.world.y -gameloop.textures[hash].image:getPixelHeight(),
|
for y = 0, gameloop.world.y -gameloop.textures[hash].image:getPixelHeight(),
|
||||||
gameloop.textures[hash].image:getPixelHeight() do
|
gameloop.textures[hash].image:getPixelHeight() do
|
||||||
love.graphics.draw(gameloop.textures[hash].image, x, y)
|
love.graphics.draw(gameloop.textures[hash].image, x, y)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
love.graphics.setCanvas()
|
end
|
||||||
|
love.graphics.setCanvas()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
local errorHandler = {}
|
||||||
|
function errorHandler.redscreen(msg)
|
||||||
|
local scale = 0.5
|
||||||
|
local errorfont
|
||||||
|
if love.filesystem.getInfo("fonts/font.ttf") then
|
||||||
|
errorfont = love.graphics.newFont("fonts/font.ttf", 45 * scale)
|
||||||
|
else
|
||||||
|
errorfont = love.graphics.newFont(45 * scale)
|
||||||
|
end
|
||||||
|
love.graphics.reset()
|
||||||
|
love.graphics.origin()
|
||||||
|
love.graphics.clear(.4, 0, 0)
|
||||||
|
love.graphics.setColor(1, 1, 1)
|
||||||
|
local message = love.graphics.newText(errorfont, "Poppy has encountered a critical fault")
|
||||||
|
local message2 = love.graphics.newText(errorfont, "Press q to exit")
|
||||||
|
local message3 = love.graphics.newText(errorfont, msg)
|
||||||
|
love.graphics.draw(message, 40, 40 * scale, 0, 1, 1)
|
||||||
|
love.graphics.draw(message2, 40, 90 * scale, 0, 1, 1)
|
||||||
|
love.graphics.draw(message3, 40, 140 * scale, 0, 1, 1)
|
||||||
|
print(msg)
|
||||||
|
local indent = 0
|
||||||
|
local messageline
|
||||||
|
for line in debug.traceback():gmatch("([^\n]*)\n?") do
|
||||||
|
print(line)
|
||||||
|
messageline = love.graphics.newText(errorfont, line)
|
||||||
|
love.graphics.draw(messageline, 40, (250 * scale) + indent, 0, 1, 1)
|
||||||
|
indent = indent + 50 * scale
|
||||||
|
end
|
||||||
|
love.graphics.present()
|
||||||
|
return function()
|
||||||
|
love.event.pump()
|
||||||
|
for event, action in love.event.poll() do
|
||||||
|
if event == "quit" then return 1 end
|
||||||
|
if event == "keypressed" then
|
||||||
|
if action == "q" then
|
||||||
|
love.event.quit( 1 )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
love.timer.sleep(0.1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return errorHandler
|
|
@ -10,6 +10,7 @@ local fonts = require("shared.fonts")
|
||||||
|
|
||||||
local rpc = require("server.rpc")
|
local rpc = require("server.rpc")
|
||||||
local constants = require("server.constants")
|
local constants = require("server.constants")
|
||||||
|
local errorHandler = require("lua.error")
|
||||||
|
|
||||||
gameloop.nwChecklist = {}
|
gameloop.nwChecklist = {}
|
||||||
gameloop.Canvas = {}
|
gameloop.Canvas = {}
|
||||||
|
@ -129,49 +130,7 @@ end
|
||||||
|
|
||||||
local function errorhandlerNetwork(msg)
|
local function errorhandlerNetwork(msg)
|
||||||
gameloop.networkSend(unit("playerLeave"))
|
gameloop.networkSend(unit("playerLeave"))
|
||||||
return errorhandler(msg)
|
return errorHandler.redscreen(msg)
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function errorhandler(msg)
|
|
||||||
local errorfont
|
|
||||||
if love.filesystem.getInfo("fonts/font.ttf") then
|
|
||||||
errorfont = love.graphics.newFont("fonts/font.ttf", 45)
|
|
||||||
else
|
|
||||||
errorfont = love.graphics.newFont(45)
|
|
||||||
end
|
|
||||||
love.graphics.reset()
|
|
||||||
love.graphics.origin()
|
|
||||||
love.graphics.clear(.4, 0, 0)
|
|
||||||
love.graphics.setColor(1, 1, 1)
|
|
||||||
local message = love.graphics.newText(errorfont, "Poppy has encountered a critical fault")
|
|
||||||
local message2 = love.graphics.newText(errorfont, "Press q to exit")
|
|
||||||
local message3 = love.graphics.newText(errorfont, msg)
|
|
||||||
love.graphics.draw(message, 40, 40, 0, 1, 1)
|
|
||||||
love.graphics.draw(message2, 40, 90, 0, 1, 1)
|
|
||||||
love.graphics.draw(message3, 40, 140, 0, 1, 1)
|
|
||||||
print(msg)
|
|
||||||
local indent = 0
|
|
||||||
local messageline
|
|
||||||
for line in debug.traceback():gmatch("([^\n]*)\n?") do
|
|
||||||
print(line)
|
|
||||||
messageline = love.graphics.newText(errorfont, line)
|
|
||||||
love.graphics.draw(messageline, 40, 250 + indent, 0, 1, 1)
|
|
||||||
indent = indent + 50
|
|
||||||
end
|
|
||||||
love.graphics.present()
|
|
||||||
return function()
|
|
||||||
love.event.pump()
|
|
||||||
for event, action in love.event.poll() do
|
|
||||||
if event == "quit" then return 1 end
|
|
||||||
if event == "keypressed" then
|
|
||||||
if action == "q" then
|
|
||||||
love.event.quit( 1 )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
love.timer.sleep(0.1)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -204,7 +163,7 @@ end
|
||||||
|
|
||||||
function gameloop.init(server, nickname, avatarHash)
|
function gameloop.init(server, nickname, avatarHash)
|
||||||
local US = constants.US
|
local US = constants.US
|
||||||
--love.errorhandler = errorhandler
|
love.errorhandler = errorHandler.redscreen
|
||||||
assert(server, "Gameloop called without server to connect to?")
|
assert(server, "Gameloop called without server to connect to?")
|
||||||
assert(nickname, "Gameloop called without nickname?")
|
assert(nickname, "Gameloop called without nickname?")
|
||||||
assert(avatarHash, "Gameloop called without avatar?")
|
assert(avatarHash, "Gameloop called without avatar?")
|
||||||
|
@ -322,6 +281,7 @@ function gameloop.loadworld(world)
|
||||||
gameloop.Canvas.dbg2 = love.graphics.newCanvas(world.x, world.y)
|
gameloop.Canvas.dbg2 = love.graphics.newCanvas(world.x, world.y)
|
||||||
end
|
end
|
||||||
gameloop.Canvas.physics = {}
|
gameloop.Canvas.physics = {}
|
||||||
|
commands.commandsWorldInit()
|
||||||
|
|
||||||
ui.init()
|
ui.init()
|
||||||
drawing.init()
|
drawing.init()
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
menu = {}
|
menu = {}
|
||||||
menu.serverlist = {
|
menu.serverlist = {
|
||||||
--{description = "A localhost server [ipv4]", host = "127.0.0.1", port = "11150"},
|
{description = "Lenjas server", host = "192.168.178.39", port = "11150"},
|
||||||
{description = "A localhost server", host = "::1", port = "11150"}
|
{description = "A localhost server", host = "::1", port = "11150"},
|
||||||
|
{description = "A localhost server [ipv4]", host = "127.0.0.1", port = "11150"}
|
||||||
}
|
}
|
||||||
|
|
||||||
local utils = require("shared.utils")
|
local utils = require("shared.utils")
|
||||||
|
@ -57,7 +58,7 @@ function menu.mousepressed(mousex, mousey)
|
||||||
love.graphics.present()
|
love.graphics.present()
|
||||||
print("Starting server!")
|
print("Starting server!")
|
||||||
local serverloop = require("server.main")
|
local serverloop = require("server.main")
|
||||||
serverloop.init()
|
serverloop.init(v.identifier)
|
||||||
end
|
end
|
||||||
if v.kind == "server" then
|
if v.kind == "server" then
|
||||||
if firstClient then
|
if firstClient then
|
||||||
|
@ -132,8 +133,8 @@ menu.layout = {name ="vertical",
|
||||||
{name = "horizontal",
|
{name = "horizontal",
|
||||||
{name = "spacer", width = 50},
|
{name = "spacer", width = 50},
|
||||||
{name = "vertical",
|
{name = "vertical",
|
||||||
{name = "spacer", height = 50},
|
{name = "spacer", height = 20},
|
||||||
{name = "cursorSelect", kind = "localServer", identifier = "::1",
|
{name = "cursorSelect", kind = "localServer", identifier = {"::1", "11150"},
|
||||||
{name = "horizontal",
|
{name = "horizontal",
|
||||||
{name = "spacer", width = 10},
|
{name = "spacer", width = 10},
|
||||||
{name = "drawTexture",
|
{name = "drawTexture",
|
||||||
|
@ -143,22 +144,36 @@ menu.layout = {name ="vertical",
|
||||||
{name = "label", text = "Spin up a local server"},
|
{name = "label", text = "Spin up a local server"},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{name = "spacer", height = 40},
|
{name = "cursorSelect", kind = "localServer", identifier = {"0.0.0.0", "11150"},
|
||||||
|
{name = "horizontal",
|
||||||
|
{name = "spacer", width = 10},
|
||||||
|
{name = "drawTexture",
|
||||||
|
texture = love.graphics.newImage("textures/menu/serverPlay.png")
|
||||||
|
},
|
||||||
|
{name = "spacer", width = 10},
|
||||||
|
{name = "label", text = "Spin up a local server [IPV4]"},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{name = "spacer", height = 20},
|
||||||
{name = "label", text = "Or pick a server to join!", font = fonts.headerFont},
|
{name = "label", text = "Or pick a server to join!", font = fonts.headerFont},
|
||||||
{name = "spacer", height = 20},
|
{name = "spacer", height = 20},
|
||||||
{name = "horizontal",
|
{name = "horizontal",
|
||||||
{name = "spacer", width = 10},
|
{name = "spacer", width = 10},
|
||||||
{name = "vertical",
|
{name = "vertical",
|
||||||
menu.layoutServerList(),
|
{name = "vertical",
|
||||||
{name = "spacer", height = 10},
|
menu.layoutServerList(),
|
||||||
{name = "horizontal",
|
},
|
||||||
{name = "drawTexture", texture = love.graphics.newImage("textures/menu/AddIcon.png")},
|
{name = "vertical",
|
||||||
{name = "spacer", width = 10 },
|
{name = "spacer", height = 10},
|
||||||
{name = "label", text = "placeholder (new server)" },
|
{name = "horizontal",
|
||||||
{name = "spacer", width = 20 },
|
{name = "drawTexture", texture = love.graphics.newImage("textures/menu/AddIcon.png")},
|
||||||
{name = "label", text = "host: newhost", font = fonts.smallFont},
|
{name = "spacer", width = 10 },
|
||||||
{name = "spacer", width = 10 },
|
{name = "label", text = "placeholder (new server)" },
|
||||||
{name = "label", text = "port: newport", font = fonts.smallFont},
|
{name = "spacer", width = 20 },
|
||||||
|
{name = "label", text = "host: newhost", font = fonts.smallFont},
|
||||||
|
{name = "spacer", width = 10 },
|
||||||
|
{name = "label", text = "port: newport", font = fonts.smallFont},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@ local textures
|
||||||
|
|
||||||
function commands.commandsInit()
|
function commands.commandsInit()
|
||||||
if gameloop then -- client
|
if gameloop then -- client
|
||||||
canvas.fg = gameloop.Canvas.fg
|
|
||||||
canvas.bg = gameloop.Canvas.bg
|
|
||||||
players = _G.players
|
players = _G.players
|
||||||
textures = gameloop.textures
|
textures = gameloop.textures
|
||||||
else
|
else
|
||||||
|
@ -22,6 +20,13 @@ function commands.commandsInit()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function commands.commandsWorldInit()
|
||||||
|
if gameloop then
|
||||||
|
canvas.fg = gameloop.Canvas.fg
|
||||||
|
canvas.bg = gameloop.Canvas.bg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
commands.moveUpdate = function(clientID, args)
|
commands.moveUpdate = function(clientID, args)
|
||||||
if not players[clientID] then return end
|
if not players[clientID] then return end
|
||||||
local x, args = utils.nextIntRecord(args)
|
local x, args = utils.nextIntRecord(args)
|
||||||
|
@ -47,22 +52,25 @@ commands.drawTexture = function(clientID, args)
|
||||||
local x, args = utils.nextIntRecord(args)
|
local x, args = utils.nextIntRecord(args)
|
||||||
local y, args = utils.nextIntRecord(args)
|
local y, args = utils.nextIntRecord(args)
|
||||||
local layer, args = utils.nextStringRecord(args)
|
local layer, args = utils.nextStringRecord(args)
|
||||||
local hash, args = utils.nextStringRecord(args)
|
local hashEncoded, args = utils.nextStringRecord(args)
|
||||||
hash = love.data.decode("string", "base64", hash)
|
hash = love.data.decode("string", "base64", hashEncoded)
|
||||||
local r, args = utils.nextIntRecord(args)
|
local r, args = utils.nextIntRecord(args)
|
||||||
local g, args = utils.nextIntRecord(args)
|
local g, args = utils.nextIntRecord(args)
|
||||||
local b, a = utils.nextIntRecord(args)
|
local b, args = utils.nextIntRecord(args)
|
||||||
a = tonumber(a)
|
a = tonumber(args) or 1
|
||||||
if not gameloop.textures[hash] then print("Failed to find hash!") return end
|
if not gameloop.textures[hash] then error("Failed to find hash!") return end
|
||||||
love.graphics.setBlendMode("replace")
|
if not textures[hash].image then love.graphics.newImage(textures[hash].data) end
|
||||||
|
|
||||||
|
print(x, y, layer, r, g, b, a)
|
||||||
|
print(hashEncoded)
|
||||||
|
print(type(canvas))
|
||||||
|
print(type(canvas[layer]))
|
||||||
love.graphics.setCanvas(canvas[layer])
|
love.graphics.setCanvas(canvas[layer])
|
||||||
love.graphics.setCanvas(canvas.bg)
|
love.graphics.setBlendMode("alpha")
|
||||||
if not textures[hash].image then love.graphics.newImage(textures[hash].data) end
|
utils.color_push()
|
||||||
utils.color_push()
|
love.graphics.setColor(r, g, b ,a )
|
||||||
love.graphics.setColor(r, g, b ,a)
|
love.graphics.draw(textures[hash].image, x, y)
|
||||||
love.graphics.draw(textures[hash].image, x, y)
|
utils.color_pop()
|
||||||
utils.color_pop()
|
|
||||||
love.graphics.setBlendMode("alpha")
|
|
||||||
love.graphics.setCanvas()
|
love.graphics.setCanvas()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
129
lua/ui.lua
129
lua/ui.lua
|
@ -2,8 +2,8 @@ ui = {}
|
||||||
ui.textureTree = nil
|
ui.textureTree = nil
|
||||||
|
|
||||||
local layout = require("lua.layout")
|
local layout = require("lua.layout")
|
||||||
|
|
||||||
local utils = require("shared.utils")
|
local utils = require("shared.utils")
|
||||||
|
local fonts = require("shared.fonts")
|
||||||
|
|
||||||
ui.sidebarScale = 1
|
ui.sidebarScale = 1
|
||||||
ui.sidebarWidth = 13 * 16
|
ui.sidebarWidth = 13 * 16
|
||||||
|
@ -129,7 +129,7 @@ function ui.addChatEntry(user, message)
|
||||||
{name = "vertical",
|
{name = "vertical",
|
||||||
{name = "label",
|
{name = "label",
|
||||||
text = chatText,
|
text = chatText,
|
||||||
font = ui.smallFont
|
font = fonts.smallFont
|
||||||
},
|
},
|
||||||
{name = "spacer",
|
{name = "spacer",
|
||||||
height = 2
|
height = 2
|
||||||
|
@ -253,126 +253,29 @@ end
|
||||||
|
|
||||||
|
|
||||||
function ui.helpDrawer(w, h)
|
function ui.helpDrawer(w, h)
|
||||||
return {name = "label",
|
return {name = "color",
|
||||||
text = ui.helptext
|
color = { 1, 1, 0.8, 0.4},
|
||||||
}
|
{name = "label",
|
||||||
end
|
text = ui.helptext,
|
||||||
|
font = fonts.smallFont
|
||||||
|
|
||||||
function ui.testDrawer(w, h)
|
|
||||||
local drawer = {name = "vertical"}
|
|
||||||
return drawer
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local selectedTab = "blocks"
|
|
||||||
function ui.tabDrawer(textureTree, w, h)
|
|
||||||
local labels
|
|
||||||
local helpTab = {name = "label",
|
|
||||||
text = ui.helptext
|
|
||||||
}
|
|
||||||
local hWidth, hHeight = layout.handle(helpTab, 0, 0, true)
|
|
||||||
local blockTab = ui.blockDrawer(textureTree, w, h)
|
|
||||||
local bWidth, bHeight = layout.handle(blockTab, 0, 0, true)
|
|
||||||
labels = {name = "horizontal",
|
|
||||||
{name = "cursorSelect",
|
|
||||||
identifier = "help",
|
|
||||||
kind = "tab",
|
|
||||||
{name = "label",
|
|
||||||
text = "Help"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{name = "spacer",
|
|
||||||
width = 5
|
|
||||||
},
|
|
||||||
{name = "cursorSelect",
|
|
||||||
identifier = "blocks",
|
|
||||||
kind = "tab",
|
|
||||||
{name = "label",
|
|
||||||
text = "Blocks"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{name = "spacer",
|
|
||||||
width = 5
|
|
||||||
},
|
|
||||||
{name = "cursorSelect",
|
|
||||||
identifier = "disconnect",
|
|
||||||
kind = "button",
|
|
||||||
{name = "label",
|
|
||||||
text = " Disconnect. "
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{name = "spacer",
|
|
||||||
width = 5
|
|
||||||
},
|
|
||||||
{name = "cursorSelect",
|
|
||||||
identifier = "increaseUISize",
|
|
||||||
kind = "button",
|
|
||||||
{name = "label",
|
|
||||||
text = "+"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{name = "spacer",
|
|
||||||
width = 5
|
|
||||||
},
|
|
||||||
{name = "cursorSelect",
|
|
||||||
identifier = "decreaseUISize",
|
|
||||||
kind = "button",
|
|
||||||
{name = "label",
|
|
||||||
text = "-"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{name = "spacer",
|
|
||||||
width = 5
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if selectedTab == "blocks" then
|
|
||||||
tab = blockTab
|
|
||||||
elseif selectedTab == "help" then
|
|
||||||
tab = helpTab
|
|
||||||
end
|
|
||||||
local drawer = {
|
|
||||||
name = "vertical",
|
|
||||||
{name = "copySize",
|
|
||||||
{name = "rect",
|
|
||||||
fill = "fill",
|
|
||||||
color = { r = .4, g = 0, b = .4 }
|
|
||||||
},
|
|
||||||
{name = "horizontal",
|
|
||||||
labels,
|
|
||||||
{name = "spacer",
|
|
||||||
height = 40,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{name = "copySize",
|
|
||||||
{name = "rect",
|
|
||||||
fill = "fill",
|
|
||||||
color = { r = .15, g = .15, b = .15 }
|
|
||||||
},
|
|
||||||
tab
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return drawer, math.max(hWidth, bWidth)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function ui.draw(w, h)
|
function ui.draw(w, h)
|
||||||
window.x, window.y = w, h
|
window.x, window.y = w, h
|
||||||
utils.color_push()
|
|
||||||
love.graphics.setCanvas(ui.buffer)
|
love.graphics.setCanvas(ui.buffer)
|
||||||
uiState = {}
|
layout.uiState = {}
|
||||||
love.graphics.clear( )
|
love.graphics.clear( )
|
||||||
local sidebar, width = ui.tabDrawer(ui.textureTree, ui.sidebarWidth * ui.sidebarScale, h)
|
local blockDrawer = ui.blockDrawer(ui.textureTree, w, h)
|
||||||
layout.handle(sidebar, window.x -width, 0)
|
local helpDrawer = ui.helpDrawer(w, h)
|
||||||
ui.space = width
|
blockMaxX, blockMaxY = layout.handle(blockDrawer, 0, 0, true)
|
||||||
if textEnabled then
|
helpMaxX, helpMaxY = layout.handle(helpDrawer, 0, 0, true)
|
||||||
local chatLayout = ui.chatEntry()
|
local blockDrawerAdjusted = ui.blockDrawer(ui.textureTree, blockMaxX, blockMaxY)
|
||||||
local sizex, sizey = layout.handle(chatLayout, 0, 0, true)
|
layout.handle(blockDrawerAdjusted, window.x - blockMaxX, 0)
|
||||||
layout.handle(chatLayout, 0, window.y - sizey)
|
layout.handle(helpDrawer, window.x - blockMaxX - helpMaxX, window.y - helpMaxY)
|
||||||
end
|
|
||||||
layout.handle(ui.chatlog(), 25, 90)
|
layout.handle(ui.chatlog(), 25, 90)
|
||||||
utils.color_pop()
|
|
||||||
love.graphics.setCanvas()
|
love.graphics.setCanvas()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ require("server.commands.physics")(commands)
|
||||||
require("server.commands.drawing")(commands)
|
require("server.commands.drawing")(commands)
|
||||||
require("server.commands.chat")(commands)
|
require("server.commands.chat")(commands)
|
||||||
|
|
||||||
|
local errorHandler = require("lua.error")
|
||||||
|
|
||||||
local unpriviligedCommands = {}
|
local unpriviligedCommands = {}
|
||||||
require("server.unpriviliged_commands.init")(unpriviligedCommands)
|
require("server.unpriviliged_commands.init")(unpriviligedCommands)
|
||||||
|
|
||||||
|
@ -25,13 +27,8 @@ serverloop = {}
|
||||||
serverloop.textures = {}
|
serverloop.textures = {}
|
||||||
|
|
||||||
server:settimeout(0)
|
server:settimeout(0)
|
||||||
assert(server:setsockname("*", 11150))
|
|
||||||
local socketString = server:getsockname()
|
|
||||||
print(socketString)
|
|
||||||
if not server or not socket then error("failed to listen on socket") end
|
if not server or not socket then error("failed to listen on socket") end
|
||||||
|
|
||||||
print("Server startup.")
|
|
||||||
|
|
||||||
function broadcast(clientID, message)
|
function broadcast(clientID, message)
|
||||||
local payload = util.unit(protocolVersion, clientID, message)
|
local payload = util.unit(protocolVersion, clientID, message)
|
||||||
for i, player in pairs(clients) do
|
for i, player in pairs(clients) do
|
||||||
|
@ -99,7 +96,13 @@ function mainloop(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function serverloop.init()
|
function serverloop.init(host)
|
||||||
|
love.errorhandler = errorHandler.redscreen
|
||||||
|
status, value = server:setsockname(host[1], host[2])
|
||||||
|
if not status then
|
||||||
|
error("Server could not be started :( " .. value)
|
||||||
|
end
|
||||||
|
print("Server startup. listening on " .. server:getsockname())
|
||||||
loadTextures("textures/blocks", serverloop.textures)
|
loadTextures("textures/blocks", serverloop.textures)
|
||||||
serverloop.Canvas = {}
|
serverloop.Canvas = {}
|
||||||
serverloop.Canvas.fg = love.graphics.newCanvas(constants.world.x, constants.world.y)
|
serverloop.Canvas.fg = love.graphics.newCanvas(constants.world.x, constants.world.y)
|
||||||
|
@ -109,7 +112,7 @@ function serverloop.init()
|
||||||
love.draw = function()
|
love.draw = function()
|
||||||
love.graphics.clear(.2, 0, .2)
|
love.graphics.clear(.2, 0, .2)
|
||||||
love.graphics.print("Poppy server is running.", fonts.normalFont, 20, 20)
|
love.graphics.print("Poppy server is running.", fonts.normalFont, 20, 20)
|
||||||
love.graphics.print("listening on " .. socketString, fonts.normalFont, 20, 50)
|
love.graphics.print("listening on " .. server:getsockname(), fonts.normalFont, 20, 50)
|
||||||
return end
|
return end
|
||||||
love.keyreleased = function() return end
|
love.keyreleased = function() return end
|
||||||
love.keypressed = function() return end
|
love.keypressed = function() return end
|
||||||
|
|
Loading…
Reference in New Issue