example: list keys inside the player submenu
This commit is contained in:
parent
a25259e6b9
commit
ddaeff3101
2 changed files with 34 additions and 0 deletions
|
@ -71,6 +71,11 @@ function OptionsMenu:addPlayerMenus()
|
||||||
local menu = "player" .. i
|
local menu = "player" .. i
|
||||||
self:addMenu(menu)
|
self:addMenu(menu)
|
||||||
Widgets.PlayerSubMenu(self, "inputs", i)
|
Widgets.PlayerSubMenu(self, "inputs", i)
|
||||||
|
for k,w in pairs(v.keys) do
|
||||||
|
-- FIXME: make sure that you can use the order you want for the keys list
|
||||||
|
-- instead of a random one
|
||||||
|
Widgets.Key(self, i, k)
|
||||||
|
end
|
||||||
Widgets.SubMenu(self, menu, "inputs", "back", 1, "<")
|
Widgets.SubMenu(self, menu, "inputs", "back", 1, "<")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,6 +33,7 @@ widgets.Switch = DoubleTextWidget:extend()
|
||||||
widgets.Resolution = DoubleTextWidget:extend()
|
widgets.Resolution = DoubleTextWidget:extend()
|
||||||
widgets.Lang = Widget.Text:extend()
|
widgets.Lang = Widget.Text:extend()
|
||||||
widgets.PlayerSubMenu = DoubleTextWidget:extend()
|
widgets.PlayerSubMenu = DoubleTextWidget:extend()
|
||||||
|
widgets.Key = DoubleTextWidget:extend()
|
||||||
|
|
||||||
-- BASIC WIDGETS
|
-- BASIC WIDGETS
|
||||||
-- Simple and reusables widgets
|
-- Simple and reusables widgets
|
||||||
|
@ -198,6 +199,7 @@ function widgets.Lang:action()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- INPUT WIDGETS
|
-- INPUT WIDGETS
|
||||||
|
-- Widgets to handle inputs
|
||||||
|
|
||||||
function widgets.PlayerSubMenu:new(scene, menu, sourceid)
|
function widgets.PlayerSubMenu:new(scene, menu, sourceid)
|
||||||
self.scene = scene
|
self.scene = scene
|
||||||
|
@ -214,4 +216,31 @@ function widgets.PlayerSubMenu:action()
|
||||||
self.scene.menusystem:switchMenu(self.newmenu)
|
self.scene.menusystem:switchMenu(self.newmenu)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Key widgets
|
||||||
|
|
||||||
|
function widgets.Key:new(scene, sourceid, key)
|
||||||
|
self.scene = scene
|
||||||
|
self.source = sourceid
|
||||||
|
self.key = key
|
||||||
|
|
||||||
|
local menu = "player" .. self.source
|
||||||
|
|
||||||
|
local widgetmenu = self.scene.menusystem.menus[menu]
|
||||||
|
local font = self.scene.assets.fonts["medium"]
|
||||||
|
local label = self.key
|
||||||
|
local label2 = self:getLabel()
|
||||||
|
|
||||||
|
widgets.Key.super.new(self, widgetmenu, font, label, label2)
|
||||||
|
self.order = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function widgets.Key:getLabel()
|
||||||
|
return core.input.data[self.source].keys[self.key]
|
||||||
|
end
|
||||||
|
|
||||||
|
function widgets.Key:action()
|
||||||
|
--self.scene:changeKey(self.source, self.key)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return widgets
|
return widgets
|
||||||
|
|
Loading…
Reference in a new issue