Played with a shadow feature to the fonts; not used now, but leaving the code in just in case we ever want that (and it's sorta likely to happen); the code also doesn't hurt to stay there if unused

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4244 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-12-05 23:47:33 +00:00
parent aa003ef977
commit f3f9829336
2 changed files with 24 additions and 2 deletions

View File

@ -28,6 +28,7 @@ ScalableFont::ScalableFont(IGUIEnvironment *env, const io::path& filename)
#endif #endif
m_scale = 1.0f; m_scale = 1.0f;
m_shadow = false;
if (Environment) if (Environment)
{ {
@ -57,7 +58,11 @@ ScalableFont::~ScalableFont()
if (SpriteBank) if (SpriteBank)
SpriteBank->drop(); SpriteBank->drop();
} }
void ScalableFont::setShadow(irr::video::SColor col)
{
m_shadow = true;
m_shadow_color = col;
}
//! loads a font file from xml //! loads a font file from xml
bool ScalableFont::load(io::IXMLReader* xml) bool ScalableFont::load(io::IXMLReader* xml)
@ -487,6 +492,19 @@ void ScalableFont::draw(const core::stringw& text, const core::rect<s32>& positi
if (!Driver) if (!Driver)
return; return;
if (m_shadow)
{
m_shadow = false; // avoid infinite recursion
core::rect<s32> shadowpos = position;
shadowpos.LowerRightCorner.X += 2;
shadowpos.LowerRightCorner.Y += 2;
draw(text, shadowpos, m_shadow_color, hcenter, vcenter, clip);
m_shadow = true; // set back
}
//color = video::SColor(255,255,255,255); //color = video::SColor(255,255,255,255);
core::dimension2d<s32> textDimension; core::dimension2d<s32> textDimension;

View File

@ -31,6 +31,8 @@ namespace gui
class ScalableFont : public IGUIFontBitmap class ScalableFont : public IGUIFontBitmap
{ {
float m_scale; float m_scale;
bool m_shadow;
irr::video::SColor m_shadow_color;
public: public:
//! constructor //! constructor
@ -70,6 +72,8 @@ public:
virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const; virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const;
virtual s32 getKerningHeight() const; virtual s32 getKerningHeight() const;
void setShadow(irr::video::SColor col);
//! gets the sprite bank //! gets the sprite bank
virtual IGUISpriteBank* getSpriteBank() const; virtual IGUISpriteBank* getSpriteBank() const;