chore: make the scene change widget a common element

This commit is contained in:
Kazhnuz 2020-08-01 12:50:11 +02:00
parent 4b9ba5eed6
commit 0984ce370e
3 changed files with 14 additions and 14 deletions

View file

@ -6,6 +6,7 @@ local Widget = require "core.modules.menusystem.widgets"
menu.DebugMenu = ListBox:extend() menu.DebugMenu = ListBox:extend()
menu.DebugWidget = Widget.Text:extend() menu.DebugWidget = Widget.Text:extend()
menu.SubMenuWidget = menu.DebugWidget:extend() menu.SubMenuWidget = menu.DebugWidget:extend()
menu.SceneWidget = menu.DebugWidget:extend()
local CONST = {} local CONST = {}
CONST.MENU = {} CONST.MENU = {}
@ -56,5 +57,15 @@ function menu.SubMenuWidget:action()
self.scene.menusystem:switchMenu(self.newmenu) self.scene.menusystem:switchMenu(self.newmenu)
end end
-- SceneWidget
function menu.SceneWidget:new(scene, menuName, newScene, newSceneName)
menu.SceneWidget.super.new(self, scene, menuName, newSceneName)
self.newScene = newScene
end
function menu.SceneWidget:action()
self.newScene()
end
return menu return menu

View file

@ -7,7 +7,7 @@ function DebugMenu:new()
DebugMenu.super.new(self) DebugMenu.super.new(self)
self.assets:batchImport("scenes.debug.commons.assets") self.assets:batchImport("scenes.debug.commons.assets")
menu.commons.DebugMenu(self, "BaseMenu") menu.commons.DebugMenu(self, "BaseMenu")
menu.SceneWidget(self, "BaseMenu", scenes.title, "Launch Game") menu.commons.SceneWidget(self, "BaseMenu", scenes.title, "Launch Game")
self:buildBattleMenu() self:buildBattleMenu()
self:buildOverworldMenu() self:buildOverworldMenu()
self:buildSaveMenu() self:buildSaveMenu()
@ -35,7 +35,7 @@ end
function DebugMenu:buildBattleMenu() function DebugMenu:buildBattleMenu()
self:addSubMenu("combat", "BaseMenu", "Battle System") self:addSubMenu("combat", "BaseMenu", "Battle System")
menu.SceneWidget(self, "combat", scenes.cbs, "Launch Battle") menu.commons.SceneWidget(self, "combat", scenes.cbs, "Launch Battle")
menu.commons.SubMenuWidget(self, "combat", "BaseMenu", "Back") menu.commons.SubMenuWidget(self, "combat", "BaseMenu", "Back")
end end
@ -47,7 +47,7 @@ end
function DebugMenu:buildOtherMenu() function DebugMenu:buildOtherMenu()
self:addSubMenu("other", "BaseMenu", "Other gameplay") self:addSubMenu("other", "BaseMenu", "Other gameplay")
menu.SceneWidget(self, "other", scenes.test, "Minigame Engine") menu.commons.SceneWidget(self, "other", scenes.test, "Minigame Engine")
menu.commons.SubMenuWidget(self, "other", "BaseMenu", "Back") menu.commons.SubMenuWidget(self, "other", "BaseMenu", "Back")
end end

View file

@ -3,7 +3,6 @@ local menu = {}
menu.commons = commons menu.commons = commons
menu.ExitWidget = commons.DebugWidget:extend() menu.ExitWidget = commons.DebugWidget:extend()
menu.ShowBackgroundWidget = commons.DebugWidget:extend() menu.ShowBackgroundWidget = commons.DebugWidget:extend()
menu.SceneWidget = commons.DebugWidget:extend()
-- ExitWidget -- ExitWidget
function menu.ExitWidget:new(scene, menuName) function menu.ExitWidget:new(scene, menuName)
@ -23,14 +22,4 @@ function menu.ShowBackgroundWidget:action()
self.scene.menusystem:deactivate() self.scene.menusystem:deactivate()
end end
-- SceneWidget
function menu.SceneWidget:new(scene, menuName, newScene, newSceneName)
menu.SceneWidget.super.new(self, scene, menuName, newSceneName)
self.newScene = newScene
end
function menu.SceneWidget:action()
self.newScene()
end
return menu return menu