mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-14 10:12:59 +02:00
cleanup logic
This commit is contained in:
parent
ac31a946e6
commit
35e198078b
@ -55,17 +55,15 @@ std::shared_ptr<CDefFile> RenderHandler::getAnimationFile(const AnimationPath &
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<ResourcePath> RenderHandler::getPath(ResourcePath path, std::string factor)
|
std::optional<ResourcePath> RenderHandler::getPathForScaleFactor(ResourcePath path, std::string factor)
|
||||||
{
|
{
|
||||||
if(CResourceHandler::get()->existsResource(path))
|
|
||||||
return path;
|
|
||||||
if(path.getType() == EResType::IMAGE)
|
if(path.getType() == EResType::IMAGE)
|
||||||
{
|
{
|
||||||
auto p = ImagePath::builtin(path.getName());
|
auto p = ImagePath::builtin(path.getName());
|
||||||
if(CResourceHandler::get()->existsResource(p.addPrefix("DATA" + factor + "X/")))
|
|
||||||
return std::optional<ResourcePath>(p.addPrefix("DATA" + factor + "X/"));
|
|
||||||
if(CResourceHandler::get()->existsResource(p.addPrefix("SPRITES" + factor + "X/")))
|
if(CResourceHandler::get()->existsResource(p.addPrefix("SPRITES" + factor + "X/")))
|
||||||
return std::optional<ResourcePath>(p.addPrefix("SPRITES" + factor + "X/"));
|
return std::optional<ResourcePath>(p.addPrefix("SPRITES" + factor + "X/"));
|
||||||
|
if(CResourceHandler::get()->existsResource(p.addPrefix("DATA" + factor + "X/")))
|
||||||
|
return std::optional<ResourcePath>(p.addPrefix("DATA" + factor + "X/"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -97,7 +95,7 @@ std::pair<ResourcePath, int> RenderHandler::getScalePath(ResourcePath p)
|
|||||||
ResourcePath scaledPath = ImagePath::builtin(name);
|
ResourcePath scaledPath = ImagePath::builtin(name);
|
||||||
if(p.getType() != EResType::IMAGE)
|
if(p.getType() != EResType::IMAGE)
|
||||||
scaledPath = AnimationPath::builtin(name);
|
scaledPath = AnimationPath::builtin(name);
|
||||||
auto tmpPath = getPath(scaledPath, std::to_string(factorToCheck));
|
auto tmpPath = getPathForScaleFactor(scaledPath, std::to_string(factorToCheck));
|
||||||
if(tmpPath)
|
if(tmpPath)
|
||||||
{
|
{
|
||||||
path = *tmpPath;
|
path = *tmpPath;
|
||||||
|
@ -29,7 +29,7 @@ class RenderHandler : public IRenderHandler
|
|||||||
std::map<EFonts, std::shared_ptr<const IFont>> fonts;
|
std::map<EFonts, std::shared_ptr<const IFont>> fonts;
|
||||||
|
|
||||||
std::shared_ptr<CDefFile> getAnimationFile(const AnimationPath & path);
|
std::shared_ptr<CDefFile> getAnimationFile(const AnimationPath & path);
|
||||||
std::optional<ResourcePath> getPath(ResourcePath path, std::string factor);
|
std::optional<ResourcePath> getPathForScaleFactor(ResourcePath path, std::string factor);
|
||||||
std::pair<ResourcePath, int> getScalePath(ResourcePath p);
|
std::pair<ResourcePath, int> getScalePath(ResourcePath p);
|
||||||
AnimationLayoutMap & getAnimationLayout(const AnimationPath & path);
|
AnimationLayoutMap & getAnimationLayout(const AnimationPath & path);
|
||||||
void initFromJson(AnimationLayoutMap & layout, const JsonNode & config);
|
void initFromJson(AnimationLayoutMap & layout, const JsonNode & config);
|
||||||
|
Loading…
Reference in New Issue
Block a user