Should check the menu category before creating a separator.
This commit is contained in:
parent
935b9e4cd6
commit
0c77179c46
|
@ -412,6 +412,17 @@ function startTradeWith(thing)
|
|||
g_mouse.pushCursor('target')
|
||||
end
|
||||
|
||||
function isMenuHookCategoryEmpty(category)
|
||||
if category and not table.empty(category) then
|
||||
for _,opt in pairs(category) do
|
||||
if opt and not table.empty(opt) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function addMenuHook(category, name, callback, condition, shortcut)
|
||||
if not hookedMenuOptions[category] then
|
||||
hookedMenuOptions[category] = {}
|
||||
|
@ -424,7 +435,7 @@ function addMenuHook(category, name, callback, condition, shortcut)
|
|||
end
|
||||
|
||||
function removeMenuHook(category, name)
|
||||
hookedMenuOptions[category][name] = {}
|
||||
hookedMenuOptions[category][name] = nil
|
||||
end
|
||||
|
||||
function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
|
@ -569,13 +580,15 @@ function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
|||
|
||||
-- hooked menu options
|
||||
for _,category in pairs(hookedMenuOptions) do
|
||||
if not isMenuHookCategoryEmpty(category) then
|
||||
menu:addSeparator()
|
||||
for name,opt in pairs(category) do
|
||||
if opt.condition(menuPosition, lookThing, useThing, creatureThing) then
|
||||
if opt and opt.condition(menuPosition, lookThing, useThing, creatureThing) then
|
||||
menu:addOption(name, opt.callback, opt.shortcut)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
menu:display(menuPosition)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue