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:
parent
369338e39f
commit
973a7cd4bb
BIN
data/fonts/BigDigitFont.xml
Normal file
BIN
data/fonts/BigDigitFont.xml
Normal file
Binary file not shown.
BIN
data/fonts/LayneHansomBigDigits.png
Normal file
BIN
data/fonts/LayneHansomBigDigits.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
@ -662,6 +662,7 @@ namespace GUIEngine
|
|||||||
ScalableFont* g_font;
|
ScalableFont* g_font;
|
||||||
ScalableFont* g_title_font;
|
ScalableFont* g_title_font;
|
||||||
ScalableFont* g_small_font;
|
ScalableFont* g_small_font;
|
||||||
|
ScalableFont* g_digit_font;
|
||||||
|
|
||||||
IrrlichtDevice* g_device;
|
IrrlichtDevice* g_device;
|
||||||
IVideoDriver* g_driver;
|
IVideoDriver* g_driver;
|
||||||
@ -897,6 +898,8 @@ namespace GUIEngine
|
|||||||
//delete g_small_font;
|
//delete g_small_font;
|
||||||
g_small_font->drop();
|
g_small_font->drop();
|
||||||
g_small_font = NULL;
|
g_small_font = NULL;
|
||||||
|
g_digit_font->drop();
|
||||||
|
g_digit_font = NULL;
|
||||||
|
|
||||||
// nothing else to delete for now AFAIK, irrlicht will automatically
|
// nothing else to delete for now AFAIK, irrlicht will automatically
|
||||||
// kill everything along the device
|
// kill everything along the device
|
||||||
@ -982,6 +985,12 @@ namespace GUIEngine
|
|||||||
sfont->setKerningHeight(-5);
|
sfont->setKerningHeight(-5);
|
||||||
g_font = sfont;
|
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;
|
Private::font_height = g_font->getDimension( L"X" ).Height;
|
||||||
|
|
||||||
ScalableFont* sfont_smaller = sfont->getHollowCopy();
|
ScalableFont* sfont_smaller = sfont->getHollowCopy();
|
||||||
@ -992,6 +1001,7 @@ namespace GUIEngine
|
|||||||
Private::small_font_height =
|
Private::small_font_height =
|
||||||
g_small_font->getDimension( L"X" ).Height;
|
g_small_font->getDimension( L"X" ).Height;
|
||||||
|
|
||||||
|
|
||||||
ScalableFont* sfont2 =
|
ScalableFont* sfont2 =
|
||||||
new ScalableFont(g_env,
|
new ScalableFont(g_env,
|
||||||
file_manager->getFontFile("title_font.xml").c_str());
|
file_manager->getFontFile("title_font.xml").c_str());
|
||||||
|
@ -84,6 +84,7 @@ namespace GUIEngine
|
|||||||
extern irr::gui::ScalableFont* g_small_font;
|
extern irr::gui::ScalableFont* g_small_font;
|
||||||
extern irr::gui::ScalableFont* g_font;
|
extern irr::gui::ScalableFont* g_font;
|
||||||
extern irr::gui::ScalableFont* g_title_font;
|
extern irr::gui::ScalableFont* g_title_font;
|
||||||
|
extern irr::gui::ScalableFont* g_digit_font;
|
||||||
|
|
||||||
extern irr::IrrlichtDevice* g_device;
|
extern irr::IrrlichtDevice* g_device;
|
||||||
extern irr::video::IVideoDriver* g_driver;
|
extern irr::video::IVideoDriver* g_driver;
|
||||||
@ -134,6 +135,11 @@ namespace GUIEngine
|
|||||||
*/
|
*/
|
||||||
inline irr::gui::ScalableFont* getFont() { return Private::g_font; }
|
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)
|
* \return the "title" font (it's bigger and orange, useful for headers/captions)
|
||||||
*/
|
*/
|
||||||
|
@ -55,7 +55,11 @@ ScalableFont::ScalableFont(IGUIEnvironment *env, const io::path& filename)
|
|||||||
setInvisibleCharacters ( L" " );
|
setInvisibleCharacters ( L" " );
|
||||||
|
|
||||||
io::IXMLReader* reader = file_manager->createXMLReader(filename.c_str());
|
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();
|
reader->drop();
|
||||||
|
|
||||||
assert(Areas.size() > 0);
|
assert(Areas.size() > 0);
|
||||||
@ -227,7 +231,10 @@ void ScalableFont::doReadXmlFile(io::IXMLReader* xml)
|
|||||||
bool ScalableFont::load(io::IXMLReader* xml)
|
bool ScalableFont::load(io::IXMLReader* xml)
|
||||||
{
|
{
|
||||||
if (!SpriteBank)
|
if (!SpriteBank)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "[ScalableFont::load] SpriteBank is NULL!!\n");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
doReadXmlFile(xml);
|
doReadXmlFile(xml);
|
||||||
|
|
||||||
|
@ -55,8 +55,6 @@ class ScalableFont : public IGUIFontBitmap
|
|||||||
|
|
||||||
std::map<int /* texture file ID */, TextureInfo> m_texture_files;
|
std::map<int /* texture file ID */, TextureInfo> m_texture_files;
|
||||||
|
|
||||||
void lazyLoadTexture(int texID);
|
|
||||||
|
|
||||||
void doReadXmlFile(io::IXMLReader* xml);
|
void doReadXmlFile(io::IXMLReader* xml);
|
||||||
|
|
||||||
bool m_is_hollow_copy;
|
bool m_is_hollow_copy;
|
||||||
@ -99,6 +97,8 @@ public:
|
|||||||
//! loads a font from an XML file
|
//! loads a font from an XML file
|
||||||
bool load(io::IXMLReader* xml);
|
bool load(io::IXMLReader* xml);
|
||||||
|
|
||||||
|
void lazyLoadTexture(int texID);
|
||||||
|
|
||||||
//! draws an text and clips it to the specified rectangle if wanted
|
//! draws an text and clips it to the specified rectangle if wanted
|
||||||
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
|
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
|
||||||
video::SColor color, bool hcenter=false,
|
video::SColor color, bool hcenter=false,
|
||||||
|
@ -754,13 +754,16 @@ bool Track::loadMainTrack(const XMLNode &root)
|
|||||||
m_force_fields.push_back(OverworldForceField(xyz, shown, val));
|
m_force_fields.push_back(OverworldForceField(xyz, shown, val));
|
||||||
|
|
||||||
core::stringw msg = StringUtils::toWString(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();
|
scene::ISceneManager* sm = irr_driver->getSceneManager();
|
||||||
sm->addBillboardTextSceneNode(GUIEngine::getFont(),
|
|
||||||
|
assert(GUIEngine::getHighresDigitFont() != NULL);
|
||||||
|
|
||||||
|
sm->addBillboardTextSceneNode(GUIEngine::getHighresDigitFont(),
|
||||||
msg.c_str(),
|
msg.c_str(),
|
||||||
NULL,
|
NULL,
|
||||||
core::dimension2df(textsize.Width/15.0f,
|
core::dimension2df(textsize.Width/45.0f,
|
||||||
textsize.Height/15.0f),
|
textsize.Height/45.0f),
|
||||||
xyz,
|
xyz,
|
||||||
-1 /* id */,
|
-1 /* id */,
|
||||||
video::SColor(255, 255, 225, 0),
|
video::SColor(255, 255, 225, 0),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user