chore: port the main menu to the new system
This commit is contained in:
parent
abfda56b14
commit
93bbf56047
1 changed files with 21 additions and 20 deletions
|
@ -40,22 +40,25 @@ function MainMenu:new()
|
|||
local name = i .. "player"
|
||||
self:addSubMenu(name, name)
|
||||
if i == 1 then
|
||||
self:addScene(name, scenes.Plateformer, "plateform", i)
|
||||
self:addScene(scenes.Plateformer, "plateform", i)
|
||||
end
|
||||
self:addScene(name, scenes.MovePlayer, "topdown", i)
|
||||
self:addScene(name, scenes.MovePlayer3D, "topdown3D", i)
|
||||
self:addScene(name, scenes.Action3D, "bigmap3D", i)
|
||||
self:addScene(scenes.MovePlayer, "topdown", i)
|
||||
self:addScene(scenes.MovePlayer3D, "topdown3D", i)
|
||||
self:addScene(scenes.Action3D, "bigmap3D", i)
|
||||
if i > 1 then
|
||||
self:addScene(name, scenes.MovePlayer, "topdown (zoom)", i, "zoom")
|
||||
self:addScene(name, scenes.MovePlayer3D, "topdown3D (zoom)", i, "zoom")
|
||||
self:addScene(scenes.MovePlayer, "topdown (zoom)", i, "zoom")
|
||||
self:addScene(scenes.MovePlayer3D, "topdown3D (zoom)", i, "zoom")
|
||||
end
|
||||
end
|
||||
self:addSubMenu("menus", "menu")
|
||||
self:addScene("menus", scenes.Inventory, "inventory")
|
||||
self:addScene("menus", scenes.Options, "options")
|
||||
self:addScene(scenes.Inventory, "inventory")
|
||||
self:addScene(scenes.Options, "options")
|
||||
self:addScene(scenes.TestMenu, "tests")
|
||||
|
||||
|
||||
self.menusystem:setSoundFromSceneAssets("navigate")
|
||||
local menu = self.menusystem.menus["main"]
|
||||
menu:switch("main")
|
||||
|
||||
ExitWidget(self, "main")
|
||||
self.menusystem:switchMenu("main")
|
||||
|
@ -65,21 +68,22 @@ end
|
|||
-- Functions that serve the handling of menus
|
||||
|
||||
function MainMenu:addMenu(name, nobackbutton)
|
||||
local screenHeight, screenWidth = core.screen:getDimensions()
|
||||
local w, h = 424/2, 240 - 48
|
||||
local x, y = w / 2, 24
|
||||
ListBox(self.menusystem, name, x, y, w, h, 8)
|
||||
end
|
||||
|
||||
function MainMenu:addSubMenu(name, fullname)
|
||||
self:addMenu(name)
|
||||
local menu = self.menusystem.menus["main"]
|
||||
menu:switch("main")
|
||||
SubMenuWidget(self, "main", name, fullname)
|
||||
SubMenuWidget(self, name, "main", "back", 1)
|
||||
menu:addSubmenu(name)
|
||||
SubMenuWidget(self, "main", "main", "back", 1)
|
||||
end
|
||||
|
||||
function MainMenu:addScene(submenu, scene, fullname, arg1, arg2, arg3, arg4, arg5)
|
||||
function MainMenu:addScene(scene, fullname, arg1, arg2, arg3, arg4, arg5)
|
||||
local args = {arg1, arg2, arg3, arg4, arg5}
|
||||
SceneWidget(self, submenu, scene, fullname, args)
|
||||
SceneWidget(self, "main", scene, fullname, args)
|
||||
end
|
||||
|
||||
function MainMenu:draw()
|
||||
|
@ -96,7 +100,6 @@ end
|
|||
|
||||
function SubMenuWidget:new(scene, menu, newmenu, fullname, order)
|
||||
self.scene = scene
|
||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
||||
local font = self.scene.assets:getFont("medium")
|
||||
self.newmenu = newmenu
|
||||
local label = ""
|
||||
|
@ -107,13 +110,13 @@ function SubMenuWidget:new(scene, menu, newmenu, fullname, order)
|
|||
label = core.lang:translate("mainmenu", fullname)
|
||||
self.sfx = "confirm"
|
||||
end
|
||||
SubMenuWidget.super.new(self, widgetmenu, font, label)
|
||||
SubMenuWidget.super.new(self, menu, font, label)
|
||||
self.order = order or 0
|
||||
end
|
||||
|
||||
function SubMenuWidget:action()
|
||||
self.scene.assets:playSFX(self.sfx)
|
||||
self.scene.menusystem:switchMenu(self.newmenu)
|
||||
self.menu:switch(self.newmenu)
|
||||
end
|
||||
|
||||
-- Scene widget :: switch scene
|
||||
|
@ -121,11 +124,10 @@ end
|
|||
function SceneWidget:new(scene, menu, newscene, fullname, args)
|
||||
self.scene = scene
|
||||
self.args = args
|
||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
||||
local font = self.scene.assets:getFont("medium")
|
||||
self.newscene = newscene
|
||||
local label = core.lang:translate("mainmenu", fullname)
|
||||
SceneWidget.super.new(self, widgetmenu, font, label)
|
||||
SceneWidget.super.new(self, menu, font, label)
|
||||
end
|
||||
|
||||
function SceneWidget:action()
|
||||
|
@ -138,10 +140,9 @@ end
|
|||
|
||||
function ExitWidget:new(scene, menu)
|
||||
self.scene = scene
|
||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
||||
local font = self.scene.assets:getFont("medium")
|
||||
local label = core.lang:translate("commons", "exit")
|
||||
SceneWidget.super.new(self, widgetmenu, font, label)
|
||||
SceneWidget.super.new(self, menu, font, label)
|
||||
end
|
||||
|
||||
function ExitWidget:action()
|
||||
|
|
Loading…
Reference in a new issue