2021-03-27 12:38:34 +01:00
|
|
|
/* Copyright (C) 2021 Wildfire Games.
|
2009-04-18 19:00:33 +02:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2004-06-03 20:38:14 +02:00
|
|
|
#include "precompiled.h"
|
2015-08-21 19:08:41 +02:00
|
|
|
|
2004-12-15 22:24:46 +01:00
|
|
|
#include "CGUISprite.h"
|
|
|
|
|
2014-01-03 21:19:43 +01:00
|
|
|
CGUISprite::~CGUISprite()
|
|
|
|
{
|
2015-08-21 19:08:41 +02:00
|
|
|
for (SGUIImage* const& img : m_Images)
|
|
|
|
delete img;
|
2014-01-03 21:19:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGUISprite::AddImage(SGUIImage* image)
|
|
|
|
{
|
|
|
|
m_Images.push_back(image);
|
|
|
|
}
|
|
|
|
|
2021-03-27 12:38:34 +01:00
|
|
|
void CGUISpriteInstance::Draw(CGUI& pGUI, const CRect& Size, std::map<CStr, const CGUISprite*>& Sprites, float Z) const
|
2004-12-15 22:24:46 +01:00
|
|
|
{
|
2021-03-27 12:38:34 +01:00
|
|
|
if (m_CachedSize != Size)
|
2004-12-15 22:24:46 +01:00
|
|
|
{
|
2021-03-27 12:38:34 +01:00
|
|
|
GUIRenderer::UpdateDrawCallCache(pGUI, m_DrawCallCache, m_SpriteName, Size, Sprites);
|
2004-12-15 22:24:46 +01:00
|
|
|
m_CachedSize = Size;
|
|
|
|
}
|
2012-01-29 21:04:21 +01:00
|
|
|
GUIRenderer::Draw(m_DrawCallCache, Z);
|
2004-12-15 22:24:46 +01:00
|
|
|
}
|
|
|
|
|
2004-12-19 13:20:04 +01:00
|
|
|
// 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()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-07-20 16:37:58 +02:00
|
|
|
CGUISpriteInstance::CGUISpriteInstance(const CStr& SpriteName)
|
2021-03-27 12:38:34 +01:00
|
|
|
: m_SpriteName(SpriteName)
|
2004-12-19 13:20:04 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-07-29 00:40:58 +02:00
|
|
|
void CGUISpriteInstance::SetName(const CStr& SpriteName)
|
2004-12-19 13:20:04 +01:00
|
|
|
{
|
|
|
|
m_SpriteName = SpriteName;
|
2019-07-29 00:40:58 +02:00
|
|
|
m_CachedSize = CRect();
|
2004-12-19 13:20:04 +01:00
|
|
|
m_DrawCallCache.clear();
|
|
|
|
}
|