1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-21 21:17:49 +02:00

remove resource

This commit is contained in:
Laserlicht 2024-08-20 22:45:11 +02:00
parent c56d667981
commit d8869a33da
5 changed files with 16 additions and 9 deletions

@ -32,10 +32,6 @@ void AssetGenerator::createAdventureOptionsCleanBackground()
return;
ResourcePath savePath(filename, EResType::IMAGE);
if(boost::filesystem::exists(*CResourceHandler::get("local")->getResourceName(savePath)) &&
boost::filesystem::file_size(*CResourceHandler::get("local")->getResourceName(savePath)))
return;
auto res = ImagePath::builtin("ADVOPTBK");
res.setOriginalResource(true);
@ -53,6 +49,8 @@ void AssetGenerator::createAdventureOptionsCleanBackground()
std::shared_ptr<IImage> image = GH.renderHandler().createImage(canvas.getInternalSurface());
image->exportBitmap(*CResourceHandler::get("local")->getResourceName(savePath));
CResourceHandler::get("local")->removeResource(savePath); // remove resource -> may overridden by mod later
}
void AssetGenerator::createBigSpellBook()
@ -63,10 +61,6 @@ void AssetGenerator::createBigSpellBook()
return;
ResourcePath savePath(filename, EResType::IMAGE);
if(boost::filesystem::exists(*CResourceHandler::get("local")->getResourceName(savePath)) &&
boost::filesystem::file_size(*CResourceHandler::get("local")->getResourceName(savePath)))
return;
auto res = ImagePath::builtin("SpelBack");
res.setOriginalResource(true);
@ -117,4 +111,6 @@ void AssetGenerator::createBigSpellBook()
std::shared_ptr<IImage> image = GH.renderHandler().createImage(canvas.getInternalSurface());
image->exportBitmap(*CResourceHandler::get("local")->getResourceName(savePath));
CResourceHandler::get("local")->removeResource(savePath); // remove resource -> may overridden by mod later
}

@ -108,6 +108,11 @@ bool CFilesystemLoader::createResource(const std::string & requestedFilename, bo
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
{
static const EResType initArray[] = {

@ -38,6 +38,7 @@ public:
bool existsResource(const ResourcePath & resourceName) const override;
std::string getMountPoint() const 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;
void updateFilteredFiles(std::function<bool(const std::string &)> filter) const override;
std::unordered_set<ResourcePath> getFilteredFiles(std::function<bool(const ResourcePath &)> filter) const override;

@ -95,6 +95,11 @@ public:
return false;
}
/**
* Remove resources from cached list.
*/
virtual void removeResource(const ResourcePath & resourceName) { };
/**
* @brief Returns all loaders that have resource with such name
*