From 5ab143e5f42c1a02a3c2a661c1adb8168cd0dd96 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 31 Mar 2019 17:07:45 +0200 Subject: [PATCH] battlesystem: create builder for skill menu --- .../scenes/battlesystem/controller/menu.lua | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sonic-radiance.love/scenes/battlesystem/controller/menu.lua b/sonic-radiance.love/scenes/battlesystem/controller/menu.lua index 714289d..25a424e 100644 --- a/sonic-radiance.love/scenes/battlesystem/controller/menu.lua +++ b/sonic-radiance.love/scenes/battlesystem/controller/menu.lua @@ -32,22 +32,23 @@ function MenuConstructor:buildBaseMenu(character) for i,v in ipairs(BaseMenu) do CharMenuWidget(self.controller, "BaseMenu", v, "", character) end + + self.controller.menusystem.menus["BaseMenu"]:setCancelWidget() end function MenuConstructor:set(currentCharacter) self:reconstruct(currentCharacter) end -function MenuConstructor:getSkillList() +function MenuConstructor:buildSkillMenu() + CharacterMenu(self.controller, "SkillMenu", MENUPOS_X1 - 16, MENUPOS_Y) local list = game.characters:getSkillList(self.character.charid) - local skillmenu = {} for k,v in pairs(list) do - table.insert(skillmenu, k) + CharMenuWidget(self.controller, "SkillMenu", k, "", character) end + CharMenuWidget(self.controller, "Back", v, "", character) - table.insert(skillmenu, "back") - - return skillmenu + self.controller.menusystem.menus["SkillMenu"]:setCancelWidget() end function MenuConstructor:unset( ) @@ -135,4 +136,15 @@ function CharMenuWidget:action() self.scene.menusystem:reset() end +-- Submenu Widget + +function SubMenuWidget:new(scene, menu_name, label, newmenu, character) + SubMenuWidget.super.new(self, scene, menu_name, label, "", character) + self.newmenu = newmenu or "BaseMenu" +end + +function SubMenuWidget:action() + self.scene.menusystem:switchMenu(newmenu) +end + return MenuConstructor