diff --git a/sonic-bluestreak.love/assets/gui/dialogs/basic.lua b/sonic-bluestreak.love/assets/gui/dialogs/basic.lua new file mode 100644 index 0000000..de2295e --- /dev/null +++ b/sonic-bluestreak.love/assets/gui/dialogs/basic.lua @@ -0,0 +1,6 @@ +return { + metadata = { + height = 8, + width = 8, + } +} diff --git a/sonic-bluestreak.love/assets/gui/dialogs/basic.png b/sonic-bluestreak.love/assets/gui/dialogs/basic.png new file mode 100644 index 0000000..88c82b0 Binary files /dev/null and b/sonic-bluestreak.love/assets/gui/dialogs/basic.png differ diff --git a/sonic-bluestreak.love/assets/gui/dialogs/cursor-menulist.png b/sonic-bluestreak.love/assets/gui/dialogs/cursor-menulist.png new file mode 100644 index 0000000..f367054 Binary files /dev/null and b/sonic-bluestreak.love/assets/gui/dialogs/cursor-menulist.png differ diff --git a/sonic-bluestreak.love/assets/gui/status/barborder.png b/sonic-bluestreak.love/assets/gui/status/barborder.png new file mode 100644 index 0000000..4e321ef Binary files /dev/null and b/sonic-bluestreak.love/assets/gui/status/barborder.png differ diff --git a/sonic-bluestreak.love/assets/gui/borders.png b/sonic-bluestreak.love/assets/gui/system/borders.png similarity index 100% rename from sonic-bluestreak.love/assets/gui/borders.png rename to sonic-bluestreak.love/assets/gui/system/borders.png diff --git a/sonic-bluestreak.love/game/modules/gui/init.lua b/sonic-bluestreak.love/game/modules/gui/init.lua index 1cdc4db..164069a 100644 --- a/sonic-bluestreak.love/game/modules/gui/init.lua +++ b/sonic-bluestreak.love/game/modules/gui/init.lua @@ -1,10 +1,12 @@ local gui = {} +local barborder = love.graphics.newImage("assets/gui/status/barborder.png") + function gui.newBorder(width, height, middlePosition) - local tileset = love.graphics.newImage("assets/gui/borders.png") + local tileset = love.graphics.newImage("assets/gui/system/borders.png") local tilequad = {} local w, h = tileset:getDimensions() - tilequad[1] = love.graphics.newQuad(0, 0, 20, 20, w, h) + tilequad[1] = love.graphics.newQuad(0, 0, 20, 20, w, h) tilequad[2] = love.graphics.newQuad(20, 0, 20, 20, w, h) tilequad[3] = love.graphics.newQuad(40, 0, 20, 20, w, h) tilequad[4] = love.graphics.newQuad(60, 0, 20, 20, w, h) @@ -38,4 +40,77 @@ function gui.newBorder(width, height, middlePosition) return Texture end +function gui.drawBar(x, y, width, height) + if (width > 0) then + local height = height or 7 + core.screen:setScissor(x, y, width, height) + love.graphics.draw(barborder, x, y) + local barwidth = math.max(width-14, 0) + love.graphics.rectangle("fill", x+7, y, barwidth, height) + love.graphics.draw(barborder, x+barwidth+7, y, 0, -1, -1, 7, 7) + core.screen:resetScissor( ) + end +end + +function gui.newTextBox(type, width, height) + local filepath = "assets/gui/dialogs/" + type + ".png" + local baseimage = love.graphics.newImage(filepath) + 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