From 1dc63849c9eda5faf0c4ef62286b381e497a3cb6 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 12 Jun 2014 09:27:45 +1000 Subject: [PATCH] Use a sigmar as big digit font and display time and lap using this font (temporarily till we agree on a font). --- data/fonts/BigDigitFont.xml | Bin 1696 -> 1330 bytes data/fonts/sigmar0.png | Bin 0 -> 2922 bytes src/guiengine/engine.cpp | 1 + src/states_screens/race_gui.cpp | 106 ++++++++++++-------------------- src/states_screens/race_gui.hpp | 21 +++---- 5 files changed, 50 insertions(+), 78 deletions(-) mode change 100644 => 100755 data/fonts/BigDigitFont.xml create mode 100755 data/fonts/sigmar0.png diff --git a/data/fonts/BigDigitFont.xml b/data/fonts/BigDigitFont.xml old mode 100644 new mode 100755 index 41536824d498e77ce15cc7648d01d6e17a4e1161..8ae41eeeb1df8a4e0f9d6349a650a6cedfc7411b GIT binary patch literal 1330 zcmbu9-A=+l5QWdJCcXpV+5p?qmYNFj9ee>q)Fuj~v<6>ZJ-f3Tr(`c0ynyb{%(rJx zXZrJ9VTBVu@Qx8au|tIfNY-QLXSz%Ff~}Q)bqv*=_t>TPAk_G)QAhGs+wcdbYjDBke0} z&kR*KY<#h*l29?$1cpe02@7rxi3JNR1H7t@Z zU=&rr6c9*7wPc)V+yG()v11gRLO3H0r*K2K5>*IP zdCEqVw4_AQ3=Gex1dUnmYRcitrk=5sazz8cYuUge66jKkf$(_b-_|dXj*Vl zioAiTh*~hyndctvXQxnTU7vP3>-9P!j*qZwkzRMan)Q$7mZehMQ1*t9>-p^E$d~6v zK&vIqGRAYDo0QhJ`7V@g@}wqdLECZEh0?c6`82j^7Y%%4g#W-Bt_be8JM3h?Q~u2m z{uhI}6i+nOSO?dVEsYk^2bhYwkt{DX983=(?skW5e2n0Y{TG7B%vvImMrlgl2r>Y; z79uYxCX}_1Zf=27oD}E>S8s}12;+cGLatz(DhjpXsW#g=uc@TKDh!~}J1Z$Fc&KRG zy2i!A+F$8U51}_2b*=s*_)ao{4qDpWL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H>V) zdOqpgjH8*)QEzPNM)_%0oWkn`~y*EQzbiL_1fD1REo@ufH;2B3tfX3Q# zeWBYbQ6QS2h%py|zcg9(0==m+3^#D0kXZ*7MdLBD;RxxclVzB3T`o=1D9c&P+3<_a z7tcXcpri=p^Edn4Aag>w<=G`LW53B zul$a_z&7HL%JP- z!PCdFnq7D7eL3CfFm6?Ljwxqo{18j-x@z&h(J#W$KD+L7p1pYa;IG(5y}nD8%?W4~ z7iWW%6eu)iB4@<$UHm{m$KC=X6O37_$YLE@a6ZDBE`1UeNkgru1a0cdOLQ!VoM#Lh zTyCh2rhAl^uZgj|WqH%_(1ghbcJ$#oC*vkSn^FAH)PWk{VZ&pqQ$DT*j6rUAXq~9s=ZF-X)|oRx6y&PCljUwyY>YaGe&#DKHNYoodTbzfykilKy)&7iP1R%@tUvE{on3%AWSVy}yF)z-+=_i%fs*U^5Bm9h zabjBZ^k>4e&C(6arQg3w9Dnrg9_T(gR?q|Vr*JB%q;@T^Mx*aTdwSH69qXIcUzB#d z@=1;cTKs1zXHBn01~cl>M^;ZLQvb45?}D<#BvBAE6^3wXWZ^)V};@%^J2 z74@y#Oa*K|W=G)|9_jeGR0l#4aJK~m8`LI}DDCSCN`d@)w6|$lC?%HdNXWgPU`pZl z{xy}8M44Oq<~)Fo&cTJb!YCN(rP{we!2cOvKRA&8rrrP0Kaj8bf2C|J>><_H?j`&e D<6oRy literal 0 HcmV?d00001 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 ();