diff --git a/client/adventureMap/CAdvMapInt.cpp b/client/adventureMap/CAdvMapInt.cpp index d56b3b326..994133bf1 100644 --- a/client/adventureMap/CAdvMapInt.cpp +++ b/client/adventureMap/CAdvMapInt.cpp @@ -1483,7 +1483,6 @@ void CAdvMapInt::changeMode(EAdvMapMode newMode, int tileSize) infoBar->activate(); worldViewOptions.clear(); - terrain->setTileSize(32); break; case EAdvMapMode::WORLD_VIEW: @@ -1496,12 +1495,17 @@ void CAdvMapInt::changeMode(EAdvMapMode newMode, int tileSize) heroList->deactivate(); infoBar->showSelection(); // to prevent new day animation interfering world view mode infoBar->deactivate(); - terrain->setTileSize(tileSize); + break; } redraw(); } + + if(mode == EAdvMapMode::NORMAL) + terrain->setTileSize(32); + if(mode == EAdvMapMode::WORLD_VIEW) + terrain->setTileSize(tileSize); } CAdvMapInt::WorldViewOptions::WorldViewOptions() diff --git a/client/adventureMap/MapView.cpp b/client/adventureMap/MapView.cpp index 8885e8b44..41d892e74 100644 --- a/client/adventureMap/MapView.cpp +++ b/client/adventureMap/MapView.cpp @@ -33,6 +33,7 @@ MapViewCache::~MapViewCache() = default; MapViewCache::MapViewCache(const std::shared_ptr & model) : model(model) , mapRenderer(new MapRenderer()) + , intermediate(new Canvas(Point(32,32))) , terrain(new Canvas(model->getCacheDimensionsPixels())) { } @@ -46,7 +47,15 @@ void MapViewCache::updateTile(const std::shared_ptr & contex { Canvas target = getTile(coordinates); - mapRenderer->renderTile(*context, target, coordinates); + if(model->getSingleTileSize() == Point(32, 32)) + { + mapRenderer->renderTile(*context, target, coordinates); + } + else + { + mapRenderer->renderTile(*context, *intermediate, coordinates); + target.drawScaled(*intermediate, Point(0, 0), model->getSingleTileSize()); + } } void MapViewCache::update(const std::shared_ptr & context) @@ -541,7 +550,7 @@ void MapViewController::update(uint32_t timeDelta) } context->animationTime += timeDelta; - context->tileSize = model->getSingleTileSize(); + context->tileSize = Point(32,32); //model->getSingleTileSize(); } void MapViewController::onObjectFadeIn(const CGObjectInstance * obj) diff --git a/client/adventureMap/MapView.h b/client/adventureMap/MapView.h index 37c3992b8..39ad45f1b 100644 --- a/client/adventureMap/MapView.h +++ b/client/adventureMap/MapView.h @@ -124,11 +124,13 @@ public: class MapViewCache { std::shared_ptr model; - std::shared_ptr mapTransition; //TODO std::unique_ptr terrain; + std::unique_ptr terrainTransition; + std::unique_ptr intermediate; std::unique_ptr mapRenderer; + Canvas getTile(const int3 & coordinates); void updateTile(const std::shared_ptr & context, const int3 & coordinates); diff --git a/client/adventureMap/mapHandler.cpp b/client/adventureMap/mapHandler.cpp index dd70778a1..8b4cd3460 100644 --- a/client/adventureMap/mapHandler.cpp +++ b/client/adventureMap/mapHandler.cpp @@ -11,32 +11,15 @@ #include "StdInc.h" #include "mapHandler.h" #include "MapRendererContext.h" -#include "MapView.h" -#include "../render/CAnimation.h" -#include "../render/Colors.h" -#include "../gui/CGuiHandler.h" -#include "../renderSDL/SDL_Extensions.h" #include "../CGameInfo.h" -#include "../render/Graphics.h" -#include "../render/IImage.h" -#include "../render/Canvas.h" -#include "../CMusicHandler.h" #include "../CPlayerInterface.h" -#include "../../CCallback.h" - #include "../../lib/UnlockGuard.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/CObjectClassesHandler.h" #include "../../lib/mapping/CMap.h" -#include "../../lib/Color.h" -#include "../../lib/CConfigHandler.h" #include "../../lib/CGeneralTextHandler.h" -#include "../../lib/CStopWatch.h" -#include "../../lib/CRandomGenerator.h" -#include "../../lib/RoadHandler.h" -#include "../../lib/RiverHandler.h" #include "../../lib/TerrainHandler.h" /* diff --git a/client/render/Canvas.cpp b/client/render/Canvas.cpp index cb36a7a95..a02d4dd0a 100644 --- a/client/render/Canvas.cpp +++ b/client/render/Canvas.cpp @@ -40,6 +40,7 @@ Canvas::Canvas(const Point & size): renderArea(Point(0,0), size), surface(CSDL_Ext::newSurface(size.x, size.y)) { + SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE); } Canvas::~Canvas() @@ -66,10 +67,17 @@ void Canvas::draw(const Canvas & image, const Point & pos) CSDL_Ext::blitSurface(image.surface, image.renderArea, surface, renderArea.topLeft() + pos); } +void Canvas::drawTransparent(const Canvas & image, const Point & pos, double transparency) +{ + SDL_SetSurfaceAlphaMod(image.surface, 255 * transparency); + CSDL_Ext::blitSurface(image.surface, image.renderArea, surface, renderArea.topLeft() + pos); + SDL_SetSurfaceAlphaMod(image.surface, 255); +} + void Canvas::drawScaled(const Canvas & image, const Point & pos, const Point & targetSize) { - SDL_Rect targetRect = CSDL_Ext::toSDL(Rect(pos, targetSize)); - SDL_BlitScaled(image.surface, nullptr, surface, &targetRect ); + SDL_Rect targetRect = CSDL_Ext::toSDL(Rect(pos + renderArea.topLeft(), targetSize)); + SDL_BlitScaled(image.surface, nullptr, surface, &targetRect); } void Canvas::drawPoint(const Point & dest, const ColorRGBA & color) diff --git a/client/render/Canvas.h b/client/render/Canvas.h index 81878f964..e40c5f2f1 100644 --- a/client/render/Canvas.h +++ b/client/render/Canvas.h @@ -27,8 +27,8 @@ class Canvas /// Current rendering area, all rendering operations will be moved into selected area Rect renderArea; - Canvas & operator = (const Canvas & other) = delete; public: + Canvas & operator = (const Canvas & other) = delete; /// constructs canvas using existing surface. Caller maintains ownership on the surface explicit Canvas(SDL_Surface * surface); @@ -53,6 +53,9 @@ public: /// renders another canvas onto this canvas void draw(const Canvas &image, const Point & pos); + /// renders another canvas onto this canvas with transparency + void drawTransparent(const Canvas & image, const Point & pos, double transparency); + /// renders another canvas onto this canvas with scaling void drawScaled(const Canvas &image, const Point & pos, const Point & targetSize);