Compare commits
2 Commits
d1e253a8e1
...
3ccbb66b2d
Author | SHA1 | Date |
---|---|---|
Pascal Abresch | 3ccbb66b2d | |
Pascal Abresch | 609e7ed5fe |
|
@ -270,6 +270,29 @@ function layout.overlayRect(container, x, y, simulate)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function layout.labelWShadow(container, x, y, simulate)
|
||||||
|
-- TODO: Replace this with a text shadow shader FFS
|
||||||
|
if not container.font then container.font = fonts.normalFont end
|
||||||
|
local text = love.graphics.newText( container.font, container.text )
|
||||||
|
if not text then text = love.graphics.newText( container.font, "Unset text!!") end
|
||||||
|
if not simulate then
|
||||||
|
utils.color_push()
|
||||||
|
love.graphics.setColor(0,0,0)
|
||||||
|
love.graphics.draw(text, x, y +4)
|
||||||
|
love.graphics.draw(text, x, y +2)
|
||||||
|
love.graphics.draw(text, x, y +0)
|
||||||
|
love.graphics.draw(text, x +2, y +2)
|
||||||
|
love.graphics.draw(text, x +2, y +0)
|
||||||
|
love.graphics.draw(text, x +4, y +4)
|
||||||
|
love.graphics.draw(text, x +4, y +2)
|
||||||
|
love.graphics.draw(text, x +4, y +0)
|
||||||
|
utils.color_pop()
|
||||||
|
love.graphics.draw(text, x +2, y +2)
|
||||||
|
end
|
||||||
|
return x + text:getWidth() + 2, y + text:getHeight() +2
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function layout.label(container, x, y, simulate)
|
function layout.label(container, x, y, simulate)
|
||||||
if not container.font then container.font = fonts.normalFont end
|
if not container.font then container.font = fonts.normalFont end
|
||||||
local text = love.graphics.newText( container.font, container.text )
|
local text = love.graphics.newText( container.font, container.text )
|
||||||
|
@ -278,6 +301,7 @@ function layout.label(container, x, y, simulate)
|
||||||
love.graphics.draw(text, x, y)
|
love.graphics.draw(text, x, y)
|
||||||
end
|
end
|
||||||
return x + text:getWidth(), y + text:getHeight()
|
return x + text:getWidth(), y + text:getHeight()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
100
lua/menuloop.lua
100
lua/menuloop.lua
|
@ -33,11 +33,6 @@ function menu.keypressed(key, _)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function menu.update(dt)
|
|
||||||
love.timer.sleep((1/60) -dt)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function menu.resize()
|
function menu.resize()
|
||||||
menu.width, menu.height = love.window.getMode()
|
menu.width, menu.height = love.window.getMode()
|
||||||
menu.Canvas = love.graphics.newCanvas(width, height)
|
menu.Canvas = love.graphics.newCanvas(width, height)
|
||||||
|
@ -108,11 +103,11 @@ menu.serverentry = function(id, description, host, port)
|
||||||
{name = "horizontal",
|
{name = "horizontal",
|
||||||
{name = "drawTexture", texture = love.graphics.newImage("textures/menu/serverPlay.png")},
|
{name = "drawTexture", texture = love.graphics.newImage("textures/menu/serverPlay.png")},
|
||||||
{name = "spacer", width = 10 },
|
{name = "spacer", width = 10 },
|
||||||
{name = "label", text = description },
|
{name = "labelWShadow", text = description },
|
||||||
{name = "spacer", width = 20 },
|
{name = "spacer", width = 20 },
|
||||||
{name = "label", text = "host: ".. host, font = fonts.smallFont},
|
{name = "labelWShadow", text = "host: ".. host, font = fonts.smallFont},
|
||||||
{name = "spacer", width = 10 },
|
{name = "spacer", width = 10 },
|
||||||
{name = "label", text = "port:".. port, font = fonts.smallFont},
|
{name = "labelWShadow", text = "port:".. port, font = fonts.smallFont},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -131,7 +126,7 @@ menu.menuMessage = function(message)
|
||||||
if not message then return {name = "skip"} end
|
if not message then return {name = "skip"} end
|
||||||
return {name = "color",
|
return {name = "color",
|
||||||
color = { 1, .5, .5, 1},
|
color = { 1, .5, .5, 1},
|
||||||
{name = "label", font = fonts.bigFont, text = "Welcome to poppy!"}
|
{name = "labelWShadow", font = fonts.bigFont, text = "Welcome to poppy!"}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -141,7 +136,7 @@ menu.layout = function(message)
|
||||||
{name = "horizontal",
|
{name = "horizontal",
|
||||||
{name = "spacer", width = 20},
|
{name = "spacer", width = 20},
|
||||||
{name = "drawTexture", texture = love.graphics.newImage("ressources/Poppy.png")},
|
{name = "drawTexture", texture = love.graphics.newImage("ressources/Poppy.png")},
|
||||||
{name = "label", font = fonts.bigFont, text = "Welcome to poppy!"},
|
{name = "labelWShadow", font = fonts.bigFont, text = "Welcome to poppy!"},
|
||||||
},
|
},
|
||||||
menu.menuMessage(message),
|
menu.menuMessage(message),
|
||||||
{name = "horizontal",
|
{name = "horizontal",
|
||||||
|
@ -156,7 +151,7 @@ menu.layout = function(message)
|
||||||
texture = love.graphics.newImage("textures/menu/serverPlay.png")
|
texture = love.graphics.newImage("textures/menu/serverPlay.png")
|
||||||
},
|
},
|
||||||
{name = "spacer", width = 10},
|
{name = "spacer", width = 10},
|
||||||
{name = "label", text = "Spin up a local server"},
|
{name = "labelWShadow", text = "Spin up a local server"},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{name = "cursorSelect", kind = "localServer",
|
{name = "cursorSelect", kind = "localServer",
|
||||||
|
@ -167,11 +162,11 @@ menu.layout = function(message)
|
||||||
texture = love.graphics.newImage("textures/menu/serverPlay.png")
|
texture = love.graphics.newImage("textures/menu/serverPlay.png")
|
||||||
},
|
},
|
||||||
{name = "spacer", width = 10},
|
{name = "spacer", width = 10},
|
||||||
{name = "label", text = "Spin up a local server [IPV4]"},
|
{name = "labelWShadow", text = "Spin up a local server [IPV4]"},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{name = "spacer", height = 20},
|
{name = "spacer", height = 20},
|
||||||
{name = "label", text = "Or pick a server to join!", font = fonts.headerFont},
|
{name = "labelWShadow", 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},
|
||||||
|
@ -184,11 +179,11 @@ menu.layout = function(message)
|
||||||
{name = "horizontal",
|
{name = "horizontal",
|
||||||
{name = "drawTexture", texture = love.graphics.newImage("textures/menu/AddIcon.png")},
|
{name = "drawTexture", texture = love.graphics.newImage("textures/menu/AddIcon.png")},
|
||||||
{name = "spacer", width = 10 },
|
{name = "spacer", width = 10 },
|
||||||
{name = "label", text = "placeholder (new server)" },
|
{name = "labelWShadow", text = "placeholder (new server)" },
|
||||||
{name = "spacer", width = 20 },
|
{name = "spacer", width = 20 },
|
||||||
{name = "label", text = "host: newhost", font = fonts.smallFont},
|
{name = "labelWShadow", text = "host: newhost", font = fonts.smallFont},
|
||||||
{name = "spacer", width = 10 },
|
{name = "spacer", width = 10 },
|
||||||
{name = "label", text = "port: newport", font = fonts.smallFont},
|
{name = "labelWShadow", text = "port: newport", font = fonts.smallFont},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,22 +205,89 @@ function drawMenu(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function menu.draw(w, h)
|
|
||||||
|
local colortable = {
|
||||||
|
{234/255, 155/255, 254/255, .8}, --pinkish
|
||||||
|
{156/255, 154/255, 251/255, .8}, --blueish
|
||||||
|
{242/255, 228/255, 148/255, .8}, --orange yellowish
|
||||||
|
{255/255, 156/255, 182/255, .8}, --magenta/orange
|
||||||
|
{145/255, 237/255, 216/255, .8}
|
||||||
|
}
|
||||||
|
local bubbles = {}
|
||||||
|
function menu.draw()
|
||||||
|
for i=1, #bubbles do
|
||||||
|
drawBubble(bubbles[i])
|
||||||
|
end
|
||||||
love.graphics.draw(menu.Canvas)
|
love.graphics.draw(menu.Canvas)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function menu.update(dt)
|
||||||
|
for i=1, #bubbles do
|
||||||
|
local bubble = bubbles[i]
|
||||||
|
local sx = bubble.sx * dt
|
||||||
|
local sy = bubble.sy * dt
|
||||||
|
local bubble = bubbles[i]
|
||||||
|
bubble.x = bubble.x + sx
|
||||||
|
bubble.y = bubble.y + sy
|
||||||
|
if bubble.x + bubble.radius >= menu.width then
|
||||||
|
bubble.x = menu.width - bubble.radius
|
||||||
|
bubble.sx = -bubble.sx
|
||||||
|
end
|
||||||
|
if bubble.x - bubble.radius <= 0 then
|
||||||
|
bubble.x = bubble.radius
|
||||||
|
bubble.sx = -bubble.sx
|
||||||
|
end
|
||||||
|
if bubble.y - bubble.radius <= 0 then
|
||||||
|
bubble.y = bubble.radius
|
||||||
|
bubble.sy = -bubble.sy
|
||||||
|
end
|
||||||
|
if bubble.y + bubble.radius >= menu.height then
|
||||||
|
bubble.y = menu.height - bubble.radius
|
||||||
|
bubble.sy = -bubble.sy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
love.timer.sleep((1/60) -dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function drawBubble(bubble)
|
||||||
|
utils.color_push()
|
||||||
|
love.graphics.setColor(bubble.color[1]* .6, bubble.color[2] * .6, bubble.color[3] * .6)
|
||||||
|
love.graphics.circle("fill", bubble.x, bubble.y, bubble.radius )
|
||||||
|
love.graphics.setColor(bubble.color[1]* .9, bubble.color[2] * .9, bubble.color[3] * .9)
|
||||||
|
love.graphics.circle("fill", bubble.x, bubble.y, bubble.radius -3 )
|
||||||
|
love.graphics.setColor(bubble.color)
|
||||||
|
love.graphics.circle("fill", bubble.x, bubble.y, bubble.radius/2 )
|
||||||
|
utils.color_pop()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function menu.init(message)
|
function menu.init(message)
|
||||||
print("init menu")
|
|
||||||
menuMusic:play()
|
|
||||||
menu.width, menu.height = love.window.getMode()
|
menu.width, menu.height = love.window.getMode()
|
||||||
|
print("init menu")
|
||||||
|
math.randomseed(os.time())
|
||||||
|
for i=1,24 do
|
||||||
|
local bubble = {}
|
||||||
|
bubble.radius = 10 + math.floor(math.random() * 30)
|
||||||
|
print(math.floor(1 + math.random() * #colortable - 0.001))
|
||||||
|
bubble.color = colortable[math.floor(1 + math.random() * #colortable - 0.001)]
|
||||||
|
bubble.y = bubble.radius + math.floor(math.random() * (menu.height - (2* bubble.radius)))
|
||||||
|
bubble.x = bubble.radius + math.floor(math.random() * (menu.width - (2* bubble.radius)))
|
||||||
|
bubble.sx = 20 - math.random() * 40
|
||||||
|
bubble.sy = 20 - math.random() * 40
|
||||||
|
table.insert(bubbles, bubble)
|
||||||
|
end
|
||||||
|
menuMusic:play()
|
||||||
menu.Canvas = love.graphics.newCanvas(menu.width, menu.height)
|
menu.Canvas = love.graphics.newCanvas(menu.width, menu.height)
|
||||||
drawMenu(message)
|
drawMenu(message)
|
||||||
love.draw = menu.draw
|
love.draw = menu.draw
|
||||||
|
love.update = menu.update
|
||||||
love.keyreleased = menu.keyreleased
|
love.keyreleased = menu.keyreleased
|
||||||
love.keypressed = menu.keypressed
|
love.keypressed = menu.keypressed
|
||||||
love.mousepressed = menu.mousepressed
|
love.mousepressed = menu.mousepressed
|
||||||
print("inited menu")
|
print("inited menu")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return menu
|
return menu
|
||||||
|
|
Loading…
Reference in New Issue