1
0
forked from 0ad/0ad
0ad/source/gui/CGUISprite.cpp
2004-12-19 12:20:04 +00:00

51 lines
1.1 KiB
C++
Executable File

#include "precompiled.h"
#include "CGUISprite.h"
void CGUISpriteInstance::Draw(CRect Size, int CellID, std::map<CStr, CGUISprite> &Sprites)
{
if (m_CachedSize != Size || m_CachedCellID != CellID)
{
GUIRenderer::UpdateDrawCallCache(m_DrawCallCache, m_SpriteName, Size, CellID, Sprites);
m_CachedSize = Size;
m_CachedCellID = CellID;
}
GUIRenderer::Draw(m_DrawCallCache);
}
void CGUISpriteInstance::Invalidate()
{
m_CachedSize = CRect();
}
bool CGUISpriteInstance::IsEmpty() const
{
return m_SpriteName=="";
}
// Plus a load of constructors / assignment operators, which don't copy the
// DrawCall cache (to avoid losing track of who has allocated various bits
// of data):
CGUISpriteInstance::CGUISpriteInstance()
{
}
CGUISpriteInstance::CGUISpriteInstance(CStr SpriteName)
: m_SpriteName(SpriteName)
{
}
CGUISpriteInstance::CGUISpriteInstance(const CGUISpriteInstance &Sprite)
: m_SpriteName(Sprite.m_SpriteName)
{
}
CGUISpriteInstance &CGUISpriteInstance::operator=(CStr SpriteName)
{
m_SpriteName = SpriteName;
m_DrawCallCache.clear();
Invalidate();
return *this;
}