diff --git a/examples/menus/options/init.lua b/examples/menus/options/init.lua index e8dc4b0..ef23f81 100644 --- a/examples/menus/options/init.lua +++ b/examples/menus/options/init.lua @@ -71,6 +71,11 @@ function OptionsMenu:addPlayerMenus() local menu = "player" .. i self:addMenu(menu) 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, "<") end end diff --git a/examples/menus/options/widgets.lua b/examples/menus/options/widgets.lua index 15010a7..ad1468d 100644 --- a/examples/menus/options/widgets.lua +++ b/examples/menus/options/widgets.lua @@ -33,6 +33,7 @@ widgets.Switch = DoubleTextWidget:extend() widgets.Resolution = DoubleTextWidget:extend() widgets.Lang = Widget.Text:extend() widgets.PlayerSubMenu = DoubleTextWidget:extend() +widgets.Key = DoubleTextWidget:extend() -- BASIC WIDGETS -- Simple and reusables widgets @@ -198,6 +199,7 @@ function widgets.Lang:action() end -- INPUT WIDGETS +-- Widgets to handle inputs function widgets.PlayerSubMenu:new(scene, menu, sourceid) self.scene = scene @@ -214,4 +216,31 @@ function widgets.PlayerSubMenu:action() self.scene.menusystem:switchMenu(self.newmenu) 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