2021-08-21 17:00:42 +02:00
|
|
|
local Scene = require "game.scenes"
|
2020-08-01 16:06:08 +02:00
|
|
|
local OptionsMenu = Scene:extend()
|
|
|
|
|
2020-08-16 09:54:11 +02:00
|
|
|
local OptionMenu = require "scenes.menus.options.menu"
|
|
|
|
local Widgets = require "scenes.menus.options.widgets"
|
2020-08-01 16:06:08 +02:00
|
|
|
|
2020-08-01 16:32:09 +02:00
|
|
|
local gui = require "game.modules.gui"
|
2021-04-05 14:20:25 +02:00
|
|
|
local MenuBack = require "game.modules.gui.menuback"
|
2020-08-01 16:32:09 +02:00
|
|
|
|
2020-08-01 16:06:08 +02:00
|
|
|
function OptionsMenu:new()
|
|
|
|
OptionsMenu.super.new(self)
|
|
|
|
|
|
|
|
self:addMenu("main", true)
|
2020-08-19 23:25:36 +02:00
|
|
|
self:addSubMenu("video", "Video")
|
|
|
|
self:addSubMenu("audio", "Audio")
|
2020-08-02 13:43:45 +02:00
|
|
|
--self:addSubMenu("langs", "langs")
|
2020-08-19 23:25:36 +02:00
|
|
|
self:addSubMenu("inputs", "Inputs")
|
2021-04-18 19:09:01 +02:00
|
|
|
self:addSubMenu("difficulty", "Difficulty")
|
2020-08-01 16:06:08 +02:00
|
|
|
|
|
|
|
Widgets.Resolution(self, "video")
|
2020-08-19 23:25:36 +02:00
|
|
|
Widgets.Switch(self, "video", "fullscreen", "Fullscreen")
|
|
|
|
Widgets.Switch(self, "video", "borders", "Borders")
|
|
|
|
Widgets.Switch(self, "video", "vsync", "Vsync")
|
2020-08-01 16:06:08 +02:00
|
|
|
|
|
|
|
self:addPlayerMenus()
|
2021-04-18 19:09:01 +02:00
|
|
|
self:addDifficultyMenu()
|
2020-08-01 16:06:08 +02:00
|
|
|
|
2020-08-02 13:43:45 +02:00
|
|
|
--self:setLanguageMenu()
|
2020-08-01 16:06:08 +02:00
|
|
|
|
2020-08-19 23:25:36 +02:00
|
|
|
Widgets.Audio(self, "audio", "sfx", "SFX")
|
|
|
|
Widgets.Audio(self, "audio", "music", "Music")
|
2020-08-01 16:06:08 +02:00
|
|
|
|
2021-04-18 16:36:40 +02:00
|
|
|
Widgets.Delete(self, "main")
|
2020-08-01 16:06:08 +02:00
|
|
|
Widgets.Exit(self, "main")
|
2020-08-19 23:25:36 +02:00
|
|
|
|
|
|
|
self.menusystem.menus["main"]:finalize()
|
2020-08-01 16:06:08 +02:00
|
|
|
self.menusystem:switchMenu("main")
|
|
|
|
|
|
|
|
self.menusystem:setSoundFromSceneAssets("mBeep")
|
|
|
|
|
|
|
|
self.keyDetector = {}
|
|
|
|
self.keyDetector.widget = nil
|
2020-08-01 16:32:09 +02:00
|
|
|
|
2021-04-04 13:17:27 +02:00
|
|
|
self.borderY = 30
|
2020-08-01 16:32:09 +02:00
|
|
|
self.borders = gui.newBorder(424, 30, 8)
|
|
|
|
|
2021-04-05 14:20:25 +02:00
|
|
|
self.back = MenuBack()
|
2020-08-01 16:32:09 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function OptionsMenu:update(dt)
|
2021-04-05 14:20:25 +02:00
|
|
|
self.back:update(dt)
|
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-19 23:25:36 +02:00
|
|
|
OptionMenu(self, name)
|
2020-08-01 16:06:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function OptionsMenu:addSubMenu(name, fullname)
|
2020-08-19 23:25:36 +02:00
|
|
|
self.menusystem.menus["main"]:addSubMenu(name, fullname)
|
2020-08-01 16:06:08 +02:00
|
|
|
end
|
|
|
|
|
2021-04-18 19:09:01 +02:00
|
|
|
function OptionsMenu:addDifficultyMenu()
|
|
|
|
Widgets.DiffSwitch(self, "difficulty", "hazardMakesKo", "Hazards can make KO")
|
|
|
|
Widgets.DiffSwitch(self, "difficulty", "playerKoChar", "Play KO characters on maps")
|
|
|
|
Widgets.DiffSwitch(self, "difficulty", "easierBattles", "Easier battles")
|
|
|
|
Widgets.DiffSwitch(self, "difficulty", "checkPointRegen", "Checkpoints heal you")
|
|
|
|
Widgets.DiffSwitch(self, "difficulty", "levelUpHeal", "Gaining a level heal")
|
|
|
|
Widgets.DiffSwitch(self, "difficulty", "allDamage", "Hazards damage everybody")
|
|
|
|
end
|
|
|
|
|
2020-08-01 16:06:08 +02:00
|
|
|
function OptionsMenu:addPlayerMenus()
|
|
|
|
for i,v in ipairs(core.input.data) do
|
2020-08-19 23:25:36 +02:00
|
|
|
|
|
|
|
self.menusystem.menus["inputs"]:addSubMenu("player" .. i, "Player " .. i, "inputs")
|
|
|
|
|
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
|
|
|
|
end
|
2020-08-19 23:25:36 +02:00
|
|
|
|
2020-08-01 16:06:08 +02:00
|
|
|
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()
|
2021-04-05 14:20:25 +02:00
|
|
|
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
|
2020-08-01 16:32:09 +02:00
|
|
|
|
2021-04-05 14:20:25 +02:00
|
|
|
function OptionsMenu:drawOverTransition()
|
2020-08-01 16:32:09 +02:00
|
|
|
love.graphics.draw(self.borders, 0, self.borderY, 0, 1, -1)
|
|
|
|
love.graphics.draw(self.borders, 424, 240 - self.borderY, 0, -1, 1)
|
2021-04-05 14:20:25 +02:00
|
|
|
self.assets.fonts["small"]:draw("v" .. game.version, 424 - 44, 240 + 10 - self.borderY)
|
2020-08-01 16:06:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return OptionsMenu
|