78 lines
2 KiB
Lua
78 lines
2 KiB
Lua
local menu = {}
|
|
|
|
local ListBox = require "core.modules.menusystem.listbox"
|
|
local Widget = require "core.modules.menusystem.widgets"
|
|
|
|
menu.DebugMenu = ListBox:extend()
|
|
menu.DebugWidget = Widget.Text:extend()
|
|
menu.SubMenuWidget = menu.DebugWidget:extend()
|
|
menu.SceneWidget = menu.DebugWidget:extend()
|
|
|
|
local CONST = {}
|
|
CONST.MENU = {}
|
|
CONST.MENU.X = 16
|
|
CONST.MENU.Y = 48
|
|
CONST.MENU.W = 424/2
|
|
CONST.MENU.ITEM_NUMBER = 8
|
|
CONST.MENU.ITEM_HEIGHT = 18
|
|
|
|
-- Basic menu structure
|
|
function menu.DebugMenu:new(scene, name)
|
|
self.scene = scene
|
|
local x, y = CONST.MENU.X, CONST.MENU.Y
|
|
local w, h = CONST.MENU.W, CONST.MENU.ITEM_NUMBER * CONST.MENU.ITEM_HEIGHT
|
|
menu.DebugMenu.super.new(self, scene.menusystem, name, x, y, w, h, CONST.MENU.ITEM_NUMBER)
|
|
end
|
|
|
|
function menu.DebugMenu:drawCursor()
|
|
|
|
end
|
|
|
|
function menu.DebugMenu:draw()
|
|
love.graphics.setColor(0, 0, 0, 0.5)
|
|
love.graphics.rectangle("fill", self.x, self.y, self.w, self.h)
|
|
utils.graphics.resetColor()
|
|
menu.DebugMenu.super.draw(self)
|
|
end
|
|
|
|
-- Widget
|
|
function menu.DebugWidget:new(scene, menu_name, label)
|
|
local font = scene.assets.fonts["small"]
|
|
self.scene = scene
|
|
local widgetMenu = scene.menusystem.menus[menu_name]
|
|
menu.DebugWidget.super.new(self, widgetMenu, font, label)
|
|
end
|
|
|
|
function menu.DebugWidget:drawCanvas()
|
|
local h = math.floor(self.height / 2) - (self.font:getHeight() / 2)
|
|
self.font:draw(self.label, 8, h, -1, "left")
|
|
end
|
|
|
|
function menu.DebugWidget:drawSelected(x, y, w, h)
|
|
love.graphics.setColor(1, 1, 0, 1)
|
|
self:draw(x, y, w, h)
|
|
utils.graphics.resetColor()
|
|
end
|
|
|
|
-- SubMenuWidget
|
|
function menu.SubMenuWidget:new(scene, menu_name, newmenu, name)
|
|
menu.SubMenuWidget.super.new(self, scene, menu_name, name)
|
|
self.newmenu = newmenu or "BaseMenu"
|
|
end
|
|
|
|
function menu.SubMenuWidget:action()
|
|
self.scene.menusystem:switchMenu(self.newmenu)
|
|
end
|
|
|
|
-- SceneWidget
|
|
function menu.SceneWidget:new(scene, menuName, newScene, newSceneName)
|
|
menu.SceneWidget.super.new(self, scene, menuName, newSceneName)
|
|
self.newScene = newScene
|
|
end
|
|
|
|
function menu.SceneWidget:action()
|
|
self.newScene()
|
|
end
|
|
|
|
|
|
return menu
|