Skip to content
Browse files

Use a sigmar as big digit font and display time and

lap using this font (temporarily till we agree on a font).
  • Loading branch information...
1 parent 9ae8446 commit 1dc63849c9eda5faf0c4ef62286b381e497a3cb6 @hiker hiker committed
View
BIN data/fonts/BigDigitFont.xml 100644 → 100755
Binary file not shown.
View
BIN data/fonts/sigmar0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
1 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;
View
106 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;
-
- m_timer_width = font->getDimension(L"99:99:99").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;
- 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<s32>(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());
-
-
- // Don't display laps in follow the leader mode
- if(world->raceHasLaps())
- {
- const int lap = world->getKartLaps(kart->getWorldKartId());
+ std::ostringstream out;
+ out << lap + 1 << "/" << race_manager->getNumLaps();
- // 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;
- }
- }
+ 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);
-} // drawRankLap
+} // drawLap
View
21 src/states_screens/race_gui.hpp
@@ -44,12 +44,6 @@ class RaceGUI : public RaceGUIBase
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 @@ class RaceGUI : public RaceGUIBase
/** 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 @@ class RaceGUI : public RaceGUIBase
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 ();

0 comments on commit 1dc6384

Please sign in to comment.
Something went wrong with that request. Please try again.