mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
dont cut overlays & shadows
This commit is contained in:
@@ -295,6 +295,7 @@ std::shared_ptr<SDLImageShared> RenderHandler::loadScaledImage(const ImageLocato
|
||||
bool generateOverlay = locator.generateOverlay && (*locator.generateOverlay) != SharedImageLocator::OverlayMode::OVERLAY_NONE;
|
||||
bool isShadow = locator.layer == EImageBlitMode::ONLY_SHADOW_HIDE_SELECTION || locator.layer == EImageBlitMode::ONLY_SHADOW_HIDE_FLAG_COLOR;
|
||||
bool isOverlay = locator.layer == EImageBlitMode::ONLY_FLAG_COLOR || locator.layer == EImageBlitMode::ONLY_SELECTION;
|
||||
bool optimizeImage = !(isShadow && generateShadow) && !(isOverlay && generateOverlay); // images needs to expanded
|
||||
|
||||
if(isOverlay && !generateOverlay)
|
||||
imagePathString += "-OVERLAY";
|
||||
@@ -312,11 +313,11 @@ std::shared_ptr<SDLImageShared> RenderHandler::loadScaledImage(const ImageLocato
|
||||
std::shared_ptr<SDLImageShared> img = nullptr;
|
||||
|
||||
if(CResourceHandler::get()->existsResource(imagePathSprites))
|
||||
img = std::make_shared<SDLImageShared>(imagePathSprites);
|
||||
img = std::make_shared<SDLImageShared>(imagePathSprites, optimizeImage);
|
||||
else if(CResourceHandler::get()->existsResource(imagePathData))
|
||||
img = std::make_shared<SDLImageShared>(imagePathData);
|
||||
img = std::make_shared<SDLImageShared>(imagePathData, optimizeImage);
|
||||
else if(CResourceHandler::get()->existsResource(imagePath))
|
||||
img = std::make_shared<SDLImageShared>(imagePath);
|
||||
img = std::make_shared<SDLImageShared>(imagePath, optimizeImage);
|
||||
|
||||
if(img)
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ SDLImageShared::SDLImageShared(SDL_Surface * from)
|
||||
fullSize.y = surf->h;
|
||||
}
|
||||
|
||||
SDLImageShared::SDLImageShared(const ImagePath & filename)
|
||||
SDLImageShared::SDLImageShared(const ImagePath & filename, bool optimizeImage)
|
||||
: surf(nullptr),
|
||||
margins(0, 0),
|
||||
fullSize(0, 0),
|
||||
@@ -89,7 +89,8 @@ SDLImageShared::SDLImageShared(const ImagePath & filename)
|
||||
fullSize.x = surf->w;
|
||||
fullSize.y = surf->h;
|
||||
|
||||
optimizeSurface();
|
||||
if(optimizeImage)
|
||||
optimizeSurface();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,6 +443,7 @@ std::shared_ptr<SDLImageShared> SDLImageShared::drawShadow(bool doSheer) const
|
||||
ret->fullSize = fullSize;
|
||||
ret->margins.x = margins.x;
|
||||
ret->margins.y = margins.y;
|
||||
ret->optimizeSurface();
|
||||
|
||||
// erase our own reference
|
||||
SDL_FreeSurface(shadow);
|
||||
@@ -463,6 +465,7 @@ std::shared_ptr<SDLImageShared> SDLImageShared::drawOutline(const ColorRGBA & co
|
||||
ret->fullSize = fullSize;
|
||||
ret->margins.x = margins.x;
|
||||
ret->margins.y = margins.y;
|
||||
ret->optimizeSurface();
|
||||
|
||||
// erase our own reference
|
||||
SDL_FreeSurface(outline);
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
//Load image from def file
|
||||
SDLImageShared(const CDefFile *data, size_t frame, size_t group=0);
|
||||
//Load from bitmap file
|
||||
SDLImageShared(const ImagePath & filename);
|
||||
SDLImageShared(const ImagePath & filename, bool optimizeImage=true);
|
||||
//Create using existing surface, extraRef will increase refcount on SDL_Surface
|
||||
SDLImageShared(SDL_Surface * from);
|
||||
~SDLImageShared();
|
||||
|
||||
@@ -974,7 +974,7 @@ SDL_Surface * CSDL_Ext::drawShadow(SDL_Surface * source, bool doSheer)
|
||||
assert(destSurface->format->format == SDL_PIXELFORMAT_ARGB8888);
|
||||
|
||||
double shearX = doSheer ? 0.5 : 0.0;
|
||||
double scaleY = 0.25;
|
||||
double scaleY = doSheer ? 0.5 : 0.25;
|
||||
|
||||
int lowestSource = getLowestNonTransparentY(sourceSurface);
|
||||
int lowestTransformed = lowestSource * scaleY;
|
||||
|
||||
Reference in New Issue
Block a user