From 64947f145e79e9ecf34715117088b634b1a9ffdb Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 2 Aug 2020 10:33:31 +0200 Subject: [PATCH] feat: add a panel for character data --- .../scenes/debug/menu/infopanel/character.lua | 15 +++++++++++++++ .../scenes/debug/menu/infopanel/init.lua | 1 + sonic-radiance.love/scenes/debug/menu/init.lua | 12 ++++++++---- sonic-radiance.love/scenes/debug/menu/menu.lua | 18 ++++++++++++++++-- 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 sonic-radiance.love/scenes/debug/menu/infopanel/character.lua diff --git a/sonic-radiance.love/scenes/debug/menu/infopanel/character.lua b/sonic-radiance.love/scenes/debug/menu/infopanel/character.lua new file mode 100644 index 0000000..a3af0a0 --- /dev/null +++ b/sonic-radiance.love/scenes/debug/menu/infopanel/character.lua @@ -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 diff --git a/sonic-radiance.love/scenes/debug/menu/infopanel/init.lua b/sonic-radiance.love/scenes/debug/menu/infopanel/init.lua index 3550ce8..d3b96a1 100644 --- a/sonic-radiance.love/scenes/debug/menu/infopanel/init.lua +++ b/sonic-radiance.love/scenes/debug/menu/infopanel/init.lua @@ -2,4 +2,5 @@ local folder = "scenes.debug.menu.infopanel." return { Gamedata = require(folder .. "gamedata"), + Character = require(folder .. "character"), } diff --git a/sonic-radiance.love/scenes/debug/menu/init.lua b/sonic-radiance.love/scenes/debug/menu/init.lua index e95973f..189e9d4 100644 --- a/sonic-radiance.love/scenes/debug/menu/init.lua +++ b/sonic-radiance.love/scenes/debug/menu/init.lua @@ -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() diff --git a/sonic-radiance.love/scenes/debug/menu/menu.lua b/sonic-radiance.love/scenes/debug/menu/menu.lua index 5c1266b..0ba4c1c 100644 --- a/sonic-radiance.love/scenes/debug/menu/menu.lua +++ b/sonic-radiance.love/scenes/debug/menu/menu.lua @@ -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