diff --git a/data/fonts/BigDigitFont.xml b/data/fonts/BigDigitFont.xml old mode 100644 new mode 100755 index 41536824d..8ae41eeeb Binary files a/data/fonts/BigDigitFont.xml and b/data/fonts/BigDigitFont.xml differ diff --git a/data/fonts/sigmar0.png b/data/fonts/sigmar0.png new file mode 100755 index 000000000..1b6939531 Binary files /dev/null and b/data/fonts/sigmar0.png differ diff --git a/src/guiengine/engine.cpp b/src/guiengine/engine.cpp index 5c12232c1..2126d1f19 100644 --- a/src/guiengine/engine.cpp +++ b/src/guiengine/engine.cpp @@ -1072,6 +1072,7 @@ namespace GUIEngine file_manager->getAssetChecked(FileManager::FONT, "BigDigitFont.xml",true)); digit_font->lazyLoadTexture(0); // make sure the texture is loaded for this one + digit_font->setMonospaceDigits(true); g_digit_font = digit_font; Private::font_height = g_font->getDimension( L"X" ).Height; diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index 681e8e649..ec0d2f4b3 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -89,39 +89,19 @@ RaceGUI::RaceGUI() m_speed_bar_icon = material_manager->getMaterial("speedfore.png"); createMarkerTexture(); - // Translate strings only one in constructor to avoid calling - // gettext in each frame. - //I18N: Shown at the end of a race - m_string_lap = _("Lap"); - m_string_rank = _("Rank"); - - // Determine maximum length of the rank/lap text, in order to // align those texts properly on the right side of the viewport. - gui::ScalableFont* font = GUIEngine::getFont(); - m_rank_lap_width = font->getDimension(m_string_lap.c_str()).Width; + gui::ScalableFont* font = GUIEngine::getHighresDigitFont(); + core::dimension2du area = font->getDimension(L"99:99:99"); + m_timer_width = area.Width; + m_font_height = area.Height; - m_timer_width = font->getDimension(L"99:99:99").Width; - - font = (race_manager->getNumLocalPlayers() > 2 ? GUIEngine::getSmallFont() - : GUIEngine::getFont()); - - int w; if (race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER || race_manager->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES || race_manager->getNumLaps() > 9) - w = font->getDimension(L"99/99").Width; + m_lap_width = font->getDimension(L"99/99").Width; else - w = font->getDimension(L"9/9").Width; - - // In some split screen configuration the energy bar might be next - // to the lap display - so make the lap X/Y display large enough to - // leave space for the energy bar (16 pixels) and 10 pixels of space - // to the right (see drawEnergyMeter for details). - w += 16 + 10; - if(m_rank_lap_width < w) m_rank_lap_width = w; - w = font->getDimension(m_string_rank.c_str()).Width; - if(m_rank_lap_width < w) m_rank_lap_width = w; + m_lap_width = font->getDimension(L"9/9").Width; // Technically we only need getNumLocalPlayers, but using the // global kart id to find the data for a specific kart. @@ -225,15 +205,15 @@ void RaceGUI::renderPlayerView(const Camera *camera, float dt) drawPlungerInFace(camera, dt); scaling *= viewport.getWidth()/800.0f; // scale race GUI along screen size - drawAllMessages (kart, viewport, scaling); + drawAllMessages(kart, viewport, scaling); if(!World::getWorld()->isRacePhase()) return; - drawPowerupIcons (kart, viewport, scaling); - drawSpeedAndEnergy (kart, viewport, scaling); + drawPowerupIcons (kart, viewport, scaling); + drawSpeedEnergyRank(kart, viewport, scaling); if (!m_is_tutorial) - drawRankLap (kart, viewport); + drawLap(kart, viewport, scaling); RaceGUIBase::renderPlayerView(camera, dt); } // renderPlayerView @@ -344,7 +324,9 @@ void RaceGUI::drawGlobalTimer() pos += core::vector2d(0, UserConfigParams::m_height/2); } - gui::ScalableFont* font = GUIEngine::getFont(); + gui::ScalableFont* font = GUIEngine::getHighresDigitFont(); + font->setShadow(video::SColor(255, 128, 0, 0)); + font->setScale(1.0f); font->draw(sw.c_str(), pos, time_color, false, false, NULL, true /* ignore RTL */); @@ -609,7 +591,7 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart, //----------------------------------------------------------------------------- -void RaceGUI::drawSpeedAndEnergy(const AbstractKart* kart, +void RaceGUI::drawSpeedEnergyRank(const AbstractKart* kart, const core::recti &viewport, const core::vector2df &scaling) { @@ -775,31 +757,40 @@ void RaceGUI::drawSpeedAndEnergy(const AbstractKart* kart, m_last_ranks[id] = kart->getPosition(); } - font->setScale(min_ratio * scale * 0.7f); + font->setScale(min_ratio * scale); font->setShadow(video::SColor(255, 128, 0, 0)); static video::SColor color = video::SColor(255, 255, 255, 255); std::ostringstream oss; oss << rank; // the current font has no . :( << "."; - pos.LowerRightCorner = core::vector2di(offset.X+int(0.6f*meter_width), + pos.LowerRightCorner = core::vector2di(int(offset.X+0.6f*meter_width), int(offset.Y-0.5f*meter_height)); - pos.UpperLeftCorner = core::vector2di(offset.X+int(0.6f*meter_width), + pos.UpperLeftCorner = core::vector2di(int(offset.X+0.6f*meter_width), int(offset.Y-0.5f*meter_height)); font->draw(oss.str().c_str(), pos, color, true, true); + font->setScale(1.0f); } -} // drawSpeedAndEnergy +} // drawSpeedEnergyRank //----------------------------------------------------------------------------- /** Displays the rank and the lap of the kart. * \param info Info object c */ -void RaceGUI::drawRankLap(const AbstractKart* kart, - const core::recti &viewport) +void RaceGUI::drawLap(const AbstractKart* kart, + const core::recti &viewport, + const core::vector2df &scaling) { // Don't display laps or ranks if the kart has already finished the race. if (kart->hasFinishedRace()) return; + + World *world = World::getWorld(); + if (!world->raceHasLaps()) return; + const int lap = world->getKartLaps(kart->getWorldKartId()); + + // don't display 'lap 0/..' at the start of a race + if (lap < 0 ) return; core::recti pos; pos.UpperLeftCorner.Y = viewport.UpperLeftCorner.Y; @@ -809,37 +800,20 @@ void RaceGUI::drawRankLap(const AbstractKart* kart, if(viewport.UpperLeftCorner.Y==0 && viewport.LowerRightCorner.X==UserConfigParams::m_width && race_manager->getNumPlayers()!=3) - pos.UpperLeftCorner.Y += 40; - pos.LowerRightCorner.Y = viewport.LowerRightCorner.Y; + pos.UpperLeftCorner.Y += m_font_height; + pos.LowerRightCorner.Y = viewport.LowerRightCorner.Y+20; pos.UpperLeftCorner.X = viewport.LowerRightCorner.X - - m_rank_lap_width - 10; + - m_lap_width - 10; pos.LowerRightCorner.X = viewport.LowerRightCorner.X; - gui::ScalableFont* font = (race_manager->getNumLocalPlayers() > 2 - ? GUIEngine::getSmallFont() - : GUIEngine::getFont()); - int font_height = (int)(font->getDimension(L"X").Height); + gui::ScalableFont* font = GUIEngine::getHighresDigitFont(); static video::SColor color = video::SColor(255, 255, 255, 255); - WorldWithRank *world = (WorldWithRank*)(World::getWorld()); + std::ostringstream out; + out << lap + 1 << "/" << race_manager->getNumLaps(); + font = GUIEngine::getHighresDigitFont(); + font->setScale(scaling.Y < 1.0f ? 0.5f: 1.0f); + font->draw(out.str().c_str(), pos, color); + font->setScale(1.0f); - // Don't display laps in follow the leader mode - if(world->raceHasLaps()) - { - const int lap = world->getKartLaps(kart->getWorldKartId()); - - // don't display 'lap 0/...' - if(lap>=0) - { - font->draw(m_string_lap.c_str(), pos, color); - char str[256]; - sprintf(str, "%d/%d", lap+1, race_manager->getNumLaps()); - pos.UpperLeftCorner.Y += font_height; - pos.LowerRightCorner.Y += font_height; - font->draw(core::stringw(str).c_str(), pos, color); - pos.UpperLeftCorner.Y += font_height; - pos.LowerRightCorner.Y += font_height; - } - } - -} // drawRankLap +} // drawLap diff --git a/src/states_screens/race_gui.hpp b/src/states_screens/race_gui.hpp index 9e4f08c95..638c86593 100644 --- a/src/states_screens/race_gui.hpp +++ b/src/states_screens/race_gui.hpp @@ -44,12 +44,6 @@ private: Material *m_speed_meter_icon; Material *m_speed_bar_icon; - /** Translated string 'lap' displayed every frame. */ - core::stringw m_string_lap; - - /** Translated string 'rank' displayed every frame. */ - core::stringw m_string_rank; - // Minimap related variables // ------------------------- /** The mini map of the track. */ @@ -81,13 +75,15 @@ private: /** Distance of map from bottom of screen. */ int m_map_bottom; - /** Maximum string length of 'rank', 'lap', '99/99'. Used to position - * the rank/lap text correctly close to the right border. */ - int m_rank_lap_width; + /** Maximum lap display length (either 9/9 or 99/99). */ + int m_lap_width; /** Maximum string length for the timer */ int m_timer_width; + /** Height of the digit font. */ + int m_font_height; + /** Animation state: none, getting smaller (old value), * getting bigger (new number). */ enum AnimationState {AS_NONE, AS_SMALLER, AS_BIGGER}; @@ -105,11 +101,12 @@ private: void drawEnergyMeter (int x, int y, const AbstractKart *kart, const core::recti &viewport, const core::vector2df &scaling); - void drawSpeedAndEnergy (const AbstractKart* kart, + void drawSpeedEnergyRank (const AbstractKart* kart, + const core::recti &viewport, + const core::vector2df &scaling); + void drawLap (const AbstractKart* kart, const core::recti &viewport, const core::vector2df &scaling); - void drawRankLap (const AbstractKart* kart, - const core::recti &viewport); /** Display items that are shown once only (for all karts). */ void drawGlobalMiniMap ();