mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
All assets generation (large spellbook, terrain animations, etc) are now done in memory and used as it, without saving to disk. This should slightly improve load times since there is no encode png / decode png, and should help with avoiding strange bug when vcmi fails to load recently saved assets. If needed, such assets can be force-dumped on disk using already existing console command
62 lines
1.7 KiB
C++
62 lines
1.7 KiB
C++
/*
|
|
* AssetGenerator.h, part of VCMI engine
|
|
*
|
|
* Authors: listed in file AUTHORS in main folder
|
|
*
|
|
* License: GNU General Public License v2.0 or later
|
|
* Full text of license available in license.txt file, in main folder
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#include "ImageLocator.h"
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
class PlayerColor;
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
class ISharedImage;
|
|
class CanvasImage;
|
|
|
|
class AssetGenerator
|
|
{
|
|
public:
|
|
using AnimationLayoutMap = std::map<size_t, std::vector<ImageLocator>>;
|
|
using CanvasPtr = std::shared_ptr<CanvasImage>;
|
|
|
|
AssetGenerator();
|
|
|
|
void initialize();
|
|
|
|
std::shared_ptr<ISharedImage> generateImage(const ImagePath & image);
|
|
|
|
std::map<ImagePath, std::shared_ptr<ISharedImage>> generateAllImages();
|
|
std::map<AnimationPath, AnimationLayoutMap> generateAllAnimations();
|
|
|
|
private:
|
|
using ImageGenerationFunctor = std::function<CanvasPtr()>;
|
|
|
|
struct PaletteAnimation
|
|
{
|
|
/// index of first color to cycle
|
|
int32_t start;
|
|
/// total numbers of colors to cycle
|
|
int32_t length;
|
|
};
|
|
|
|
std::map<ImagePath, ImageGenerationFunctor> imageFiles;
|
|
std::map<AnimationPath, AnimationLayoutMap> animationFiles;
|
|
|
|
CanvasPtr createAdventureOptionsCleanBackground();
|
|
CanvasPtr createBigSpellBook();
|
|
CanvasPtr createPlayerColoredBackground(const PlayerColor & player);
|
|
CanvasPtr createCombatUnitNumberWindow(float multR, float multG, float multB);
|
|
CanvasPtr createCampaignBackground();
|
|
CanvasPtr createChroniclesCampaignImages(int chronicle);
|
|
CanvasPtr createPaletteShiftedImage(const AnimationPath & source, const std::vector<PaletteAnimation> & animation, int frameIndex, int paletteShiftCounter);
|
|
|
|
void createPaletteShiftedSprites();
|
|
void generatePaletteShiftedAnimation(const AnimationPath & source, const std::vector<PaletteAnimation> & animation);
|
|
|
|
};
|