1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Animation.cpp fixes after review

This commit is contained in:
krs
2022-11-22 14:27:27 +02:00
parent 221a9e14b9
commit f0b66b6192
3 changed files with 26 additions and 23 deletions

View File

@@ -21,6 +21,8 @@
#include "../lib/JsonNode.h"
#include "../lib/CRandomGenerator.h"
namespace bfs = boost::filesystem;
class SDLImageLoader;
typedef std::map <size_t, std::vector <JsonNode> > source_map;
@@ -95,7 +97,7 @@ public:
void draw(SDL_Surface * where, int posX=0, int posY=0, Rect *src=nullptr, ui8 alpha=255) const override;
void draw(SDL_Surface * where, SDL_Rect * dest, SDL_Rect * src, ui8 alpha=255) const override;
std::shared_ptr<IImage> scaleFast(float scale) const override;
void exportBitmap(const boost::filesystem::path & path) const override;
void exportBitmap(const bfs::path & path) const override;
void playerColored(PlayerColor player) override;
void setFlagColor(PlayerColor player) override;
int width() const override;
@@ -714,7 +716,7 @@ std::shared_ptr<IImage> SDLImage::scaleFast(float scale) const
return std::shared_ptr<IImage>(ret);
}
void SDLImage::exportBitmap(const boost::filesystem::path& path) const
void SDLImage::exportBitmap(const bfs::path & path) const
{
SDL_SaveBMP(surf, path.string().c_str());
}
@@ -951,7 +953,7 @@ void CAnimation::initFromJson(const JsonNode & config)
}
}
void CAnimation::exportBitmaps(const boost::filesystem::path& path, bool prependResourceName) const
void CAnimation::exportBitmaps(const bfs::path & path, bool prependResourceName) const
{
if(images.empty())
{
@@ -959,8 +961,8 @@ void CAnimation::exportBitmaps(const boost::filesystem::path& path, bool prepend
return;
}
boost::filesystem::path actualPath = path / "Sprites" / name;
boost::filesystem::create_directories(actualPath);
bfs::path actualPath = path / "Sprites" / name;
bfs::create_directories(actualPath);
size_t counter = 0;

View File

@@ -91,13 +91,13 @@ void CArchiveLoader::initLODArchive(const std::string &mountPoint, CFileInputStr
boost::to_upper(fName);
if(fName.find(".PCX") != std::string::npos)
extractToFolder("Images", mountPoint, entry);
extractToFolder("IMAGES", mountPoint, entry);
else if ((fName.find(".DEF") != std::string::npos ) || (fName.find(".MSK") != std::string::npos) || (fName.find(".FNT") != std::string::npos) || (fName.find(".PAL") != std::string::npos))
extractToFolder("Sprites", mountPoint, entry);
extractToFolder("SPRITES", mountPoint, entry);
else if ((fName.find(".h3c") != std::string::npos))
extractToFolder("Sprites", mountPoint, entry);
extractToFolder("SPRITES", mountPoint, entry);
else
extractToFolder("Misc", mountPoint, entry);
extractToFolder("MISC", mountPoint, entry);
fileStream.seek(currentPosition); // restore filestream position
}
@@ -138,7 +138,7 @@ void CArchiveLoader::initVIDArchive(const std::string &mountPoint, CFileInputStr
entry.second.fullSize = *it - entry.second.offset;
if(extractArchives)
extractToFolder("Video", fileStream, entry.second);
extractToFolder("VIDEO", fileStream, entry.second);
}
}
@@ -168,7 +168,7 @@ void CArchiveLoader::initSNDArchive(const std::string &mountPoint, CFileInputStr
entries[ResourceID(mountPoint + entry.name)] = entry;
if(extractArchives)
extractToFolder("Sound", fileStream, entry);
extractToFolder("SOUND", fileStream, entry);
}
}

View File

@@ -22,6 +22,7 @@
#include "../lib/VCMIDirs.h"
#include <boost/filesystem.hpp>
namespace bfs = boost::filesystem;
typedef std::map<size_t, std::vector<JsonNode>> source_map;
@@ -697,8 +698,8 @@ void Animation::exportBitmaps(const bfs::path& path, bool prependResourceName) c
return;
}
boost::filesystem::path actualPath = path / "Sprites" / name;
boost::filesystem::create_directories(actualPath);
bfs::path actualPath = path / "SPRITES" / name;
bfs::create_directories(actualPath);
size_t counter = 0;