mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Basic version of scaling for view world
This commit is contained in:
parent
16e7f860ff
commit
40413ee6be
@ -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()
|
||||
|
@ -33,6 +33,7 @@ MapViewCache::~MapViewCache() = default;
|
||||
MapViewCache::MapViewCache(const std::shared_ptr<MapViewModel> & 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<MapRendererContext> & 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<MapRendererContext> & 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)
|
||||
|
@ -124,11 +124,13 @@ public:
|
||||
class MapViewCache
|
||||
{
|
||||
std::shared_ptr<MapViewModel> model;
|
||||
std::shared_ptr<IImage> mapTransition; //TODO
|
||||
|
||||
std::unique_ptr<Canvas> terrain;
|
||||
std::unique_ptr<Canvas> terrainTransition;
|
||||
std::unique_ptr<Canvas> intermediate;
|
||||
std::unique_ptr<MapRenderer> mapRenderer;
|
||||
|
||||
|
||||
Canvas getTile(const int3 & coordinates);
|
||||
void updateTile(const std::shared_ptr<MapRendererContext> & context, const int3 & coordinates);
|
||||
|
||||
|
@ -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"
|
||||
|
||||
/*
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user