summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-08-24 04:12:07 +0200
committerAki <nthirtyone@gmail.com>2016-08-24 04:12:07 +0200
commite22d7b380513aec4d83dc06c59dfd461b5d3a8b2 (patch)
treed5024296ebdfd949f154431629bfc792bf67b4f5
parenta1d3d14781565f226e7795e4d426c28614baab88 (diff)
downloadroflnauts-e22d7b380513aec4d83dc06c59dfd461b5d3a8b2.zip
roflnauts-e22d7b380513aec4d83dc06c59dfd461b5d3a8b2.tar.gz
roflnauts-e22d7b380513aec4d83dc06c59dfd461b5d3a8b2.tar.bz2
locks, selections, init
-rw-r--r--selector.lua53
1 files changed, 47 insertions, 6 deletions
diff --git a/selector.lua b/selector.lua
index 9e2ad23..96113df 100644
--- a/selector.lua
+++ b/selector.lua
@@ -6,6 +6,7 @@ selector:new(menu)
:setPosition(x, y)
:set("list", require "file_with_list")
:set("global", true/false) -- true: single selector; false: selector for each controller set present
+ :init()
]]
Selector = {
@@ -26,10 +27,6 @@ function Selector:new(parent)
setmetatable(o, self)
self.__index = self
o.parent = parent
- o.list = {}
- o.sets = {}
- o.locks = {}
- o.selections = {}
return o
end
@@ -50,11 +47,55 @@ function Selector:set(name, func)
return self
end
--- Selecting functions
-function Selector:getSelection(n) end
+-- Initialize Selector with current settings.
+function Selector:init()
+ -- Make sure that there is list present
+ if self.list == nil then
+ self.list = {}
+ end
+ -- Initialize global Selector
+ if self.global then
+ self.locks = {false}
+ self.selections = {1}
+ -- Initialize Selector for Controllers
+ else
+ self.sets = Controller.getSets()
+ self.locks = {}
+ self.selections = {}
+ for i=1,#self.sets do
+ self.locks[i] = false
+ self.selections[i] = 1
+ end
+ end
+end
+
+-- Cycle through list on given number
function Selector:next(n) end
function Selector:previous(n) end
+-- Get number associated with a given set
+function Selector:checkNumber(set)
+ if self.global then return 1 end -- For global Selector
+ for n,check in pairs(self.sets) do
+ if check == set then return n end
+ end
+end
+
+-- Check if given number is locked
+function Selector:isLocked(n)
+ return self.locks[n]
+end
+
+-- Get value of selection of given number
+function Selector:getSelectionValue(n)
+ return self.selections[n]
+end
+
+-- Get value from list by selection
+function Selector:getListValue(i)
+ return self.list[i]
+end
+
-- Menu callbacks
function Selector:focus() -- Called when Element gains focus
self.focused = true