Browse Source

cleanup logic

Laserlicht 11 months ago
parent
commit
35e198078b
2 changed files with 5 additions and 7 deletions
  1. 4 6
      client/renderSDL/RenderHandler.cpp
  2. 1 1
      client/renderSDL/RenderHandler.h

+ 4 - 6
client/renderSDL/RenderHandler.cpp

@@ -55,17 +55,15 @@ std::shared_ptr<CDefFile> RenderHandler::getAnimationFile(const AnimationPath &
 	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)
 	{
 		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/")))
 			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
 	{
@@ -97,7 +95,7 @@ std::pair<ResourcePath, int> RenderHandler::getScalePath(ResourcePath p)
 			ResourcePath scaledPath = ImagePath::builtin(name);
 			if(p.getType() != EResType::IMAGE)
 				scaledPath = AnimationPath::builtin(name);
-			auto tmpPath = getPath(scaledPath, std::to_string(factorToCheck));
+			auto tmpPath = getPathForScaleFactor(scaledPath, std::to_string(factorToCheck));
 			if(tmpPath)
 			{
 				path = *tmpPath;

+ 1 - 1
client/renderSDL/RenderHandler.h

@@ -29,7 +29,7 @@ class RenderHandler : public IRenderHandler
 	std::map<EFonts, std::shared_ptr<const IFont>> fonts;
 
 	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);
 	AnimationLayoutMap & getAnimationLayout(const AnimationPath & path);
 	void initFromJson(AnimationLayoutMap & layout, const JsonNode & config);