2019-07-09 02:18:48 +02:00
|
|
|
/* Copyright (C) 2019 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);
|
|
|
|
}
|
|
|
|
|
2019-08-21 12:12:33 +02:00
|
|
|
void CGUISpriteInstance::Draw(CGUI& pGUI, const CRect& Size, int CellID, std::map<CStr, const CGUISprite*>& Sprites, float Z) const
|
2004-12-15 22:24:46 +01:00
|
|
|
{
|
2004-12-18 14:32:00 +01:00
|
|
|
if (m_CachedSize != Size || m_CachedCellID != CellID)
|
2004-12-15 22:24:46 +01:00
|
|
|
{
|
Delete wrongful proxy CGUIManager::GetPreDefinedColor from f0d9806b3f.
It is wrong because the predefined colors should be loaded from the GUI
page that requests to have the color parsed, which may be different from
the topmost page.
Similar to FindObjectByName removed in f9b529f2fb.
Achieve this by implementing the CGUISetting<CGUIColor>::FromJSVal
specialization, moved from ScriptInterface::FromJSVal<CGUIColor>,
instead of adding a CGUI pointer to CGUIColor.
Mark ScriptInterface::FromJSVal<GUIColor> and inherited
CColor::ParseString explicitly as deleted, so that people get a compile
error if they forget to check for predefined colors when parsing a
color.
Refs #5387, D1746 > D1684 > this > f9b529f2fb, 9be8a560a9, 415939b59b,
2c47fbd66a, 85a622b13a.
Differential Revision: https://code.wildfiregames.com/D2108
Tested on: clang 8, VS2015
This was SVN commit r22663.
2019-08-13 20:00:41 +02:00
|
|
|
GUIRenderer::UpdateDrawCallCache(pGUI, m_DrawCallCache, m_SpriteName, Size, CellID, Sprites);
|
2004-12-15 22:24:46 +01:00
|
|
|
m_CachedSize = Size;
|
2004-12-18 14:32:00 +01:00
|
|
|
m_CachedCellID = CellID;
|
2004-12-15 22:24:46 +01:00
|
|
|
}
|
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()
|
2005-10-30 00:50:54 +02:00
|
|
|
: m_CachedCellID(-1)
|
2004-12-19 13:20:04 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-07-20 16:37:58 +02:00
|
|
|
CGUISpriteInstance::CGUISpriteInstance(const CStr& SpriteName)
|
2011-02-20 21:52:35 +01:00
|
|
|
: m_SpriteName(SpriteName), m_CachedCellID(-1)
|
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();
|
2019-07-29 00:40:58 +02:00
|
|
|
m_CachedCellID = -1;
|
2004-12-19 13:20:04 +01:00
|
|
|
}
|