mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-17 00:07:41 +02:00
@ -585,7 +585,9 @@ SDLImage::SDLImage(std::string filename, bool compressed):
|
|||||||
delete [] pic;
|
delete [] pic;
|
||||||
}
|
}
|
||||||
else if(bitmaph->haveFile(filename, FILE_GRAPHICS))
|
else if(bitmaph->haveFile(filename, FILE_GRAPHICS))
|
||||||
|
{
|
||||||
surf = BitmapHandler::loadBitmap(filename);
|
surf = BitmapHandler::loadBitmap(filename);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tlog0<<"Error: file not found: "<<filename<<"\n";
|
tlog0<<"Error: file not found: "<<filename<<"\n";
|
||||||
@ -648,8 +650,9 @@ CompImage::CompImage(SDL_Surface * surf)
|
|||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, unsigned char rotation) const
|
void CompImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 alpha) const
|
||||||
{
|
{
|
||||||
|
int rotation = 0; //TODO
|
||||||
//rotation & 2 = horizontal rotation
|
//rotation & 2 = horizontal rotation
|
||||||
//rotation & 4 = vertical rotation
|
//rotation & 4 = vertical rotation
|
||||||
if (!surf)
|
if (!surf)
|
||||||
@ -706,7 +709,7 @@ void CompImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, unsigned
|
|||||||
while (currX + size < sourceRect.w)
|
while (currX + size < sourceRect.w)
|
||||||
{
|
{
|
||||||
//blit block, pointers will be modified if needed
|
//blit block, pointers will be modified if needed
|
||||||
BlitBlockWithBpp(bpp, type, size, data, blitPos, rotation & 2);
|
BlitBlockWithBpp(bpp, type, size, data, blitPos, alpha, rotation & 2);
|
||||||
|
|
||||||
currX += size;
|
currX += size;
|
||||||
type = *(data++);
|
type = *(data++);
|
||||||
@ -714,14 +717,14 @@ void CompImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, unsigned
|
|||||||
}
|
}
|
||||||
//Blit last, semi-visible block
|
//Blit last, semi-visible block
|
||||||
size = sourceRect.w - currX;
|
size = sourceRect.w - currX;
|
||||||
BlitBlockWithBpp(bpp, type, size, data, blitPos, rotation & 2);
|
BlitBlockWithBpp(bpp, type, size, data, blitPos, alpha, rotation & 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CASEBPP(x,y) case x: BlitBlock<x,y>(type, size, data, dest); break
|
#define CASEBPP(x,y) case x: BlitBlock<x,y>(type, size, data, dest, alpha); break
|
||||||
|
|
||||||
//FIXME: better way to get blitter
|
//FIXME: better way to get blitter
|
||||||
void CompImage::BlitBlockWithBpp(ui8 bpp, ui8 type, ui8 size, ui8 *&data, ui8 *&dest, bool rotated) const
|
void CompImage::BlitBlockWithBpp(ui8 bpp, ui8 type, ui8 size, ui8 *&data, ui8 *&dest, ui8 alpha, bool rotated) const
|
||||||
{
|
{
|
||||||
assert(bpp>1 && bpp<5);
|
assert(bpp>1 && bpp<5);
|
||||||
|
|
||||||
@ -744,22 +747,33 @@ void CompImage::BlitBlockWithBpp(ui8 bpp, ui8 type, ui8 size, ui8 *&data, ui8 *&
|
|||||||
|
|
||||||
//Blit one block from RLE-d surface
|
//Blit one block from RLE-d surface
|
||||||
template<int bpp, int dir>
|
template<int bpp, int dir>
|
||||||
void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest) const
|
void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest, ui8 alpha) const
|
||||||
{
|
{
|
||||||
//Raw data
|
//Raw data
|
||||||
if (type == 0xff)
|
if (type == 0xff)
|
||||||
{
|
{
|
||||||
ui8 color = *data;
|
ui8 color = *data;
|
||||||
|
if (alpha != 255)//Per-surface alpha is set
|
||||||
|
{
|
||||||
|
for (size_t i=0; i<size; i++)
|
||||||
|
{
|
||||||
|
SDL_Color col = palette[*(data++)];
|
||||||
|
col.unused = (unsigned int)col.unused*(255-alpha)/255;
|
||||||
|
ColorPutter<bpp, 1>::PutColorAlpha(dest, col);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (palette[color].unused == 255)
|
if (palette[color].unused == 255)
|
||||||
{
|
{
|
||||||
//Put row of RGB data
|
//Put row of RGB data
|
||||||
for (int i=0; i<size; i++)
|
for (size_t i=0; i<size; i++)
|
||||||
ColorPutter<bpp, 1>::PutColor(dest, palette[*(data++)]);
|
ColorPutter<bpp, 1>::PutColor(dest, palette[*(data++)]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Put row of RGBA data
|
//Put row of RGBA data
|
||||||
for (int i=0; i<size; i++)
|
for (size_t i=0; i<size; i++)
|
||||||
ColorPutter<bpp, 1>::PutColorAlpha(dest, palette[*(data++)]);
|
ColorPutter<bpp, 1>::PutColorAlpha(dest, palette[*(data++)]);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -767,6 +781,15 @@ void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest) const
|
|||||||
//RLE-d sequence
|
//RLE-d sequence
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (alpha != 255 && palette[type].unused !=0)//Per-surface alpha is set
|
||||||
|
{
|
||||||
|
SDL_Color col = palette[type];
|
||||||
|
col.unused = (int)col.unused*(255-alpha)/255;
|
||||||
|
for (size_t i=0; i<size; i++)
|
||||||
|
ColorPutter<bpp, 1>::PutColorAlpha(dest, col);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (palette[type].unused)
|
switch (palette[type].unused)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -784,7 +807,7 @@ void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest) const
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
//Put RGBA row
|
//Put RGBA row
|
||||||
for (int i=0; i<size; i++)
|
for (size_t i=0; i<size; i++)
|
||||||
ColorPutter<bpp, 1>::PutColorAlpha(dest, palette[type]);
|
ColorPutter<bpp, 1>::PutColorAlpha(dest, palette[type]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -792,7 +815,6 @@ void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CompImage::playerColored(int player)
|
void CompImage::playerColored(int player)
|
||||||
{
|
{
|
||||||
SDL_Color *pal = NULL;
|
SDL_Color *pal = NULL;
|
||||||
@ -991,6 +1013,7 @@ CAnimation::CAnimation(std::string Name, bool Compressed):
|
|||||||
CDefFile * file = getFile();
|
CDefFile * file = getFile();
|
||||||
init(file);
|
init(file);
|
||||||
delete file;
|
delete file;
|
||||||
|
loadedAnims.insert(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnimation::CAnimation():
|
CAnimation::CAnimation():
|
||||||
@ -998,6 +1021,7 @@ CAnimation::CAnimation():
|
|||||||
compressed(false)
|
compressed(false)
|
||||||
{
|
{
|
||||||
init(NULL);
|
init(NULL);
|
||||||
|
loadedAnims.insert(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnimation::~CAnimation()
|
CAnimation::~CAnimation()
|
||||||
@ -1009,6 +1033,7 @@ CAnimation::~CAnimation()
|
|||||||
for (image_map::iterator image = group->second.begin(); image != group->second.end(); ++image )
|
for (image_map::iterator image = group->second.begin(); image != group->second.end(); ++image )
|
||||||
delete image->second;
|
delete image->second;
|
||||||
}
|
}
|
||||||
|
loadedAnims.erase(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimation::setCustom(std::string filename, size_t frame, size_t group)
|
void CAnimation::setCustom(std::string filename, size_t frame, size_t group)
|
||||||
@ -1090,6 +1115,21 @@ size_t CAnimation::size(size_t group) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<CAnimation*> CAnimation::loadedAnims;
|
||||||
|
|
||||||
|
void CAnimation::getAnimInfo()
|
||||||
|
{
|
||||||
|
tlog1<<"Animation stats: Loaded "<<loadedAnims.size()<<" total\n";
|
||||||
|
for (std::set<CAnimation*>::iterator it = loadedAnims.begin(); it != loadedAnims.end(); it++)
|
||||||
|
{
|
||||||
|
CAnimation * anim = *it;
|
||||||
|
tlog1<<"Name: "<<anim->name<<" Groups: "<<anim->images.size();
|
||||||
|
if (!anim->images.empty())
|
||||||
|
tlog1<<", "<<anim->images.begin()->second.size()<<" image loaded in group "<< anim->images.begin()->first;
|
||||||
|
tlog1<<"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CAnimImage::CAnimImage(std::string name, size_t Frame, size_t Group, int x, int y, unsigned char Flags):
|
CAnimImage::CAnimImage(std::string name, size_t Frame, size_t Group, int x, int y, unsigned char Flags):
|
||||||
frame(Frame),
|
frame(Frame),
|
||||||
group(Group),
|
group(Group),
|
||||||
@ -1172,7 +1212,8 @@ CShowableAnim::CShowableAnim(int x, int y, std::string name, unsigned char Flags
|
|||||||
value(0),
|
value(0),
|
||||||
flags(Flags),
|
flags(Flags),
|
||||||
xOffset(0),
|
xOffset(0),
|
||||||
yOffset(0)
|
yOffset(0),
|
||||||
|
alpha(255)
|
||||||
{
|
{
|
||||||
anim.loadGroup(group);
|
anim.loadGroup(group);
|
||||||
last = anim.size(group);
|
last = anim.size(group);
|
||||||
@ -1188,6 +1229,11 @@ CShowableAnim::~CShowableAnim()
|
|||||||
anim.unloadGroup(group);
|
anim.unloadGroup(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CShowableAnim::setAlpha(unsigned int alphaValue)
|
||||||
|
{
|
||||||
|
alpha = std::min<unsigned int>(alphaValue, 255);
|
||||||
|
}
|
||||||
|
|
||||||
bool CShowableAnim::set(size_t Group, size_t from, size_t to)
|
bool CShowableAnim::set(size_t Group, size_t from, size_t to)
|
||||||
{
|
{
|
||||||
size_t max = anim.size(Group);
|
size_t max = anim.size(Group);
|
||||||
@ -1265,7 +1311,7 @@ void CShowableAnim::blitImage(size_t frame, size_t group, SDL_Surface *to)
|
|||||||
assert(to);
|
assert(to);
|
||||||
Rect src( xOffset, yOffset, pos.w, pos.h);
|
Rect src( xOffset, yOffset, pos.w, pos.h);
|
||||||
IImage * img = anim.getImage(frame, group);
|
IImage * img = anim.getImage(frame, group);
|
||||||
img->draw(to, pos.x-xOffset, pos.y-yOffset, &src);
|
img->draw(to, pos.x-xOffset, pos.y-yOffset, &src, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CShowableAnim::rotate(bool on, bool vertical)
|
void CShowableAnim::rotate(bool on, bool vertical)
|
||||||
@ -1350,8 +1396,7 @@ void CCreatureAnim::reset()
|
|||||||
if (set(at))
|
if (set(at))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
set(type);
|
set(HOLDING);
|
||||||
tlog0<<"Warning: next sequence was not found for animation!\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCreatureAnim::startPreview()
|
void CCreatureAnim::startPreview()
|
||||||
|
@ -68,7 +68,7 @@ class IImage
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//draws image on surface "where" at position
|
//draws image on surface "where" at position
|
||||||
virtual void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, unsigned char rotation=0) const=0;
|
virtual void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, ui8 alpha=255) const=0;
|
||||||
|
|
||||||
//decrease ref count, returns true if image can be deleted (refCount <= 0)
|
//decrease ref count, returns true if image can be deleted (refCount <= 0)
|
||||||
bool decreaseRef();
|
bool decreaseRef();
|
||||||
@ -104,7 +104,7 @@ public:
|
|||||||
SDLImage(SDL_Surface * from, bool extraRef);
|
SDLImage(SDL_Surface * from, bool extraRef);
|
||||||
~SDLImage();
|
~SDLImage();
|
||||||
|
|
||||||
void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, unsigned char rotation=0) const;
|
void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, ui8 alpha=255) const;
|
||||||
void playerColored(int player);
|
void playerColored(int player);
|
||||||
int width() const;
|
int width() const;
|
||||||
int height() const;
|
int height() const;
|
||||||
@ -140,8 +140,8 @@ class CompImage : public IImage
|
|||||||
|
|
||||||
//Used internally to blit one block of data
|
//Used internally to blit one block of data
|
||||||
template<int bpp, int dir>
|
template<int bpp, int dir>
|
||||||
void BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest) const;
|
void BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest, ui8 alpha) const;
|
||||||
void BlitBlockWithBpp(ui8 bpp, ui8 type, ui8 size, ui8 *&data, ui8 *&dest, bool rotated) const;
|
void BlitBlockWithBpp(ui8 bpp, ui8 type, ui8 size, ui8 *&data, ui8 *&dest, ui8 alpha, bool rotated) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//Load image from def file
|
//Load image from def file
|
||||||
@ -150,7 +150,7 @@ public:
|
|||||||
CompImage(SDL_Surface * surf);
|
CompImage(SDL_Surface * surf);
|
||||||
~CompImage();
|
~CompImage();
|
||||||
|
|
||||||
void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, unsigned char rotation=0) const;
|
void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, ui8 alpha=255) const;
|
||||||
void playerColored(int player);
|
void playerColored(int player);
|
||||||
int width() const;
|
int width() const;
|
||||||
int height() const;
|
int height() const;
|
||||||
@ -158,9 +158,8 @@ public:
|
|||||||
friend class CompImageLoader;
|
friend class CompImageLoader;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Class for handling animation.
|
/// Class for handling animation
|
||||||
*/
|
|
||||||
class CAnimation
|
class CAnimation
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -201,6 +200,10 @@ public:
|
|||||||
CAnimation();
|
CAnimation();
|
||||||
~CAnimation();
|
~CAnimation();
|
||||||
|
|
||||||
|
//static method for debugging - print info about loaded animations in tlog1
|
||||||
|
static void getAnimInfo();
|
||||||
|
static std::set<CAnimation*> loadedAnims;
|
||||||
|
|
||||||
//add custom surface to the selected position.
|
//add custom surface to the selected position.
|
||||||
void setCustom(std::string filename, size_t frame, size_t group=0);
|
void setCustom(std::string filename, size_t frame, size_t group=0);
|
||||||
|
|
||||||
@ -223,9 +226,8 @@ public:
|
|||||||
size_t size(size_t group=0) const;
|
size_t size(size_t group=0) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Class for displaying one image from animation
|
/// Class for displaying one image from animation
|
||||||
*/
|
|
||||||
class CAnimImage: public CIntObject
|
class CAnimImage: public CIntObject
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -283,10 +285,15 @@ protected:
|
|||||||
//For clipping in rect, offsets of picture coordinates
|
//For clipping in rect, offsets of picture coordinates
|
||||||
int xOffset, yOffset;
|
int xOffset, yOffset;
|
||||||
|
|
||||||
|
ui8 alpha;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//called when next animation sequence is required
|
//called when next animation sequence is required
|
||||||
boost::function<void()> callback;
|
boost::function<void()> callback;
|
||||||
|
|
||||||
|
//Set per-surface alpha, 0 = transparent, 255 = opaque
|
||||||
|
void setAlpha(unsigned int alphaValue);
|
||||||
|
|
||||||
CShowableAnim(int x, int y, std::string name, unsigned char flags=0, unsigned int Delay=4, size_t Group=0);
|
CShowableAnim(int x, int y, std::string name, unsigned char flags=0, unsigned int Delay=4, size_t Group=0);
|
||||||
~CShowableAnim();
|
~CShowableAnim();
|
||||||
|
|
||||||
@ -308,7 +315,7 @@ public:
|
|||||||
void showAll(SDL_Surface *to);
|
void showAll(SDL_Surface *to);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Creature-dependend animations like attacking, moving,... outside battles
|
/// Creature-dependend animations like attacking, moving,...
|
||||||
class CCreatureAnim: public CShowableAnim
|
class CCreatureAnim: public CShowableAnim
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,7 @@ class CTransformerWindow;
|
|||||||
class CPicture;
|
class CPicture;
|
||||||
class CCreaturePic;
|
class CCreaturePic;
|
||||||
class CMinorResDataBar;
|
class CMinorResDataBar;
|
||||||
|
class CCastleBuildings;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CCastleInterface.h, part of VCMI engine
|
* CCastleInterface.h, part of VCMI engine
|
||||||
@ -34,10 +35,14 @@ class CMinorResDataBar;
|
|||||||
class CBuildingRect : public CShowableAnim
|
class CBuildingRect : public CShowableAnim
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
CCastleBuildings * parent;
|
||||||
const Structure* str;
|
const Structure* str;
|
||||||
SDL_Surface* border;
|
SDL_Surface* border;
|
||||||
SDL_Surface* area;
|
SDL_Surface* area;
|
||||||
CBuildingRect(const Structure *Str); //c-tor
|
|
||||||
|
unsigned int stateCounter;//For building construction - current stage in animation
|
||||||
|
|
||||||
|
CBuildingRect(CCastleBuildings * Par, const Structure *Str); //c-tor
|
||||||
~CBuildingRect(); //d-tor
|
~CBuildingRect(); //d-tor
|
||||||
bool operator<(const CBuildingRect & p2) const;
|
bool operator<(const CBuildingRect & p2) const;
|
||||||
void hover(bool on);
|
void hover(bool on);
|
||||||
@ -67,6 +72,54 @@ public:
|
|||||||
~CHeroGSlot(); //d-tor
|
~CHeroGSlot(); //d-tor
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Class for town screen management (town background and structures)
|
||||||
|
class CCastleBuildings : public CIntObject
|
||||||
|
{
|
||||||
|
struct AnimRule
|
||||||
|
{
|
||||||
|
int townID, buildID;
|
||||||
|
int toCheck;
|
||||||
|
size_t firstA, lastA;
|
||||||
|
size_t firstB, lastB;
|
||||||
|
};
|
||||||
|
|
||||||
|
CPicture *background;
|
||||||
|
//List of buildings for each group
|
||||||
|
std::map< int, std::vector<const Structure*> > groups;
|
||||||
|
//Vector with all blittable buildings
|
||||||
|
std::vector<CBuildingRect*> buildings;
|
||||||
|
|
||||||
|
const CGTownInstance * town;
|
||||||
|
|
||||||
|
const CGHeroInstance* getHero();//Select hero for buildings usage
|
||||||
|
void checkRules();//Check animation rules (special anims for Shipyard and Mana Vortex)
|
||||||
|
|
||||||
|
void enterBlacksmith(int ArtifactID);//support for blacksmith + ballista yard
|
||||||
|
void enterBuilding(int building);//for buildings with simple description + pic left-click messages
|
||||||
|
void enterCastleGate();
|
||||||
|
void enterFountain(int building);//Rampart's fountains
|
||||||
|
void enterMagesGuild();
|
||||||
|
void enterTownHall();
|
||||||
|
|
||||||
|
void openMagesGuild();
|
||||||
|
void openTownHall();
|
||||||
|
|
||||||
|
public:
|
||||||
|
CBuildingRect * selectedBuilding;
|
||||||
|
|
||||||
|
CCastleBuildings(const CGTownInstance* town);
|
||||||
|
~CCastleBuildings();
|
||||||
|
|
||||||
|
void enterDwelling(int level);
|
||||||
|
|
||||||
|
void buildingClicked(int building);
|
||||||
|
void addBuilding(int building);
|
||||||
|
void removeBuilding(int building);//FIXME: not tested!!!
|
||||||
|
|
||||||
|
void show(SDL_Surface *to);
|
||||||
|
void showAll(SDL_Surface *to);
|
||||||
|
};
|
||||||
|
|
||||||
/// Huge class which manages the castle window
|
/// Huge class which manages the castle window
|
||||||
class CCastleInterface : public CWindowWithGarrison
|
class CCastleInterface : public CWindowWithGarrison
|
||||||
{
|
{
|
||||||
@ -83,7 +136,7 @@ class CCastleInterface : public CWindowWithGarrison
|
|||||||
void clickRight(tribool down, bool previousState);
|
void clickRight(tribool down, bool previousState);
|
||||||
void show(SDL_Surface * to);
|
void show(SDL_Surface * to);
|
||||||
};
|
};
|
||||||
/// Town info which gets shown by right-clicking on a town at the map
|
/// Icons from town screen with castle\town hall images
|
||||||
class CTownInfo : public CIntObject
|
class CTownInfo : public CIntObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -96,15 +149,13 @@ class CCastleInterface : public CWindowWithGarrison
|
|||||||
void clickRight(tribool down, bool previousState);
|
void clickRight(tribool down, bool previousState);
|
||||||
void show(SDL_Surface * to);
|
void show(SDL_Surface * to);
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool showing; //indicates if interface is active
|
CCastleBuildings *builds;
|
||||||
CBuildingRect * hBuild; //highlighted building
|
|
||||||
SDL_Surface * townInt;
|
SDL_Surface * townInt;
|
||||||
SDL_Surface * cityBg;
|
|
||||||
const CGTownInstance * town;
|
const CGTownInstance * town;
|
||||||
CStatusBar * statusbar;
|
CStatusBar * statusbar;
|
||||||
CResDataBar *resdatabar;
|
CResDataBar *resdatabar;
|
||||||
unsigned char animval, count;
|
|
||||||
int winMode;//0=right-click popup, 1 = normal, 2 = town hall only, 3 = fort only;
|
int winMode;//0=right-click popup, 1 = normal, 2 = town hall only, 3 = fort only;
|
||||||
|
|
||||||
CDefEssential *bars, //0 - yellow, 1 - green, 2 - red, 3 - gray
|
CDefEssential *bars, //0 - yellow, 1 - green, 2 - red, 3 - gray
|
||||||
@ -118,7 +169,6 @@ public:
|
|||||||
AdventureMapButton *split;
|
AdventureMapButton *split;
|
||||||
|
|
||||||
std::vector<CCreaInfo*> creainfo;//small icons of creatures (bottom-left corner);
|
std::vector<CCreaInfo*> creainfo;//small icons of creatures (bottom-left corner);
|
||||||
std::vector<CBuildingRect*> buildings; //building id, building def, structure struct, border, filling
|
|
||||||
|
|
||||||
CCastleInterface(const CGTownInstance * Town, int listPos = 1); //c-tor
|
CCastleInterface(const CGTownInstance * Town, int listPos = 1); //c-tor
|
||||||
~CCastleInterface(); //d-tor
|
~CCastleInterface(); //d-tor
|
||||||
@ -128,22 +178,12 @@ public:
|
|||||||
void keyPressed(const SDL_KeyboardEvent & key);
|
void keyPressed(const SDL_KeyboardEvent & key);
|
||||||
void show(SDL_Surface * to);
|
void show(SDL_Surface * to);
|
||||||
void showAll(SDL_Surface * to);
|
void showAll(SDL_Surface * to);
|
||||||
void buildingClicked(int building);
|
|
||||||
void defaultBuildingClicked(int building);//for buildings with simple description + pic left-click messages
|
|
||||||
void enterFountain(int building);
|
|
||||||
void enterBlacksmith(int ArtifactID);//support for blacksmith + ballista yard
|
|
||||||
void enterTavern();
|
|
||||||
void enterMageGuild();
|
|
||||||
void splitClicked(); //for hero meeting (splitting stacks is handled by garrison int)
|
void splitClicked(); //for hero meeting (splitting stacks is handled by garrison int)
|
||||||
void showRecruitmentWindow( int level );
|
|
||||||
void enterHall();
|
|
||||||
void close();
|
void close();
|
||||||
void splitF();
|
|
||||||
void activate();
|
void activate();
|
||||||
void deactivate();
|
void deactivate();
|
||||||
void addBuilding(int bid);
|
void addBuilding(int bid);
|
||||||
void removeBuilding(int bid);
|
void removeBuilding(int bid);
|
||||||
void recreateBuildings();
|
|
||||||
void recreateIcons();
|
void recreateIcons();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -153,7 +193,7 @@ class CHallInterface : public CIntObject
|
|||||||
public:
|
public:
|
||||||
CMinorResDataBar * resdatabar;
|
CMinorResDataBar * resdatabar;
|
||||||
|
|
||||||
/// The building information box which gets shown by right-clicking on a building image
|
/// Building box from town hall (building icon + subtitle)
|
||||||
class CBuildingBox : public CIntObject
|
class CBuildingBox : public CIntObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -169,7 +209,7 @@ public:
|
|||||||
~CBuildingBox(); //d-tor
|
~CBuildingBox(); //d-tor
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The actual building window where you can decide to buy a building or not
|
/// Window where you can decide to buy a building or not
|
||||||
class CBuildWindow: public CIntObject
|
class CBuildWindow: public CIntObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -263,7 +303,7 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The blacksmith window where you can buy one of the three war machines
|
/// The blacksmith window where you can buy available in town war machine
|
||||||
class CBlacksmithDialog : public CIntObject
|
class CBlacksmithDialog : public CIntObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -66,8 +66,15 @@ private:
|
|||||||
int curFrame, internalFrame; //number of currently displayed frame
|
int curFrame, internalFrame; //number of currently displayed frame
|
||||||
unsigned int frames; //number of frames
|
unsigned int frames; //number of frames
|
||||||
CCreatureAnim::EAnimType type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
|
CCreatureAnim::EAnimType type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
|
||||||
public:
|
|
||||||
|
template<int bpp>
|
||||||
|
int nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
||||||
|
int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
||||||
|
|
||||||
std::map<int, std::vector<int> > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group
|
std::map<int, std::vector<int> > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group
|
||||||
|
bool once;
|
||||||
|
|
||||||
|
public:
|
||||||
int fullWidth, fullHeight; //read-only, please!
|
int fullWidth, fullHeight; //read-only, please!
|
||||||
CCreatureAnimation(std::string name); //c-tor
|
CCreatureAnimation(std::string name); //c-tor
|
||||||
~CCreatureAnimation(); //d-tor
|
~CCreatureAnimation(); //d-tor
|
||||||
@ -75,17 +82,12 @@ public:
|
|||||||
void setType(CCreatureAnim::EAnimType type); //sets type of animation and cleares framecount
|
void setType(CCreatureAnim::EAnimType type); //sets type of animation and cleares framecount
|
||||||
CCreatureAnim::EAnimType getType() const; //returns type of animation
|
CCreatureAnim::EAnimType getType() const; //returns type of animation
|
||||||
|
|
||||||
|
|
||||||
template<int bpp>
|
|
||||||
int nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
|
||||||
int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
||||||
int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
|
||||||
void incrementFrame();
|
void incrementFrame();
|
||||||
int getFrame() const;
|
int getFrame() const;
|
||||||
bool onFirstFrameInGroup();
|
bool onFirstFrameInGroup();
|
||||||
bool onLastFrameInGroup();
|
bool onLastFrameInGroup();
|
||||||
|
|
||||||
bool once;
|
|
||||||
void playOnce(CCreatureAnim::EAnimType type); //plays once given stage of animation, then resets to 2
|
void playOnce(CCreatureAnim::EAnimType type); //plays once given stage of animation, then resets to 2
|
||||||
|
|
||||||
int framesInGroup(CCreatureAnim::EAnimType group) const; //retirns number of fromes in given group
|
int framesInGroup(CCreatureAnim::EAnimType group) const; //retirns number of fromes in given group
|
||||||
|
@ -224,8 +224,8 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Set environment vars to make window centered. Sometimes work, sometimes not. :/
|
//Set environment vars to make window centered. Sometimes work, sometimes not. :/
|
||||||
putenv("SDL_VIDEO_WINDOW_POS");
|
putenv((char*)"SDL_VIDEO_WINDOW_POS");
|
||||||
putenv("SDL_VIDEO_CENTERED=1");
|
putenv((char*)"SDL_VIDEO_CENTERED=1");
|
||||||
|
|
||||||
timeHandler total, pomtime;
|
timeHandler total, pomtime;
|
||||||
std::cout.flags(std::ios::unitbuf);
|
std::cout.flags(std::ios::unitbuf);
|
||||||
@ -482,6 +482,10 @@ void processCommand(const std::string &message)
|
|||||||
if(const CArtifactInstance *a = h->getArt(id2))
|
if(const CArtifactInstance *a = h->getArt(id2))
|
||||||
tlog4 << a->nodeName();
|
tlog4 << a->nodeName();
|
||||||
}
|
}
|
||||||
|
else if (what == "anim" )
|
||||||
|
{
|
||||||
|
CAnimation::getAnimInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(client && client->serv && client->serv->connected) //send to server
|
else if(client && client->serv && client->serv->connected) //send to server
|
||||||
{
|
{
|
||||||
|
@ -264,7 +264,7 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details)
|
|||||||
//TODO: smooth disappear / appear effect
|
//TODO: smooth disappear / appear effect
|
||||||
}
|
}
|
||||||
|
|
||||||
if (details.result != TryMoveHero::SUCCESS && details.result != TryMoveHero::FAILED //hero didn't change tile but visit succeeded
|
if ((details.result != TryMoveHero::SUCCESS && details.result != TryMoveHero::FAILED) //hero didn't change tile but visit succeeded
|
||||||
|| directlyAttackingCreature) // or creature was attacked from endangering tile.
|
|| directlyAttackingCreature) // or creature was attacked from endangering tile.
|
||||||
{
|
{
|
||||||
eraseCurrentPathOf(ho);
|
eraseCurrentPathOf(ho);
|
||||||
@ -1021,7 +1021,7 @@ void CPlayerInterface::heroBonusChanged( const CGHeroInstance *hero, const Bonus
|
|||||||
if(bonus.type == Bonus::NONE) return;
|
if(bonus.type == Bonus::NONE) return;
|
||||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||||
updateInfo(hero);
|
updateInfo(hero);
|
||||||
if (bonus.type == Bonus::FLYING_MOVEMENT || bonus.type == Bonus::WATER_WALKING && !gain)
|
if ((bonus.type == Bonus::FLYING_MOVEMENT || bonus.type == Bonus::WATER_WALKING) && !gain)
|
||||||
{
|
{
|
||||||
//recalculate paths because hero has lost bonus influencing pathfinding
|
//recalculate paths because hero has lost bonus influencing pathfinding
|
||||||
cb->recalculatePaths();
|
cb->recalculatePaths();
|
||||||
@ -1213,10 +1213,12 @@ void CPlayerInterface::objectPropertyChanged(const SetObjectProperty * sop)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(obj->ID == TOWNI_TYPE)
|
if(obj->ID == TOWNI_TYPE)
|
||||||
|
{
|
||||||
if(obj->tempOwner == playerID)
|
if(obj->tempOwner == playerID)
|
||||||
towns.push_back(static_cast<const CGTownInstance *>(obj));
|
towns.push_back(static_cast<const CGTownInstance *>(obj));
|
||||||
else
|
else
|
||||||
towns -= obj;
|
towns -= obj;
|
||||||
|
}
|
||||||
|
|
||||||
assert(cb->getTownsInfo().size() == towns.size());
|
assert(cb->getTownsInfo().size() == towns.size());
|
||||||
}
|
}
|
||||||
@ -1279,7 +1281,7 @@ void CPlayerInterface::newObject( const CGObjectInstance * obj )
|
|||||||
&& obj->pos-obj->getVisitableOffset() == LOCPLINT->castleInt->town->bestLocation())
|
&& obj->pos-obj->getVisitableOffset() == LOCPLINT->castleInt->town->bestLocation())
|
||||||
{
|
{
|
||||||
CCS->soundh->playSound(soundBase::newBuilding);
|
CCS->soundh->playSound(soundBase::newBuilding);
|
||||||
LOCPLINT->castleInt->recreateBuildings();
|
LOCPLINT->castleInt->addBuilding(20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2054,7 +2056,7 @@ void CPlayerInterface::showMarketWindow(const IMarket *market, const CGHeroInsta
|
|||||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||||
if(market->o->ID == 2) //Altar
|
if(market->o->ID == 2) //Altar
|
||||||
{
|
{
|
||||||
EMarketMode mode = market->availableModes().front();
|
//EMarketMode mode = market->availableModes().front();
|
||||||
if(market->allowsTrade(ARTIFACT_EXP) && visitor->getAlignment() != EVIL)
|
if(market->allowsTrade(ARTIFACT_EXP) && visitor->getAlignment() != EVIL)
|
||||||
GH.pushInt(new CAltarWindow(market, visitor, ARTIFACT_EXP));
|
GH.pushInt(new CAltarWindow(market, visitor, ARTIFACT_EXP));
|
||||||
else if(market->allowsTrade(CREATURE_EXP) && visitor->getAlignment() != GOOD)
|
else if(market->allowsTrade(CREATURE_EXP) && visitor->getAlignment() != GOOD)
|
||||||
@ -2158,7 +2160,7 @@ void CPlayerInterface::newStackInserted(const StackLocation &location, const CSt
|
|||||||
void CPlayerInterface::stacksRebalanced(const StackLocation &src, const StackLocation &dst, TQuantity count)
|
void CPlayerInterface::stacksRebalanced(const StackLocation &src, const StackLocation &dst, TQuantity count)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||||
bool updateInfobox = true;
|
//bool updateInfobox = true;
|
||||||
garrisonChanged(src.army, UPDATE_IF(src));
|
garrisonChanged(src.army, UPDATE_IF(src));
|
||||||
if(dst.army != src.army)
|
if(dst.army != src.army)
|
||||||
garrisonChanged(dst.army, UPDATE_IF(dst));
|
garrisonChanged(dst.army, UPDATE_IF(dst));
|
||||||
@ -2179,28 +2181,40 @@ void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const Artifact
|
|||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||||
BOOST_FOREACH(IShowActivable *isa, GH.listInt)
|
BOOST_FOREACH(IShowActivable *isa, GH.listInt)
|
||||||
|
{
|
||||||
if(isa->type & IShowActivable::WITH_ARTIFACTS)
|
if(isa->type & IShowActivable::WITH_ARTIFACTS)
|
||||||
|
{
|
||||||
BOOST_FOREACH(CArtifactsOfHero *aoh, (dynamic_cast<CWindowWithArtifacts*>(isa))->artSets)
|
BOOST_FOREACH(CArtifactsOfHero *aoh, (dynamic_cast<CWindowWithArtifacts*>(isa))->artSets)
|
||||||
aoh->artifactMoved(src, dst);
|
aoh->artifactMoved(src, dst);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CPlayerInterface::artifactAssembled(const ArtifactLocation &al)
|
void CPlayerInterface::artifactAssembled(const ArtifactLocation &al)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||||
BOOST_FOREACH(IShowActivable *isa, GH.listInt)
|
BOOST_FOREACH(IShowActivable *isa, GH.listInt)
|
||||||
|
{
|
||||||
if(isa->type & IShowActivable::WITH_ARTIFACTS)
|
if(isa->type & IShowActivable::WITH_ARTIFACTS)
|
||||||
|
{
|
||||||
BOOST_FOREACH(CArtifactsOfHero *aoh, (dynamic_cast<CWindowWithArtifacts*>(isa))->artSets)
|
BOOST_FOREACH(CArtifactsOfHero *aoh, (dynamic_cast<CWindowWithArtifacts*>(isa))->artSets)
|
||||||
aoh->artifactAssembled(al);
|
aoh->artifactAssembled(al);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al)
|
void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||||
BOOST_FOREACH(IShowActivable *isa, GH.listInt)
|
BOOST_FOREACH(IShowActivable *isa, GH.listInt)
|
||||||
|
{
|
||||||
if(isa->type & IShowActivable::WITH_ARTIFACTS)
|
if(isa->type & IShowActivable::WITH_ARTIFACTS)
|
||||||
|
{
|
||||||
BOOST_FOREACH(CArtifactsOfHero *aoh, (dynamic_cast<CWindowWithArtifacts*>(isa))->artSets)
|
BOOST_FOREACH(CArtifactsOfHero *aoh, (dynamic_cast<CWindowWithArtifacts*>(isa))->artSets)
|
||||||
aoh->artifactDisassembled(al);
|
aoh->artifactDisassembled(al);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boost::recursive_mutex * CPlayerInterface::pim = new boost::recursive_mutex;
|
boost::recursive_mutex * CPlayerInterface::pim = new boost::recursive_mutex;
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ void CGuiHandler::popInt( IShowActivable *top )
|
|||||||
if(listInt.size())
|
if(listInt.size())
|
||||||
listInt.front()->activate();
|
listInt.front()->activate();
|
||||||
totalRedraw();
|
totalRedraw();
|
||||||
|
fakeMouseMove();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuiHandler::popIntTotally( IShowActivable *top )
|
void CGuiHandler::popIntTotally( IShowActivable *top )
|
||||||
@ -333,7 +334,7 @@ void CGuiHandler::fakeMouseMove()
|
|||||||
|
|
||||||
evnt.motion = sme;
|
evnt.motion = sme;
|
||||||
current = &evnt;
|
current = &evnt;
|
||||||
handleMoveInterested(sme);
|
handleMouseMotion(&evnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuiHandler::run()
|
void CGuiHandler::run()
|
||||||
|
@ -494,6 +494,8 @@ void CGarrisonInt::setArmy(const CArmedInstance *army, bool bottomGarrison)
|
|||||||
CInfoWindow::CInfoWindow(std::string Text, int player, const TCompsInfo &comps, const TButtonsInfo &Buttons, bool delComps)
|
CInfoWindow::CInfoWindow(std::string Text, int player, const TCompsInfo &comps, const TButtonsInfo &Buttons, bool delComps)
|
||||||
{
|
{
|
||||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||||
|
|
||||||
|
type |= BLOCK_ADV_HOTKEYS;
|
||||||
ID = -1;
|
ID = -1;
|
||||||
for(int i=0;i<Buttons.size();i++)
|
for(int i=0;i<Buttons.size();i++)
|
||||||
{
|
{
|
||||||
@ -4919,9 +4921,9 @@ void LRClickableAreaOpenTown::clickLeft(tribool down, bool previousState)
|
|||||||
LOCPLINT->openTownWindow(town);
|
LOCPLINT->openTownWindow(town);
|
||||||
LOCPLINT->castleInt->winMode = type;
|
LOCPLINT->castleInt->winMode = type;
|
||||||
if ( type == 2 )
|
if ( type == 2 )
|
||||||
LOCPLINT->castleInt->buildingClicked(10);
|
LOCPLINT->castleInt->builds->buildingClicked(10);
|
||||||
else if ( type == 3 && town->fortLevel() )
|
else if ( type == 3 && town->fortLevel() )
|
||||||
LOCPLINT->castleInt->buildingClicked(7);
|
LOCPLINT->castleInt->builds->buildingClicked(7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +90,8 @@ GROUP
|
|||||||
19
|
19
|
||||||
CASTLE 6
|
CASTLE 6
|
||||||
GROUP
|
GROUP
|
||||||
|
21
|
||||||
|
GROUP
|
||||||
30
|
30
|
||||||
37
|
37
|
||||||
18
|
18
|
||||||
|
Reference in New Issue
Block a user