New image arguments format (#983)

This commit is contained in:
Justin 2024-07-06 19:04:25 -04:00 committed by GitHub
parent 9009b3db6a
commit 0a3de6cd4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -338,16 +338,25 @@ struct MDParser {
else if (s_lastImage.size()) {
bool isFrame = false;
std::vector<std::string> imgArguments = utils::string::split(s_lastImage, "&");
std::vector<std::string> 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:")) {