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