lualoader: Allow carousel 'items' to be a table as well as a function

We don't have any in-tree users of this, but for a static set of carousel
options having to define a callback is excessive.
This commit is contained in:
Kyle Evans 2018-02-21 05:04:58 +00:00
parent a51f9f0c48
commit 4f437f9eab
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329700
2 changed files with 8 additions and 4 deletions

View File

@ -190,8 +190,10 @@ drawer.menu_name_handlers = {
[core.MENU_CAROUSEL_ENTRY] = function(drawing_menu, entry)
local carid = entry.carousel_id
local caridx = config.getCarouselIndex(carid)
local choices = entry.items()
local choices = entry.items
if type(choices) == "function" then
choices = choices()
end
if #choices < caridx then
caridx = 1
end

View File

@ -65,8 +65,10 @@ menu.handlers = {
-- carousel (rotating) functionality
local carid = entry.carousel_id
local caridx = config.getCarouselIndex(carid)
local choices = entry.items()
local choices = entry.items
if type(choices) == "function" then
choices = choices()
end
if #choices > 0 then
caridx = (caridx % #choices) + 1
config.setCarouselIndex(carid, caridx)