improvement: port the debug menu to the new framework
This commit is contained in:
parent
625123813c
commit
78fca02441
6 changed files with 53 additions and 128 deletions
|
@ -1,12 +1,10 @@
|
|||
local menu = {}
|
||||
|
||||
local ListBox = require "core.modules.menusystem.listbox"
|
||||
local RadianceListMenu = require "game.modules.menus.list"
|
||||
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()
|
||||
menu.DebugMenu = RadianceListMenu.ListMenu:extend()
|
||||
menu.SceneWidget = RadianceListMenu.DualTextWidget:extend()
|
||||
|
||||
local CONST = {}
|
||||
CONST.MENU = {}
|
||||
|
@ -14,18 +12,29 @@ 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)
|
||||
local w = CONST.MENU.W
|
||||
local itemNumber = CONST.MENU.ITEM_NUMBER
|
||||
menu.DebugMenu.super.new(self, scene, name, x, y, w, itemNumber, false)
|
||||
end
|
||||
|
||||
function menu.DebugMenu:drawCursor()
|
||||
function menu.DebugMenu:setPanel(panel, panelArgument)
|
||||
self.panel = panel
|
||||
self.panelArgument = panelArgument
|
||||
end
|
||||
|
||||
function menu.DebugMenu:activationAction()
|
||||
print("test")
|
||||
if (self.panel ~= nil) then
|
||||
self.scene.panel = self.panel(self.panelArgument)
|
||||
end
|
||||
end
|
||||
|
||||
function menu.DebugMenu:clone(name)
|
||||
return menu.DebugMenu(self.scene, name)
|
||||
end
|
||||
|
||||
function menu.DebugMenu:draw()
|
||||
|
@ -35,38 +44,9 @@ function menu.DebugMenu:draw()
|
|||
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, sceneArgument)
|
||||
menu.SceneWidget.super.new(self, scene, menuName, newSceneName)
|
||||
menu.SceneWidget.super.new(self, scene, menuName, newSceneName, "")
|
||||
self.newScene = newScene
|
||||
self.sceneArgument = sceneArgument
|
||||
end
|
||||
|
|
|
@ -18,6 +18,7 @@ function DebugMenu:new()
|
|||
menu.commons.SceneWidget(self, "BaseMenu", scenes.options, "Options")
|
||||
menu.ExitWidget(self, "BaseMenu")
|
||||
|
||||
self.menusystem.menus["BaseMenu"]:finalize()
|
||||
self.menusystem:activate()
|
||||
self.menusystem:switchMenu("BaseMenu")
|
||||
|
||||
|
@ -27,7 +28,6 @@ end
|
|||
function DebugMenu:buildOverworldMenu()
|
||||
self:addSubMenu("overworld", "BaseMenu", "Overworld")
|
||||
menu.commons.SceneWidget(self, "overworld", scenes.overworld, "Launch Overworld")
|
||||
menu.commons.SubMenuWidget(self, "overworld", "BaseMenu", "Back")
|
||||
end
|
||||
|
||||
function DebugMenu:buildBattleMenu()
|
||||
|
@ -41,9 +41,6 @@ function DebugMenu:buildBattleMenu()
|
|||
|
||||
menu.commons.SceneWidget(self, "combat", scenes.debug.viewers.battleBack, "Background Viewer")
|
||||
menu.commons.SceneWidget(self, "combat", scenes.debug.viewers.choregraphy, "Ennemies' Action Viewer")
|
||||
|
||||
menu.commons.SubMenuWidget(self, "combat", "BaseMenu", "Back")
|
||||
menu.commons.SubMenuWidget(self, "launchBattle", "combat", "Back")
|
||||
end
|
||||
|
||||
function DebugMenu:addBattles(battleCat)
|
||||
|
@ -54,13 +51,11 @@ function DebugMenu:addBattles(battleCat)
|
|||
local data = battleutils.getBattleData(battleCat, battleName)
|
||||
menu.commons.SceneWidget(self, menuName, scenes.cbs, "Launch " .. battleName, data)
|
||||
end
|
||||
|
||||
menu.commons.SubMenuWidget(self, menuName, "launchBattle", "Back")
|
||||
end
|
||||
|
||||
function DebugMenu:buildSaveMenu()
|
||||
self:addSubMenu("save", "BaseMenu", "Save System")
|
||||
self:addSubMenu("characters", "save", "Characters")
|
||||
self:addSubMenu("save", "BaseMenu", "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
|
||||
|
@ -75,18 +70,11 @@ function DebugMenu:buildSaveMenu()
|
|||
menu.LoadWidget(self, "load", i)
|
||||
end
|
||||
menu.SaveWidget(self, "save")
|
||||
|
||||
|
||||
menu.commons.SubMenuWidget(self, "save", "BaseMenu", "Back")
|
||||
menu.commons.SubMenuWidget(self, "characters", "save", "Back")
|
||||
menu.commons.SubMenuWidget(self, "load", "save", "Back")
|
||||
menu.SubMenuWidget(self, "team", "save", "Back", panels.Gamedata, nil)
|
||||
end
|
||||
|
||||
function DebugMenu:addCharacterMenu(name, data)
|
||||
self:addSubMenu(name, "characters", data.fullname, panels.Character, data)
|
||||
menu.LevelUpWidget(self, name, data)
|
||||
menu.SubMenuWidget(self, name, "characters", "Back", panels.Gamedata, nil)
|
||||
end
|
||||
|
||||
function DebugMenu:addInventory()
|
||||
|
@ -96,9 +84,7 @@ function DebugMenu:addInventory()
|
|||
for j, item in ipairs(itemutils.getItemsFromCategory(pocket.name)) do
|
||||
menu.ItemWidget(self, pocket.name, itemutils.getItemData(pocket.name, item))
|
||||
end
|
||||
menu.commons.SubMenuWidget(self, pocket.name, "inventory", "Back")
|
||||
end
|
||||
menu.commons.SubMenuWidget(self, "inventory", "save", "Back")
|
||||
end
|
||||
|
||||
function DebugMenu:buildOtherMenu()
|
||||
|
@ -112,9 +98,6 @@ function DebugMenu:buildOtherMenu()
|
|||
end
|
||||
|
||||
menu.commons.SceneWidget(self, "other", scenes.test2, "Shadow Shot Maps")
|
||||
|
||||
menu.commons.SubMenuWidget(self, "battle", "other", "Back")
|
||||
menu.commons.SubMenuWidget(self, "other", "BaseMenu", "Back")
|
||||
end
|
||||
|
||||
|
||||
|
@ -126,12 +109,10 @@ end
|
|||
|
||||
function DebugMenu:addSubMenu(submenu, parent, name, panel, panelArgument)
|
||||
local parent = parent or "BaseMenu"
|
||||
menu.commons.DebugMenu(self, submenu)
|
||||
if (panel == nil) then
|
||||
menu.commons.SubMenuWidget(self, parent, submenu, name .. " >")
|
||||
else
|
||||
menu.SubMenuWidget(self, parent, submenu, name .. " >", panel, panelArgument)
|
||||
end
|
||||
self.menusystem.menus[parent]:addSubMenu(submenu, name)
|
||||
if (panel ~= nil) then
|
||||
self.menusystem.menus[submenu]:setPanel(panel, panelArgument)
|
||||
end
|
||||
end
|
||||
|
||||
function DebugMenu:draw()
|
||||
|
|
|
@ -1,37 +1,28 @@
|
|||
local commons = require "scenes.debug.commons.menu"
|
||||
local listMenu = require "game.modules.menus.list"
|
||||
|
||||
local menu = {}
|
||||
menu.commons = commons
|
||||
menu.ExitWidget = commons.DebugWidget:extend()
|
||||
menu.ShowBackgroundWidget = commons.DebugWidget:extend()
|
||||
menu.SaveWidget = commons.DebugWidget:extend()
|
||||
menu.LoadWidget = commons.DebugWidget:extend()
|
||||
menu.LevelUpWidget = commons.DebugWidget:extend()
|
||||
menu.AddRemoveWidget = commons.DebugWidget:extend()
|
||||
menu.ChangeLeaderWidget = commons.DebugWidget:extend()
|
||||
menu.SubMenuWidget = commons.SubMenuWidget:extend()
|
||||
menu.ItemWidget = commons.DebugWidget:extend()
|
||||
menu.ExitWidget = listMenu.DualTextWidget:extend()
|
||||
menu.SaveWidget = listMenu.DualTextWidget:extend()
|
||||
menu.LoadWidget = listMenu.DualTextWidget:extend()
|
||||
menu.LevelUpWidget = listMenu.DualTextWidget:extend()
|
||||
menu.AddRemoveWidget = listMenu.DualTextWidget:extend()
|
||||
menu.ChangeLeaderWidget = listMenu.DualTextWidget:extend()
|
||||
menu.ItemWidget = listMenu.DualTextWidget:extend()
|
||||
|
||||
-- ExitWidget
|
||||
function menu.ExitWidget:new(scene, menuName)
|
||||
menu.ExitWidget.super.new(self, scene, menuName, "Exit")
|
||||
menu.ExitWidget.super.new(self, scene, menuName, "Exit", "")
|
||||
end
|
||||
|
||||
function menu.ExitWidget:action()
|
||||
love.event.quit("000")
|
||||
end
|
||||
|
||||
-- ShowBackground
|
||||
function menu.ShowBackgroundWidget:new(scene, menuName)
|
||||
menu.ShowBackgroundWidget.super.new(self, scene, menuName, "Show Background")
|
||||
end
|
||||
|
||||
function menu.ShowBackgroundWidget:action()
|
||||
self.scene.menusystem:deactivate()
|
||||
end
|
||||
|
||||
-- Save game
|
||||
function menu.SaveWidget:new(scene, menuName)
|
||||
menu.SaveWidget.super.new(self, scene, menuName, "Save game")
|
||||
menu.SaveWidget.super.new(self, scene, menuName, "Save game", "")
|
||||
end
|
||||
|
||||
function menu.SaveWidget:action()
|
||||
|
@ -40,7 +31,7 @@ end
|
|||
|
||||
-- Save game
|
||||
function menu.LoadWidget:new(scene, menuName, slot)
|
||||
menu.LoadWidget.super.new(self, scene, menuName, "Load file " .. slot)
|
||||
menu.LoadWidget.super.new(self, scene, menuName, "Load file ", slot)
|
||||
self.slot = slot
|
||||
end
|
||||
|
||||
|
@ -48,21 +39,9 @@ function menu.LoadWidget:action()
|
|||
game:read(self.slot)
|
||||
end
|
||||
|
||||
-- Submenu
|
||||
function menu.SubMenuWidget:new(scene, menu_name, newmenu, name, panel, panelArgument)
|
||||
menu.SubMenuWidget.super.new(self, scene, menu_name, newmenu, name)
|
||||
self.panel = panel
|
||||
self.panelArgument = panelArgument
|
||||
end
|
||||
|
||||
function menu.SubMenuWidget:action()
|
||||
self.scene.menusystem:switchMenu(self.newmenu)
|
||||
self.scene.panel = self.panel(self.panelArgument)
|
||||
end
|
||||
|
||||
-- Level Up
|
||||
function menu.LevelUpWidget:new(scene, menuName, character)
|
||||
menu.ShowBackgroundWidget.super.new(self, scene, menuName, "Level Up")
|
||||
menu.LevelUpWidget.super.new(self, scene, menuName, "Levelup to", character.level + 1)
|
||||
self.character = character
|
||||
end
|
||||
|
||||
|
@ -72,7 +51,7 @@ end
|
|||
|
||||
-- Add Remove Widget
|
||||
function menu.AddRemoveWidget:new(scene, menuName, character)
|
||||
menu.AddRemoveWidget.super.new(self, scene, menuName, "Add/Remove " .. character.name)
|
||||
menu.AddRemoveWidget.super.new(self, scene, menuName, "Add/Remove", character.name)
|
||||
self.character = character
|
||||
end
|
||||
|
||||
|
@ -82,7 +61,7 @@ end
|
|||
|
||||
--Change Team Leader
|
||||
function menu.ChangeLeaderWidget:new(scene, menuName)
|
||||
menu.ShowBackgroundWidget.super.new(self, scene, menuName, "Change active character")
|
||||
menu.ChangeLeaderWidget.super.new(self, scene, menuName, "Change active character", "")
|
||||
end
|
||||
|
||||
function menu.ChangeLeaderWidget:action()
|
||||
|
@ -91,7 +70,7 @@ end
|
|||
|
||||
-- ItemWidget
|
||||
function menu.ItemWidget:new(scene, menuName, itemdata)
|
||||
menu.ItemWidget.super.new(self, scene, menuName, itemdata.fullname)
|
||||
menu.ItemWidget.super.new(self, scene, menuName, itemdata.fullname, "")
|
||||
self.category = menuName
|
||||
self.itemName = itemdata.name
|
||||
end
|
||||
|
@ -101,5 +80,4 @@ function menu.ItemWidget:action()
|
|||
end
|
||||
|
||||
|
||||
|
||||
return menu
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
local commons = require "scenes.debug.commons.menu"
|
||||
local listMenu = require "game.modules.menus.list"
|
||||
local menu = {}
|
||||
menu.commons = commons
|
||||
menu.ShowBackgroundWidget = menu.commons.DebugWidget:extend()
|
||||
menu.ShowBackgroundWidget = listMenu.DualTextWidget:extend()
|
||||
|
||||
-- ShowBackground
|
||||
function menu.ShowBackgroundWidget:new(scene, menuName, backgroundName, backgroundId)
|
||||
menu.ShowBackgroundWidget.super.new(self, scene, menuName, backgroundName)
|
||||
menu.ShowBackgroundWidget.super.new(self, scene, menuName, backgroundName, "")
|
||||
self.backgroundId = backgroundId
|
||||
end
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ function ChoregraphyViewer:buildMenu()
|
|||
|
||||
self:buildCharacterMenu()
|
||||
|
||||
self.menusystem.menus["MainMenu"]:finalize()
|
||||
self.menusystem:activate()
|
||||
self.menusystem:switchMenu("MainMenu")
|
||||
menu.commons.SceneWidget(self, "MainMenu", scenes.debug.menu, "Back")
|
||||
|
@ -38,9 +39,7 @@ function ChoregraphyViewer:buildCharacterMenu()
|
|||
self:addSubMenu(k, "characters", character.fullname)
|
||||
menu.HeroChoregraphyWidget(self, k, game.skills:getSkillData("attack"))
|
||||
self:buildSkillMenu(k)
|
||||
menu.commons.SubMenuWidget(self, k, "characters", "Back")
|
||||
end
|
||||
menu.commons.SubMenuWidget(self, "characters", "MainMenu", "Back")
|
||||
end
|
||||
|
||||
function ChoregraphyViewer:buildEnnemyListMenu(category)
|
||||
|
@ -48,7 +47,6 @@ function ChoregraphyViewer:buildEnnemyListMenu(category)
|
|||
for i,ennemy in ipairs(ennutils.getEnnemiesFromCategory(category)) do
|
||||
self:buildEnnemySkillMenu(category, ennemy)
|
||||
end
|
||||
menu.commons.SubMenuWidget(self, category, "MainMenu", "Back")
|
||||
end
|
||||
|
||||
function ChoregraphyViewer:buildEnnemySkillMenu(category, ennemy)
|
||||
|
@ -59,7 +57,6 @@ function ChoregraphyViewer:buildEnnemySkillMenu(category, ennemy)
|
|||
menu.EnnemyChoregraphyWidget(self, category, ennemy, game.skills:getEnnemySkillData(skillName))
|
||||
end
|
||||
end
|
||||
menu.commons.SubMenuWidget(self, ennemy, category, "Back")
|
||||
end
|
||||
|
||||
function ChoregraphyViewer:buildSkillMenu(charName)
|
||||
|
@ -78,8 +75,7 @@ end
|
|||
|
||||
function ChoregraphyViewer:addSubMenu(submenu, parent, name)
|
||||
local parent = parent or "MainMenu"
|
||||
menu.commons.DebugMenu(self, submenu)
|
||||
menu.commons.SubMenuWidget(self, parent, submenu, name .. " >")
|
||||
self.menusystem.menus[parent]:addSubMenu(submenu, name)
|
||||
end
|
||||
|
||||
-- MOCKS FUNCTIONS
|
||||
|
|
|
@ -1,24 +1,13 @@
|
|||
local commons = require "scenes.debug.commons.menu"
|
||||
local listMenu = require "game.modules.menus.list"
|
||||
local menu = {}
|
||||
menu.commons = commons
|
||||
menu.ShowBackgroundWidget = menu.commons.DebugWidget:extend()
|
||||
menu.HeroChoregraphyWidget = commons.DebugWidget:extend()
|
||||
menu.EnnemyChoregraphyWidget = commons.DebugWidget:extend()
|
||||
|
||||
-- ShowBackground
|
||||
function menu.ShowBackgroundWidget:new(scene, menuName, backgroundName, backgroundId)
|
||||
menu.ShowBackgroundWidget.super.new(self, scene, menuName, backgroundName)
|
||||
self.backgroundId = backgroundId
|
||||
end
|
||||
|
||||
function menu.ShowBackgroundWidget:action()
|
||||
self.scene:setBackground(self.backgroundId)
|
||||
self.scene.menusystem:deactivate()
|
||||
end
|
||||
menu.HeroChoregraphyWidget = listMenu.DualTextWidget:extend()
|
||||
menu.EnnemyChoregraphyWidget = listMenu.DualTextWidget:extend()
|
||||
|
||||
-- ShowBackground
|
||||
function menu.HeroChoregraphyWidget:new(scene, charName, skillData)
|
||||
menu.HeroChoregraphyWidget.super.new(self, scene, charName, skillData.name)
|
||||
menu.HeroChoregraphyWidget.super.new(self, scene, charName, skillData.name, "")
|
||||
self.character = charName
|
||||
self.skillData = skillData
|
||||
end
|
||||
|
@ -30,7 +19,7 @@ end
|
|||
|
||||
-- ShowBackground
|
||||
function menu.EnnemyChoregraphyWidget:new(scene, category, charName, skillData)
|
||||
menu.EnnemyChoregraphyWidget.super.new(self, scene, charName, skillData.name)
|
||||
menu.EnnemyChoregraphyWidget.super.new(self, scene, charName, skillData.name, "")
|
||||
self.category = category
|
||||
self.character = charName
|
||||
self.skillData = skillData
|
||||
|
|
Loading…
Reference in a new issue