From 1339337e6eae2fcb7defa49eef90464d51528599 Mon Sep 17 00:00:00 2001 From: SeaSide53 <125594629+SeaSide53@users.noreply.github.com> Date: Sun, 4 Jun 2023 15:53:19 +0200 Subject: [PATCH] Fixed typos and cleaned up code in the Images library (#93) * Updated setTheme.md * Updated 1.6 setTheme.md * Fixed typo * Cleaned up loadImage functions * Changed it to use the new function * More typos --------- Co-authored-by: SeaSide53 --- Basalt/libraries/images.lua | 27 ++++++++++++++++----------- Basalt/objects/Image.lua | 2 +- docs/objects/Frame/addObject.md | 6 +++--- docs/objects/Image.md | 2 +- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Basalt/libraries/images.lua b/Basalt/libraries/images.lua index ce6ac00..a8caaa8 100644 --- a/Basalt/libraries/images.lua +++ b/Basalt/libraries/images.lua @@ -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 diff --git a/Basalt/objects/Image.lua b/Basalt/objects/Image.lua index 3f68d45..63e8fd9 100644 --- a/Basalt/objects/Image.lua +++ b/Basalt/objects/Image.lua @@ -145,7 +145,7 @@ return function(name, basalt) loadImage = function(self, path) if(fs.exists(path))then - local newBimg = images.loadBIMG(path) + local newBimg = images.loadImageAsBimg(path) bimgLibrary = bimg(newBimg) activeFrame = 1 bimgFrame = bimgLibrary.getFrameObject(1) diff --git a/docs/objects/Frame/addObject.md b/docs/objects/Frame/addObject.md index b025eda..faa903b 100644 --- a/docs/objects/Frame/addObject.md +++ b/docs/objects/Frame/addObject.md @@ -1,9 +1,9 @@ ## add<Object> -Adds a new object. Don't use add<Object> please use addTheObjectYouNeed For example if you want a new Frame, use -addFrame, if you want to add a button, use addButton +Adds a new object. Don't use add<Object> please use addTheObjectYouNeed. For example if you want a new Frame, use +addFrame, if you want to add a button, use addButton. #### Parameters: -1. `string` optional - the id if you don't add a id it will autimatically generate one for you +1. `string` optional - the id if you don't add a id it will automatically generate one for you #### Returns: 1. `object` The new object you've created diff --git a/docs/objects/Image.md b/docs/objects/Image.md index 64cbb55..6f3709b 100644 --- a/docs/objects/Image.md +++ b/docs/objects/Image.md @@ -1,6 +1,6 @@ The Image object is designed for adding more advanced backgrounds to your interface. It supports the loading of .nfp and .bimg images, allowing for greater customization of your interface's appearance. -In addition to the Object and VisualObject methods, Progressbar objects have the following methods: +In addition to the Object and VisualObject methods, Image objects have the following methods: | | | |---|---|