examples/options: rough way to change keys

This commit is contained in:
Kazhnuz 2019-04-15 17:21:23 +02:00
parent ddaeff3101
commit db4370803a
2 changed files with 23 additions and 1 deletions

View file

@ -48,6 +48,9 @@ function OptionsMenu:new()
Widgets.Exit(self, "main")
self.menusystem:switchMenu("main")
self.keyDetector = {}
self.keyDetector.widget = nil
end
-- MENU FUNCTION
@ -90,6 +93,18 @@ function OptionsMenu:setLanguageMenu()
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()
end
end
function OptionsMenu:draw()
love.graphics.setColor(.3, .1, .4, 1)
love.graphics.rectangle("fill", 0, 0, 424, 240)

View file

@ -239,7 +239,14 @@ function widgets.Key:getLabel()
end
function widgets.Key:action()
--self.scene:changeKey(self.source, self.key)
self.scene:changeKey(self)
self.scene.menusystem:deactivate()
end
function widgets.Key:receiveKey( key )
core.options:setInputKey(self.source, self.key, key)
self.label2 = self:getLabel()
self:invalidateCanvas()
end