mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
fix
This commit is contained in:
parent
02002ce69d
commit
c2290f5f6e
@ -28,12 +28,15 @@ void AssetGenerator::createAdventureOptionsCleanBackground()
|
|||||||
{
|
{
|
||||||
std::string filename = "data/ADVOPTBC.bmp";
|
std::string filename = "data/ADVOPTBC.bmp";
|
||||||
|
|
||||||
|
if(CResourceHandler::get()->existsResource(ResourcePath(filename))) // overridden by mod, no generation
|
||||||
|
return;
|
||||||
|
|
||||||
if(!CResourceHandler::get("local")->createResource(filename))
|
if(!CResourceHandler::get("local")->createResource(filename))
|
||||||
return;
|
return;
|
||||||
ResourcePath savePath(filename, EResType::IMAGE);
|
ResourcePath savePath(filename, EResType::IMAGE);
|
||||||
|
|
||||||
auto res = ImagePath::builtin("ADVOPTBK");
|
auto res = ImagePath::builtin("ADVOPTBK");
|
||||||
res.setOriginalResource(true);
|
res = res.setOriginalResource(true);
|
||||||
|
|
||||||
std::shared_ptr<IImage> img = GH.renderHandler().loadImage(res, EImageBlitMode::OPAQUE);
|
std::shared_ptr<IImage> img = GH.renderHandler().loadImage(res, EImageBlitMode::OPAQUE);
|
||||||
|
|
||||||
@ -49,20 +52,21 @@ void AssetGenerator::createAdventureOptionsCleanBackground()
|
|||||||
std::shared_ptr<IImage> image = GH.renderHandler().createImage(canvas.getInternalSurface());
|
std::shared_ptr<IImage> image = GH.renderHandler().createImage(canvas.getInternalSurface());
|
||||||
|
|
||||||
image->exportBitmap(*CResourceHandler::get("local")->getResourceName(savePath));
|
image->exportBitmap(*CResourceHandler::get("local")->getResourceName(savePath));
|
||||||
|
|
||||||
CResourceHandler::get("local")->removeResource(savePath); // remove resource -> may overridden by mod later
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetGenerator::createBigSpellBook()
|
void AssetGenerator::createBigSpellBook()
|
||||||
{
|
{
|
||||||
std::string filename = "data/SpelBk2.bmp";
|
std::string filename = "data/SpelBk2.bmp";
|
||||||
|
|
||||||
|
if(CResourceHandler::get()->existsResource(ResourcePath(filename))) // overridden by mod, no generation
|
||||||
|
return;
|
||||||
|
|
||||||
if(!CResourceHandler::get("local")->createResource(filename))
|
if(!CResourceHandler::get("local")->createResource(filename))
|
||||||
return;
|
return;
|
||||||
ResourcePath savePath(filename, EResType::IMAGE);
|
ResourcePath savePath(filename, EResType::IMAGE);
|
||||||
|
|
||||||
auto res = ImagePath::builtin("SpelBack");
|
auto res = ImagePath::builtin("SpelBack");
|
||||||
res.setOriginalResource(true);
|
res = res.setOriginalResource(true);
|
||||||
|
|
||||||
std::shared_ptr<IImage> img = GH.renderHandler().loadImage(res, EImageBlitMode::OPAQUE);
|
std::shared_ptr<IImage> img = GH.renderHandler().loadImage(res, EImageBlitMode::OPAQUE);
|
||||||
Canvas canvas = Canvas(Point(800, 600), CanvasScalingPolicy::IGNORE);
|
Canvas canvas = Canvas(Point(800, 600), CanvasScalingPolicy::IGNORE);
|
||||||
@ -111,6 +115,4 @@ void AssetGenerator::createBigSpellBook()
|
|||||||
std::shared_ptr<IImage> image = GH.renderHandler().createImage(canvas.getInternalSurface());
|
std::shared_ptr<IImage> image = GH.renderHandler().createImage(canvas.getInternalSurface());
|
||||||
|
|
||||||
image->exportBitmap(*CResourceHandler::get("local")->getResourceName(savePath));
|
image->exportBitmap(*CResourceHandler::get("local")->getResourceName(savePath));
|
||||||
|
|
||||||
CResourceHandler::get("local")->removeResource(savePath); // remove resource -> may overridden by mod later
|
|
||||||
}
|
}
|
||||||
|
@ -108,11 +108,6 @@ bool CFilesystemLoader::createResource(const std::string & requestedFilename, bo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFilesystemLoader::removeResource(const ResourcePath & resourceName)
|
|
||||||
{
|
|
||||||
fileList.erase(resourceName);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unordered_map<ResourcePath, boost::filesystem::path> CFilesystemLoader::listFiles(const std::string &mountPoint, size_t depth, bool initial) const
|
std::unordered_map<ResourcePath, boost::filesystem::path> CFilesystemLoader::listFiles(const std::string &mountPoint, size_t depth, bool initial) const
|
||||||
{
|
{
|
||||||
static const EResType initArray[] = {
|
static const EResType initArray[] = {
|
||||||
|
@ -38,7 +38,6 @@ public:
|
|||||||
bool existsResource(const ResourcePath & resourceName) const override;
|
bool existsResource(const ResourcePath & resourceName) const override;
|
||||||
std::string getMountPoint() const override;
|
std::string getMountPoint() const override;
|
||||||
bool createResource(const std::string & filename, bool update = false) override;
|
bool createResource(const std::string & filename, bool update = false) override;
|
||||||
void removeResource(const ResourcePath & resourceName) override;
|
|
||||||
std::optional<boost::filesystem::path> getResourceName(const ResourcePath & resourceName) const override;
|
std::optional<boost::filesystem::path> getResourceName(const ResourcePath & resourceName) const override;
|
||||||
void updateFilteredFiles(std::function<bool(const std::string &)> filter) const override;
|
void updateFilteredFiles(std::function<bool(const std::string &)> filter) const override;
|
||||||
std::unordered_set<ResourcePath> getFilteredFiles(std::function<bool(const ResourcePath &)> filter) const override;
|
std::unordered_set<ResourcePath> getFilteredFiles(std::function<bool(const ResourcePath &)> filter) const override;
|
||||||
|
@ -182,6 +182,9 @@ void CResourceHandler::initialize()
|
|||||||
knownLoaders["root"] = globalResourceHandler.rootLoader.get();
|
knownLoaders["root"] = globalResourceHandler.rootLoader.get();
|
||||||
knownLoaders["saves"] = new CFilesystemLoader("SAVES/", VCMIDirs::get().userSavePath());
|
knownLoaders["saves"] = new CFilesystemLoader("SAVES/", VCMIDirs::get().userSavePath());
|
||||||
knownLoaders["config"] = new CFilesystemLoader("CONFIG/", VCMIDirs::get().userConfigPath());
|
knownLoaders["config"] = new CFilesystemLoader("CONFIG/", VCMIDirs::get().userConfigPath());
|
||||||
|
|
||||||
|
if(boost::filesystem::is_directory(VCMIDirs::get().userDataPath() / "Generated"))
|
||||||
|
boost::filesystem::remove_all(VCMIDirs::get().userDataPath() / "Generated");
|
||||||
knownLoaders["gen_data"] = new CFilesystemLoader("DATA/", VCMIDirs::get().userDataPath() / "Generated" / "Data");
|
knownLoaders["gen_data"] = new CFilesystemLoader("DATA/", VCMIDirs::get().userDataPath() / "Generated" / "Data");
|
||||||
knownLoaders["gen_sprites"] = new CFilesystemLoader("SPRITES/", VCMIDirs::get().userDataPath() / "Generated" / "Sprites");
|
knownLoaders["gen_sprites"] = new CFilesystemLoader("SPRITES/", VCMIDirs::get().userDataPath() / "Generated" / "Sprites");
|
||||||
|
|
||||||
|
@ -95,11 +95,6 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove resources from cached list.
|
|
||||||
*/
|
|
||||||
virtual void removeResource(const ResourcePath & resourceName) { };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns all loaders that have resource with such name
|
* @brief Returns all loaders that have resource with such name
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user