Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathListParameter.lua
More file actions
Latest commit
40 lines (34 loc) · 1.1 KB
/
Copy pathListParameter.lua
File metadata and controls
40 lines (34 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
--- A parameter with a list of string values that the user can adjust by pressing keys in LOVE
---
---@classListParameter
ListParameter=CpObject()
functionListParameter:init(current, name, up, down, values, names)
self.current=current
self.name=name
self.up=up
self.down=down
self.values=values
self.names=names
end
functionListParameter:onKey(key, callback)
ifkey==self.upthen
self.current=self.current+1
self.current=self.current>#self.valuesand1orself.current
elseifkey==self.downthen
self.current=self.current-1
self.current=self.current<1and#self.valuesorself.current
end
callback()
end
functionListParameter:get()
returnself.values[self.current]
end
---@returntable to use with love.graphics.print()
functionListParameter:toColoredText(nameColor, keyColor, valueColor)
return {nameColor, self.name, keyColor, string.format(' (%s/%s): ', self.down, self.up),
valueColor, self.names[self.current]}
end
functionListParameter:__tostring()
returnstring.format('%s (%s/%s): %s', self.name, self.down, self.up, self.names[self.current])
end