scenes/mainmenu: prerender textbox
This commit is contained in:
parent
fbce0aee91
commit
61b667457f
|
@ -24,4 +24,63 @@ function gui.newBorder(id, width, height)
|
|||
return canvas
|
||||
end
|
||||
|
||||
function gui.newTextBox(filename, width, height)
|
||||
local baseimage = love.graphics.newImage(filename)
|
||||
local quad = {}
|
||||
quad[1] = love.graphics.newQuad(00, 00, 8, 8, 24, 24)
|
||||
quad[2] = love.graphics.newQuad(00, 08, 8, 8, 24, 24)
|
||||
quad[3] = love.graphics.newQuad(00, 16, 8, 8, 24, 24)
|
||||
quad[4] = love.graphics.newQuad(08, 00, 8, 8, 24, 24)
|
||||
quad[5] = love.graphics.newQuad(08, 08, 8, 8, 24, 24)
|
||||
quad[6] = love.graphics.newQuad(08, 16, 8, 8, 24, 24)
|
||||
quad[7] = love.graphics.newQuad(16, 00, 8, 8, 24, 24)
|
||||
quad[8] = love.graphics.newQuad(16, 08, 8, 8, 24, 24)
|
||||
quad[9] = love.graphics.newQuad(16, 16, 8, 8, 24, 24)
|
||||
local canvas = love.graphics.newCanvas(width, height)
|
||||
|
||||
love.graphics.setCanvas( canvas )
|
||||
|
||||
|
||||
for i=1, math.floor(width/8) do
|
||||
if (i == 1) then
|
||||
-- first line
|
||||
for j=1, math.floor(height/8) do
|
||||
if j == 1 then
|
||||
love.graphics.draw(baseimage, quad[1], (i-1)*8, (j-1)*8)
|
||||
elseif j == math.floor(height/8) then
|
||||
love.graphics.draw(baseimage, quad[3], (i-1)*8, (j-1)*8)
|
||||
else
|
||||
love.graphics.draw(baseimage, quad[2], (i-1)*8, (j-1)*8)
|
||||
end
|
||||
end
|
||||
elseif (i == math.floor(width/8)) then
|
||||
-- last line
|
||||
for j=1, math.floor(height/8) do
|
||||
if j == 1 then
|
||||
love.graphics.draw(baseimage, quad[7], (i-1)*8, (j-1)*8)
|
||||
elseif j == math.floor(height/8) then
|
||||
love.graphics.draw(baseimage, quad[9], (i-1)*8, (j-1)*8)
|
||||
else
|
||||
love.graphics.draw(baseimage, quad[8], (i-1)*8, (j-1)*8)
|
||||
end
|
||||
end
|
||||
else
|
||||
-- middle lines
|
||||
for j=1, math.floor(height/8) do
|
||||
if j == 1 then
|
||||
love.graphics.draw(baseimage, quad[4], (i-1)*8, (j-1)*8)
|
||||
elseif j == math.floor(height/8) then
|
||||
love.graphics.draw(baseimage, quad[6], (i-1)*8, (j-1)*8)
|
||||
else
|
||||
love.graphics.draw(baseimage, quad[5], (i-1)*8, (j-1)*8)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
love.graphics.setCanvas( )
|
||||
|
||||
return canvas
|
||||
end
|
||||
|
||||
return gui
|
||||
|
|
|
@ -22,9 +22,7 @@ function MainMenu:new()
|
|||
self:createBanner()
|
||||
self.leftborder = game.gui.newBorder(0, 64+24, 424)
|
||||
self.rightborder = game.gui.newBorder(1, 64+24, 424)
|
||||
|
||||
assets:clearTextBox()
|
||||
assets:addTextBox("bluetextbox")
|
||||
self.textbox = game.gui.newTextBox("assets/sprites/gui/textbox/bluetextbox.png", 240, 42+16)
|
||||
self:register()
|
||||
end
|
||||
|
||||
|
@ -96,8 +94,8 @@ function MainMenu:draw()
|
|||
|
||||
self.assets.fonts["small"]:set()
|
||||
self.assets.fonts["small"]:setLineHeight(1.2)
|
||||
assets.textbox["bluetextbox"]:draw(120, 216, 240, 42)
|
||||
love.graphics.printf(self.debugmenu.description, 120, 216, 240, "left")
|
||||
love.graphics.draw(self.textbox, 212-120, 190-16)
|
||||
love.graphics.printf(self.debugmenu.description, 212-120+8, 190-8, 240-16, "left")
|
||||
end
|
||||
|
||||
return MainMenu
|
||||
|
|
Loading…
Reference in New Issue