2020-08-01 16:06:08 +02:00
|
|
|
local Scene = require "core.modules.scenes"
|
|
|
|
local OptionsMenu = Scene:extend()
|
|
|
|
|
2020-08-01 16:32:09 +02:00
|
|
|
local OptionMenu = require "scenes.options.menu"
|
2020-08-01 16:06:08 +02:00
|
|
|
local Widgets = require "scenes.options.widgets"
|
|
|
|
|
2020-08-01 16:32:09 +02:00
|
|
|
local gui = require "game.modules.gui"
|
|
|
|
|
2020-08-01 16:06:08 +02:00
|
|
|
function OptionsMenu:new()
|
|
|
|
OptionsMenu.super.new(self)
|
|
|
|
|
|
|
|
self.assets:batchImport("scenes.options.assets")
|
|
|
|
self:addMenu("main", true)
|
|
|
|
self:addSubMenu("video", "video")
|
|
|
|
self:addSubMenu("audio", "audio")
|
2020-08-02 13:43:45 +02:00
|
|
|
--self:addSubMenu("langs", "langs")
|
2020-08-01 16:06:08 +02:00
|
|
|
self:addSubMenu("inputs", "inputs")
|
|
|
|
|
|
|
|
Widgets.Resolution(self, "video")
|
|
|
|
Widgets.Switch(self, "video", "fullscreen")
|
|
|
|
Widgets.Switch(self, "video", "borders")
|
|
|
|
Widgets.Switch(self, "video", "vsync")
|
|
|
|
|
|
|
|
self:addPlayerMenus()
|
|
|
|
|
2020-08-02 13:43:45 +02:00
|
|
|
--self:setLanguageMenu()
|
2020-08-01 16:06:08 +02:00
|
|
|
|
|
|
|
Widgets.Audio(self, "audio", "sfx")
|
|
|
|
Widgets.Audio(self, "audio", "music")
|
|
|
|
|
|
|
|
Widgets.Exit(self, "main")
|
|
|
|
self.menusystem:switchMenu("main")
|
|
|
|
|
|
|
|
self.menusystem:setSoundFromSceneAssets("mBeep")
|
|
|
|
|
|
|
|
self.keyDetector = {}
|
|
|
|
self.keyDetector.widget = nil
|
2020-08-01 16:32:09 +02:00
|
|
|
|
|
|
|
self.borderY = 25
|
|
|
|
self.borders = gui.newBorder(424, 30, 8)
|
|
|
|
|
|
|
|
self.timer = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
function OptionsMenu:update(dt)
|
|
|
|
self.timer = (self.timer + (30 * dt)) % 128
|
2020-08-01 16:06:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- MENU FUNCTION
|
|
|
|
-- Functions that serve the handling of menus
|
|
|
|
|
|
|
|
function OptionsMenu:addMenu(name, nobackbutton)
|
2020-08-01 16:32:09 +02:00
|
|
|
OptionMenu(self.menusystem, name)
|
2020-08-01 16:06:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function OptionsMenu:addSubMenu(name, fullname)
|
|
|
|
self:addMenu(name)
|
|
|
|
Widgets.SubMenu(self, "main", name, fullname)
|
|
|
|
Widgets.SubMenu(self, name, "main", "back", 1, "<")
|
|
|
|
end
|
|
|
|
|
|
|
|
function OptionsMenu:addPlayerMenus()
|
|
|
|
for i,v in ipairs(core.input.data) do
|
|
|
|
local menu = "player" .. i
|
|
|
|
self:addMenu(menu)
|
|
|
|
Widgets.PlayerSubMenu(self, "inputs", i)
|
2020-08-02 13:41:58 +02:00
|
|
|
local keyList = require "datas.keys"
|
|
|
|
for j, key in ipairs(keyList) do
|
|
|
|
Widgets.Key(self, i, key)
|
2020-08-01 16:06:08 +02:00
|
|
|
end
|
|
|
|
Widgets.SubMenu(self, menu, "inputs", "back", 1, "<")
|
|
|
|
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()
|
2020-08-01 16:32:09 +02:00
|
|
|
local w, h = core.screen:getDimensions()
|
|
|
|
for i=-1, (w/128) do
|
|
|
|
for j=-1,(h/128) do
|
|
|
|
self.assets.images["background"]:draw(i*128 + self.timer, j*128 + self.timer)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
love.graphics.draw(self.borders, 0, self.borderY, 0, 1, -1)
|
|
|
|
love.graphics.draw(self.borders, 424, 240 - self.borderY, 0, -1, 1)
|
2020-08-01 16:06:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return OptionsMenu
|