1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00

remove original resource functionality

This commit is contained in:
Laserlicht 2024-08-28 23:44:31 +02:00
parent 70190ea1fe
commit f327224d45
5 changed files with 8 additions and 40 deletions

View File

@ -36,7 +36,6 @@ void AssetGenerator::createAdventureOptionsCleanBackground()
ResourcePath savePath(filename, EResType::IMAGE);
auto res = ImagePath::builtin("ADVOPTBK");
res = res.setOriginalResource(true);
std::shared_ptr<IImage> img = GH.renderHandler().loadImage(res, EImageBlitMode::OPAQUE);
@ -66,7 +65,6 @@ void AssetGenerator::createBigSpellBook()
ResourcePath savePath(filename, EResType::IMAGE);
auto res = ImagePath::builtin("SpelBack");
res = res.setOriginalResource(true);
std::shared_ptr<IImage> img = GH.renderHandler().loadImage(res, EImageBlitMode::OPAQUE);
Canvas canvas = Canvas(Point(800, 600), CanvasScalingPolicy::IGNORE);

View File

@ -66,19 +66,10 @@ CFilesystemList::~CFilesystemList()
std::unique_ptr<CInputStream> CFilesystemList::load(const ResourcePath & resourceName) const
{
if(resourceName.getOriginalResource())
{
for(const auto & loader : loaders)
if (loader->existsResource(resourceName))
return loader->load(resourceName);
}
else
{
// load resource from last loader that have it (last overridden version)
for(const auto & loader : boost::adaptors::reverse(loaders))
if (loader->existsResource(resourceName))
return loader->load(resourceName);
}
// load resource from last loader that have it (last overridden version)
for(const auto & loader : boost::adaptors::reverse(loaders))
if (loader->existsResource(resourceName))
return loader->load(resourceName);
throw std::runtime_error("Resource with name " + resourceName.getName() + " and type "
+ EResTypeHelper::getEResTypeAsString(resourceName.getType()) + " wasn't found.");

View File

@ -51,22 +51,19 @@ static inline std::string readName(std::string name, bool uppercase)
ResourcePath::ResourcePath(const std::string & name_):
type(readType(name_)),
name(readName(name_, true)),
originalName(readName(name_, false)),
originalResource(false)
originalName(readName(name_, false))
{}
ResourcePath::ResourcePath(const std::string & name_, EResType type_):
type(type_),
name(readName(name_, true)),
originalName(readName(name_, false)),
originalResource(false)
originalName(readName(name_, false))
{}
ResourcePath::ResourcePath(const JsonNode & name, EResType type):
type(type),
name(readName(name.String(), true)),
originalName(readName(name.String(), false)),
originalResource(false)
originalName(readName(name.String(), false))
{
}

View File

@ -99,7 +99,6 @@ public:
bool empty() const {return name.empty();}
std::string getName() const {return name;}
std::string getOriginalName() const {return originalName;}
bool getOriginalResource() const {return originalResource;}
EResType getType() const {return type;}
void serializeJson(JsonSerializeFormat & handler);
@ -109,8 +108,6 @@ public:
h & type;
h & name;
h & originalName;
if (h.version >= Handler::Version::RESOURCE_GENERATION)
h & originalResource;
}
protected:
@ -123,9 +120,6 @@ protected:
/// name in original case
std::string originalName;
/// flag for requesting unmodded, original resource
bool originalResource;
};
template<EResType Type>
@ -186,17 +180,6 @@ public:
ResourcePathTempl result;
result.name = prefix + this->getName();
result.originalName = prefix + this->getOriginalName();
result.originalResource = this->getOriginalResource();
return result;
}
ResourcePathTempl setOriginalResource(bool original) const
{
ResourcePathTempl result;
result.name = this->getName();
result.originalName = this->getOriginalName();
result.originalResource = original;
return result;
}

View File

@ -66,7 +66,6 @@ enum class ESerializationVersion : int32_t
NEW_TOWN_BUILDINGS, // 855 - old bonusing buildings have been removed
STATISTICS_SCREEN, // 856 - extent statistic functions
NEW_MARKETS, // 857 - reworked market classes
RESOURCE_GENERATION, // 858 - resource generation
CURRENT = RESOURCE_GENERATION
CURRENT = NEW_MARKETS
};