diff --git a/sonic-radiance.love/assets/gui/bar_small.lua b/sonic-radiance.love/assets/gui/bar_small.lua new file mode 100644 index 0000000..fe8752b --- /dev/null +++ b/sonic-radiance.love/assets/gui/bar_small.lua @@ -0,0 +1,6 @@ +return { + metadata = { + height = 7, + width = 14, + } +} \ No newline at end of file diff --git a/sonic-radiance.love/assets/gui/bar_small.png b/sonic-radiance.love/assets/gui/bar_small.png new file mode 100644 index 0000000..0e7413f Binary files /dev/null and b/sonic-radiance.love/assets/gui/bar_small.png differ diff --git a/sonic-radiance.love/game/modules/gui/init.lua b/sonic-radiance.love/game/modules/gui/init.lua index c8f0426..70f8869 100644 --- a/sonic-radiance.love/game/modules/gui/init.lua +++ b/sonic-radiance.love/game/modules/gui/init.lua @@ -1,6 +1,8 @@ local gui = {} +local TileSet = require "birb.modules.assets.types.tileset" local barborder = love.graphics.newImage("assets/gui/barborder.png") +local barSmall = TileSet("assets/gui/bar_small") function gui.newBorder(width, height, middlePosition) local tileset = love.graphics.newImage("assets/gui/borders.png") @@ -79,14 +81,18 @@ function gui.newChoiceBack(approximateWidth) end function gui.drawBar(x, y, width, height) + width = math.floor(width) + 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( ) + height = 7 + if (width <= 8) then + barSmall:drawTile(9 - width, 0, 0) + else + 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) + end end end