Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cSpriteMap Class Reference

#include <cSpriteMap.h>

Public Types

enum  P_TYPE_ { P_QTY }
 
typedef int ELEM_t
 what element/icon number of this sprite map? More...
 

Public Member Functions

 cSpriteMap () noexcept
 
virtual ~cSpriteMap ()
 
ELEM_t get_ElemQty () const noexcept
 
void ClearMap ()
 
virtual HRESULT put_TextureName (cStringF sFileName)
 
const cRectIGetElemRectX (ELEM_t nElem) const noexcept
 
cRectI GetElemRect (ELEM_t nElem) const
 
bool SetElemRect (ELEM_t nElem, cRectI rect)
 
cWinSize GetElemSize (ELEM_t nElem) const noexcept
 
PIXELS_t GetElemWidth (ELEM_t nElem) const noexcept
 
PIXELS_t GetElemHeight (ELEM_t nElem) const noexcept
 
bool SetGrid (int nx, int ny, PIXELS_t cx, PIXELS_t cy)
 
virtual HRESULT LoadMapProp (cStringA sKey, const cVariant &vArgs, const char **ppEnumTags, size_t nEnumTagSize=sizeof(char *))
 
HRESULT ReadMapScript (const FILECHAR_t *pszMapScript, const char **ppEnumTags=nullptr, size_t nSizeEnumElem=sizeof(char *))
 
HRESULT ReadMapHTML (const FILECHAR_t *pszMapFile, const char **ppEnumTags=nullptr, size_t nSizeEnumElem=sizeof(char *))
 
 UNITTEST_FRIEND (cSpriteMap)
 

Static Public Attributes

static const char * sm_Props [P_QTY+1]
 

Detailed Description

A Sub divided image/surface. Define the mapping of (maybe overlapping) rectangles inside a surface for sprite elements/frames. Similar to cFont16F, and cSurfaceFrames AKA Sprite sheet. NOT used as a texture for 3d objects. http://en.wikipedia.org/wiki/Sprite_%28computer_graphics%29 Subdivide as:

  1. a fixed size grid of frames / elements. (fixed sized elements/frames)
  2. an array of rectangles in the texture. (maybe variable sized)
    Note
    We can NOT TEXTURELOAD_FILTER this texture because we are mapping to specific coordinates!!!
    ASSUME texture is a Power of 2 texture to avoid DX stretching problems.

Member Typedef Documentation

◆ ELEM_t

what element/icon number of this sprite map?

Member Enumeration Documentation

◆ P_TYPE_

Enumerator
P_QTY 

Constructor & Destructor Documentation

◆ cSpriteMap()

GrayLib::cSpriteMap::cSpriteMap ( )
noexcept

◆ ~cSpriteMap()

GrayLib::cSpriteMap::~cSpriteMap ( )
virtual

Member Function Documentation

◆ ClearMap()

void GrayLib::cSpriteMap::ClearMap ( )
inline

◆ get_ElemQty()

ELEM_t GrayLib::cSpriteMap::get_ElemQty ( ) const
inlinenoexcept

◆ GetElemHeight()

PIXELS_t GrayLib::cSpriteMap::GetElemHeight ( ELEM_t  nElem) const
inlinenoexcept

◆ GetElemRect()

cRectI GrayLib::cSpriteMap::GetElemRect ( ELEM_t  nElem) const

Get the size of the source rect for a particular sprite element/frame.

Returns
empty rect if not existent.

◆ GetElemRectX()

const cRectI& GrayLib::cSpriteMap::GetElemRectX ( ELEM_t  nElem) const
inlinenoexcept

get a rectangle that is known to exist in m_aRects. ASSERT if not.

◆ GetElemSize()

cWinSize GrayLib::cSpriteMap::GetElemSize ( ELEM_t  nElem) const
inlinenoexcept

◆ GetElemWidth()

PIXELS_t GrayLib::cSpriteMap::GetElemWidth ( ELEM_t  nElem) const
inlinenoexcept

◆ LoadMapProp()

HRESULT GrayLib::cSpriteMap::LoadMapProp ( cStringA  sKey,
const cVariant vArgs,
const char **  ppEnumTags,
size_t  nEnumTagSize = sizeof(char*) 
)
virtual

◆ put_TextureName()

HRESULT GrayLib::cSpriteMap::put_TextureName ( cStringF  sFileName)
virtual

◆ ReadMapHTML()

HRESULT GrayLib::cSpriteMap::ReadMapHTML ( const FILECHAR_t pszMapFile,
const char **  ppEnumTags = nullptr,
size_t  nSizeEnumElem = sizeof(char*) 
)

Read a "<MAP>" section from a HTML type file.

  • pszMapFile = full path for loading Xml/HTML script. Define areas in the image via HTML map files. i.e. "<AREA SHAPE="RECT" COORDS="48,0,64,16" HREF="DLG_CONTROL_ScrollBarVPrev_MouseOver">" Can use tools like: Visual Studio HTML design panel (sort of). http://www.carlosag.net/Tools/XMap/ Forthtech Map Designer Pro v.2.20

◆ ReadMapScript()

HRESULT GrayLib::cSpriteMap::ReadMapScript ( const FILECHAR_t pszMapScript,
const char **  ppEnumTags = nullptr,
size_t  nSizeEnumElem = sizeof(char*) 
)

Read the rectangle mapping info from a INI type file.

  • pszMapScript = full path for loading ini script. assume m_Install.MakeFilePath(pszMapScript) Assume the script has the same name as the texture it maps.

◆ SetElemRect()

bool GrayLib::cSpriteMap::SetElemRect ( ELEM_t  nElem,
cRectI  rect 
)

Not a grid.

◆ SetGrid()

bool GrayLib::cSpriteMap::SetGrid ( int  nx,
int  ny,
PIXELS_t  cx,
PIXELS_t  cy 
)

The texture is made of a grid of cells/frames of all the same size. Compute all the rectangles in the grid. m_SizeEx

◆ UNITTEST_FRIEND()

GrayLib::cSpriteMap::UNITTEST_FRIEND ( cSpriteMap  )

Member Data Documentation

◆ sm_Props

const char * GrayLib::cSpriteMap::sm_Props
static
Initial value:
=
{
#define cSpriteMapProp(a,b,c)
nullptr,
}

The documentation for this class was generated from the following files: