diff options
author | Aki <nthirtyone@gmail.com> | 2016-08-28 20:41:48 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-08-28 20:41:48 +0200 |
commit | 96b4407ae6410affd0db1e6d6d657d4f65d32235 (patch) | |
tree | 6bace9e2efac1f9aa9499f0b841ade56c1feab5f | |
parent | f3318c4549a63ed151577b0ee0742440f780e4ca (diff) | |
download | roflnauts-96b4407ae6410affd0db1e6d6d657d4f65d32235.zip roflnauts-96b4407ae6410affd0db1e6d6d657d4f65d32235.tar.gz roflnauts-96b4407ae6410affd0db1e6d6d657d4f65d32235.tar.bz2 |
No blinking; buttons enabled/disabled
-rw-r--r-- | button.lua | 17 | ||||
-rw-r--r-- | config/menuhost.lua | 3 | ||||
-rw-r--r-- | config/menumain.lua | 12 | ||||
-rw-r--r-- | config/menuselect.lua | 8 | ||||
-rw-r--r-- | selector.lua | 2 |
5 files changed, 22 insertions, 20 deletions
@@ -9,8 +9,7 @@ Button = { sprite, quads, delay = 2, - blinker = 1, - parent + parent, } function Button:new(parent) @@ -39,9 +38,7 @@ function Button:blur() self.focused = false end function Button:active() end -function Button:blink() - self.blinker = 0 -end +function Button:isEnabled() return true end function Button:set(name, func) if type(name) == "string" and type(func) == "function" then self[name] = func @@ -50,13 +47,12 @@ function Button:set(name, func) end function Button:draw(scale) local x,y = self:getPosition() - local blinker = math.floor(self.blinker*4) local quad = self.quads local sprite = self.sprite - if blinker%2 == 0 then + if self:isEnabled() then love.graphics.setColor(255, 255, 255, 255) else - love.graphics.setColor(255, 100, 100, 255) + love.graphics.setColor(140, 140, 140, 255) end love.graphics.draw(sprite, quad.button.normal, x*scale, y*scale, 0, scale, scale) if self.focused then @@ -71,12 +67,9 @@ function Button:update(dt) if self.delay > Button.delay then -- Button.delay is initial self.delay = self.delay - Button.delay end - if self.blinker < Button.blinker then -- Button.blink is initial - self.blinker = self.blinker + dt - end end function Button:controlpressed(set, action, key) - if action == "attack" and self.focused then + if action == "attack" and self.focused and self:isEnabled() then self:active() end end diff --git a/config/menuhost.lua b/config/menuhost.lua index 6e52482..487b75f 100644 --- a/config/menuhost.lua +++ b/config/menuhost.lua @@ -24,6 +24,9 @@ return { button:new(menu) :setText("Select") :setPosition(bx,101) + :set("isEnabled", function () + return map_selector:isLocked() + end) :set("active", function (self) MAP = map_selector:getFullSelection(true)[1][1] self.parent:load("menuselect") diff --git a/config/menumain.lua b/config/menumain.lua index 2ca2c59..e1bd89f 100644 --- a/config/menumain.lua +++ b/config/menumain.lua @@ -18,22 +18,22 @@ return { button:new(menu) :setText("Join") :setPosition(bx, 96) - :set("active", function (self) - self:blink() + :set("isEnabled", function (self) + return false end) , button:new(menu) :setText("Settings") :setPosition(bx, 112) - :set("active", function (self) - self:blink() + :set("isEnabled", function (self) + return false end) , button:new(menu) :setText("Credits") :setPosition(bx, 128) - :set("active", function (self) - self:blink() + :set("isEnabled", function (self) + return false end) , button:new(menu) diff --git a/config/menuselect.lua b/config/menuselect.lua index 31cf02e..c79396c 100644 --- a/config/menuselect.lua +++ b/config/menuselect.lua @@ -24,12 +24,16 @@ return { start_button :setText("Force start") :setPosition(bx,134) + :set("isEnabled", function () + if #naut_selector:getFullSelection(false) > 1 then + return true + end + return false + end) :set("active", function (self) local nauts = naut_selector:getFullSelection(false) if #nauts > 1 then changeScene(World:new(MAP, nauts)) - else - self:blink() end end) , diff --git a/selector.lua b/selector.lua index f382bbb..75c0190 100644 --- a/selector.lua +++ b/selector.lua @@ -136,11 +136,13 @@ end -- Check if given number is locked function Selector:isLocked(n) + local n = n or 1 return self.locks[n] end -- Get value of selection of given number function Selector:getSelection(n) + local n = n or 1 return self.selections[n] end |