examples/options : list players as submenus
This commit is contained in:
parent
f37eaef79a
commit
a25259e6b9
2 changed files with 29 additions and 0 deletions
|
@ -42,6 +42,8 @@ function OptionsMenu:new()
|
|||
Widgets.Switch(self, "video", "borders")
|
||||
Widgets.Switch(self, "video", "vsync")
|
||||
|
||||
self:addPlayerMenus()
|
||||
|
||||
self:setLanguageMenu()
|
||||
|
||||
Widgets.Exit(self, "main")
|
||||
|
@ -64,6 +66,15 @@ function OptionsMenu:addSubMenu(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)
|
||||
Widgets.SubMenu(self, menu, "inputs", "back", 1, "<")
|
||||
end
|
||||
end
|
||||
|
||||
function OptionsMenu:addScene(submenu, scene, fullname)
|
||||
Widgets.Dummy(self, submenu, fullname)
|
||||
end
|
||||
|
|
|
@ -32,6 +32,7 @@ widgets.Exit = Widget.Text:extend()
|
|||
widgets.Switch = DoubleTextWidget:extend()
|
||||
widgets.Resolution = DoubleTextWidget:extend()
|
||||
widgets.Lang = Widget.Text:extend()
|
||||
widgets.PlayerSubMenu = DoubleTextWidget:extend()
|
||||
|
||||
-- BASIC WIDGETS
|
||||
-- Simple and reusables widgets
|
||||
|
@ -196,4 +197,21 @@ function widgets.Lang:action()
|
|||
--self.scene.menusystem:invalidateAllWidgets()
|
||||
end
|
||||
|
||||
-- INPUT WIDGETS
|
||||
|
||||
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.menusystem:switchMenu(self.newmenu)
|
||||
end
|
||||
|
||||
return widgets
|
||||
|
|
Loading…
Reference in a new issue