Changeset View
Changeset View
Standalone View
Standalone View
stand/lua/drawer.lua
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | if name_handler ~= nil then | ||||
return name_handler(drawing_menu, entry) | return name_handler(drawing_menu, entry) | ||||
end | end | ||||
if type(entry.name) == "function" then | if type(entry.name) == "function" then | ||||
return entry.name() | return entry.name() | ||||
end | end | ||||
return entry.name | return entry.name | ||||
end | end | ||||
local function processFile(filename, addFunc) | |||||
if filename == nil then | |||||
return false, "Missing filename" | |||||
end | |||||
local ret = try_include(filename) | |||||
if ret == nil then | |||||
return false, "Nothing returned" | |||||
freqlabs: "Nothing returned" is not a reasonably descriptive error message. | |||||
end | |||||
-- Legacy format | |||||
if type(ret) ~= "table" then | |||||
return true | |||||
end | |||||
for gfxname, def in pairs(ret) do | |||||
addFunc(gfxname, def) | |||||
end | |||||
return true | |||||
end | |||||
Done Inline ActionsOdd to print the error message return true, instead of returning false and the error message as done above. freqlabs: Odd to print the error message return true, instead of returning false and the error message as… | |||||
local function getBranddef(brand) | local function getBranddef(brand) | ||||
if brand == nil then | if brand == nil then | ||||
return nil | return nil | ||||
end | end | ||||
-- Look it up | -- Look it up | ||||
local branddef = branddefs[brand] | local branddef = branddefs[brand] | ||||
-- Try to pull it in | -- Try to pull it in | ||||
if branddef == nil then | if branddef == nil then | ||||
try_include('brand-' .. brand) | processFile('brand-' .. brand, drawer.addBrand) | ||||
Not Done Inline ActionsIt would be good to check for false and print the error. freqlabs: It would be good to check for false and print the error. | |||||
branddef = branddefs[brand] | branddef = branddefs[brand] | ||||
end | end | ||||
return branddef | return branddef | ||||
end | end | ||||
local function getLogodef(logo) | local function getLogodef(logo) | ||||
if logo == nil then | if logo == nil then | ||||
return nil | return nil | ||||
end | end | ||||
-- Look it up | -- Look it up | ||||
local logodef = logodefs[logo] | local logodef = logodefs[logo] | ||||
-- Try to pull it in | -- Try to pull it in | ||||
if logodef == nil then | if logodef == nil then | ||||
try_include('logo-' .. logo) | processFile('logo-' .. logo, drawer.addLogo) | ||||
Not Done Inline ActionsLikewise re: error handling freqlabs: Likewise re: error handling | |||||
logodef = logodefs[logo] | logodef = logodefs[logo] | ||||
end | end | ||||
return logodef | return logodef | ||||
end | end | ||||
local function draw(x, y, logo) | local function draw(x, y, logo) | ||||
for i = 1, #logo do | for i = 1, #logo do | ||||
▲ Show 20 Lines • Show All 309 Lines • Show Last 20 Lines |
"Nothing returned" is not a reasonably descriptive error message.