diff --git a/client/gui/CAnimation.cpp b/client/gui/CAnimation.cpp index 6ecebe647..c76d96245 100644 --- a/client/gui/CAnimation.cpp +++ b/client/gui/CAnimation.cpp @@ -1306,7 +1306,7 @@ void CFadeAnimation::draw(SDL_Surface * targetSurface, const SDL_Rect * sourceRe return; } - SDL_SetSurfaceAlphaMod(fadingSurface, fadingCounter * 255); - SDL_BlitSurface(fadingSurface, sourceRect, targetSurface, destRect); - SDL_SetSurfaceAlphaMod(fadingSurface, 255); + CSDL_Ext::setAlpha(fadingSurface, fadingCounter * 255); + SDL_BlitSurface(fadingSurface, const_cast(sourceRect), targetSurface, destRect); //FIXME + CSDL_Ext::setAlpha(fadingSurface, 255); } diff --git a/client/gui/CAnimation.h b/client/gui/CAnimation.h index fff1690da..2cf67047d 100644 --- a/client/gui/CAnimation.h +++ b/client/gui/CAnimation.h @@ -221,6 +221,8 @@ public: size_t size(size_t group=0) const; }; +const float DEFAULT_DELTA = 0.05f; + class CFadeAnimation { public: @@ -229,7 +231,6 @@ public: NONE, IN, OUT }; private: - static constexpr float DEFAULT_DELTA = 0.05f; float delta; SDL_Surface * fadingSurface; bool fading; diff --git a/client/gui/SDL_Extensions.h b/client/gui/SDL_Extensions.h index 9681c0062..9dfcfe48b 100644 --- a/client/gui/SDL_Extensions.h +++ b/client/gui/SDL_Extensions.h @@ -86,23 +86,32 @@ namespace CSDL_Ext { STRONG_INLINE void colorSetAlpha(SDL_Color & color, Uint8 alpha) { - #ifdef VCMI_SDL1 +#ifdef VCMI_SDL1 color.unused = alpha; - #else +#else color.a = alpha; - #endif +#endif } //todo: should this better be assignment operator? STRONG_INLINE void colorAssign(SDL_Color & dest, const SDL_Color & source) { - dest.r = source.r; + dest.r = source.r; dest.g = source.g; - dest.b = source.b; - #ifdef VCMI_SDL1 + dest.b = source.b; +#ifdef VCMI_SDL1 dest.unused = source.unused; - #else +#else dest.a = source.a; - #endif +#endif + } + + inline void setAlpha(SDL_Surface * bg, int value) + { +#ifdef VCMI_SDL1 + SDL_SetAlpha(bg, SDL_SRCALPHA, value); +#else + SDL_SetSurfaceAlphaMod(bg, value); +#endif } } struct Rect; diff --git a/client/mapHandler.h b/client/mapHandler.h index 1c2962d80..19bb22efe 100644 --- a/client/mapHandler.h +++ b/client/mapHandler.h @@ -200,7 +200,7 @@ class CMapHandler class CMapBlitter { protected: - static constexpr int FRAMES_PER_MOVE_ANIM_GROUP = 8; + const int FRAMES_PER_MOVE_ANIM_GROUP = 8; CMapHandler * parent; // ptr to enclosing map handler; generally for legacy reasons, probably could/should be refactored out of here int tileSize; // size of a tile drawn on map [in pixels] int halfTileSizeCeil; // half of the tile size, rounded up diff --git a/client/widgets/Images.cpp b/client/widgets/Images.cpp index 7ba42a1f4..3b02f8ffe 100644 --- a/client/widgets/Images.cpp +++ b/client/widgets/Images.cpp @@ -151,11 +151,7 @@ void CPicture::convertToScreenBPP() void CPicture::setAlpha(int value) { - #ifdef VCMI_SDL1 - SDL_SetAlpha(bg, SDL_SRCALPHA, value); - #else - SDL_SetSurfaceAlphaMod(bg,value); - #endif // 0 + CSDL_Ext::setAlpha (bg, value); } void CPicture::scaleTo(Point size)