improvement: port the options to the new system
This commit is contained in:
parent
78fca02441
commit
cb626bfa4a
5 changed files with 47 additions and 117 deletions
|
@ -54,7 +54,7 @@ function list.ListMenu:finalize()
|
||||||
end
|
end
|
||||||
|
|
||||||
function list.ListMenu:clone(name)
|
function list.ListMenu:clone(name)
|
||||||
return list.ListMenu(self.scene, name, self.x, self.y, self.w, self.itemNumber)
|
return list.ListMenu(self.scene, name, self.x, self.y, self.w, self.itemNumber, self.isBoxed)
|
||||||
end
|
end
|
||||||
|
|
||||||
function list.ListMenu:getSubmenuWidget()
|
function list.ListMenu:getSubmenuWidget()
|
||||||
|
@ -97,7 +97,7 @@ end
|
||||||
|
|
||||||
function list.ListMenu:draw()
|
function list.ListMenu:draw()
|
||||||
if (self.isBoxed) then
|
if (self.isBoxed) then
|
||||||
|
love.graphics.draw(self.box, self.x - 8, self.y - 8)
|
||||||
end
|
end
|
||||||
self:updateView()
|
self:updateView()
|
||||||
local widgety = self.y
|
local widgety = self.y
|
||||||
|
|
|
@ -6,6 +6,9 @@ return {
|
||||||
["textures"] = {
|
["textures"] = {
|
||||||
{"background", "assets/backgrounds/options.png"}
|
{"background", "assets/backgrounds/options.png"}
|
||||||
},
|
},
|
||||||
|
["fonts"] = {
|
||||||
|
{"small", "assets/gui/fonts/PixelOperator.ttf", 16}
|
||||||
|
},
|
||||||
["imagefonts"] = {
|
["imagefonts"] = {
|
||||||
{"medium", "assets/gui/fonts/SA2font"},
|
{"medium", "assets/gui/fonts/SA2font"},
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,24 +11,26 @@ function OptionsMenu:new()
|
||||||
|
|
||||||
self.assets:batchImport("scenes.menus.options.assets")
|
self.assets:batchImport("scenes.menus.options.assets")
|
||||||
self:addMenu("main", true)
|
self:addMenu("main", true)
|
||||||
self:addSubMenu("video", "video")
|
self:addSubMenu("video", "Video")
|
||||||
self:addSubMenu("audio", "audio")
|
self:addSubMenu("audio", "Audio")
|
||||||
--self:addSubMenu("langs", "langs")
|
--self:addSubMenu("langs", "langs")
|
||||||
self:addSubMenu("inputs", "inputs")
|
self:addSubMenu("inputs", "Inputs")
|
||||||
|
|
||||||
Widgets.Resolution(self, "video")
|
Widgets.Resolution(self, "video")
|
||||||
Widgets.Switch(self, "video", "fullscreen")
|
Widgets.Switch(self, "video", "fullscreen", "Fullscreen")
|
||||||
Widgets.Switch(self, "video", "borders")
|
Widgets.Switch(self, "video", "borders", "Borders")
|
||||||
Widgets.Switch(self, "video", "vsync")
|
Widgets.Switch(self, "video", "vsync", "Vsync")
|
||||||
|
|
||||||
self:addPlayerMenus()
|
self:addPlayerMenus()
|
||||||
|
|
||||||
--self:setLanguageMenu()
|
--self:setLanguageMenu()
|
||||||
|
|
||||||
Widgets.Audio(self, "audio", "sfx")
|
Widgets.Audio(self, "audio", "sfx", "SFX")
|
||||||
Widgets.Audio(self, "audio", "music")
|
Widgets.Audio(self, "audio", "music", "Music")
|
||||||
|
|
||||||
Widgets.Exit(self, "main")
|
Widgets.Exit(self, "main")
|
||||||
|
|
||||||
|
self.menusystem.menus["main"]:finalize()
|
||||||
self.menusystem:switchMenu("main")
|
self.menusystem:switchMenu("main")
|
||||||
|
|
||||||
self.menusystem:setSoundFromSceneAssets("mBeep")
|
self.menusystem:setSoundFromSceneAssets("mBeep")
|
||||||
|
@ -50,26 +52,24 @@ end
|
||||||
-- Functions that serve the handling of menus
|
-- Functions that serve the handling of menus
|
||||||
|
|
||||||
function OptionsMenu:addMenu(name, nobackbutton)
|
function OptionsMenu:addMenu(name, nobackbutton)
|
||||||
OptionMenu(self.menusystem, name)
|
OptionMenu(self, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function OptionsMenu:addSubMenu(name, fullname)
|
function OptionsMenu:addSubMenu(name, fullname)
|
||||||
self:addMenu(name)
|
self.menusystem.menus["main"]:addSubMenu(name, fullname)
|
||||||
Widgets.SubMenu(self, "main", name, fullname)
|
|
||||||
Widgets.SubMenu(self, name, "main", "back", 1, "<")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function OptionsMenu:addPlayerMenus()
|
function OptionsMenu:addPlayerMenus()
|
||||||
for i,v in ipairs(core.input.data) do
|
for i,v in ipairs(core.input.data) do
|
||||||
local menu = "player" .. i
|
|
||||||
self:addMenu(menu)
|
self.menusystem.menus["inputs"]:addSubMenu("player" .. i, "Player " .. i, "inputs")
|
||||||
Widgets.PlayerSubMenu(self, "inputs", i)
|
|
||||||
local keyList = require "datas.keys"
|
local keyList = require "datas.keys"
|
||||||
for j, key in ipairs(keyList) do
|
for j, key in ipairs(keyList) do
|
||||||
Widgets.Key(self, i, key)
|
Widgets.Key(self, i, key)
|
||||||
end
|
end
|
||||||
Widgets.SubMenu(self, menu, "inputs", "back", 1, "<")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function OptionsMenu:addScene(submenu, scene, fullname)
|
function OptionsMenu:addScene(submenu, scene, fullname)
|
||||||
|
|
|
@ -1,22 +1,15 @@
|
||||||
local ListBox = require "core.modules.menusystem.listbox"
|
local RadianceListMenu = require "game.modules.menus.list"
|
||||||
local OptionMenu = ListBox:extend()
|
|
||||||
local WIDTH = 424/1.4
|
|
||||||
local HEIGHT = 240/1.9
|
|
||||||
|
|
||||||
local gui = require "game.modules.gui"
|
local OptionMenu = RadianceListMenu.ListMenu:extend()
|
||||||
|
local WIDTH = 128+32
|
||||||
|
local ITEMNUMBER = 6
|
||||||
|
|
||||||
function OptionMenu:new(menusystem, name)
|
function OptionMenu:new(scene, name)
|
||||||
local w, h = math.floor(WIDTH), math.floor(HEIGHT)
|
local w, h = math.floor(WIDTH), math.floor(17 * ITEMNUMBER)
|
||||||
local screenw, screenh = core.screen:getDimensions()
|
local screenw, screenh = core.screen:getDimensions()
|
||||||
local x = (screenw/2) - (w/2)
|
local x = (screenw/2) - (w/2)
|
||||||
local y = (screenh/2) - (h/2)
|
local y = (screenh/2) - (h/2)
|
||||||
OptionMenu.super.new(self, menusystem, name, x, y, w, h, 6)
|
OptionMenu.super.new(self, scene, name, x, y, w, ITEMNUMBER, true)
|
||||||
self.box = gui.newTextBox("assets/gui/dialogbox.png", w+16, h+16)
|
|
||||||
end
|
|
||||||
|
|
||||||
function OptionMenu:draw()
|
|
||||||
love.graphics.draw(self.box, self.x-8, self.y-8)
|
|
||||||
OptionMenu.super.draw(self)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return OptionMenu
|
return OptionMenu
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
local widgets = {}
|
local widgets = {}
|
||||||
|
|
||||||
local Widget = require "core.modules.menusystem.widgets"
|
local Widget = require "core.modules.menusystem.widgets"
|
||||||
|
local RadianceListMenu = require "game.modules.menus.list"
|
||||||
|
|
||||||
local DoubleTextWidget = Widget.Text:extend()
|
local DoubleTextWidget = Widget.Text:extend()
|
||||||
|
|
||||||
widgets.SubMenu = DoubleTextWidget:extend()
|
widgets.SubMenu = DoubleTextWidget:extend()
|
||||||
widgets.Dummy = Widget.Text:extend()
|
widgets.Dummy = RadianceListMenu.DualTextWidget:extend()
|
||||||
widgets.Exit = Widget.Text:extend()
|
widgets.Exit = RadianceListMenu.DualTextWidget:extend()
|
||||||
widgets.Switch = DoubleTextWidget:extend()
|
widgets.Switch = RadianceListMenu.DualTextWidget:extend()
|
||||||
widgets.Resolution = DoubleTextWidget:extend()
|
widgets.Resolution = RadianceListMenu.DualTextWidget:extend()
|
||||||
widgets.Lang = Widget.Text:extend()
|
widgets.Lang = RadianceListMenu.DualTextWidget:extend()
|
||||||
widgets.PlayerSubMenu = DoubleTextWidget:extend()
|
widgets.PlayerSubMenu = RadianceListMenu.DualTextWidget:extend()
|
||||||
widgets.Key = DoubleTextWidget:extend()
|
widgets.Key = RadianceListMenu.DualTextWidget:extend()
|
||||||
widgets.Audio = DoubleTextWidget:extend()
|
widgets.Audio = RadianceListMenu.DualTextWidget:extend()
|
||||||
|
|
||||||
-- BASIC WIDGETS
|
-- BASIC WIDGETS
|
||||||
-- Simple and reusables widgets
|
-- Simple and reusables widgets
|
||||||
|
@ -52,10 +54,7 @@ end
|
||||||
-- Dummy widget :: An empty widget to serve as a base for others
|
-- Dummy widget :: An empty widget to serve as a base for others
|
||||||
|
|
||||||
function widgets.Dummy:new(scene, menu, fullname)
|
function widgets.Dummy:new(scene, menu, fullname)
|
||||||
self.scene = scene
|
widgets.Dummy.super.new(self, scene, menu, fullname)
|
||||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
|
||||||
local font = self.scene.assets.fonts["medium"]
|
|
||||||
widgets.Dummy.super.new(self, widgetmenu, font, fullname)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function widgets.Dummy:action()
|
function widgets.Dummy:action()
|
||||||
|
@ -65,11 +64,7 @@ end
|
||||||
-- Exit Widget : exit the examples
|
-- Exit Widget : exit the examples
|
||||||
|
|
||||||
function widgets.Exit:new(scene, menu)
|
function widgets.Exit:new(scene, menu)
|
||||||
self.scene = scene
|
widgets.Exit.super.new(self, scene, menu, "Exit", "")
|
||||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
|
||||||
local font = self.scene.assets.fonts["medium"]
|
|
||||||
local label = core.lang:translate("commons", "exit")
|
|
||||||
widgets.Exit.super.new(self, widgetmenu, font, "Exit")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function widgets.Exit:action()
|
function widgets.Exit:action()
|
||||||
|
@ -82,14 +77,10 @@ end
|
||||||
|
|
||||||
-- Switch widget (One widget to handle graphical switch)
|
-- Switch widget (One widget to handle graphical switch)
|
||||||
|
|
||||||
function widgets.Switch:new(scene, menu, keyname)
|
function widgets.Switch:new(scene, menu, keyname, label)
|
||||||
self.scene = scene
|
|
||||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
|
||||||
local font = self.scene.assets.fonts["medium"]
|
|
||||||
self.keyname = keyname
|
self.keyname = keyname
|
||||||
local label = core.lang:translate("options", keyname)
|
|
||||||
local label2 = self:getLabel()
|
local label2 = self:getLabel()
|
||||||
widgets.Switch.super.new(self, widgetmenu, font, label, label2)
|
widgets.Switch.super.new(self, scene, menu, label, label2)
|
||||||
self.order = order or 0
|
self.order = order or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -138,12 +129,9 @@ end
|
||||||
-- Resolution Widget
|
-- Resolution Widget
|
||||||
|
|
||||||
function widgets.Resolution:new(scene, menu)
|
function widgets.Resolution:new(scene, menu)
|
||||||
self.scene = scene
|
|
||||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
|
||||||
local font = self.scene.assets.fonts["medium"]
|
|
||||||
local label = core.lang:translate("options", "resolution")
|
local label = core.lang:translate("options", "resolution")
|
||||||
local label2 = self:getLabel()
|
local label2 = self:getLabel()
|
||||||
widgets.Resolution.super.new(self, widgetmenu, font, label, label2)
|
widgets.Resolution.super.new(self, scene, menu, label, label2)
|
||||||
end
|
end
|
||||||
|
|
||||||
function widgets.Resolution:getLabel()
|
function widgets.Resolution:getLabel()
|
||||||
|
@ -163,58 +151,16 @@ function widgets.Resolution:action()
|
||||||
core.options:write()
|
core.options:write()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- LANGS WIDGET
|
|
||||||
-- Allow you to change the lang of the game
|
|
||||||
|
|
||||||
function widgets.Lang:new(scene, menu, lang)
|
|
||||||
self.scene = scene
|
|
||||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
|
||||||
local font = self.scene.assets.fonts["medium"]
|
|
||||||
local label = core.lang:getLangName(lang)
|
|
||||||
self.lang = lang
|
|
||||||
widgets.Lang.super.new(self, widgetmenu, font, label)
|
|
||||||
end
|
|
||||||
|
|
||||||
function widgets.Lang:action()
|
|
||||||
self.scene.assets:playSFX("mSelect")
|
|
||||||
core.options:setLanguage(self.lang)
|
|
||||||
--self.scene.menusystem:invalidateAllWidgets()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- INPUT WIDGETS
|
|
||||||
-- Widgets to handle inputs
|
|
||||||
|
|
||||||
function widgets.PlayerSubMenu:new(scene, menu, sourceid)
|
|
||||||
self.scene = scene
|
|
||||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
|
||||||
local font = self.scene.assets.fonts["medium"]
|
|
||||||
local label = core.lang:translate("options", "player") .. " " .. sourceid
|
|
||||||
local label2 = ">"
|
|
||||||
self.newmenu = "player" .. sourceid
|
|
||||||
widgets.PlayerSubMenu.super.new(self, widgetmenu, font, label, label2)
|
|
||||||
self.order = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function widgets.PlayerSubMenu:action()
|
|
||||||
self.scene.assets:playSFX("mSelect")
|
|
||||||
self.scene.menusystem:switchMenu(self.newmenu)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Key widgets
|
-- Key widgets
|
||||||
|
|
||||||
function widgets.Key:new(scene, sourceid, key)
|
function widgets.Key:new(scene, sourceid, key)
|
||||||
self.scene = scene
|
|
||||||
self.source = sourceid
|
self.source = sourceid
|
||||||
self.key = key
|
self.key = key
|
||||||
|
|
||||||
local menu = "player" .. self.source
|
local menu = "player" .. self.source
|
||||||
|
|
||||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
|
||||||
local font = self.scene.assets.fonts["medium"]
|
|
||||||
local label = self.key
|
local label = self.key
|
||||||
local label2 = self:getLabel()
|
local label2 = self:getLabel()
|
||||||
|
|
||||||
widgets.Key.super.new(self, widgetmenu, font, label, label2)
|
widgets.Key.super.new(self, scene, menu, label, label2)
|
||||||
self.order = 0
|
self.order = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -238,23 +184,11 @@ end
|
||||||
-- AUDIO FUNCTIONS
|
-- AUDIO FUNCTIONS
|
||||||
-- Sounds/Music functions
|
-- Sounds/Music functions
|
||||||
|
|
||||||
function widgets.Audio:new(scene, menu, audiotype)
|
function widgets.Audio:new(scene, menu, audiotype, label)
|
||||||
self.scene = scene
|
|
||||||
self.audiotype = key
|
|
||||||
|
|
||||||
|
|
||||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
|
||||||
local font = self.scene.assets.fonts["medium"]
|
|
||||||
self.audiotype = audiotype
|
self.audiotype = audiotype
|
||||||
local label = ""
|
|
||||||
if (self.audiotype == "sfx") then
|
|
||||||
label = core.lang:translate("options", "sfx")
|
|
||||||
else
|
|
||||||
label = core.lang:translate("options", "music")
|
|
||||||
end
|
|
||||||
local label2 = self:getLabel()
|
|
||||||
|
|
||||||
widgets.Audio.super.new(self, widgetmenu, font, label, label2)
|
local label2 = self:getLabel()
|
||||||
|
widgets.Audio.super.new(self, scene, menu, label, label2)
|
||||||
self.order = 0
|
self.order = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue