From 40c7ddcaf4973a368733945824cbf2bef83457fd Mon Sep 17 00:00:00 2001 From: Michael <13953785+Laserlicht@users.noreply.github.com> Date: Tue, 29 Aug 2023 22:22:22 +0200 Subject: [PATCH] dim adventuremap --- client/adventureMap/AdventureMapInterface.cpp | 13 +++++++++++++ client/adventureMap/AdventureMapInterface.h | 3 +++ client/render/Canvas.h | 2 +- client/renderSDL/SDL_Extensions.cpp | 5 ++++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/client/adventureMap/AdventureMapInterface.cpp b/client/adventureMap/AdventureMapInterface.cpp index 175bf25e4..8d816261c 100644 --- a/client/adventureMap/AdventureMapInterface.cpp +++ b/client/adventureMap/AdventureMapInterface.cpp @@ -24,6 +24,9 @@ #include "../mapView/mapHandler.h" #include "../mapView/MapView.h" #include "../windows/InfoWindows.h" +#include "../windows/CCastleInterface.h" +#include "../windows/CHeroWindow.h" +#include "../windows/CKingdomInterface.h" #include "../CGameInfo.h" #include "../gui/CursorHandler.h" #include "../gui/CGuiHandler.h" @@ -153,15 +156,25 @@ void AdventureMapInterface::deactivate() void AdventureMapInterface::showAll(Canvas & to) { CIntObject::showAll(to); + dim(to); LOCPLINT->cingconsole->show(to); } void AdventureMapInterface::show(Canvas & to) { CIntObject::show(to); + dim(to); LOCPLINT->cingconsole->show(to); } +void AdventureMapInterface::dim(Canvas & to) +{ + if(!GH.windows().findWindows().empty() || + !GH.windows().findWindows().empty() || + !GH.windows().findWindows().empty()) + to.drawColor(Rect(0, 0, GH.screenDimensions().x, GH.screenDimensions().y), ColorRGBA(0, 0, 0, 128)); +} + void AdventureMapInterface::tick(uint32_t msPassed) { handleMapScrollingUpdate(msPassed); diff --git a/client/adventureMap/AdventureMapInterface.h b/client/adventureMap/AdventureMapInterface.h index 55546b6a3..39fa43281 100644 --- a/client/adventureMap/AdventureMapInterface.h +++ b/client/adventureMap/AdventureMapInterface.h @@ -89,6 +89,9 @@ private: /// casts current spell at specified location void performSpellcasting(const int3 & castTarget); + /// dim interface if some windows opened + void dim(Canvas & to); + protected: /// CIntObject interface implementation diff --git a/client/render/Canvas.h b/client/render/Canvas.h index c624507d1..773be3cae 100644 --- a/client/render/Canvas.h +++ b/client/render/Canvas.h @@ -93,7 +93,7 @@ public: /// renders multiple lines of text with specified parameters void drawText(const Point & position, const EFonts & font, const ColorRGBA & colorDest, ETextAlignment alignment, const std::vector & text ); - /// fills selected area with solid color, ignoring any transparency + /// fills selected area with solid color void drawColor(const Rect & target, const ColorRGBA & color); /// Compatibility method. AVOID USAGE. To be removed once SDL abstraction layer is finished. diff --git a/client/renderSDL/SDL_Extensions.cpp b/client/renderSDL/SDL_Extensions.cpp index 6702153a3..7b5e8b4c0 100644 --- a/client/renderSDL/SDL_Extensions.cpp +++ b/client/renderSDL/SDL_Extensions.cpp @@ -804,7 +804,10 @@ void CSDL_Ext::fillRect( SDL_Surface *dst, const Rect & dstrect, const SDL_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); + 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); + SDL_FreeSurface(tmp); } STRONG_INLINE static uint32_t mapColor(SDL_Surface * surface, SDL_Color color)