From 9250a0de60ec055f7ed60b8a0d92ec6e289f58c1 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 15 Jan 2017 00:05:33 +0100 Subject: Displaying old keys when changing them in settings --- config/menusettings.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/menusettings.lua b/config/menusettings.lua index 3046781..1631e4f 100644 --- a/config/menusettings.lua +++ b/config/menusettings.lua @@ -12,13 +12,16 @@ local keys = {"Left", "Right", "Up", "Down", "Attack", "Jump"} local dimmer = element:new(menu) :setPosition(width/2, 15) :set("visible", false) - :set("currentControl", "Left") + :set("currentControl", "Left") -- it actually means control that is being set CURRENTLY + :set("previousControl", "") -- it actually means key that was set as this control PREVIOUSLY :set("draw", function (self, scale) if self.visible then love.graphics.setColor(0, 0, 0, 210) love.graphics.rectangle("fill",0,0,width*getRealScale(),height*getRealScale()) love.graphics.setColor(120, 255, 120, 255) love.graphics.printf("Press new key for: \n> " .. self.currentControl .. " <", (width/2-110)*scale, (height/2-4)*scale, 220, "center", 0, scale, scale) + love.graphics.setColor(120, 120, 120, 255) + love.graphics.printf("Old: " .. self.previousControl .. "", (width/2-110)*scale, (height/2+16)*scale, 220, "center", 0, scale, scale) love.graphics.setColor(255, 255, 255, 255) end end) @@ -36,6 +39,8 @@ local startChange = function (self) self.parent.allowMove = false self.inProgress = true self.currentKey = 0 + -- Displaying old key should be done less tricky; REWORK NEEDED + dimmer:set("previousControl", Controller.sets[self.setNumber()][string.lower(keys[self.currentKey+1])]) self.newSet = {} end local controlreleased = function(self, set, action, key) @@ -44,14 +49,16 @@ local controlreleased = function(self, set, action, key) table.insert(self.newSet, key) dimmer:set("currentControl", keys[self.currentKey+1]) end + -- There is something wrong with this `if` statements... I mean, look at these numbers. if self.currentKey > 5 then dimmer:set("visible", false) self.parent.allowMove = true self.inProgress = false - table.insert(self.newSet, Controller.sets[self.setNumber()].joystick) + table.insert(self.newSet, Controller.getSets()[self.setNumber()].joystick) print(self.newSet[7]) Settings.change(self.setNumber(), self.newSet[1], self.newSet[2], self.newSet[3], self.newSet[4], self.newSet[5], self.newSet[6], self.newSet[7]) else + dimmer:set("previousControl", Controller.sets[self.setNumber()][string.lower(keys[self.currentKey+1])]) self.currentKey = self.currentKey + 1 end end -- cgit v1.1