feat: add a smaller border option for menus

This commit is contained in:
Kazhnuz 2021-04-23 09:22:58 +02:00
parent 6c451e7aee
commit 50981a7823

View file

@ -12,7 +12,7 @@ local MENU_ITEM_HEIGHT = 16
local gui = require "game.modules.gui" local gui = require "game.modules.gui"
-- ListMenu -- ListMenu
function list.ListMenu:new(scene, name, x, y, w, itemNumber, isBoxed) function list.ListMenu:new(scene, name, x, y, w, itemNumber, isBoxed, smallborder)
self.scene = scene self.scene = scene
self.name = name self.name = name
local h = itemNumber * MENU_ITEM_HEIGHT local h = itemNumber * MENU_ITEM_HEIGHT
@ -21,10 +21,15 @@ function list.ListMenu:new(scene, name, x, y, w, itemNumber, isBoxed)
self.cursorTransition = 0 self.cursorTransition = 0
self.submenus = {} self.submenus = {}
self.itemNumber = itemNumber self.itemNumber = itemNumber
self.smallborder = (smallborder == true)
self.isBoxed = isBoxed self.isBoxed = isBoxed
if (self.isBoxed) then if (self.isBoxed) then
self.box = gui.newTextBox("assets/gui/dialogbox.png", w, h+16) local border = h+16
if (self.smallborder) then
border = h+8
end
self.box = gui.newTextBox("assets/gui/dialogbox.png", w, border)
end end
end end
@ -87,7 +92,11 @@ end
function list.ListMenu:draw() function list.ListMenu:draw()
if (self.isBoxed) then if (self.isBoxed) then
love.graphics.draw(self.box, self.x, self.y - 8) local dy = 8
if (self.smallborder) then
dy = 4
end
love.graphics.draw(self.box, self.x, self.y - dy)
end end
self:updateView() self:updateView()
local widgety = self.y local widgety = self.y