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

add ImageLocator::toString

This commit is contained in:
Ivan Savenko 2024-09-12 20:26:40 +00:00
parent 2d08e18f6a
commit 66a2c8dc37
2 changed files with 39 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
};