Forráskód Böngészése

add ImageLocator::toString

Ivan Savenko 1 éve
szülő
commit
66a2c8dc37
2 módosított fájl, 39 hozzáadás és 0 törlés
  1. 34 0
      client/render/ImageLocator.cpp
  2. 5 0
      client/render/ImageLocator.h

+ 34 - 0
client/render/ImageLocator.cpp

@@ -90,3 +90,37 @@ ImageLocator ImageLocator::copyFileTransformScale() const
 {
 	return *this; // full copy
 }
+
+std::string ImageLocator::toString() const
+{
+	std::string result;
+	if (empty())
+		return "invalid";
+
+	if (image)
+		result += image->getOriginalName();
+
+	if (defFile)
+	{
+		result += defFile->getOriginalName();
+		result += "-" + std::to_string(defGroup);
+		result += "-" + std::to_string(defFrame);
+	}
+
+	if (verticalFlip)
+		result += "-vflip";
+
+	if (horizontalFlip)
+		result += "-hflip";
+
+	if (scalingFactor > 1)
+		result += "-scale" + std::to_string(scalingFactor);
+
+	if (playerColored.isValidPlayer())
+		result += "-player" + playerColored.toString();
+
+	if (layer != EImageLayer::ALL)
+		result =+ "-layer" + std::to_string(static_cast<int>(layer));
+
+	return result;
+}

+ 5 - 0
client/render/ImageLocator.h

@@ -46,4 +46,9 @@ struct ImageLocator
 	ImageLocator copyFile() const;
 	ImageLocator copyFileTransform() const;
 	ImageLocator copyFileTransformScale() const;
+
+	// generates string representation of this image locator
+	// guaranteed to be a valid file path with no extension
+	// but may contain '/' if source file is in directory
+	std::string toString() const;
 };