mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
remove resource
This commit is contained in:
parent
c56d667981
commit
d8869a33da
@ -31,10 +31,6 @@ void AssetGenerator::createAdventureOptionsCleanBackground()
|
||||
if(!CResourceHandler::get("local")->createResource(filename))
|
||||
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()
|
||||
@ -62,10 +60,6 @@ void AssetGenerator::createBigSpellBook()
|
||||
if(!CResourceHandler::get("local")->createResource(filename))
|
||||
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
|
||||
}
|
||||
|
@ -16,4 +16,4 @@ class AssetGenerator
|
||||
|
||||
public:
|
||||
static void generate();
|
||||
};
|
||||
};
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user