mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-08 00:39:47 +02:00
fix image creation
This commit is contained in:
parent
9c0aef6ca2
commit
3967c70bf2
@ -135,7 +135,7 @@ MapRendererTerrain::MapRendererTerrain()
|
||||
{
|
||||
logGlobal->debug("Loading map terrains");
|
||||
for(const auto & terrain : VLC->terrainTypeHandler->objects)
|
||||
storage.load(terrain->getIndex(), terrain->tilesFilename, EImageBlitMode::OPAQUE);
|
||||
storage.load(terrain->getIndex(), AnimationPath::builtin(terrain->tilesFilename.getName() + (terrain->paletteAnimation.size() ? "_Shifted": "")), EImageBlitMode::OPAQUE);
|
||||
logGlobal->debug("Done loading map terrains");
|
||||
}
|
||||
|
||||
@ -156,8 +156,8 @@ void MapRendererTerrain::renderTile(IMapRendererContext & context, Canvas & targ
|
||||
return;
|
||||
}
|
||||
|
||||
// for( auto const & element : mapTile.getTerrain()->paletteAnimation)
|
||||
// image->shiftPalette(element.start, element.length, context.terrainImageIndex(element.length));
|
||||
for( auto const & element : mapTile.getTerrain()->paletteAnimation)
|
||||
image->shiftPalette(element.start, element.length, context.terrainImageIndex(element.length));
|
||||
|
||||
target.draw(image, Point(0, 0));
|
||||
}
|
||||
@ -176,7 +176,7 @@ MapRendererRiver::MapRendererRiver()
|
||||
{
|
||||
logGlobal->debug("Loading map rivers");
|
||||
for(const auto & river : VLC->riverTypeHandler->objects)
|
||||
storage.load(river->getIndex(), river->tilesFilename, EImageBlitMode::COLORKEY);
|
||||
storage.load(river->getIndex(), AnimationPath::builtin(river->tilesFilename.getName() + (river->paletteAnimation.size() ? "_Shifted": "")), EImageBlitMode::COLORKEY);
|
||||
logGlobal->debug("Done loading map rivers");
|
||||
}
|
||||
|
||||
@ -193,8 +193,8 @@ void MapRendererRiver::renderTile(IMapRendererContext & context, Canvas & target
|
||||
|
||||
const auto & image = storage.find(terrainIndex, rotationIndex, imageIndex);
|
||||
|
||||
//for( auto const & element : mapTile.getRiver()->paletteAnimation)
|
||||
// image->shiftPalette(element.start, element.length, context.terrainImageIndex(element.length));
|
||||
for( auto const & element : mapTile.getRiver()->paletteAnimation)
|
||||
image->shiftPalette(element.start, element.length, context.terrainImageIndex(element.length));
|
||||
|
||||
target.draw(image, Point(0, 0));
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ void AssetGenerator::createPaletteShiftedSprites()
|
||||
auto filename = AnimationPath::builtin(sprite).addPrefix("SPRITES/");
|
||||
auto filenameNew = AnimationPath::builtin(sprite + "_Shifted").addPrefix("SPRITES/");
|
||||
|
||||
if(CResourceHandler::get()->existsResource(ResourcePath(filenameNew))) // overridden by mod, no generation
|
||||
if(CResourceHandler::get()->existsResource(ResourcePath(filenameNew.getName(), EResType::JSON))) // overridden by mod, no generation
|
||||
return;
|
||||
|
||||
auto anim = GH.renderHandler().loadAnimation(filename, EImageBlitMode::COLORKEY);
|
||||
@ -409,12 +409,15 @@ void AssetGenerator::createPaletteShiftedSprites()
|
||||
img->shiftPalette(tmp.start, tmp.length, l % tmp.length);
|
||||
}
|
||||
}
|
||||
img->exportBitmap(*CResourceHandler::get("local")->getResourceName(savePath));
|
||||
Canvas canvas = Canvas(Point(32, 32), CanvasScalingPolicy::IGNORE);
|
||||
canvas.draw(img, Point((32 - img->dimensions().x) / 2, (32 - img->dimensions().y) / 2));
|
||||
std::shared_ptr<IImage> image = GH.renderHandler().createImage(canvas.getInternalSurface());
|
||||
image->exportBitmap(*CResourceHandler::get("local")->getResourceName(savePath));
|
||||
|
||||
JsonNode node;
|
||||
node.Struct() = {
|
||||
{ "group", JsonNode(std::to_string(l)) },
|
||||
{ "frame", JsonNode(std::to_string(j)) },
|
||||
{ "group", JsonNode(l) },
|
||||
{ "frame", JsonNode(j) },
|
||||
{ "file", JsonNode(spriteName) }
|
||||
};
|
||||
config["images"].Vector().push_back(node);
|
||||
@ -425,7 +428,7 @@ void AssetGenerator::createPaletteShiftedSprites()
|
||||
if(!CResourceHandler::get("local")->createResource(filenameNew.getOriginalName() + ".json"))
|
||||
return;
|
||||
|
||||
std::fstream file(CResourceHandler::get()->getResourceName(savePath)->c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
std::fstream file(CResourceHandler::get("local")->getResourceName(savePath)->c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
file << config.toString();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user