2020-08-01 10:31:09 +02:00
|
|
|
local menu = {}
|
|
|
|
|
2021-04-04 13:17:12 +02:00
|
|
|
local RadianceListMenu = require "game.modules.menus.fancy"
|
2021-05-05 08:30:32 +02:00
|
|
|
local defTransitions = require "birb.modules.transitions"
|
2020-08-01 10:31:09 +02:00
|
|
|
|
2021-04-04 13:17:12 +02:00
|
|
|
menu.MainMenu = RadianceListMenu.FancyMenu:extend()
|
|
|
|
menu.DebugMenu = RadianceListMenu.FancyMenu:extend()
|
|
|
|
menu.SceneWidget = RadianceListMenu.BaseWidget:extend()
|
2020-08-01 10:31:09 +02:00
|
|
|
|
|
|
|
local CONST = {}
|
|
|
|
CONST.MENU = {}
|
|
|
|
CONST.MENU.X = 16
|
|
|
|
CONST.MENU.Y = 48
|
|
|
|
CONST.MENU.W = 424/2
|
2020-08-01 14:01:08 +02:00
|
|
|
CONST.MENU.ITEM_NUMBER = 8
|
2020-08-01 10:31:09 +02:00
|
|
|
|
|
|
|
-- Basic menu structure
|
2021-04-04 13:17:12 +02:00
|
|
|
function menu.MainMenu:new(scene, name)
|
|
|
|
local x, y = CONST.MENU.X, CONST.MENU.Y
|
|
|
|
local w = CONST.MENU.W / 1.5
|
|
|
|
local itemNumber = CONST.MENU.ITEM_NUMBER
|
|
|
|
menu.MainMenu.super.new(self, scene, name, x, y, w, itemNumber, false)
|
|
|
|
end
|
|
|
|
|
2020-08-01 10:31:09 +02:00
|
|
|
function menu.DebugMenu:new(scene, name)
|
|
|
|
local x, y = CONST.MENU.X, CONST.MENU.Y
|
2020-08-19 20:44:38 +02:00
|
|
|
local w = CONST.MENU.W
|
|
|
|
local itemNumber = CONST.MENU.ITEM_NUMBER
|
|
|
|
menu.DebugMenu.super.new(self, scene, name, x, y, w, itemNumber, false)
|
2020-08-01 10:31:09 +02:00
|
|
|
end
|
|
|
|
|
2020-08-19 20:44:38 +02:00
|
|
|
function menu.DebugMenu:setPanel(panel, panelArgument)
|
|
|
|
self.panel = panel
|
|
|
|
self.panelArgument = panelArgument
|
|
|
|
end
|
|
|
|
|
|
|
|
function menu.DebugMenu:activationAction()
|
|
|
|
if (self.panel ~= nil) then
|
|
|
|
self.scene.panel = self.panel(self.panelArgument)
|
|
|
|
end
|
|
|
|
end
|
2020-08-01 10:31:09 +02:00
|
|
|
|
2020-08-19 20:44:38 +02:00
|
|
|
function menu.DebugMenu:clone(name)
|
|
|
|
return menu.DebugMenu(self.scene, name)
|
2020-08-01 10:31:09 +02:00
|
|
|
end
|
|
|
|
|
2020-08-01 14:01:08 +02:00
|
|
|
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
|
|
|
|
|
2020-08-01 12:50:11 +02:00
|
|
|
-- SceneWidget
|
2020-08-02 10:18:40 +02:00
|
|
|
function menu.SceneWidget:new(scene, menuName, newScene, newSceneName, sceneArgument)
|
2020-08-19 20:44:38 +02:00
|
|
|
menu.SceneWidget.super.new(self, scene, menuName, newSceneName, "")
|
2020-08-01 12:50:11 +02:00
|
|
|
self.newScene = newScene
|
2020-08-02 10:18:40 +02:00
|
|
|
self.sceneArgument = sceneArgument
|
2020-08-01 12:50:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function menu.SceneWidget:action()
|
2021-04-11 10:32:49 +02:00
|
|
|
self.scene.assets:playSFX("mSelect")
|
2020-08-16 11:03:06 +02:00
|
|
|
self.scene:flushKeys()
|
2020-08-02 10:18:40 +02:00
|
|
|
if (self.sceneArgument ~= nil) then
|
2021-04-05 14:20:25 +02:00
|
|
|
core.screen:startTransition(defTransitions.default, defTransitions.default,
|
|
|
|
function() self.newScene(self.sceneArgument) end,
|
|
|
|
0, 0)
|
2020-08-02 10:18:40 +02:00
|
|
|
else
|
2021-04-05 14:20:25 +02:00
|
|
|
core.screen:startTransition(defTransitions.default, defTransitions.default,
|
|
|
|
function() self.newScene() end,
|
|
|
|
0, 0)
|
2020-08-02 10:18:40 +02:00
|
|
|
end
|
2020-08-01 12:50:11 +02:00
|
|
|
end
|
|
|
|
|
2020-08-01 10:31:09 +02:00
|
|
|
|
|
|
|
return menu
|