Files
vcmi/client/CDefHandler.h
T

105 lines
2.1 KiB
C++
Raw Normal View History

#pragma once
2013-02-05 19:56:28 +00:00
#include "../lib/vcmi_endian.h"
2010-08-17 14:58:13 +00:00
2009-04-16 11:14:13 +00:00
struct SDL_Surface;
struct SDL_Color;
2009-04-16 11:14:13 +00:00
/*
* CDefHandler.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
2009-04-16 11:14:13 +00:00
*/
struct Cimage
{
int groupNumber;
std::string imName; //name without extension
SDL_Surface * bitmap;
};
// Def entry in file. Integer fields are all little endian and will
// need to be converted.
2013-02-05 19:56:28 +00:00
struct SDefEntryBlock
{
2010-08-17 14:58:13 +00:00
ui32 unknown1;
ui32 totalInBlock;
ui32 unknown2;
ui32 unknown3;
ui8 data[0];
2013-02-05 19:56:28 +00:00
} PACKED_STRUCT;
// Def entry in file. Integer fields are all little endian and will
// need to be converted.
2013-02-05 19:56:28 +00:00
struct SDefEntry
{
2010-08-17 14:58:13 +00:00
ui32 DEFType;
ui32 width;
ui32 height;
ui32 totalBlocks;
struct {
ui8 R;
ui8 G;
ui8 B;
} palette[256];
// SDefEntry is followed by a series of SDefEntryBlock
// This is commented out because VC++ doesn't accept C99 syntax.
//struct SDefEntryBlock blocks[];
2013-02-05 19:56:28 +00:00
} PACKED_STRUCT;
// Def entry in file. Integer fields are all little endian and will
// need to be converted.
2013-02-05 19:56:28 +00:00
struct SSpriteDef
{
2010-08-17 14:58:13 +00:00
ui32 prSize;
ui32 defType2;
ui32 FullWidth;
ui32 FullHeight;
ui32 SpriteWidth;
ui32 SpriteHeight;
ui32 LeftMargin;
ui32 TopMargin;
2013-02-05 19:56:28 +00:00
} PACKED_STRUCT;
2010-08-17 14:58:13 +00:00
class CDefEssential //DefHandler with images only
{
public:
std::vector<Cimage> ourImages;
~CDefEssential(); //d-tor
};
2009-04-16 11:14:13 +00:00
class CDefHandler
{
private:
ui32 DEFType;
2009-04-16 11:14:13 +00:00
struct SEntry
{
std::string name;
int offset;
int group;
} ;
std::vector<SEntry> SEntries ;
2015-09-02 18:27:56 +03:00
void openFromMemory(ui8 * table, const std::string & name);
SDL_Surface * getSprite (int SIndex, const ui8 * FDef, const SDL_Color * palette) const;
2009-04-16 11:14:13 +00:00
public:
int width, height; //width and height
2009-10-25 14:36:11 +00:00
std::string defName;
2009-04-16 11:14:13 +00:00
std::vector<Cimage> ourImages;
bool notFreeImgs;
CDefHandler(); //c-tor
~CDefHandler(); //d-tor
2015-09-02 18:27:56 +03:00
2009-04-16 11:14:13 +00:00
CDefEssential * essentialize();
2010-02-21 18:07:24 +00:00
static CDefHandler * giveDef(const std::string & defName);
static CDefEssential * giveDefEss(const std::string & defName);
2009-04-16 11:14:13 +00:00
};