Cleaned up loadImage functions

This commit is contained in:
SeaSide53
2023-06-04 15:05:52 +02:00
parent 1b74c1fdfe
commit 5d92bc9703

View File

@@ -27,24 +27,29 @@ local function loadBBFAsBimg(path)
end
local function loadImage(path, f, binaryMode)
if(sub(path, -4) == ".bimg")then
local function loadImage(path, binaryMode)
--Loads the image with the right loader, returns error if the file type is unknown.
if(sub(path, -5) == ".bimg")then
return loadBIMG(path, binaryMode)
elseif(sub(path, -3) == ".bbf")then
return loadBBF(path, binaryMode)
elseif(sub(path, -4) == ".bbf")then
return loadBBF(path)
elseif(sub(path, -4) == ".nfp")then
return loadNFP(path)
else
return loadNFP(path, binaryMode)
error("Unknown file type")
end
-- ...
end
local function loadImageAsBimg(path)
if(path:find(".bimg"))then
return loadBIMG(path)
elseif(path:find(".bbf"))then
local function loadImageAsBimg(path, binaryMode)
--Loads the image with the right Bimg loader, returns error if the file type is unknown.
if(sub(path, -5) == ".bimg")then
return loadBIMG(path, binaryMode)
elseif(sub(path, -4) == ".bbf")then
return loadBBFAsBimg(path)
else
elseif(sub(path, -4) == ".nfp")then
return loadNFPAsBimg(path)
else
error("Unknown file type")
end
end