mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
@ -154,7 +154,7 @@ void init()
|
|||||||
logGlobal->infoStream()<<"Screen handler: "<<pomtime.getDiff();
|
logGlobal->infoStream()<<"Screen handler: "<<pomtime.getDiff();
|
||||||
pomtime.getDiff();
|
pomtime.getDiff();
|
||||||
|
|
||||||
graphics->loadHeroAnims();
|
graphics->load();
|
||||||
logGlobal->infoStream()<<"\tMain graphics: "<<pomtime.getDiff();
|
logGlobal->infoStream()<<"\tMain graphics: "<<pomtime.getDiff();
|
||||||
logGlobal->infoStream()<<"Initializing game graphics: "<<tmh.getDiff();
|
logGlobal->infoStream()<<"Initializing game graphics: "<<tmh.getDiff();
|
||||||
|
|
||||||
@ -934,6 +934,8 @@ void dispose()
|
|||||||
}
|
}
|
||||||
CMessage::dispose();
|
CMessage::dispose();
|
||||||
|
|
||||||
|
vstd::clear_pointer(graphics);
|
||||||
|
|
||||||
if(console)
|
if(console)
|
||||||
{
|
{
|
||||||
delete console; // should be removed after everything else since used by logging
|
delete console; // should be removed after everything else since used by logging
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "../lib/filesystem/CBinaryReader.h"
|
#include "../lib/filesystem/CBinaryReader.h"
|
||||||
#include "CDefHandler.h"
|
#include "CDefHandler.h"
|
||||||
#include "gui/SDL_Extensions.h"
|
#include "gui/SDL_Extensions.h"
|
||||||
|
#include "gui/CAnimation.h"
|
||||||
#include <SDL_ttf.h>
|
#include <SDL_ttf.h>
|
||||||
#include "../lib/CThreadHelper.h"
|
#include "../lib/CThreadHelper.h"
|
||||||
#include "CGameInfo.h"
|
#include "CGameInfo.h"
|
||||||
@ -144,8 +145,6 @@ Graphics::Graphics()
|
|||||||
tasks += std::bind(&Graphics::initializeBattleGraphics,this);
|
tasks += std::bind(&Graphics::initializeBattleGraphics,this);
|
||||||
tasks += std::bind(&Graphics::loadErmuToPicture,this);
|
tasks += std::bind(&Graphics::loadErmuToPicture,this);
|
||||||
tasks += std::bind(&Graphics::initializeImageLists,this);
|
tasks += std::bind(&Graphics::initializeImageLists,this);
|
||||||
tasks += GET_DEF_ESS(resources32,"RESOURCE.DEF");
|
|
||||||
tasks += GET_DEF_ESS(heroMoveArrows,"ADAG.DEF");
|
|
||||||
|
|
||||||
CThreadHelper th(&tasks,std::max((ui32)1,boost::thread::hardware_concurrency()));
|
CThreadHelper th(&tasks,std::max((ui32)1,boost::thread::hardware_concurrency()));
|
||||||
th.run();
|
th.run();
|
||||||
@ -156,14 +155,17 @@ Graphics::Graphics()
|
|||||||
initializeBattleGraphics();
|
initializeBattleGraphics();
|
||||||
loadErmuToPicture();
|
loadErmuToPicture();
|
||||||
initializeImageLists();
|
initializeImageLists();
|
||||||
resources32 = CDefHandler::giveDefEss("RESOURCE.DEF");
|
|
||||||
heroMoveArrows = CDefHandler::giveDefEss("ADAG.DEF");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(auto & elem : heroMoveArrows->ourImages)
|
//(!) do not load any CAnimation here
|
||||||
{
|
}
|
||||||
CSDL_Ext::alphaTransform(elem.bitmap);
|
|
||||||
}
|
void Graphics::load()
|
||||||
|
{
|
||||||
|
heroMoveArrows = std::make_shared<CAnimation>("ADAG");
|
||||||
|
heroMoveArrows->preload();
|
||||||
|
|
||||||
|
loadHeroAnims();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::loadHeroAnims()
|
void Graphics::loadHeroAnims()
|
||||||
|
@ -38,20 +38,30 @@ class Graphics
|
|||||||
{
|
{
|
||||||
void addImageListEntry(size_t index, std::string listName, std::string imageName);
|
void addImageListEntry(size_t index, std::string listName, std::string imageName);
|
||||||
|
|
||||||
|
void initializeBattleGraphics();
|
||||||
|
void loadPaletteAndColors();
|
||||||
|
void loadHeroFlags();
|
||||||
|
void loadHeroFlagsDetail(std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > &pr, bool mode);
|
||||||
|
void loadHeroAnims();
|
||||||
|
CDefEssential * loadHeroAnim(const std::string &name, const std::vector<std::pair<int,int> > &rotations);
|
||||||
|
void loadErmuToPicture();
|
||||||
|
|
||||||
|
void loadFonts();
|
||||||
|
void initializeImageLists();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//Fonts
|
//Fonts
|
||||||
static const int FONTS_NUMBER = 9;
|
static const int FONTS_NUMBER = 9;
|
||||||
IFont * fonts[FONTS_NUMBER];
|
IFont * fonts[FONTS_NUMBER];
|
||||||
|
|
||||||
//various graphics
|
//various graphics
|
||||||
SDL_Color * playerColors; //array [8]
|
SDL_Color * playerColors; //array [8]
|
||||||
SDL_Color * neutralColor;
|
SDL_Color * neutralColor;
|
||||||
SDL_Color * playerColorPalette; //palette to make interface colors good - array of size [256]
|
SDL_Color * playerColorPalette; //palette to make interface colors good - array of size [256]
|
||||||
SDL_Color * neutralColorPalette;
|
SDL_Color * neutralColorPalette;
|
||||||
|
|
||||||
std::vector<CDefEssential *> flags1, flags2, flags3, flags4; //flags blitted on heroes when ,
|
std::vector<CDefEssential *> flags1, flags2, flags3, flags4; //flags blitted on heroes when ,
|
||||||
CDefEssential * resources32; //resources 32x32
|
std::shared_ptr<CAnimation> heroMoveArrows;
|
||||||
CDefEssential * heroMoveArrows;
|
|
||||||
std::map<std::string, CDefEssential *> heroAnims; // [hero class def name] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing
|
std::map<std::string, CDefEssential *> heroAnims; // [hero class def name] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing
|
||||||
std::vector<CDefEssential *> boatAnims; // [boat type: 0 - 3] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing
|
std::vector<CDefEssential *> boatAnims; // [boat type: 0 - 3] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing
|
||||||
CDefHandler * FoWfullHide; //for Fog of War
|
CDefHandler * FoWfullHide; //for Fog of War
|
||||||
@ -68,18 +78,11 @@ public:
|
|||||||
std::vector< std::vector< std::string > > battleBacks; //battleBacks[terType] - vector of possible names for certain terrain type
|
std::vector< std::vector< std::string > > battleBacks; //battleBacks[terType] - vector of possible names for certain terrain type
|
||||||
std::map< int, std::vector < std::string > > battleACToDef; //maps AC format to vector of appropriate def names
|
std::map< int, std::vector < std::string > > battleACToDef; //maps AC format to vector of appropriate def names
|
||||||
//functions
|
//functions
|
||||||
Graphics();
|
Graphics();
|
||||||
void initializeBattleGraphics();
|
|
||||||
void loadPaletteAndColors();
|
|
||||||
void loadHeroFlags();
|
|
||||||
void loadHeroFlagsDetail(std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > &pr, bool mode);
|
|
||||||
void loadHeroAnims();
|
|
||||||
CDefEssential * loadHeroAnim(const std::string &name, const std::vector<std::pair<int,int> > &rotations);
|
|
||||||
void loadErmuToPicture();
|
|
||||||
void blueToPlayersAdv(SDL_Surface * sur, PlayerColor player); //replaces blue interface colour with a color of player
|
|
||||||
|
|
||||||
void loadFonts();
|
void load();
|
||||||
void initializeImageLists();
|
|
||||||
|
void blueToPlayersAdv(SDL_Surface * sur, PlayerColor player); //replaces blue interface colour with a color of player
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Graphics * graphics;
|
extern Graphics * graphics;
|
||||||
|
@ -127,8 +127,8 @@ CDefFile::CDefFile(std::string Name):
|
|||||||
static SDL_Color H3Palette[8] =
|
static SDL_Color H3Palette[8] =
|
||||||
{
|
{
|
||||||
{ 0, 0, 0, 0},// 100% - transparency
|
{ 0, 0, 0, 0},// 100% - transparency
|
||||||
{ 0, 0, 0, 64},// 75% - shadow border,
|
{ 0, 0, 0, 32},// 75% - shadow border,
|
||||||
{ 0, 0, 0, 128},// TODO: find exact value
|
{ 0, 0, 0, 64},// TODO: find exact value
|
||||||
{ 0, 0, 0, 128},// TODO: for transparency
|
{ 0, 0, 0, 128},// TODO: for transparency
|
||||||
{ 0, 0, 0, 128},// 50% - shadow body
|
{ 0, 0, 0, 128},// 50% - shadow body
|
||||||
{ 0, 0, 0, 0},// 100% - selection highlight
|
{ 0, 0, 0, 0},// 100% - selection highlight
|
||||||
@ -269,7 +269,7 @@ void CDefFile::loadFrame(size_t frame, size_t group, ImageLoader &loader) const
|
|||||||
|
|
||||||
if (code==7)//Raw data
|
if (code==7)//Raw data
|
||||||
{
|
{
|
||||||
loader.Load(length, FDef[currentOffset]);
|
loader.Load(length, FDef + currentOffset);
|
||||||
currentOffset += length;
|
currentOffset += length;
|
||||||
}
|
}
|
||||||
else//RLE
|
else//RLE
|
||||||
@ -631,10 +631,11 @@ SDLImage::SDLImage(std::string filename, bool compressed):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 rotation) const
|
void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 alpha) const
|
||||||
{
|
{
|
||||||
if (!surf)
|
if (!surf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Rect sourceRect(margins.x, margins.y, surf->w, surf->h);
|
Rect sourceRect(margins.x, margins.y, surf->w, surf->h);
|
||||||
//TODO: rotation and scaling
|
//TODO: rotation and scaling
|
||||||
if (src)
|
if (src)
|
||||||
@ -644,7 +645,21 @@ void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 rotat
|
|||||||
Rect destRect(posX, posY, surf->w, surf->h);
|
Rect destRect(posX, posY, surf->w, surf->h);
|
||||||
destRect += sourceRect.topLeft();
|
destRect += sourceRect.topLeft();
|
||||||
sourceRect -= margins;
|
sourceRect -= margins;
|
||||||
CSDL_Ext::blitSurface(surf, &sourceRect, where, &destRect);
|
|
||||||
|
if(surf->format->BitsPerPixel == 8)
|
||||||
|
{
|
||||||
|
CSDL_Ext::blit8bppAlphaTo24bpp(surf, &sourceRect, where, &destRect);
|
||||||
|
}
|
||||||
|
else if(surf->format->Amask == 0)
|
||||||
|
{
|
||||||
|
SDL_BlitSurface(surf, &sourceRect, where, &destRect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_SetSurfaceBlendMode(surf, SDL_BLENDMODE_BLEND);
|
||||||
|
SDL_BlitSurface(surf, &sourceRect, where, &destRect);
|
||||||
|
SDL_SetSurfaceBlendMode(surf, SDL_BLENDMODE_NONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLImage::playerColored(PlayerColor player)
|
void SDLImage::playerColored(PlayerColor player)
|
||||||
@ -1056,7 +1071,8 @@ void CAnimation::printError(size_t frame, size_t group, std::string type) const
|
|||||||
|
|
||||||
CAnimation::CAnimation(std::string Name, bool Compressed):
|
CAnimation::CAnimation(std::string Name, bool Compressed):
|
||||||
name(Name),
|
name(Name),
|
||||||
compressed(Compressed)
|
compressed(Compressed),
|
||||||
|
preloaded(false)
|
||||||
{
|
{
|
||||||
size_t dotPos = name.find_last_of('.');
|
size_t dotPos = name.find_last_of('.');
|
||||||
if ( dotPos!=-1 )
|
if ( dotPos!=-1 )
|
||||||
@ -1069,14 +1085,18 @@ CAnimation::CAnimation(std::string Name, bool Compressed):
|
|||||||
|
|
||||||
CAnimation::CAnimation():
|
CAnimation::CAnimation():
|
||||||
name(""),
|
name(""),
|
||||||
compressed(false)
|
compressed(false),
|
||||||
|
preloaded(false)
|
||||||
{
|
{
|
||||||
init(nullptr);
|
init(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnimation::~CAnimation()
|
CAnimation::~CAnimation()
|
||||||
{
|
{
|
||||||
if (!images.empty())
|
if(preloaded)
|
||||||
|
unload();
|
||||||
|
|
||||||
|
if(!images.empty())
|
||||||
{
|
{
|
||||||
logGlobal->warnStream()<<"Warning: not all frames were unloaded from "<<name;
|
logGlobal->warnStream()<<"Warning: not all frames were unloaded from "<<name;
|
||||||
for (auto & elem : images)
|
for (auto & elem : images)
|
||||||
@ -1126,6 +1146,12 @@ void CAnimation::unload()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAnimation::preload()
|
||||||
|
{
|
||||||
|
preloaded = true;
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
void CAnimation::loadGroup(size_t group)
|
void CAnimation::loadGroup(size_t group)
|
||||||
{
|
{
|
||||||
CDefFile * file = getFile();
|
CDefFile * file = getFile();
|
||||||
|
@ -99,6 +99,7 @@ public:
|
|||||||
~SDLImage();
|
~SDLImage();
|
||||||
|
|
||||||
void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=nullptr, ui8 alpha=255) const override;
|
void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=nullptr, ui8 alpha=255) const override;
|
||||||
|
|
||||||
void playerColored(PlayerColor player) override;
|
void playerColored(PlayerColor player) override;
|
||||||
int width() const override;
|
int width() const override;
|
||||||
int height() const override;
|
int height() const override;
|
||||||
@ -169,6 +170,8 @@ private:
|
|||||||
//if true all frames will be stored in compressed (RLE) state
|
//if true all frames will be stored in compressed (RLE) state
|
||||||
const bool compressed;
|
const bool compressed;
|
||||||
|
|
||||||
|
bool preloaded;
|
||||||
|
|
||||||
//loader, will be called by load(), require opened def file for loading from it. Returns true if image is loaded
|
//loader, will be called by load(), require opened def file for loading from it. Returns true if image is loaded
|
||||||
bool loadFrame(CDefFile * file, size_t frame, size_t group);
|
bool loadFrame(CDefFile * file, size_t frame, size_t group);
|
||||||
|
|
||||||
@ -204,6 +207,7 @@ public:
|
|||||||
//all available frames
|
//all available frames
|
||||||
void load ();
|
void load ();
|
||||||
void unload();
|
void unload();
|
||||||
|
void preload();
|
||||||
|
|
||||||
//all frames from group
|
//all frames from group
|
||||||
void loadGroup (size_t group);
|
void loadGroup (size_t group);
|
||||||
|
@ -528,7 +528,7 @@ CMapHandler::CMapNormalBlitter::CMapNormalBlitter(CMapHandler * parent)
|
|||||||
defaultTileRect = Rect(0, 0, tileSize, tileSize);
|
defaultTileRect = Rect(0, 0, tileSize, tileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface * CMapHandler::CMapWorldViewBlitter::objectToIcon(Obj id, si32 subId, PlayerColor owner) const
|
IImage * CMapHandler::CMapWorldViewBlitter::objectToIcon(Obj id, si32 subId, PlayerColor owner) const
|
||||||
{
|
{
|
||||||
int ownerIndex = 0;
|
int ownerIndex = 0;
|
||||||
if(owner < PlayerColor::PLAYER_LIMIT)
|
if(owner < PlayerColor::PLAYER_LIMIT)
|
||||||
@ -545,19 +545,19 @@ SDL_Surface * CMapHandler::CMapWorldViewBlitter::objectToIcon(Obj id, si32 subId
|
|||||||
case Obj::MONOLITH_ONE_WAY_ENTRANCE:
|
case Obj::MONOLITH_ONE_WAY_ENTRANCE:
|
||||||
case Obj::MONOLITH_ONE_WAY_EXIT:
|
case Obj::MONOLITH_ONE_WAY_EXIT:
|
||||||
case Obj::MONOLITH_TWO_WAY:
|
case Obj::MONOLITH_TWO_WAY:
|
||||||
return info->iconsDef->ourImages[(int)EWorldViewIcon::TELEPORT].bitmap;
|
return info->icons->getImage((int)EWorldViewIcon::TELEPORT);
|
||||||
case Obj::SUBTERRANEAN_GATE:
|
case Obj::SUBTERRANEAN_GATE:
|
||||||
return info->iconsDef->ourImages[(int)EWorldViewIcon::GATE].bitmap;
|
return info->icons->getImage((int)EWorldViewIcon::GATE);
|
||||||
case Obj::ARTIFACT:
|
case Obj::ARTIFACT:
|
||||||
return info->iconsDef->ourImages[(int)EWorldViewIcon::ARTIFACT].bitmap;
|
return info->icons->getImage((int)EWorldViewIcon::ARTIFACT);
|
||||||
case Obj::TOWN:
|
case Obj::TOWN:
|
||||||
return info->iconsDef->ourImages[(int)EWorldViewIcon::TOWN + ownerIndex].bitmap;
|
return info->icons->getImage((int)EWorldViewIcon::TOWN + ownerIndex);
|
||||||
case Obj::HERO:
|
case Obj::HERO:
|
||||||
return info->iconsDef->ourImages[(int)EWorldViewIcon::HERO + ownerIndex].bitmap;
|
return info->icons->getImage((int)EWorldViewIcon::HERO + ownerIndex);
|
||||||
case Obj::MINE:
|
case Obj::MINE:
|
||||||
return info->iconsDef->ourImages[(int)EWorldViewIcon::MINE_WOOD + subId + ownerIndex].bitmap;
|
return info->icons->getImage((int)EWorldViewIcon::MINE_WOOD + subId + ownerIndex);
|
||||||
case Obj::RESOURCE:
|
case Obj::RESOURCE:
|
||||||
return info->iconsDef->ourImages[(int)EWorldViewIcon::RES_WOOD + subId + ownerIndex].bitmap;
|
return info->icons->getImage((int)EWorldViewIcon::RES_WOOD + subId + ownerIndex);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -645,13 +645,13 @@ void CMapHandler::CMapWorldViewBlitter::drawTileOverlay(SDL_Surface * targetSurf
|
|||||||
{
|
{
|
||||||
auto drawIcon = [this,targetSurf](Obj id, si32 subId, PlayerColor owner)
|
auto drawIcon = [this,targetSurf](Obj id, si32 subId, PlayerColor owner)
|
||||||
{
|
{
|
||||||
SDL_Surface * wvIcon = this->objectToIcon(id, subId, owner);
|
IImage * wvIcon = this->objectToIcon(id, subId, owner);
|
||||||
|
|
||||||
if (nullptr != wvIcon)
|
if(nullptr != wvIcon)
|
||||||
{
|
{
|
||||||
// centering icon on the object
|
// centering icon on the object
|
||||||
Rect destRect(realPos.x + tileSize / 2 - wvIcon->w / 2, realPos.y + tileSize / 2 - wvIcon->h / 2, wvIcon->w, wvIcon->h);
|
Point dest(realPos.x + tileSize / 2 - wvIcon->width() / 2, realPos.y + tileSize / 2 - wvIcon->height() / 2);
|
||||||
CSDL_Ext::blitSurface(wvIcon, nullptr, targetSurf, &destRect);
|
wvIcon->draw(targetSurf, dest.x, dest.y);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -690,13 +690,13 @@ void CMapHandler::CMapWorldViewBlitter::drawOverlayEx(SDL_Surface * targetSurf)
|
|||||||
realPos.x = initPos.x + (iconInfo.pos.x - topTile.x) * tileSize;
|
realPos.x = initPos.x + (iconInfo.pos.x - topTile.x) * tileSize;
|
||||||
realPos.y = initPos.x + (iconInfo.pos.y - topTile.y) * tileSize;
|
realPos.y = initPos.x + (iconInfo.pos.y - topTile.y) * tileSize;
|
||||||
|
|
||||||
SDL_Surface * wvIcon = this->objectToIcon(iconInfo.id, iconInfo.subId, iconInfo.owner);
|
IImage * wvIcon = this->objectToIcon(iconInfo.id, iconInfo.subId, iconInfo.owner);
|
||||||
|
|
||||||
if (nullptr != wvIcon)
|
if(nullptr != wvIcon)
|
||||||
{
|
{
|
||||||
// centering icon on the object
|
// centering icon on the object
|
||||||
Rect destRect(realPos.x + tileSize / 2 - wvIcon->w / 2, realPos.y + tileSize / 2 - wvIcon->h / 2, wvIcon->w, wvIcon->h);
|
Point dest(realPos.x + tileSize / 2 - wvIcon->width() / 2, realPos.y + tileSize / 2 - wvIcon->height() / 2);
|
||||||
CSDL_Ext::blitSurface(wvIcon, nullptr, targetSurf, &destRect);
|
wvIcon->draw(targetSurf, dest.x, dest.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -778,8 +778,8 @@ void CMapHandler::CMapPuzzleViewBlitter::drawObjects(SDL_Surface * targetSurf, c
|
|||||||
// grail X mark
|
// grail X mark
|
||||||
if(pos.x == info->grailPos.x && pos.y == info->grailPos.y)
|
if(pos.x == info->grailPos.x && pos.y == info->grailPos.y)
|
||||||
{
|
{
|
||||||
Rect destRect(realTileRect);
|
const IImage * mark = graphics->heroMoveArrows->getImage(0);
|
||||||
CSDL_Ext::blit8bppAlphaTo24bpp(graphics->heroMoveArrows->ourImages[0].bitmap, nullptr, targetSurf, &destRect);
|
mark->draw(targetSurf,realTileRect.x,realTileRect.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ struct TerrainTile;
|
|||||||
struct SDL_Surface;
|
struct SDL_Surface;
|
||||||
struct SDL_Rect;
|
struct SDL_Rect;
|
||||||
class CDefEssential;
|
class CDefEssential;
|
||||||
|
class CAnimation;
|
||||||
|
class IImage;
|
||||||
class CFadeAnimation;
|
class CFadeAnimation;
|
||||||
class PlayerColor;
|
class PlayerColor;
|
||||||
|
|
||||||
@ -71,7 +73,7 @@ struct TerrainTileObject
|
|||||||
const CGObjectInstance *obj;
|
const CGObjectInstance *obj;
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
int fadeAnimKey;
|
int fadeAnimKey;
|
||||||
|
|
||||||
TerrainTileObject(const CGObjectInstance *obj_, SDL_Rect rect_);
|
TerrainTileObject(const CGObjectInstance *obj_, SDL_Rect rect_);
|
||||||
~TerrainTileObject();
|
~TerrainTileObject();
|
||||||
};
|
};
|
||||||
@ -90,7 +92,7 @@ struct MapDrawingInfo
|
|||||||
int3 &topTile; // top-left tile in viewport [in tiles]
|
int3 &topTile; // top-left tile in viewport [in tiles]
|
||||||
const std::vector< std::vector< std::vector<ui8> > > * visibilityMap;
|
const std::vector< std::vector< std::vector<ui8> > > * visibilityMap;
|
||||||
SDL_Rect * drawBounds; // map rect drawing bounds on screen
|
SDL_Rect * drawBounds; // map rect drawing bounds on screen
|
||||||
CDefHandler * iconsDef; // holds overlay icons for world view mode
|
std::shared_ptr<CAnimation> icons; // holds overlay icons for world view mode
|
||||||
float scale; // map scale for world view mode (only if scaled == true)
|
float scale; // map scale for world view mode (only if scaled == true)
|
||||||
|
|
||||||
bool otherheroAnim;
|
bool otherheroAnim;
|
||||||
@ -101,17 +103,17 @@ struct MapDrawingInfo
|
|||||||
|
|
||||||
bool puzzleMode;
|
bool puzzleMode;
|
||||||
int3 grailPos; // location of grail for puzzle mode [in tiles]
|
int3 grailPos; // location of grail for puzzle mode [in tiles]
|
||||||
|
|
||||||
const std::vector<ObjectPosInfo> * additionalIcons;
|
const std::vector<ObjectPosInfo> * additionalIcons;
|
||||||
|
|
||||||
bool showAllTerrain; //for expert viewEarth
|
bool showAllTerrain; //for expert viewEarth
|
||||||
|
|
||||||
MapDrawingInfo(int3 &topTile_, const std::vector< std::vector< std::vector<ui8> > > * visibilityMap_, SDL_Rect * drawBounds_, CDefHandler * iconsDef_ = nullptr)
|
MapDrawingInfo(int3 &topTile_, const std::vector< std::vector< std::vector<ui8> > > * visibilityMap_, SDL_Rect * drawBounds_, std::shared_ptr<CAnimation> icons_ = nullptr)
|
||||||
: scaled(false),
|
: scaled(false),
|
||||||
topTile(topTile_),
|
topTile(topTile_),
|
||||||
visibilityMap(visibilityMap_),
|
visibilityMap(visibilityMap_),
|
||||||
drawBounds(drawBounds_),
|
drawBounds(drawBounds_),
|
||||||
iconsDef(iconsDef_),
|
icons(icons_),
|
||||||
scale(1.0f),
|
scale(1.0f),
|
||||||
otherheroAnim(false),
|
otherheroAnim(false),
|
||||||
anim(0u),
|
anim(0u),
|
||||||
@ -188,14 +190,14 @@ class CMapHandler
|
|||||||
SDL_Surface * cacheWorldViewEntry(EMapCacheType type, intptr_t key, SDL_Surface * entry);
|
SDL_Surface * cacheWorldViewEntry(EMapCacheType type, intptr_t key, SDL_Surface * entry);
|
||||||
intptr_t genKey(intptr_t realPtr, ui8 mod);
|
intptr_t genKey(intptr_t realPtr, ui8 mod);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// helper struct to pass around resolved bitmaps of an object; surfaces can be nullptr if object doesn't have bitmap of that type
|
/// helper struct to pass around resolved bitmaps of an object; surfaces can be nullptr if object doesn't have bitmap of that type
|
||||||
struct AnimBitmapHolder
|
struct AnimBitmapHolder
|
||||||
{
|
{
|
||||||
SDL_Surface * objBitmap; // main object bitmap
|
SDL_Surface * objBitmap; // main object bitmap
|
||||||
SDL_Surface * flagBitmap; // flag bitmap for the object (probably only for heroes and boats with heroes)
|
SDL_Surface * flagBitmap; // flag bitmap for the object (probably only for heroes and boats with heroes)
|
||||||
bool isMoving; // indicates if the object is moving (again, heroes/boats only)
|
bool isMoving; // indicates if the object is moving (again, heroes/boats only)
|
||||||
|
|
||||||
AnimBitmapHolder(SDL_Surface * objBitmap_ = nullptr, SDL_Surface * flagBitmap_ = nullptr, bool moving = false)
|
AnimBitmapHolder(SDL_Surface * objBitmap_ = nullptr, SDL_Surface * flagBitmap_ = nullptr, bool moving = false)
|
||||||
: objBitmap(objBitmap_),
|
: objBitmap(objBitmap_),
|
||||||
flagBitmap(flagBitmap_),
|
flagBitmap(flagBitmap_),
|
||||||
@ -205,7 +207,7 @@ class CMapHandler
|
|||||||
|
|
||||||
|
|
||||||
class CMapBlitter
|
class CMapBlitter
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
const 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
|
CMapHandler * parent; // ptr to enclosing map handler; generally for legacy reasons, probably could/should be refactored out of here
|
||||||
@ -267,16 +269,16 @@ class CMapHandler
|
|||||||
|
|
||||||
virtual bool canDrawObject(const CGObjectInstance * obj) const;
|
virtual bool canDrawObject(const CGObjectInstance * obj) const;
|
||||||
virtual bool canDrawCurrentTile() const;
|
virtual bool canDrawCurrentTile() const;
|
||||||
|
|
||||||
// internal helper methods to choose correct bitmap(s) for object; called internally by findObjectBitmap
|
// internal helper methods to choose correct bitmap(s) for object; called internally by findObjectBitmap
|
||||||
AnimBitmapHolder findHeroBitmap(const CGHeroInstance * hero, int anim) const;
|
AnimBitmapHolder findHeroBitmap(const CGHeroInstance * hero, int anim) const;
|
||||||
AnimBitmapHolder findBoatBitmap(const CGBoat * hero, int anim) const;
|
AnimBitmapHolder findBoatBitmap(const CGBoat * hero, int anim) const;
|
||||||
SDL_Surface * findFlagBitmap(const CGHeroInstance * obj, int anim, const PlayerColor * color, int indexOffset) const;
|
SDL_Surface * findFlagBitmap(const CGHeroInstance * obj, int anim, const PlayerColor * color, int indexOffset) const;
|
||||||
SDL_Surface * findHeroFlagBitmap(const CGHeroInstance * obj, int anim, const PlayerColor * color, int indexOffset) const;
|
SDL_Surface * findHeroFlagBitmap(const CGHeroInstance * obj, int anim, const PlayerColor * color, int indexOffset) const;
|
||||||
SDL_Surface * findBoatFlagBitmap(const CGBoat * obj, int anim, const PlayerColor * color, int indexOffset, ui8 dir) const;
|
SDL_Surface * findBoatFlagBitmap(const CGBoat * obj, int anim, const PlayerColor * color, int indexOffset, ui8 dir) const;
|
||||||
SDL_Surface * findFlagBitmapInternal(const CDefEssential * def, int anim, int indexOffset, ui8 dir, bool moving) const;
|
SDL_Surface * findFlagBitmapInternal(const CDefEssential * def, int anim, int indexOffset, ui8 dir, bool moving) const;
|
||||||
int findAnimIndexByGroup(const CDefEssential * def, int groupNum) const;
|
int findAnimIndexByGroup(const CDefEssential * def, int groupNum) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMapBlitter(CMapHandler * p) : parent(p) {}
|
CMapBlitter(CMapHandler * p) : parent(p) {}
|
||||||
virtual ~CMapBlitter(){}
|
virtual ~CMapBlitter(){}
|
||||||
@ -303,7 +305,7 @@ class CMapHandler
|
|||||||
class CMapWorldViewBlitter : public CMapBlitter
|
class CMapWorldViewBlitter : public CMapBlitter
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SDL_Surface * objectToIcon(Obj id, si32 subId, PlayerColor owner) const;
|
IImage * objectToIcon(Obj id, si32 subId, PlayerColor owner) const;
|
||||||
protected:
|
protected:
|
||||||
void drawElement(EMapCacheType cacheType, SDL_Surface * sourceSurf, SDL_Rect * sourceRect,
|
void drawElement(EMapCacheType cacheType, SDL_Surface * sourceSurf, SDL_Rect * sourceRect,
|
||||||
SDL_Surface * targetSurf, SDL_Rect * destRect, bool alphaBlit = false, ui8 rotationInfo = 0u) const override;
|
SDL_Surface * targetSurf, SDL_Rect * destRect, bool alphaBlit = false, ui8 rotationInfo = 0u) const override;
|
||||||
@ -344,7 +346,7 @@ class CMapHandler
|
|||||||
CMapBlitter * normalBlitter;
|
CMapBlitter * normalBlitter;
|
||||||
CMapBlitter * worldViewBlitter;
|
CMapBlitter * worldViewBlitter;
|
||||||
CMapBlitter * puzzleViewBlitter;
|
CMapBlitter * puzzleViewBlitter;
|
||||||
|
|
||||||
std::map<int, std::pair<int3, CFadeAnimation*>> fadeAnims;
|
std::map<int, std::pair<int3, CFadeAnimation*>> fadeAnims;
|
||||||
int fadeAnimCounter;
|
int fadeAnimCounter;
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include "../gui/CGuiHandler.h"
|
#include "../gui/CGuiHandler.h"
|
||||||
#include "../gui/SDL_Pixels.h"
|
#include "../gui/SDL_Pixels.h"
|
||||||
|
|
||||||
|
#include "../widgets/Images.h"
|
||||||
|
|
||||||
#include "../windows/InfoWindows.h"
|
#include "../windows/InfoWindows.h"
|
||||||
#include "../windows/CAdvmapInterface.h"
|
#include "../windows/CAdvmapInterface.h"
|
||||||
#include "../windows/GUIClasses.h"
|
#include "../windows/GUIClasses.h"
|
||||||
@ -1256,11 +1258,11 @@ void CAdvMapPanel::addChildToPanel(CIntObject * obj, ui8 actions /* = 0 */)
|
|||||||
addChild(obj, false);
|
addChild(obj, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAdvMapWorldViewPanel::CAdvMapWorldViewPanel(SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color)
|
CAdvMapWorldViewPanel::CAdvMapWorldViewPanel(std::shared_ptr<CAnimation> _icons, SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color)
|
||||||
: CAdvMapPanel(bg, position)
|
: CAdvMapPanel(bg, position), icons(_icons)
|
||||||
{
|
{
|
||||||
fillerHeight = bg ? spaceBottom - pos.y - pos.h : 0;
|
fillerHeight = bg ? spaceBottom - pos.y - pos.h : 0;
|
||||||
|
|
||||||
if (fillerHeight > 0)
|
if (fillerHeight > 0)
|
||||||
{
|
{
|
||||||
tmpBackgroundFiller = CMessage::drawDialogBox(pos.w, fillerHeight, color);
|
tmpBackgroundFiller = CMessage::drawDialogBox(pos.w, fillerHeight, color);
|
||||||
@ -1275,23 +1277,16 @@ CAdvMapWorldViewPanel::~CAdvMapWorldViewPanel()
|
|||||||
SDL_FreeSurface(tmpBackgroundFiller);
|
SDL_FreeSurface(tmpBackgroundFiller);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAdvMapWorldViewPanel::recolorIcons(const PlayerColor &color, const CDefHandler *def, int indexOffset)
|
void CAdvMapWorldViewPanel::recolorIcons(const PlayerColor &color, int indexOffset)
|
||||||
{
|
{
|
||||||
for (auto &pic : currentIcons)
|
assert(iconsData.size() == currentIcons.size());
|
||||||
{
|
|
||||||
removeChild(pic);
|
|
||||||
delete pic;
|
|
||||||
}
|
|
||||||
currentIcons.clear();
|
|
||||||
|
|
||||||
for (auto &data : iconsData)
|
for(size_t idx = 0; idx < iconsData.size(); idx++)
|
||||||
{
|
{
|
||||||
auto pic = new CPicture(def->ourImages[data.first + indexOffset].bitmap, data.second.x, data.second.y, false);
|
const auto & data = iconsData.at(idx);
|
||||||
pic->recActions |= SHOWALL;
|
currentIcons[idx]->setFrame(data.first + indexOffset);
|
||||||
currentIcons.push_back(pic);
|
|
||||||
addChildToPanel(pic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fillerHeight > 0)
|
if (fillerHeight > 0)
|
||||||
{
|
{
|
||||||
if (tmpBackgroundFiller)
|
if (tmpBackgroundFiller)
|
||||||
@ -1300,18 +1295,17 @@ void CAdvMapWorldViewPanel::recolorIcons(const PlayerColor &color, const CDefHan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAdvMapWorldViewPanel::addChildIcon(std::pair<int, Point> data, const CDefHandler *def, int indexOffset)
|
void CAdvMapWorldViewPanel::addChildIcon(std::pair<int, Point> data, int indexOffset)
|
||||||
{
|
{
|
||||||
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||||
iconsData.push_back(data);
|
iconsData.push_back(data);
|
||||||
auto pic = new CPicture(def->ourImages[data.first + indexOffset].bitmap, data.second.x, data.second.y, false);
|
currentIcons.push_back(new CAnimImage(icons, data.first + indexOffset, 0, data.second.x, data.second.y));
|
||||||
currentIcons.push_back(pic);
|
|
||||||
addChildToPanel(pic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAdvMapWorldViewPanel::showAll(SDL_Surface * to)
|
void CAdvMapWorldViewPanel::showAll(SDL_Surface * to)
|
||||||
{
|
{
|
||||||
if (tmpBackgroundFiller)
|
if (tmpBackgroundFiller)
|
||||||
{
|
{
|
||||||
blitAt(tmpBackgroundFiller, pos.x, pos.y + pos.h, to);
|
blitAt(tmpBackgroundFiller, pos.x, pos.y + pos.h, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include "../../lib/FunctionList.h"
|
#include "../../lib/FunctionList.h"
|
||||||
|
|
||||||
class CArmedInstance;
|
class CArmedInstance;
|
||||||
|
class CAnimation;
|
||||||
|
class CAnimImage;
|
||||||
class CShowableAnim;
|
class CShowableAnim;
|
||||||
class CGGarrison;
|
class CGGarrison;
|
||||||
class CGObjectInstance;
|
class CGObjectInstance;
|
||||||
@ -340,17 +342,18 @@ class CAdvMapWorldViewPanel : public CAdvMapPanel
|
|||||||
/// data that allows reconstruction of panel info icons
|
/// data that allows reconstruction of panel info icons
|
||||||
std::vector<std::pair<int, Point>> iconsData;
|
std::vector<std::pair<int, Point>> iconsData;
|
||||||
/// ptrs to child-pictures constructed from iconsData
|
/// ptrs to child-pictures constructed from iconsData
|
||||||
std::vector<CPicture *> currentIcons;
|
std::vector<CAnimImage *> currentIcons;
|
||||||
/// temporary surface drawn below world view panel on higher resolutions (won't be needed when world view panel is configured for extraResolutions mod)
|
/// temporary surface drawn below world view panel on higher resolutions (won't be needed when world view panel is configured for extraResolutions mod)
|
||||||
SDL_Surface * tmpBackgroundFiller;
|
SDL_Surface * tmpBackgroundFiller;
|
||||||
int fillerHeight;
|
int fillerHeight;
|
||||||
|
std::shared_ptr<CAnimation> icons;
|
||||||
public:
|
public:
|
||||||
CAdvMapWorldViewPanel(SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color);
|
CAdvMapWorldViewPanel(std::shared_ptr<CAnimation> _icons, SDL_Surface * bg, Point position, int spaceBottom, const PlayerColor &color);
|
||||||
virtual ~CAdvMapWorldViewPanel();
|
virtual ~CAdvMapWorldViewPanel();
|
||||||
|
|
||||||
void addChildIcon(std::pair<int, Point> data, const CDefHandler *def, int indexOffset);
|
void addChildIcon(std::pair<int, Point> data, int indexOffset);
|
||||||
/// recreates all pictures from given def to recolor them according to current player color
|
/// recreates all pictures from given def to recolor them according to current player color
|
||||||
void recolorIcons(const PlayerColor &color, const CDefHandler *def, int indexOffset);
|
void recolorIcons(const PlayerColor &color, int indexOffset);
|
||||||
void showAll(SDL_Surface * to) override;
|
void showAll(SDL_Surface * to) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -227,13 +227,14 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to)
|
|||||||
pn+=25;
|
pn+=25;
|
||||||
if (pn>=0)
|
if (pn>=0)
|
||||||
{
|
{
|
||||||
CDefEssential * arrows = graphics->heroMoveArrows;
|
const IImage * arrow = graphics->heroMoveArrows->getImage(pn);
|
||||||
|
|
||||||
int x = 32*(curPos.x-adventureInt->position.x)+CGI->mh->offsetX + pos.x,
|
int x = 32*(curPos.x-adventureInt->position.x)+CGI->mh->offsetX + pos.x,
|
||||||
y = 32*(curPos.y-adventureInt->position.y)+CGI->mh->offsetY + pos.y;
|
y = 32*(curPos.y-adventureInt->position.y)+CGI->mh->offsetY + pos.y;
|
||||||
if (x< -32 || y< -32 || x>pos.w || y>pos.h)
|
if (x< -32 || y< -32 || x>pos.w || y>pos.h)
|
||||||
continue;
|
continue;
|
||||||
int hvx = (x+arrows->ourImages[pn].bitmap->w)-(pos.x+pos.w),
|
int hvx = (x + arrow->width()) - (pos.x + pos.w),
|
||||||
hvy = (y+arrows->ourImages[pn].bitmap->h)-(pos.y+pos.h);
|
hvy = (y + arrow->height()) - (pos.y + pos.h);
|
||||||
|
|
||||||
SDL_Rect prevClip;
|
SDL_Rect prevClip;
|
||||||
SDL_GetClipRect(to, &prevClip);
|
SDL_GetClipRect(to, &prevClip);
|
||||||
@ -243,52 +244,44 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to)
|
|||||||
{
|
{
|
||||||
if (hvx<0 && hvy<0)
|
if (hvx<0 && hvy<0)
|
||||||
{
|
{
|
||||||
Rect dstRect = genRect(32, 32, x + moveX, y + moveY);
|
arrow->draw(to, x + moveX, y + moveY);
|
||||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, nullptr, to, &dstRect);
|
|
||||||
}
|
}
|
||||||
else if(hvx<0)
|
else if(hvx<0)
|
||||||
{
|
{
|
||||||
Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, 0, 0);
|
Rect srcRect = genRect(arrow->height() - hvy, arrow->width(), 0, 0);
|
||||||
Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x + moveX, y + moveY);
|
arrow->draw(to, x + moveX, y + moveY, &srcRect);
|
||||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect);
|
|
||||||
}
|
}
|
||||||
else if (hvy<0)
|
else if (hvy<0)
|
||||||
{
|
{
|
||||||
Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, 0, 0);
|
Rect srcRect = genRect(arrow->height(), arrow->width() - hvx, 0, 0);
|
||||||
Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY);
|
arrow->draw(to, x + moveX, y + moveY, &srcRect);
|
||||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, 0, 0);
|
Rect srcRect = genRect(arrow->height() - hvy, arrow->width() - hvx, 0, 0);
|
||||||
Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY);
|
arrow->draw(to, x + moveX, y + moveY, &srcRect);
|
||||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else //standard version
|
else //standard version
|
||||||
{
|
{
|
||||||
if (hvx<0 && hvy<0)
|
if (hvx<0 && hvy<0)
|
||||||
{
|
{
|
||||||
Rect dstRect = genRect(32, 32, x, y);
|
arrow->draw(to, x, y);
|
||||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, nullptr, to, &dstRect);
|
|
||||||
}
|
}
|
||||||
else if(hvx<0)
|
else if(hvx<0)
|
||||||
{
|
{
|
||||||
Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, 0, 0);
|
Rect srcRect = genRect(arrow->height() - hvy, arrow->width(), 0, 0);
|
||||||
Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x, y);
|
arrow->draw(to, x, y, &srcRect);
|
||||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect);
|
|
||||||
}
|
}
|
||||||
else if (hvy<0)
|
else if (hvy<0)
|
||||||
{
|
{
|
||||||
Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, 0, 0);
|
Rect srcRect = genRect(arrow->height(), arrow->width() - hvx, 0, 0);
|
||||||
Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x, y);
|
arrow->draw(to, x, y, &srcRect);
|
||||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, 0, 0);
|
Rect srcRect = genRect(arrow->height() - hvy, arrow->width() - hvx, 0, 0);
|
||||||
Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x, y);
|
arrow->draw(to, x, y, &srcRect);
|
||||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_SetClipRect(to, &prevClip);
|
SDL_SetClipRect(to, &prevClip);
|
||||||
@ -321,9 +314,6 @@ void CTerrainRect::show(SDL_Surface * to)
|
|||||||
showPath(&pos, to);
|
showPath(&pos, to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//SDL_BlitSurface(teren,&genRect(pos.h,pos.w,0,0),screen,&genRect(547,594,7,6));
|
|
||||||
//SDL_FreeSurface(teren);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTerrainRect::showAll(SDL_Surface * to)
|
void CTerrainRect::showAll(SDL_Surface * to)
|
||||||
@ -331,7 +321,7 @@ void CTerrainRect::showAll(SDL_Surface * to)
|
|||||||
// world view map is static and doesn't need redraw every frame
|
// world view map is static and doesn't need redraw every frame
|
||||||
if (adventureInt->mode == EAdvMapMode::WORLD_VIEW)
|
if (adventureInt->mode == EAdvMapMode::WORLD_VIEW)
|
||||||
{
|
{
|
||||||
MapDrawingInfo info(adventureInt->position, &LOCPLINT->cb->getVisibilityMap(), &pos, adventureInt->worldViewIconsDef);
|
MapDrawingInfo info(adventureInt->position, &LOCPLINT->cb->getVisibilityMap(), &pos, adventureInt->worldViewIcons);
|
||||||
info.scaled = true;
|
info.scaled = true;
|
||||||
info.scale = adventureInt->worldViewScale;
|
info.scale = adventureInt->worldViewScale;
|
||||||
adventureInt->worldViewOptions.adjustDrawingInfo(info);
|
adventureInt->worldViewOptions.adjustDrawingInfo(info);
|
||||||
@ -501,11 +491,14 @@ CAdvMapInt::CAdvMapInt():
|
|||||||
logGlobal->warn("bgWorldView not defined in resolution config; fallback to VWorld.bmp");
|
logGlobal->warn("bgWorldView not defined in resolution config; fallback to VWorld.bmp");
|
||||||
bgWorldView = BitmapHandler::loadBitmap("VWorld.bmp");
|
bgWorldView = BitmapHandler::loadBitmap("VWorld.bmp");
|
||||||
}
|
}
|
||||||
worldViewIconsDef = CDefHandler::giveDef("VwSymbol.def");
|
|
||||||
|
worldViewIcons = std::make_shared<CAnimation>("VwSymbol");//todo: customize with ADVOPT
|
||||||
|
//preload all for faster map drawing
|
||||||
|
worldViewIcons->load();//TODO: make special method in CAnimation fro that
|
||||||
|
|
||||||
for (int g=0; g<ADVOPT.gemG.size(); ++g)
|
for (int g=0; g<ADVOPT.gemG.size(); ++g)
|
||||||
{
|
{
|
||||||
gems.push_back(CDefHandler::giveDef(ADVOPT.gemG[g]));
|
gems.push_back(new CAnimImage(ADVOPT.gemG[g], 0, 0, ADVOPT.gemX[g], ADVOPT.gemY[g]));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto makeButton = [&] (int textID, std::function<void()> callback, config::ButtonInfo info, int key) -> CButton *
|
auto makeButton = [&] (int textID, std::function<void()> callback, config::ButtonInfo info, int key) -> CButton *
|
||||||
@ -531,7 +524,7 @@ CAdvMapInt::CAdvMapInt():
|
|||||||
|
|
||||||
panelMain = new CAdvMapPanel(nullptr, Point(0, 0));
|
panelMain = new CAdvMapPanel(nullptr, Point(0, 0));
|
||||||
// TODO correct drawing position
|
// TODO correct drawing position
|
||||||
panelWorldView = new CAdvMapWorldViewPanel(bgWorldView, Point(heroList.pos.x - 2, 195), panelSpaceBottom, LOCPLINT->playerID);
|
panelWorldView = new CAdvMapWorldViewPanel(worldViewIcons, bgWorldView, Point(heroList.pos.x - 2, 195), panelSpaceBottom, LOCPLINT->playerID);
|
||||||
|
|
||||||
panelMain->addChildColorableButton(kingOverview);
|
panelMain->addChildColorableButton(kingOverview);
|
||||||
panelMain->addChildColorableButton(underground);
|
panelMain->addChildColorableButton(underground);
|
||||||
@ -600,16 +593,17 @@ CAdvMapInt::CAdvMapInt():
|
|||||||
|
|
||||||
int iconColorMultiplier = player.getNum() * 19;
|
int iconColorMultiplier = player.getNum() * 19;
|
||||||
int wvLeft = heroList.pos.x - 2; // TODO correct drawing position
|
int wvLeft = heroList.pos.x - 2; // TODO correct drawing position
|
||||||
|
//int wvTop = 195;
|
||||||
for (int i = 0; i < 5; ++i)
|
for (int i = 0; i < 5; ++i)
|
||||||
{
|
{
|
||||||
panelWorldView->addChildIcon(std::pair<int, Point>(i, Point(wvLeft + 5, 253 + i * 20)), worldViewIconsDef, iconColorMultiplier);
|
panelWorldView->addChildIcon(std::pair<int, Point>(i, Point(5, 58 + i * 20)), iconColorMultiplier);
|
||||||
panelWorldView->addChildToPanel(new CLabel(wvLeft + 45, 263 + i * 20, EFonts::FONT_SMALL, EAlignment::TOPLEFT,
|
panelWorldView->addChildToPanel(new CLabel(wvLeft + 45, 263 + i * 20, EFonts::FONT_SMALL, EAlignment::TOPLEFT,
|
||||||
Colors::WHITE, CGI->generaltexth->allTexts[612 + i]));
|
Colors::WHITE, CGI->generaltexth->allTexts[612 + i]));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 7; ++i)
|
for (int i = 0; i < 7; ++i)
|
||||||
{
|
{
|
||||||
panelWorldView->addChildIcon(std::pair<int, Point>(i + 5, Point(wvLeft + 5, 377 + i * 20)), worldViewIconsDef, iconColorMultiplier);
|
panelWorldView->addChildIcon(std::pair<int, Point>(i + 5, Point(5, 182 + i * 20)), iconColorMultiplier);
|
||||||
panelWorldView->addChildIcon(std::pair<int, Point>(i + 12, Point(wvLeft + 160, 377 + i * 20)), worldViewIconsDef, iconColorMultiplier);
|
panelWorldView->addChildIcon(std::pair<int, Point>(i + 12, Point(160, 182 + i * 20)), iconColorMultiplier);
|
||||||
panelWorldView->addChildToPanel(new CLabel(wvLeft + 45, 387 + i * 20, EFonts::FONT_SMALL, EAlignment::TOPLEFT,
|
panelWorldView->addChildToPanel(new CLabel(wvLeft + 45, 387 + i * 20, EFonts::FONT_SMALL, EAlignment::TOPLEFT,
|
||||||
Colors::WHITE, CGI->generaltexth->allTexts[619 + i]));
|
Colors::WHITE, CGI->generaltexth->allTexts[619 + i]));
|
||||||
}
|
}
|
||||||
@ -633,10 +627,7 @@ CAdvMapInt::~CAdvMapInt()
|
|||||||
{
|
{
|
||||||
SDL_FreeSurface(bg);
|
SDL_FreeSurface(bg);
|
||||||
|
|
||||||
for(int i=0; i<gems.size(); i++)
|
worldViewIcons->unload();
|
||||||
delete gems[i];
|
|
||||||
|
|
||||||
delete worldViewIconsDef;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAdvMapInt::fshowOverview()
|
void CAdvMapInt::fshowOverview()
|
||||||
@ -983,6 +974,8 @@ void CAdvMapInt::show(SDL_Surface * to)
|
|||||||
scrollingState = false;
|
scrollingState = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for(int i = 0; i < 4; i++)
|
||||||
|
gems[i]->setFrame(LOCPLINT->playerID.getNum());
|
||||||
if(updateScreen)
|
if(updateScreen)
|
||||||
{
|
{
|
||||||
int3 betterPos = LOCPLINT->repairScreenPos(position);
|
int3 betterPos = LOCPLINT->repairScreenPos(position);
|
||||||
@ -993,16 +986,16 @@ void CAdvMapInt::show(SDL_Surface * to)
|
|||||||
}
|
}
|
||||||
|
|
||||||
terrain.show(to);
|
terrain.show(to);
|
||||||
for(int i=0;i<4;i++)
|
for(int i = 0; i < 4; i++)
|
||||||
blitAt(gems[i]->ourImages[LOCPLINT->playerID.getNum()].bitmap,ADVOPT.gemX[i],ADVOPT.gemY[i],to);
|
gems[i]->showAll(to);
|
||||||
updateScreen=false;
|
updateScreen=false;
|
||||||
LOCPLINT->cingconsole->show(to);
|
LOCPLINT->cingconsole->show(to);
|
||||||
}
|
}
|
||||||
else if (terrain.needsAnimUpdate())
|
else if (terrain.needsAnimUpdate())
|
||||||
{
|
{
|
||||||
terrain.showAnim(to);
|
terrain.showAnim(to);
|
||||||
for(int i=0;i<4;i++)
|
for(int i = 0; i < 4; i++)
|
||||||
blitAt(gems[i]->ourImages[LOCPLINT->playerID.getNum()].bitmap,ADVOPT.gemX[i],ADVOPT.gemY[i],to);
|
gems[i]->showAll(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
infoBar.show(to);
|
infoBar.show(to);
|
||||||
@ -1378,11 +1371,8 @@ void CAdvMapInt::setPlayer(PlayerColor Player)
|
|||||||
|
|
||||||
panelMain->setPlayerColor(player);
|
panelMain->setPlayerColor(player);
|
||||||
panelWorldView->setPlayerColor(player);
|
panelWorldView->setPlayerColor(player);
|
||||||
panelWorldView->recolorIcons(player, worldViewIconsDef, player.getNum() * 19);
|
panelWorldView->recolorIcons(player, player.getNum() * 19);
|
||||||
graphics->blueToPlayersAdv(resdatabar.bg,player);
|
graphics->blueToPlayersAdv(resdatabar.bg,player);
|
||||||
|
|
||||||
//heroList.updateHList();
|
|
||||||
//townList.genList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAdvMapInt::startTurn()
|
void CAdvMapInt::startTurn()
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include "../../lib/spells/ViewSpellInt.h"
|
#include "../../lib/spells/ViewSpellInt.h"
|
||||||
|
|
||||||
class CDefHandler;
|
|
||||||
class CCallback;
|
class CCallback;
|
||||||
struct CGPath;
|
struct CGPath;
|
||||||
class CAdvMapInt;
|
class CAdvMapInt;
|
||||||
@ -131,25 +130,25 @@ public:
|
|||||||
|
|
||||||
EAdvMapMode mode;
|
EAdvMapMode mode;
|
||||||
float worldViewScale;
|
float worldViewScale;
|
||||||
|
|
||||||
struct WorldViewOptions
|
struct WorldViewOptions
|
||||||
{
|
{
|
||||||
bool showAllTerrain; //for expert viewEarth
|
bool showAllTerrain; //for expert viewEarth
|
||||||
|
|
||||||
std::vector<ObjectPosInfo> iconPositions;
|
std::vector<ObjectPosInfo> iconPositions;
|
||||||
|
|
||||||
WorldViewOptions();
|
WorldViewOptions();
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void adjustDrawingInfo(MapDrawingInfo & info);
|
void adjustDrawingInfo(MapDrawingInfo & info);
|
||||||
};
|
};
|
||||||
|
|
||||||
WorldViewOptions worldViewOptions;
|
WorldViewOptions worldViewOptions;
|
||||||
|
|
||||||
SDL_Surface * bg;
|
SDL_Surface * bg;
|
||||||
SDL_Surface * bgWorldView;
|
SDL_Surface * bgWorldView;
|
||||||
std::vector<CDefHandler *> gems;
|
std::vector<CAnimImage *> gems;
|
||||||
CMinimap minimap;
|
CMinimap minimap;
|
||||||
CGStatusBar statusbar;
|
CGStatusBar statusbar;
|
||||||
|
|
||||||
@ -176,7 +175,7 @@ public:
|
|||||||
CAdvMapWorldViewPanel *panelWorldView; // panel that holds all buttons and other ui in world view
|
CAdvMapWorldViewPanel *panelWorldView; // panel that holds all buttons and other ui in world view
|
||||||
CAdvMapPanel *activeMapPanel; // currently active panel (either main or world view, depending on current mode)
|
CAdvMapPanel *activeMapPanel; // currently active panel (either main or world view, depending on current mode)
|
||||||
|
|
||||||
CDefHandler * worldViewIconsDef; // images for world view overlay
|
std::shared_ptr<CAnimation> worldViewIcons;// images for world view overlay
|
||||||
|
|
||||||
const CSpell *spellBeingCasted; //nullptr if none
|
const CSpell *spellBeingCasted; //nullptr if none
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user