From 0a3de6cd4e455c042fd855aa4b7eefb66676e034 Mon Sep 17 00:00:00 2001 From: Justin <52604018+hiimjustin000@users.noreply.github.com> Date: Sat, 6 Jul 2024 19:04:25 -0400 Subject: [PATCH] New image arguments format (#983) --- loader/src/ui/nodes/MDTextArea.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/loader/src/ui/nodes/MDTextArea.cpp b/loader/src/ui/nodes/MDTextArea.cpp index 1147ec7c..e3f4c0a9 100644 --- a/loader/src/ui/nodes/MDTextArea.cpp +++ b/loader/src/ui/nodes/MDTextArea.cpp @@ -338,16 +338,25 @@ struct MDParser { else if (s_lastImage.size()) { bool isFrame = false; - std::vector imgArguments = utils::string::split(s_lastImage, "&"); + std::vector imgArguments = utils::string::split(s_lastImage, "?"); s_lastImage = imgArguments.at(0); + if (utils::string::contains(s_lastImage, "&")) { //old format + imgArguments = utils::string::split(s_lastImage, "&"); + s_lastImage = imgArguments.at(0); + } imgArguments.erase(imgArguments.begin()); //remove the image path + // Split by "&" to get arguments + if (imgArguments.size() > 0) { + imgArguments = utils::string::split(imgArguments.at(0), "&"); + } + float spriteScale = 1.0f; for(std::string arg : imgArguments){ - if(utils::string::startsWith(arg, "scale:")){ - std::string scaleValue = arg.substr(arg.find(":") + 1); + if(utils::string::startsWith(arg, "scale=")){ + std::string scaleValue = arg.substr(arg.find("=") + 1); std::stringstream s(scaleValue); float scale; @@ -355,6 +364,15 @@ struct MDParser { spriteScale = scale; } } + else if(utils::string::startsWith(arg, "scale:")){ //old format + std::string scaleValue = arg.substr(arg.find(":") + 1); + std::stringstream s(scaleValue); + + float scale; + if (s >> scale) { + spriteScale = scale; + } + } } if (utils::string::startsWith(s_lastImage, "frame:")) {