1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Merge pull request #2740 from Laserlicht/fix_cursor_issue

This commit is contained in:
Nordsoft91
2023-09-11 22:20:11 +02:00
committed by GitHub
5 changed files with 21 additions and 2 deletions

View File

@@ -175,7 +175,7 @@ void AdventureMapInterface::dim(Canvas & to)
Rect targetRect(0, 0, GH.screenDimensions().x, GH.screenDimensions().y);
ColorRGBA colorToFill(0, 0, 0, std::clamp<int>(backgroundDimLevel, 0, 255));
if(backgroundDimLevel > 0)
to.drawColor(targetRect, colorToFill);
to.drawColorBlended(targetRect, colorToFill);
return;
}
}

View File

@@ -175,6 +175,13 @@ void Canvas::drawColor(const Rect & target, const ColorRGBA & color)
CSDL_Ext::fillRect(surface, realTarget, CSDL_Ext::toSDL(color));
}
void Canvas::drawColorBlended(const Rect & target, const ColorRGBA & color)
{
Rect realTarget = target + renderArea.topLeft();
CSDL_Ext::fillRectBlended(surface, realTarget, CSDL_Ext::toSDL(color));
}
SDL_Surface * Canvas::getInternalSurface()
{
return surface;

View File

@@ -96,6 +96,9 @@ public:
/// fills selected area with solid color
void drawColor(const Rect & target, const ColorRGBA & color);
/// fills selected area with blended color
void drawColorBlended(const Rect & target, const ColorRGBA & color);
/// Compatibility method. AVOID USAGE. To be removed once SDL abstraction layer is finished.
SDL_Surface * getInternalSurface();
};

View File

@@ -799,11 +799,19 @@ void CSDL_Ext::fillSurface( SDL_Surface *dst, const SDL_Color & color )
fillRect(dst, allSurface, color);
}
void CSDL_Ext::fillRect( SDL_Surface *dst, const Rect & dstrect, const SDL_Color & color )
void CSDL_Ext::fillRect( SDL_Surface *dst, const Rect & dstrect, const SDL_Color & color)
{
SDL_Rect newRect = CSDL_Ext::toSDL(dstrect);
uint32_t sdlColor = SDL_MapRGBA(dst->format, color.r, color.g, color.b, color.a);
SDL_FillRect(dst, &newRect, sdlColor);
}
void CSDL_Ext::fillRectBlended( SDL_Surface *dst, const Rect & dstrect, const SDL_Color & color)
{
SDL_Rect newRect = CSDL_Ext::toSDL(dstrect);
uint32_t sdlColor = SDL_MapRGBA(dst->format, color.r, color.g, color.b, color.a);
SDL_Surface * tmp = SDL_CreateRGBSurface(0, newRect.w, newRect.h, dst->format->BitsPerPixel, dst->format->Rmask, dst->format->Gmask, dst->format->Bmask, dst->format->Amask);
SDL_FillRect(tmp, NULL, sdlColor);
SDL_BlitSurface(tmp, NULL, dst, &newRect);

View File

@@ -59,6 +59,7 @@ using TColorPutterAlpha = void (*)(uint8_t *&, const uint8_t &, const uint8_t &,
void fillSurface(SDL_Surface * dst, const SDL_Color & color);
void fillRect(SDL_Surface * dst, const Rect & dstrect, const SDL_Color & color);
void fillRectBlended(SDL_Surface * dst, const Rect & dstrect, const SDL_Color & color);
void updateRect(SDL_Surface * surface, const Rect & rect);