Use higher-res font for the digits in the overworld

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10756 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2012-01-30 00:27:53 +00:00
parent 369338e39f
commit 973a7cd4bb
7 changed files with 34 additions and 8 deletions

BIN
data/fonts/BigDigitFont.xml Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -662,6 +662,7 @@ namespace GUIEngine
ScalableFont* g_font;
ScalableFont* g_title_font;
ScalableFont* g_small_font;
ScalableFont* g_digit_font;
IrrlichtDevice* g_device;
IVideoDriver* g_driver;
@ -897,6 +898,8 @@ namespace GUIEngine
//delete g_small_font;
g_small_font->drop();
g_small_font = NULL;
g_digit_font->drop();
g_digit_font = NULL;
// nothing else to delete for now AFAIK, irrlicht will automatically
// kill everything along the device
@ -982,6 +985,12 @@ namespace GUIEngine
sfont->setKerningHeight(-5);
g_font = sfont;
ScalableFont* digit_font =
new ScalableFont(g_env,
file_manager->getFontFile("BigDigitFont.xml").c_str());
digit_font->lazyLoadTexture(0); // make sure the texture is loaded for this one
g_digit_font = digit_font;
Private::font_height = g_font->getDimension( L"X" ).Height;
ScalableFont* sfont_smaller = sfont->getHollowCopy();
@ -992,6 +1001,7 @@ namespace GUIEngine
Private::small_font_height =
g_small_font->getDimension( L"X" ).Height;
ScalableFont* sfont2 =
new ScalableFont(g_env,
file_manager->getFontFile("title_font.xml").c_str());

View File

@ -84,6 +84,7 @@ namespace GUIEngine
extern irr::gui::ScalableFont* g_small_font;
extern irr::gui::ScalableFont* g_font;
extern irr::gui::ScalableFont* g_title_font;
extern irr::gui::ScalableFont* g_digit_font;
extern irr::IrrlichtDevice* g_device;
extern irr::video::IVideoDriver* g_driver;
@ -134,6 +135,11 @@ namespace GUIEngine
*/
inline irr::gui::ScalableFont* getFont() { return Private::g_font; }
/**
* \return the "high-res digits" font (useful for big numbers)
*/
inline irr::gui::ScalableFont* getHighresDigitFont() { return Private::g_digit_font; }
/**
* \return the "title" font (it's bigger and orange, useful for headers/captions)
*/

View File

@ -55,7 +55,11 @@ ScalableFont::ScalableFont(IGUIEnvironment *env, const io::path& filename)
setInvisibleCharacters ( L" " );
io::IXMLReader* reader = file_manager->createXMLReader(filename.c_str());
load( reader );
if (!load( reader ))
{
fprintf(stderr, "[ScalableFont] Loading font failed\n");
assert(false);
}
reader->drop();
assert(Areas.size() > 0);
@ -227,7 +231,10 @@ void ScalableFont::doReadXmlFile(io::IXMLReader* xml)
bool ScalableFont::load(io::IXMLReader* xml)
{
if (!SpriteBank)
{
fprintf(stderr, "[ScalableFont::load] SpriteBank is NULL!!\n");
return false;
}
doReadXmlFile(xml);

View File

@ -55,8 +55,6 @@ class ScalableFont : public IGUIFontBitmap
std::map<int /* texture file ID */, TextureInfo> m_texture_files;
void lazyLoadTexture(int texID);
void doReadXmlFile(io::IXMLReader* xml);
bool m_is_hollow_copy;
@ -99,6 +97,8 @@ public:
//! loads a font from an XML file
bool load(io::IXMLReader* xml);
void lazyLoadTexture(int texID);
//! draws an text and clips it to the specified rectangle if wanted
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
video::SColor color, bool hcenter=false,

View File

@ -754,13 +754,16 @@ bool Track::loadMainTrack(const XMLNode &root)
m_force_fields.push_back(OverworldForceField(xyz, shown, val));
core::stringw msg = StringUtils::toWString(val);
core::dimension2d<u32> textsize = GUIEngine::getFont()->getDimension(msg.c_str());
core::dimension2d<u32> textsize = GUIEngine::getHighresDigitFont()->getDimension(msg.c_str());
scene::ISceneManager* sm = irr_driver->getSceneManager();
sm->addBillboardTextSceneNode(GUIEngine::getFont(),
assert(GUIEngine::getHighresDigitFont() != NULL);
sm->addBillboardTextSceneNode(GUIEngine::getHighresDigitFont(),
msg.c_str(),
NULL,
core::dimension2df(textsize.Width/15.0f,
textsize.Height/15.0f),
core::dimension2df(textsize.Width/45.0f,
textsize.Height/45.0f),
xyz,
-1 /* id */,
video::SColor(255, 255, 225, 0),