1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

code review

This commit is contained in:
Laserlicht 2024-11-15 19:09:34 +01:00 committed by GitHub
parent 1e77d08d1a
commit 149c6cd778
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -326,24 +326,24 @@ std::shared_ptr<ISharedImage> RenderHandler::scaleImage(const ImageLocator & loc
std::shared_ptr<IImage> RenderHandler::loadImage(const ImageLocator & locator, EImageBlitMode mode) std::shared_ptr<IImage> RenderHandler::loadImage(const ImageLocator & locator, EImageBlitMode mode)
{ {
ImageLocator loc = locator; ImageLocator adjustedLocator = locator;
if(loc.defFile && loc.scalingFactor == 0) if(adjustedLocator.defFile && adjustedLocator.scalingFactor == 0)
{ {
auto tmp = getScalePath(*loc.defFile); auto tmp = getScalePath(*adjustedLocator.defFile);
loc.defFile = AnimationPath::builtin(tmp.first.getName()); adjustedLocator.defFile = AnimationPath::builtin(tmp.first.getName());
loc.preScaledFactor = tmp.second; adjustedLocator.preScaledFactor = tmp.second;
} }
if(loc.image && loc.scalingFactor == 0) if(adjustedLocator.image && adjustedLocator.scalingFactor == 0)
{ {
auto tmp = getScalePath(*loc.image); auto tmp = getScalePath(*adjustedLocator.image);
loc.image = ImagePath::builtin(tmp.first.getName()); adjustedLocator.image = ImagePath::builtin(tmp.first.getName());
loc.preScaledFactor = tmp.second; adjustedLocator.preScaledFactor = tmp.second;
} }
if (loc.scalingFactor == 0 && getScalingFactor() != 1 ) if (adjustedLocator.scalingFactor == 0 && getScalingFactor() != 1 )
{ {
auto unscaledLocator = loc; auto unscaledLocator = adjustedLocator;
auto scaledLocator = loc; auto scaledLocator = adjustedLocator;
unscaledLocator.scalingFactor = 1; unscaledLocator.scalingFactor = 1;
scaledLocator.scalingFactor = getScalingFactor(); scaledLocator.scalingFactor = getScalingFactor();
@ -352,28 +352,28 @@ std::shared_ptr<IImage> RenderHandler::loadImage(const ImageLocator & locator, E
return std::make_shared<ImageScaled>(scaledLocator, unscaledImage, mode); return std::make_shared<ImageScaled>(scaledLocator, unscaledImage, mode);
} }
if (loc.scalingFactor == 0) if (adjustedLocator.scalingFactor == 0)
{ {
auto scaledLocator = loc; auto scaledLocator = adjustedLocator;
scaledLocator.scalingFactor = getScalingFactor(); scaledLocator.scalingFactor = getScalingFactor();
return loadImageImpl(scaledLocator)->createImageReference(mode); return loadImageImpl(scaledLocator)->createImageReference(mode);
} }
else else
{ {
if(loc.image) if(adjustedLocator.image)
{ {
std::string imgPath = (*loc.image).getName(); std::string imgPath = (*adjustedLocator.image).getName();
if(loc.layer == EImageLayer::OVERLAY) if(adjustedLocator.layer == EImageLayer::OVERLAY)
imgPath += "-overlay"; imgPath += "-overlay";
if(loc.layer == EImageLayer::SHADOW) if(adjustedLocator.layer == EImageLayer::SHADOW)
imgPath += "-shadow"; imgPath += "-shadow";
if(CResourceHandler::get()->existsResource(ImagePath::builtin(imgPath))) if(CResourceHandler::get()->existsResource(ImagePath::builtin(imgPath)))
loc.image = ImagePath::builtin(imgPath); adjustedLocator.image = ImagePath::builtin(imgPath);
} }
return loadImageImpl(loc)->createImageReference(mode); return loadImageImpl(adjustedLocator)->createImageReference(mode);
} }
} }