feat: add a panel for character data
This commit is contained in:
parent
cf377f15b8
commit
64947f145e
4 changed files with 40 additions and 6 deletions
|
@ -0,0 +1,15 @@
|
|||
local Parent = require "scenes.debug.menu.infopanel.parent"
|
||||
local CharacterPanel = Parent:extend()
|
||||
|
||||
function CharacterPanel:new(character)
|
||||
CharacterPanel.super.new(self)
|
||||
self.character = character
|
||||
end
|
||||
|
||||
function CharacterPanel:drawContent(x, y)
|
||||
local debugString = "# " .. self.character.name .. "(" .. "Lvl " .. self.character.level .. ")" .. "\n"
|
||||
|
||||
love.graphics.print(debugString, x, y)
|
||||
end
|
||||
|
||||
return CharacterPanel
|
|
@ -2,4 +2,5 @@ local folder = "scenes.debug.menu.infopanel."
|
|||
|
||||
return {
|
||||
Gamedata = require(folder .. "gamedata"),
|
||||
Character = require(folder .. "character"),
|
||||
}
|
||||
|
|
|
@ -56,8 +56,8 @@ function DebugMenu:buildSaveMenu()
|
|||
end
|
||||
|
||||
function DebugMenu:addCharacterMenu(name, data)
|
||||
self:addSubMenu(name, "characters", data.fullname)
|
||||
menu.commons.SubMenuWidget(self, name, "characters", "Back")
|
||||
self:addSubMenu(name, "characters", data.fullname, panels.Character, data)
|
||||
menu.SubMenuWidget(self, name, "characters", "Back", panels.Gamedata, nil)
|
||||
end
|
||||
|
||||
function DebugMenu:buildOtherMenu()
|
||||
|
@ -83,10 +83,14 @@ function DebugMenu:update(dt)
|
|||
end
|
||||
end
|
||||
|
||||
function DebugMenu:addSubMenu(submenu, parent, name)
|
||||
function DebugMenu:addSubMenu(submenu, parent, name, panel, panelArgument)
|
||||
local parent = parent or "BaseMenu"
|
||||
menu.commons.DebugMenu(self, submenu)
|
||||
menu.commons.SubMenuWidget(self, parent, submenu, name .. " >")
|
||||
if (panel == nil) then
|
||||
menu.commons.SubMenuWidget(self, parent, submenu, name .. " >")
|
||||
else
|
||||
menu.SubMenuWidget(self, parent, submenu, name .. " >", panel, panelArgument)
|
||||
end
|
||||
end
|
||||
|
||||
function DebugMenu:draw()
|
||||
|
|
|
@ -5,6 +5,7 @@ menu.ExitWidget = commons.DebugWidget:extend()
|
|||
menu.ShowBackgroundWidget = commons.DebugWidget:extend()
|
||||
menu.SaveWidget = commons.DebugWidget:extend()
|
||||
menu.LoadWidget = commons.DebugWidget:extend()
|
||||
menu.SubMenuWidget = commons.SubMenuWidget:extend()
|
||||
|
||||
-- ExitWidget
|
||||
function menu.ExitWidget:new(scene, menuName)
|
||||
|
@ -26,7 +27,7 @@ end
|
|||
|
||||
-- Save game
|
||||
function menu.SaveWidget:new(scene, menuName)
|
||||
menu.ShowBackgroundWidget.super.new(self, scene, menuName, "Save game")
|
||||
menu.SaveWidget.super.new(self, scene, menuName, "Save game")
|
||||
end
|
||||
|
||||
function menu.SaveWidget:action()
|
||||
|
@ -35,7 +36,7 @@ end
|
|||
|
||||
-- Save game
|
||||
function menu.LoadWidget:new(scene, menuName, slot)
|
||||
menu.ShowBackgroundWidget.super.new(self, scene, menuName, "Load file " .. slot)
|
||||
menu.LoadWidget.super.new(self, scene, menuName, "Load file " .. slot)
|
||||
self.slot = slot
|
||||
end
|
||||
|
||||
|
@ -43,5 +44,18 @@ 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
|
||||
|
||||
|
||||
|
||||
return menu
|
||||
|
|
Loading…
Reference in a new issue