diff --git a/client/render/AssetGenerator.cpp b/client/render/AssetGenerator.cpp index 1ea31ee2e..0ee1d38ef 100644 --- a/client/render/AssetGenerator.cpp +++ b/client/render/AssetGenerator.cpp @@ -369,20 +369,20 @@ void AssetGenerator::createPaletteShiftedSprites() auto anim = GH.renderHandler().loadAnimation(filename, EImageBlitMode::COLORKEY); for(int j = 0; j < anim->size(); j++) { - int counter = 0; - for(int k = 0; k < paletteAnimations[i].size(); k++) + for(int l = 0; l < 11; l++) { - auto element = paletteAnimations[i][k]; - int length = std::holds_alternative(element) ? std::get(element).length : std::get(element).length; - for(int l = 0; l < length; l++) + std::string filenameNew = "sprites/" + sprite + "_Shifted" + "/" + sprite + boost::str(boost::format("%02d") % j) + "_" + std::to_string(l) + ".png"; + ResourcePath savePath(filenameNew, EResType::IMAGE); + + if(!CResourceHandler::get("local")->createResource(filenameNew)) + return; + + auto imgLoc = anim->getImageLocator(j, 0); + imgLoc.scalingFactor = 1; + auto img = GH.renderHandler().loadImage(imgLoc, EImageBlitMode::COLORKEY); + for(int k = 0; k < paletteAnimations[i].size(); k++) { - std::string filenameNew = "sprites/" + sprite + "_Shifted" + "/" + sprite + boost::str(boost::format("%02d") % j) + "_" + std::to_string(counter) + ".png"; - ResourcePath savePath(filenameNew, EResType::IMAGE); - - if(!CResourceHandler::get("local")->createResource(filenameNew)) - return; - - auto img = anim->getImage(j); + auto element = paletteAnimations[i][k]; if(std::holds_alternative(element)) { auto tmp = std::get(element); @@ -393,11 +393,8 @@ void AssetGenerator::createPaletteShiftedSprites() auto tmp = std::get(element); img->shiftPalette(tmp.start, tmp.length, l); } - - img->exportBitmap(*CResourceHandler::get("local")->getResourceName(savePath)); - - counter++; } + img->exportBitmap(*CResourceHandler::get("local")->getResourceName(savePath)); } } } diff --git a/client/render/CAnimation.h b/client/render/CAnimation.h index 75c8d1566..86c0b95a9 100644 --- a/client/render/CAnimation.h +++ b/client/render/CAnimation.h @@ -50,8 +50,6 @@ private: void printError(size_t frame, size_t group, std::string type) const; std::shared_ptr getImageImpl(size_t frame, size_t group=0, bool verbose=true); - - ImageLocator getImageLocator(size_t frame, size_t group) const; public: CAnimation(const AnimationPath & Name, std::map > layout, EImageBlitMode mode); ~CAnimation(); @@ -74,5 +72,7 @@ public: void playerColored(PlayerColor player); void createFlippedGroup(const size_t sourceGroup, const size_t targetGroup); + + ImageLocator getImageLocator(size_t frame, size_t group) const; };