Use a sigmar as big digit font and display time and
lap using this font (temporarily till we agree on a font).
This commit is contained in:
parent
9ae8446fae
commit
1dc63849c9
BIN
data/fonts/BigDigitFont.xml
Normal file → Executable file
BIN
data/fonts/BigDigitFont.xml
Normal file → Executable file
Binary file not shown.
BIN
data/fonts/sigmar0.png
Executable file
BIN
data/fonts/sigmar0.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
@ -1072,6 +1072,7 @@ namespace GUIEngine
|
|||||||
file_manager->getAssetChecked(FileManager::FONT,
|
file_manager->getAssetChecked(FileManager::FONT,
|
||||||
"BigDigitFont.xml",true));
|
"BigDigitFont.xml",true));
|
||||||
digit_font->lazyLoadTexture(0); // make sure the texture is loaded for this one
|
digit_font->lazyLoadTexture(0); // make sure the texture is loaded for this one
|
||||||
|
digit_font->setMonospaceDigits(true);
|
||||||
g_digit_font = digit_font;
|
g_digit_font = digit_font;
|
||||||
|
|
||||||
Private::font_height = g_font->getDimension( L"X" ).Height;
|
Private::font_height = g_font->getDimension( L"X" ).Height;
|
||||||
|
@ -89,39 +89,19 @@ RaceGUI::RaceGUI()
|
|||||||
m_speed_bar_icon = material_manager->getMaterial("speedfore.png");
|
m_speed_bar_icon = material_manager->getMaterial("speedfore.png");
|
||||||
createMarkerTexture();
|
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
|
// Determine maximum length of the rank/lap text, in order to
|
||||||
// align those texts properly on the right side of the viewport.
|
// align those texts properly on the right side of the viewport.
|
||||||
gui::ScalableFont* font = GUIEngine::getFont();
|
gui::ScalableFont* font = GUIEngine::getHighresDigitFont();
|
||||||
m_rank_lap_width = font->getDimension(m_string_lap.c_str()).Width;
|
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 ||
|
if (race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER ||
|
||||||
race_manager->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES ||
|
race_manager->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES ||
|
||||||
race_manager->getNumLaps() > 9)
|
race_manager->getNumLaps() > 9)
|
||||||
w = font->getDimension(L"99/99").Width;
|
m_lap_width = font->getDimension(L"99/99").Width;
|
||||||
else
|
else
|
||||||
w = font->getDimension(L"9/9").Width;
|
m_lap_width = 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;
|
|
||||||
|
|
||||||
// Technically we only need getNumLocalPlayers, but using the
|
// Technically we only need getNumLocalPlayers, but using the
|
||||||
// global kart id to find the data for a specific kart.
|
// 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);
|
drawPlungerInFace(camera, dt);
|
||||||
|
|
||||||
scaling *= viewport.getWidth()/800.0f; // scale race GUI along screen size
|
scaling *= viewport.getWidth()/800.0f; // scale race GUI along screen size
|
||||||
drawAllMessages (kart, viewport, scaling);
|
drawAllMessages(kart, viewport, scaling);
|
||||||
|
|
||||||
if(!World::getWorld()->isRacePhase()) return;
|
if(!World::getWorld()->isRacePhase()) return;
|
||||||
|
|
||||||
drawPowerupIcons (kart, viewport, scaling);
|
drawPowerupIcons (kart, viewport, scaling);
|
||||||
drawSpeedAndEnergy (kart, viewport, scaling);
|
drawSpeedEnergyRank(kart, viewport, scaling);
|
||||||
|
|
||||||
if (!m_is_tutorial)
|
if (!m_is_tutorial)
|
||||||
drawRankLap (kart, viewport);
|
drawLap(kart, viewport, scaling);
|
||||||
|
|
||||||
RaceGUIBase::renderPlayerView(camera, dt);
|
RaceGUIBase::renderPlayerView(camera, dt);
|
||||||
} // renderPlayerView
|
} // renderPlayerView
|
||||||
@ -344,7 +324,9 @@ void RaceGUI::drawGlobalTimer()
|
|||||||
pos += core::vector2d<s32>(0, UserConfigParams::m_height/2);
|
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,
|
font->draw(sw.c_str(), pos, time_color, false, false, NULL,
|
||||||
true /* ignore RTL */);
|
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::recti &viewport,
|
||||||
const core::vector2df &scaling)
|
const core::vector2df &scaling)
|
||||||
{
|
{
|
||||||
@ -775,32 +757,41 @@ void RaceGUI::drawSpeedAndEnergy(const AbstractKart* kart,
|
|||||||
m_last_ranks[id] = kart->getPosition();
|
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));
|
font->setShadow(video::SColor(255, 128, 0, 0));
|
||||||
static video::SColor color = video::SColor(255, 255, 255, 255);
|
static video::SColor color = video::SColor(255, 255, 255, 255);
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << rank; // the current font has no . :( << ".";
|
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));
|
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));
|
int(offset.Y-0.5f*meter_height));
|
||||||
|
|
||||||
font->draw(oss.str().c_str(), pos, color, true, true);
|
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.
|
/** Displays the rank and the lap of the kart.
|
||||||
* \param info Info object c
|
* \param info Info object c
|
||||||
*/
|
*/
|
||||||
void RaceGUI::drawRankLap(const AbstractKart* kart,
|
void RaceGUI::drawLap(const AbstractKart* kart,
|
||||||
const core::recti &viewport)
|
const core::recti &viewport,
|
||||||
|
const core::vector2df &scaling)
|
||||||
{
|
{
|
||||||
// Don't display laps or ranks if the kart has already finished the race.
|
// Don't display laps or ranks if the kart has already finished the race.
|
||||||
if (kart->hasFinishedRace()) return;
|
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;
|
core::recti pos;
|
||||||
pos.UpperLeftCorner.Y = viewport.UpperLeftCorner.Y;
|
pos.UpperLeftCorner.Y = viewport.UpperLeftCorner.Y;
|
||||||
// If the time display in the top right is in this viewport,
|
// If the time display in the top right is in this viewport,
|
||||||
@ -809,37 +800,20 @@ void RaceGUI::drawRankLap(const AbstractKart* kart,
|
|||||||
if(viewport.UpperLeftCorner.Y==0 &&
|
if(viewport.UpperLeftCorner.Y==0 &&
|
||||||
viewport.LowerRightCorner.X==UserConfigParams::m_width &&
|
viewport.LowerRightCorner.X==UserConfigParams::m_width &&
|
||||||
race_manager->getNumPlayers()!=3)
|
race_manager->getNumPlayers()!=3)
|
||||||
pos.UpperLeftCorner.Y += 40;
|
pos.UpperLeftCorner.Y += m_font_height;
|
||||||
pos.LowerRightCorner.Y = viewport.LowerRightCorner.Y;
|
pos.LowerRightCorner.Y = viewport.LowerRightCorner.Y+20;
|
||||||
pos.UpperLeftCorner.X = viewport.LowerRightCorner.X
|
pos.UpperLeftCorner.X = viewport.LowerRightCorner.X
|
||||||
- m_rank_lap_width - 10;
|
- m_lap_width - 10;
|
||||||
pos.LowerRightCorner.X = viewport.LowerRightCorner.X;
|
pos.LowerRightCorner.X = viewport.LowerRightCorner.X;
|
||||||
|
|
||||||
gui::ScalableFont* font = (race_manager->getNumLocalPlayers() > 2
|
gui::ScalableFont* font = GUIEngine::getHighresDigitFont();
|
||||||
? GUIEngine::getSmallFont()
|
|
||||||
: GUIEngine::getFont());
|
|
||||||
int font_height = (int)(font->getDimension(L"X").Height);
|
|
||||||
static video::SColor color = video::SColor(255, 255, 255, 255);
|
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
|
} // drawLap
|
||||||
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
|
|
||||||
|
@ -44,12 +44,6 @@ private:
|
|||||||
Material *m_speed_meter_icon;
|
Material *m_speed_meter_icon;
|
||||||
Material *m_speed_bar_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
|
// Minimap related variables
|
||||||
// -------------------------
|
// -------------------------
|
||||||
/** The mini map of the track. */
|
/** The mini map of the track. */
|
||||||
@ -81,13 +75,15 @@ private:
|
|||||||
/** Distance of map from bottom of screen. */
|
/** Distance of map from bottom of screen. */
|
||||||
int m_map_bottom;
|
int m_map_bottom;
|
||||||
|
|
||||||
/** Maximum string length of 'rank', 'lap', '99/99'. Used to position
|
/** Maximum lap display length (either 9/9 or 99/99). */
|
||||||
* the rank/lap text correctly close to the right border. */
|
int m_lap_width;
|
||||||
int m_rank_lap_width;
|
|
||||||
|
|
||||||
/** Maximum string length for the timer */
|
/** Maximum string length for the timer */
|
||||||
int m_timer_width;
|
int m_timer_width;
|
||||||
|
|
||||||
|
/** Height of the digit font. */
|
||||||
|
int m_font_height;
|
||||||
|
|
||||||
/** Animation state: none, getting smaller (old value),
|
/** Animation state: none, getting smaller (old value),
|
||||||
* getting bigger (new number). */
|
* getting bigger (new number). */
|
||||||
enum AnimationState {AS_NONE, AS_SMALLER, AS_BIGGER};
|
enum AnimationState {AS_NONE, AS_SMALLER, AS_BIGGER};
|
||||||
@ -105,11 +101,12 @@ private:
|
|||||||
void drawEnergyMeter (int x, int y, const AbstractKart *kart,
|
void drawEnergyMeter (int x, int y, const AbstractKart *kart,
|
||||||
const core::recti &viewport,
|
const core::recti &viewport,
|
||||||
const core::vector2df &scaling);
|
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::recti &viewport,
|
||||||
const core::vector2df &scaling);
|
const core::vector2df &scaling);
|
||||||
void drawRankLap (const AbstractKart* kart,
|
|
||||||
const core::recti &viewport);
|
|
||||||
|
|
||||||
/** Display items that are shown once only (for all karts). */
|
/** Display items that are shown once only (for all karts). */
|
||||||
void drawGlobalMiniMap ();
|
void drawGlobalMiniMap ();
|
||||||
|
Loading…
Reference in New Issue
Block a user