1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Merge pull request #2712 from Laserlicht/dim_map

Dim adventuremap
This commit is contained in:
Ivan Savenko 2023-09-01 22:37:10 +03:00 committed by GitHub
commit cab2bddf7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 4 deletions

View File

@ -153,15 +153,34 @@ 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)
{
for (auto window : GH.windows().findWindows<IShowActivatable>())
{
std::shared_ptr<AdventureMapInterface> casted = std::dynamic_pointer_cast<AdventureMapInterface>(window);
if (!casted && !window->isPopupWindow())
{
int backgroundDimLevel = settings["adventure"]["backgroundDimLevel"].Integer();
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);
return;
}
}
}
void AdventureMapInterface::tick(uint32_t msPassed)
{
handleMapScrollingUpdate(msPassed);

View File

@ -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

View File

@ -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<std::string> & 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.

View File

@ -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)

View File

@ -226,7 +226,7 @@
"type" : "object",
"additionalProperties" : false,
"default" : {},
"required" : [ "heroMoveTime", "enemyMoveTime", "scrollSpeedPixels", "heroReminder", "quickCombat", "objectAnimation", "terrainAnimation", "forceQuickCombat", "borderScroll", "leftButtonDrag", "smoothDragging" ],
"required" : [ "heroMoveTime", "enemyMoveTime", "scrollSpeedPixels", "heroReminder", "quickCombat", "objectAnimation", "terrainAnimation", "forceQuickCombat", "borderScroll", "leftButtonDrag", "smoothDragging", "backgroundDimLevel" ],
"properties" : {
"heroMoveTime" : {
"type" : "number",
@ -274,7 +274,11 @@
"smoothDragging" : {
"type" : "boolean",
"default" : true
}
},
"backgroundDimLevel" : {
"type" : "number",
"default" : 128
},
}
},
"battle" : {