2020-04-05 18:18:13 +02:00
|
|
|
-- scenes/mainmenu :: the main menu of the different birb scenes
|
2019-04-06 19:08:30 +02:00
|
|
|
|
|
|
|
--[[
|
|
|
|
Copyright © 2019 Kazhnuz
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
this software and associated documentation files (the "Software"), to deal in
|
|
|
|
the Software without restriction, including without limitation the rights to
|
|
|
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
]]
|
|
|
|
|
2020-04-05 18:18:13 +02:00
|
|
|
local Scene = require "birb.modules.scenes"
|
2019-04-06 19:08:30 +02:00
|
|
|
local MainMenu = Scene:extend()
|
|
|
|
|
2021-12-04 14:12:17 +01:00
|
|
|
local TextMenu = require "birb.modules.gui.textmenu"
|
2021-01-23 18:31:40 +01:00
|
|
|
|
|
|
|
local SceneWidget = TextMenu.baseWidgets.Base:extend()
|
|
|
|
local ExitWidget = TextMenu.baseWidgets.Base:extend()
|
|
|
|
|
|
|
|
local MENU_NAME = "mainMenu"
|
2019-04-06 19:08:30 +02:00
|
|
|
|
2021-01-30 09:18:59 +01:00
|
|
|
function MainMenu:start()
|
2020-04-05 18:18:13 +02:00
|
|
|
self.assets:batchImport("scenes.mainmenu.assets")
|
2021-01-23 18:31:40 +01:00
|
|
|
print(self.assets:getFont("medium"))
|
|
|
|
local menu = self:addMenu()
|
2019-07-12 23:42:25 +02:00
|
|
|
for i=1, 4 do
|
|
|
|
local name = i .. "player"
|
2021-01-23 18:31:40 +01:00
|
|
|
menu:addSubmenu(name, core.lang:translate("commons", name))
|
2019-07-12 23:42:25 +02:00
|
|
|
if i == 1 then
|
2020-12-05 09:02:42 +01:00
|
|
|
self:addScene(scenes.Plateformer, "plateform", i)
|
2019-07-12 23:42:25 +02:00
|
|
|
end
|
2020-12-05 09:02:42 +01:00
|
|
|
self:addScene(scenes.MovePlayer, "topdown", i)
|
|
|
|
self:addScene(scenes.MovePlayer3D, "topdown3D", i)
|
|
|
|
self:addScene(scenes.Action3D, "bigmap3D", i)
|
2019-07-12 23:42:25 +02:00
|
|
|
if i > 1 then
|
2020-12-05 09:02:42 +01:00
|
|
|
self:addScene(scenes.MovePlayer, "topdown (zoom)", i, "zoom")
|
|
|
|
self:addScene(scenes.MovePlayer3D, "topdown3D (zoom)", i, "zoom")
|
2019-07-12 23:42:25 +02:00
|
|
|
end
|
|
|
|
end
|
2019-07-12 23:52:49 +02:00
|
|
|
self:addSubMenu("menus", "menu")
|
2020-12-05 09:02:42 +01:00
|
|
|
self:addScene(scenes.Inventory, "inventory")
|
|
|
|
self:addScene(scenes.Options, "options")
|
|
|
|
self:addScene(scenes.TestMenu, "tests")
|
2019-07-12 23:42:25 +02:00
|
|
|
|
2019-04-20 17:56:30 +02:00
|
|
|
|
|
|
|
self.menusystem:setSoundFromSceneAssets("navigate")
|
2021-01-23 18:31:40 +01:00
|
|
|
local menu = self.menusystem.menus[MENU_NAME]
|
2020-12-05 09:02:42 +01:00
|
|
|
menu:switch("main")
|
2019-04-20 17:56:30 +02:00
|
|
|
|
2019-04-07 13:02:39 +02:00
|
|
|
ExitWidget(self, "main")
|
2021-01-23 18:31:40 +01:00
|
|
|
self.menusystem:switchMenu(MENU_NAME)
|
2019-04-06 19:08:30 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- MENU FUNCTION
|
|
|
|
-- Functions that serve the handling of menus
|
|
|
|
|
2021-01-23 18:31:40 +01:00
|
|
|
function MainMenu:addMenu()
|
|
|
|
local w = 424/2
|
2019-04-06 19:08:30 +02:00
|
|
|
local x, y = w / 2, 24
|
2021-01-23 18:31:40 +01:00
|
|
|
return TextMenu(MENU_NAME, "medium", x, y, w, 8, 0)
|
2019-04-06 19:08:30 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function MainMenu:addSubMenu(name, fullname)
|
2021-01-23 18:31:40 +01:00
|
|
|
local menu = self.menusystem.menus[MENU_NAME]
|
|
|
|
menu:addSubmenu(name, core.lang:translate("mainmenu", fullname))
|
2019-04-06 19:08:30 +02:00
|
|
|
end
|
|
|
|
|
2020-12-05 09:02:42 +01:00
|
|
|
function MainMenu:addScene(scene, fullname, arg1, arg2, arg3, arg4, arg5)
|
2019-07-12 23:35:04 +02:00
|
|
|
local args = {arg1, arg2, arg3, arg4, arg5}
|
2021-01-23 18:31:40 +01:00
|
|
|
SceneWidget(self, MENU_NAME, scene, fullname, args)
|
2019-04-06 19:08:30 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function MainMenu:draw()
|
|
|
|
love.graphics.setColor(.3, .1, .4, 1)
|
|
|
|
love.graphics.rectangle("fill", 0, 0, 424, 240)
|
2019-07-24 10:44:03 +02:00
|
|
|
utils.graphics.resetColor()
|
|
|
|
love.graphics.print(math.floor(game.playtime), 8, 8)
|
2019-04-06 19:08:30 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- WIDGETS
|
|
|
|
-- Widgets used by menus
|
|
|
|
|
|
|
|
-- Scene widget :: switch scene
|
|
|
|
|
2019-07-12 23:35:04 +02:00
|
|
|
function SceneWidget:new(scene, menu, newscene, fullname, args)
|
|
|
|
self.scene = scene
|
|
|
|
self.args = args
|
2019-04-06 19:08:30 +02:00
|
|
|
self.newscene = newscene
|
2019-04-14 17:49:25 +02:00
|
|
|
local label = core.lang:translate("mainmenu", fullname)
|
2021-01-23 18:31:40 +01:00
|
|
|
SceneWidget.super.new(self, MENU_NAME, label)
|
2019-04-06 19:08:30 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function SceneWidget:action()
|
|
|
|
core.scenemanager:storeCurrentScene("mainmenu")
|
2019-09-08 16:23:42 +02:00
|
|
|
core.scenemanager:prepareTransition()
|
2019-07-12 23:35:04 +02:00
|
|
|
self.newscene(self.args[1], self.args[2], self.args[3], self.args[4], self.args[5])
|
2019-04-06 19:08:30 +02:00
|
|
|
end
|
|
|
|
|
2020-04-05 18:18:13 +02:00
|
|
|
-- Exit Widget : exit the scenes
|
2019-04-07 13:02:39 +02:00
|
|
|
|
|
|
|
function ExitWidget:new(scene, menu)
|
|
|
|
self.scene = scene
|
2019-04-14 17:49:25 +02:00
|
|
|
local label = core.lang:translate("commons", "exit")
|
2021-01-23 18:31:40 +01:00
|
|
|
SceneWidget.super.new(self, MENU_NAME, label)
|
2019-04-07 13:02:39 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function ExitWidget:action()
|
2019-07-24 10:44:03 +02:00
|
|
|
game:write()
|
2019-04-07 13:02:39 +02:00
|
|
|
love.event.quit()
|
|
|
|
end
|
2019-04-06 19:08:30 +02:00
|
|
|
|
|
|
|
return MainMenu
|