diff options
author | Aki <nthirtyone@gmail.com> | 2017-09-04 20:07:12 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-09-04 20:07:12 +0200 |
commit | de2ee3b44373da6e3c110d00644d04c78f2efa24 (patch) | |
tree | a4dfbb29083df775470ef63c304eb42c2524f699 /not | |
parent | f98ca666a8cdc2c179b2daed280d36ca03d32860 (diff) | |
download | roflnauts-de2ee3b44373da6e3c110d00644d04c78f2efa24.zip roflnauts-de2ee3b44373da6e3c110d00644d04c78f2efa24.tar.gz roflnauts-de2ee3b44373da6e3c110d00644d04c78f2efa24.tar.bz2 |
No more dank name: Demux => Group
Diffstat (limited to 'not')
-rw-r--r-- | not/Group.lua (renamed from not/Demultiplexer.lua) | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/not/Demultiplexer.lua b/not/Group.lua index cbbbcef..5dedc9a 100644 --- a/not/Demultiplexer.lua +++ b/not/Group.lua @@ -1,8 +1,8 @@ ---- Element used for grouping elements and demultiplexing input of different controller sets. -Demultiplexer = require "not.Element":extends() +--- Element used for grouping elements and passing input to selected child based on controller set. +Group = require "not.Element":extends() -function Demultiplexer:new (parent) - Demultiplexer.__super.new(self, parent) +function Group:new (parent) + Group.__super.new(self, parent) self.children = {} end @@ -10,7 +10,7 @@ end -- @param func key of function to call -- @param ... parameters passed to function -- @return table with calls' results -function Demultiplexer:callEach (func, ...) +function Group:callEach (func, ...) local results = {} for _,child in ipairs(self.children) do if type(child[func]) == "function" then @@ -24,7 +24,7 @@ end -- @param set controller set -- @param func key of function to call -- @param ... parameters passed to function -function Demultiplexer:callWithSet (set, func, ...) +function Group:callWithSet (set, func, ...) for i,test in ipairs(Controller.getSets()) do if test == set then local child = self.children[i] @@ -35,35 +35,35 @@ function Demultiplexer:callWithSet (set, func, ...) end end -function Demultiplexer:focus () +function Group:focus () self:callEach("focus") self.focused = true return true end -function Demultiplexer:blur () +function Group:blur () self:callEach("blur") self.focused = false end -function Demultiplexer:draw (scale) +function Group:draw (scale) self:callEach("draw", scale) end -function Demultiplexer:update (dt) +function Group:update (dt) self:callEach("update", dt) end -function Demultiplexer:controlpressed (set, action, key) +function Group:controlpressed (set, action, key) if self.focused then self:callWithSet(set, "controlpressed", set, action, key) end end -function Demultiplexer:controlreleased (set, action, key) +function Group:controlreleased (set, action, key) if self.focused then self:callWithSet(set, "controlreleased", set, action, key) end end -return Demultiplexer +return Group |