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

159 lines
5 KiB
Lua
Raw Normal View History

2021-05-05 08:30:32 +02:00
local Scene = require "birb.modules.scenes"
2020-08-01 10:31:09 +02:00
local menu = require "scenes.debug.menu.menu"
local DebugMenu = Scene:extend()
2020-08-02 08:30:19 +02:00
local panels = require "scenes.debug.menu.infopanel"
2020-08-01 10:31:09 +02:00
local gui = require "game.modules.gui"
2021-04-04 13:17:12 +02:00
local MenuBack = require "game.modules.gui.menuback"
local TweenManager = require "birb.classes.time"
2020-08-01 10:31:09 +02:00
function DebugMenu:new()
DebugMenu.super.new(self)
self.assets:batchImport("scenes.menus.assets")
2021-04-04 13:17:12 +02:00
menu.commons.MainMenu(self, "BaseMenu")
menu.StartGameWidget(self, "BaseMenu")
2020-08-01 16:06:08 +02:00
menu.commons.SceneWidget(self, "BaseMenu", scenes.options, "Options")
self:buildDebugMenu()
menu.TitleWidget(self, "BaseMenu")
self.menusystem.menus["BaseMenu"]:setCancelWidget()
2020-08-01 10:31:09 +02:00
menu.ExitWidget(self, "BaseMenu")
self.menusystem.menus["BaseMenu"]:finalize()
2020-08-01 10:31:09 +02:00
self.menusystem:activate()
self.menusystem:switchMenu("BaseMenu")
self.menusystem:setSoundFromSceneAssets("mBeep")
2020-08-02 08:30:19 +02:00
self.panel = panels.Gamedata()
2021-04-04 13:17:12 +02:00
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)
2020-08-01 10:31:09 +02:00
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
2020-08-01 10:31:09 +02:00
function DebugMenu:buildOverworldMenu()
self:addSubMenu("overworld", "debug", "Overworld")
menu.commons.SceneWidget(self, "overworld", scenes.overworld, "Launch Overworld")
2020-08-01 10:31:09 +02:00
end
function DebugMenu:buildBattleMenu()
self:addSubMenu("combat", "debug", "Battle System")
self:addSubMenu("launchBattle", "combat", "Launch Battle")
local listCat = core.datas:getCategories("battles")
for i,battleCat in ipairs(listCat) do
self:addBattles(battleCat)
end
2020-08-01 14:01:08 +02:00
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(core.datas:getFromCategory("battles", battleCat)) do
local data = core.datas:get("battles", battleName)
menu.commons.SceneWidget(self, menuName, scenes.cbs, "Launch " .. battleName, data)
end
2020-08-01 10:31:09 +02:00
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")
2020-08-02 08:30:19 +02:00
for name, data in pairs(game.characters.list) do
self:addCharacterMenu(name, data)
menu.AddRemoveWidget(self, "team", data)
2020-08-02 08:30:19 +02:00
end
2020-08-15 22:43:46 +02:00
self:addInventory()
2020-08-02 09:59:47 +02:00
self:addSubMenu("load", "save", "Load Saves")
for i=1, game.slotNumber do
menu.LoadWidget(self, "load", i)
end
menu.SaveWidget(self, "save")
2020-08-02 08:30:19 +02:00
end
function DebugMenu:addCharacterMenu(name, data)
2020-08-02 10:33:31 +02:00
self:addSubMenu(name, "characters", data.fullname, panels.Character, data)
menu.LevelUpWidget(self, name, data)
2020-08-01 10:31:09 +02:00
end
2020-08-15 22:43:46 +02:00
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(core.datas:getFromCategory("items", pocket.name)) do
menu.ItemWidget(self, pocket.name, core.datas:get("items", item))
2020-08-15 22:43:46 +02:00
end
end
end
2020-08-01 10:31:09 +02:00
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")
2020-08-01 10:31:09 +02:00
end
function DebugMenu:update(dt)
if (love.keyboard.isDown("space") and (not self.menusystem.isActive)) then
self.menusystem:activate()
end
2021-04-04 13:17:12 +02:00
self.back:update(dt)
self.tweens:update(dt)
2020-08-01 10:31:09 +02:00
end
2020-08-02 10:33:31 +02:00
function DebugMenu:addSubMenu(submenu, parent, name, panel, panelArgument)
2020-08-01 10:31:09 +02:00
local parent = parent or "BaseMenu"
self.menusystem.menus[parent]:addSubMenu(submenu, name)
if (panel ~= nil) then
2021-04-05 21:10:18 +02:00
--self.menusystem.menus[submenu]:setPanel(panel, panelArgument)
end
2020-08-01 10:31:09 +02:00
end
function DebugMenu:draw()
2021-04-04 13:17:12 +02:00
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)
2020-08-02 08:30:19 +02:00
if (self.menusystem.isActive) then
2020-08-02 08:30:19 +02:00
self.panel:draw(240, 48)
2020-08-01 10:31:09 +02:00
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
2020-08-01 10:31:09 +02:00
return DebugMenu;