fccc4a5d8e
Fixes #73
113 lines
2.9 KiB
Lua
113 lines
2.9 KiB
Lua
local Scene = require "core.modules.scenes"
|
|
local OptionsMenu = Scene:extend()
|
|
|
|
local OptionMenu = require "scenes.menus.options.menu"
|
|
local Widgets = require "scenes.menus.options.widgets"
|
|
|
|
local gui = require "game.modules.gui"
|
|
local MenuBack = require "game.modules.gui.menuback"
|
|
|
|
function OptionsMenu:new()
|
|
OptionsMenu.super.new(self)
|
|
|
|
self.assets:batchImport("scenes.menus.options.assets")
|
|
self:addMenu("main", true)
|
|
self:addSubMenu("video", "Video")
|
|
self:addSubMenu("audio", "Audio")
|
|
--self:addSubMenu("langs", "langs")
|
|
self:addSubMenu("inputs", "Inputs")
|
|
|
|
Widgets.Resolution(self, "video")
|
|
Widgets.Switch(self, "video", "fullscreen", "Fullscreen")
|
|
Widgets.Switch(self, "video", "borders", "Borders")
|
|
Widgets.Switch(self, "video", "vsync", "Vsync")
|
|
|
|
self:addPlayerMenus()
|
|
|
|
--self:setLanguageMenu()
|
|
|
|
Widgets.Audio(self, "audio", "sfx", "SFX")
|
|
Widgets.Audio(self, "audio", "music", "Music")
|
|
|
|
Widgets.Exit(self, "main")
|
|
|
|
self.menusystem.menus["main"]:finalize()
|
|
self.menusystem:switchMenu("main")
|
|
|
|
self.menusystem:setSoundFromSceneAssets("mBeep")
|
|
|
|
self.keyDetector = {}
|
|
self.keyDetector.widget = nil
|
|
|
|
self.borderY = 30
|
|
self.borders = gui.newBorder(424, 30, 8)
|
|
|
|
self.back = MenuBack()
|
|
end
|
|
|
|
function OptionsMenu:update(dt)
|
|
self.back:update(dt)
|
|
end
|
|
|
|
-- MENU FUNCTION
|
|
-- Functions that serve the handling of menus
|
|
|
|
function OptionsMenu:addMenu(name, nobackbutton)
|
|
OptionMenu(self, name)
|
|
end
|
|
|
|
function OptionsMenu:addSubMenu(name, fullname)
|
|
self.menusystem.menus["main"]:addSubMenu(name, fullname)
|
|
end
|
|
|
|
function OptionsMenu:addPlayerMenus()
|
|
for i,v in ipairs(core.input.data) do
|
|
|
|
self.menusystem.menus["inputs"]:addSubMenu("player" .. i, "Player " .. i, "inputs")
|
|
|
|
local keyList = require "datas.keys"
|
|
for j, key in ipairs(keyList) do
|
|
Widgets.Key(self, i, key)
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
function OptionsMenu:addScene(submenu, scene, fullname)
|
|
Widgets.Dummy(self, submenu, fullname)
|
|
end
|
|
|
|
function OptionsMenu:setLanguageMenu()
|
|
for i,v in ipairs(core.lang.data.available) do
|
|
Widgets.Lang(self, "langs", v)
|
|
end
|
|
end
|
|
|
|
function OptionsMenu:changeKey(widget)
|
|
self.keyDetector.isActive = true
|
|
self.keyDetector.widget = widget
|
|
end
|
|
|
|
function OptionsMenu:keypressed( key )
|
|
if (self.keyDetector.isActive) then
|
|
self.keyDetector.widget:receiveKey( key )
|
|
self.menusystem:activate()
|
|
self.keyDetector.isActive = false
|
|
end
|
|
end
|
|
|
|
function OptionsMenu:draw()
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
love.graphics.rectangle("fill", 0, 0, 424, 240)
|
|
self.back:draw()
|
|
utils.graphics.resetColor()
|
|
self.assets.images["background"]:draw(0, 0)
|
|
end
|
|
|
|
function OptionsMenu:drawOverTransition()
|
|
love.graphics.draw(self.borders, 0, self.borderY, 0, 1, -1)
|
|
love.graphics.draw(self.borders, 424, 240 - self.borderY, 0, -1, 1)
|
|
self.assets.fonts["small"]:draw("v" .. game.version, 424 - 44, 240 + 10 - self.borderY)
|
|
end
|
|
|
|
return OptionsMenu
|