mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-25 12:14:46 +02:00
code review
This commit is contained in:
parent
1fb5301750
commit
4b103fd63b
@ -125,7 +125,7 @@ std::shared_ptr<IImage> MapTileStorage::find(size_t fileIndex, size_t rotationIn
|
||||
{
|
||||
const auto & animation = animations[fileIndex][rotationIndex];
|
||||
if (animation)
|
||||
return animation->getImage(imageIndex, groupIndex); // ask for group
|
||||
return animation->getImage(imageIndex, groupIndex);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
@ -134,7 +134,7 @@ int MapTileStorage::groupCount(size_t fileIndex, size_t rotationIndex, size_t im
|
||||
{
|
||||
const auto & animation = animations[fileIndex][rotationIndex];
|
||||
if (animation)
|
||||
for(int i = 0; true; i++)
|
||||
for(int i = 0;; i++)
|
||||
if(!animation->getImage(imageIndex, i, false))
|
||||
return i;
|
||||
return 1;
|
||||
|
@ -336,7 +336,8 @@ void AssetGenerator::createPaletteShiftedSprites()
|
||||
{
|
||||
std::vector<std::string> tiles;
|
||||
std::vector<std::vector<std::variant<TerrainPaletteAnimation, RiverPaletteAnimation>>> paletteAnimations;
|
||||
VLC->terrainTypeHandler->forEach([&](const TerrainType *entity, bool &stop){
|
||||
for(auto entity : VLC->terrainTypeHandler->objects)
|
||||
{
|
||||
if(entity->paletteAnimation.size())
|
||||
{
|
||||
tiles.push_back(entity->tilesFilename.getName());
|
||||
@ -345,8 +346,9 @@ void AssetGenerator::createPaletteShiftedSprites()
|
||||
tmpAnim.push_back(animEntity);
|
||||
paletteAnimations.push_back(tmpAnim);
|
||||
}
|
||||
});
|
||||
VLC->riverTypeHandler->forEach([&](const RiverType *entity, bool &stop){
|
||||
}
|
||||
for(auto entity : VLC->riverTypeHandler->objects)
|
||||
{
|
||||
if(entity->paletteAnimation.size())
|
||||
{
|
||||
tiles.push_back(entity->tilesFilename.getName());
|
||||
@ -355,7 +357,7 @@ void AssetGenerator::createPaletteShiftedSprites()
|
||||
tmpAnim.push_back(animEntity);
|
||||
paletteAnimations.push_back(tmpAnim);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for(int i = 0; i < tiles.size(); i++)
|
||||
{
|
||||
@ -374,14 +376,14 @@ void AssetGenerator::createPaletteShiftedSprites()
|
||||
auto anim = GH.renderHandler().loadAnimation(filename, EImageBlitMode::COLORKEY);
|
||||
for(int j = 0; j < anim->size(); j++)
|
||||
{
|
||||
int maxLen = 0;
|
||||
int maxLen = 1;
|
||||
for(int k = 0; k < paletteAnimations[i].size(); k++)
|
||||
{
|
||||
auto element = paletteAnimations[i][k];
|
||||
if(std::holds_alternative<TerrainPaletteAnimation>(element))
|
||||
maxLen = std::max(maxLen, std::get<TerrainPaletteAnimation>(element).length);
|
||||
maxLen = std::lcm(maxLen, std::get<TerrainPaletteAnimation>(element).length);
|
||||
else
|
||||
maxLen = std::max(maxLen, std::get<RiverPaletteAnimation>(element).length);
|
||||
maxLen = std::lcm(maxLen, std::get<RiverPaletteAnimation>(element).length);
|
||||
}
|
||||
for(int l = 0; l < maxLen; l++)
|
||||
{
|
||||
@ -415,12 +417,11 @@ void AssetGenerator::createPaletteShiftedSprites()
|
||||
std::shared_ptr<IImage> image = GH.renderHandler().createImage(canvas.getInternalSurface());
|
||||
image->exportBitmap(*CResourceHandler::get("local")->getResourceName(savePath));
|
||||
|
||||
JsonNode node;
|
||||
node.Struct() = {
|
||||
JsonNode node(JsonMap{
|
||||
{ "group", JsonNode(l) },
|
||||
{ "frame", JsonNode(j) },
|
||||
{ "file", JsonNode(spriteName) }
|
||||
};
|
||||
});
|
||||
config["images"].Vector().push_back(node);
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,11 @@ JsonNode::JsonNode(const std::string & string)
|
||||
{
|
||||
}
|
||||
|
||||
JsonNode::JsonNode(const JsonMap & map)
|
||||
: data(map)
|
||||
{
|
||||
}
|
||||
|
||||
JsonNode::JsonNode(const std::byte * data, size_t datasize, const std::string & fileName)
|
||||
: JsonNode(data, datasize, JsonParsingSettings(), fileName)
|
||||
{
|
||||
|
@ -71,6 +71,9 @@ public:
|
||||
explicit JsonNode(const char * string);
|
||||
explicit JsonNode(const std::string & string);
|
||||
|
||||
/// Create tree from map
|
||||
explicit JsonNode(const JsonMap & map);
|
||||
|
||||
/// Create tree from Json-formatted input
|
||||
explicit JsonNode(const std::byte * data, size_t datasize, const std::string & fileName);
|
||||
explicit JsonNode(const std::byte * data, size_t datasize, const JsonParsingSettings & parserSettings, const std::string & fileName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user