sonic-radiance/sonic-radiance.love/scenes/debug/menu/init.lua

160 lines
5.1 KiB
Lua

local Scene = require "birb.modules.scenes"
local menu = require "scenes.debug.menu.menu"
local DebugMenu = Scene:extend()
local panels = require "scenes.debug.menu.infopanel"
local battleutils = require "game.utils.battle"
local itemutils = require "game.utils.items"
local gui = require "game.modules.gui"
local MenuBack = require "game.modules.gui.menuback"
local TweenManager = require "birb.classes.time"
function DebugMenu:new()
DebugMenu.super.new(self)
self.assets:batchImport("scenes.menus.assets")
menu.commons.MainMenu(self, "BaseMenu")
menu.StartGameWidget(self, "BaseMenu")
menu.commons.SceneWidget(self, "BaseMenu", scenes.options, "Options")
self:buildDebugMenu()
menu.TitleWidget(self, "BaseMenu")
self.menusystem.menus["BaseMenu"]:setCancelWidget()
menu.ExitWidget(self, "BaseMenu")
self.menusystem.menus["BaseMenu"]:finalize()
self.menusystem:activate()
self.menusystem:switchMenu("BaseMenu")
self.menusystem:setSoundFromSceneAssets("mBeep")
self.panel = panels.Gamedata()
self.borderY = 30
self.borders = gui.newBorder(424, 30, 8)
self.backImage = love.graphics.newImage("assets/artworks/back.png")
self.back = MenuBack()
self.tweens = TweenManager(self)
end
function DebugMenu:buildDebugMenu()
if (core.debug.active) then
self:addSubMenu("debug", "BaseMenu", "Debug Menu")
self:buildBattleMenu()
--self:buildOverworldMenu()
self:buildSaveMenu()
self:buildOtherMenu()
end
end
function DebugMenu:buildOverworldMenu()
self:addSubMenu("overworld", "debug", "Overworld")
menu.commons.SceneWidget(self, "overworld", scenes.overworld, "Launch Overworld")
end
function DebugMenu:buildBattleMenu()
self:addSubMenu("combat", "debug", "Battle System")
self:addSubMenu("launchBattle", "combat", "Launch Battle")
local listCat = battleutils.listCategories()
for i,battleCat in ipairs(listCat) do
self:addBattles(battleCat)
end
menu.commons.SceneWidget(self, "combat", scenes.debug.viewers.battleBack, "Background Viewer")
menu.commons.SceneWidget(self, "combat", scenes.debug.viewers.choregraphy, "Ennemies' Action Viewer")
end
function DebugMenu:addBattles(battleCat)
local menuName = "b_" .. battleCat
self:addSubMenu(menuName, "launchBattle", battleCat)
for i,battleName in ipairs(battleutils.getBattleFromCategory(battleCat)) do
local data = battleutils.getBattleData(battleCat, battleName)
menu.commons.SceneWidget(self, menuName, scenes.cbs, "Launch " .. battleName, data)
end
end
function DebugMenu:buildSaveMenu()
self:addSubMenu("save", "debug", "Save System", panels.Gamedata, nil)
self:addSubMenu("characters", "save", "Characters", panels.Gamedata, nil)
self:addSubMenu("team", "save", "Team Formation", panels.Team, nil)
menu.ChangeLeaderWidget(self, "team")
for name, data in pairs(game.characters.list) do
self:addCharacterMenu(name, data)
menu.AddRemoveWidget(self, "team", data)
end
self:addInventory()
self:addSubMenu("load", "save", "Load Saves")
for i=1, game.slotNumber do
menu.LoadWidget(self, "load", i)
end
menu.SaveWidget(self, "save")
end
function DebugMenu:addCharacterMenu(name, data)
self:addSubMenu(name, "characters", data.fullname, panels.Character, data)
menu.LevelUpWidget(self, name, data)
end
function DebugMenu:addInventory()
self:addSubMenu("inventory", "save", "Inventory")
for i,pocket in ipairs(game.loot.inventory) do
self:addSubMenu(pocket.name, "inventory", pocket.fullname)
for j, item in ipairs(itemutils.getItemsFromCategory(pocket.name)) do
menu.ItemWidget(self, pocket.name, itemutils.getItemData(pocket.name, item))
end
end
end
function DebugMenu:buildOtherMenu()
self:addSubMenu("other", "debug", "Other gameplay")
self:addSubMenu("battle", "other", "Sonic Battle Maps")
local mapList = require "datas.gamedata.maps.battle"
for i, name in ipairs(mapList) do
local mapData = require("datas.gamedata.maps.battle." .. name)
local trueName = mapData.name
menu.commons.SceneWidget(self, "battle", scenes.test, trueName, name)
end
menu.commons.SceneWidget(self, "other", scenes.test2, "Shadow Shot Maps")
end
function DebugMenu:update(dt)
if (love.keyboard.isDown("space") and (not self.menusystem.isActive)) then
self.menusystem:activate()
end
self.back:update(dt)
self.tweens:update(dt)
end
function DebugMenu:addSubMenu(submenu, parent, name, panel, panelArgument)
local parent = parent or "BaseMenu"
self.menusystem.menus[parent]:addSubMenu(submenu, name)
if (panel ~= nil) then
--self.menusystem.menus[submenu]:setPanel(panel, panelArgument)
end
end
function DebugMenu:draw()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.rectangle("fill", 0, 0, 424, 240)
self.back:draw()
utils.graphics.resetColor()
love.graphics.draw(self.backImage, 0, 0)
if (self.menusystem.isActive) then
self.panel:draw(240, 48)
end
end
function DebugMenu:drawOverTransition()
love.graphics.draw(self.borders, 0, self.borderY, 0, 1, -1)
love.graphics.draw(self.borders, 424, 240 - self.borderY, 0, -1, 1)
self.assets.fonts["small"]:draw("v" .. game.version, 424 - 44, 240 + 10 - self.borderY)
end
return DebugMenu;