2004-05-29 22:56:24 +02:00
|
|
|
#ifndef _TEXTUREENTRY_H
|
|
|
|
#define _TEXTUREENTRY_H
|
|
|
|
|
2004-12-07 03:04:38 +01:00
|
|
|
#include "res/handle.h"
|
2004-05-29 22:56:24 +02:00
|
|
|
#include "CStr.h"
|
2004-06-08 14:10:51 +02:00
|
|
|
|
2005-06-20 17:14:36 +02:00
|
|
|
#include "TextureManager.h"
|
|
|
|
|
|
|
|
class XMBElement;
|
|
|
|
class CXeromyces;
|
|
|
|
|
2004-06-08 14:10:51 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CTextureEntry: class wrapping a terrain texture object; contains various other required
|
2004-06-07 21:56:26 +02:00
|
|
|
// elements - color of minimap, terrain "group" it belongs to, etc
|
2004-05-29 22:56:24 +02:00
|
|
|
class CTextureEntry
|
|
|
|
{
|
|
|
|
public:
|
2005-06-20 17:14:36 +02:00
|
|
|
typedef std::vector<CTerrainTypeGroup *> GroupVector;
|
|
|
|
|
2004-12-16 13:01:47 +01:00
|
|
|
~CTextureEntry();
|
2004-06-08 14:10:51 +02:00
|
|
|
|
2005-06-20 17:14:36 +02:00
|
|
|
CStr GetTag() const
|
|
|
|
{ return m_Tag; }
|
|
|
|
|
|
|
|
CStr GetTexturePath() const
|
|
|
|
{ return m_TexturePath; }
|
2004-06-08 14:10:51 +02:00
|
|
|
|
|
|
|
// accessor - get UI bitmap object
|
|
|
|
void* GetBitmap() const { return m_Bitmap; }
|
|
|
|
// accessor - set UI bitmap object
|
|
|
|
void SetBitmap(void* bmp) { m_Bitmap=bmp; }
|
|
|
|
|
|
|
|
// accessor - get texture handle
|
|
|
|
Handle GetHandle() {
|
2004-12-16 13:01:47 +01:00
|
|
|
if (m_Handle==-1) LoadTexture();
|
2004-06-08 14:10:51 +02:00
|
|
|
return m_Handle;
|
|
|
|
}
|
|
|
|
// accessor - get mipmap color
|
|
|
|
u32 GetBaseColor() {
|
|
|
|
if (!m_BaseColorValid) BuildBaseColor();
|
|
|
|
return m_BaseColor;
|
|
|
|
}
|
2005-06-20 17:14:36 +02:00
|
|
|
|
2005-06-20 19:34:17 +02:00
|
|
|
int GetType() const
|
|
|
|
{ return m_Groups[0]->GetIndex(); }
|
2005-06-20 17:14:36 +02:00
|
|
|
const GroupVector &GetGroups() const
|
|
|
|
{ return m_Groups; }
|
|
|
|
|
2005-02-10 00:19:48 +01:00
|
|
|
// returns whether this texture-entry has loaded any data yet
|
|
|
|
bool IsLoaded() { return (m_Handle!=-1); }
|
2005-06-20 17:14:36 +02:00
|
|
|
|
|
|
|
static CTextureEntry *FromXML(XMBElement el, CXeromyces *pFile);
|
|
|
|
|
|
|
|
// Load all properties from the parent (run on all terrains after loading
|
|
|
|
// all the xml's or when changes has been made on the parent)
|
|
|
|
// This will only actually work once per instance (noop on subsequent calls)
|
|
|
|
void LoadParent();
|
2005-02-10 00:19:48 +01:00
|
|
|
|
2004-06-08 14:10:51 +02:00
|
|
|
private:
|
2005-06-20 17:14:36 +02:00
|
|
|
CTextureEntry();
|
|
|
|
|
2004-06-08 14:10:51 +02:00
|
|
|
// load texture from file
|
|
|
|
void LoadTexture();
|
|
|
|
// calculate the root color of the texture, used for coloring minimap
|
|
|
|
void BuildBaseColor();
|
|
|
|
|
2005-06-20 17:14:36 +02:00
|
|
|
CStr m_Tag;
|
|
|
|
CStr m_ParentName;
|
|
|
|
CTextureEntry *m_pParent;
|
|
|
|
|
|
|
|
CStr m_TexturePath;
|
|
|
|
void* m_Bitmap; // UI bitmap object (user data for ScEd)
|
|
|
|
Handle m_Handle; // handle to GL texture data
|
|
|
|
|
|
|
|
// BGRA color of topmost mipmap level, for coloring minimap, or a color
|
|
|
|
// manually specified in the Terrain XML (or by any parent)
|
|
|
|
// ..Valid is true if the base color is a cached value or an XML override
|
2004-06-08 14:10:51 +02:00
|
|
|
u32 m_BaseColor;
|
2004-06-07 21:56:26 +02:00
|
|
|
bool m_BaseColorValid;
|
2005-06-20 17:14:36 +02:00
|
|
|
|
|
|
|
// All terrain type groups we're a member of
|
|
|
|
GroupVector m_Groups;
|
2004-05-29 22:56:24 +02:00
|
|
|
};
|
|
|
|
|
2005-06-20 17:14:36 +02:00
|
|
|
#endif
|