Add a thin outline for lap time/battle lives

This commit is contained in:
Alayan 2018-10-08 16:18:13 +02:00
parent 027705f9b1
commit b4cb7321d6
5 changed files with 38 additions and 3 deletions

View File

@ -40,6 +40,9 @@ private:
* the colored border will take priority. */ * the colored border will take priority. */
bool m_colored_border; bool m_colored_border;
/* True if the border to draw should be thin */
bool m_thin_border;
/** If true, characters will have right alignment when rendering, for RTL /** If true, characters will have right alignment when rendering, for RTL
* language. */ * language. */
bool m_rtl; bool m_rtl;
@ -62,12 +65,14 @@ public:
/** Constructor. It will initialize all members with default values if no /** Constructor. It will initialize all members with default values if no
* parameter is given. */ * parameter is given. */
FontSettings(bool black_border = false, bool colored_border = false, FontSettings(bool black_border = false, bool colored_border = false,
bool thin_border = false,
bool rtl = false, float scale = 1.0f, bool shadow = false, bool rtl = false, float scale = 1.0f, bool shadow = false,
const video::SColor& shadow_color = video::SColor(0, 0, 0, 0), const video::SColor& shadow_color = video::SColor(0, 0, 0, 0),
const video::SColor& border_color = video::SColor(0, 0, 0, 0)) const video::SColor& border_color = video::SColor(0, 0, 0, 0))
{ {
m_black_border = black_border; m_black_border = black_border;
m_colored_border = colored_border; m_colored_border = colored_border;
m_thin_border = thin_border;
m_rtl = rtl; m_rtl = rtl;
m_scale = scale; m_scale = scale;
m_shadow = shadow; m_shadow = shadow;
@ -104,6 +109,9 @@ public:
* \param border If it's enabled. */ * \param border If it's enabled. */
void setColoredBorder(bool border ) { m_colored_border = border; } void setColoredBorder(bool border ) { m_colored_border = border; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Set whether the text outline should be thin or not. */
void setThinBorder(bool thin) { m_thin_border = thin; }
// ------------------------------------------------------------------------
/** Set the color of border (used when a non-black border is requested). /** Set the color of border (used when a non-black border is requested).
* \param col The color of border to be set. */ * \param col The color of border to be set. */
void setBorderColor(const video::SColor &col) { m_border_color = col; } void setBorderColor(const video::SColor &col) { m_border_color = col; }
@ -117,6 +125,9 @@ public:
/** Return if black border is enabled. */ /** Return if black border is enabled. */
bool useColoredBorder() const { return m_colored_border; } bool useColoredBorder() const { return m_colored_border; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Return if the border should be thin or not. */
bool useThinBorder() const { return m_thin_border; }
// ------------------------------------------------------------------------
/** Set right text alignment for RTL language. /** Set right text alignment for RTL language.
* \param rtl If it's enabled. */ * \param rtl If it's enabled. */
void setRTL(bool rtl) { m_rtl = rtl; } void setRTL(bool rtl) { m_rtl = rtl; }

View File

@ -676,9 +676,14 @@ void FontWithFace::render(const core::stringw& text,
m_fallback_font->m_spritebank->getTexture(tex_id) : m_fallback_font->m_spritebank->getTexture(tex_id) :
m_spritebank->getTexture(tex_id)); m_spritebank->getTexture(tex_id));
for (int x_delta = -2; x_delta <= 2; x_delta++) const bool thin_border = font_settings ?
font_settings->useThinBorder() : false;
int thickness = (thin_border) ? 1 : 2;
for (int x_delta = -thickness; x_delta <= thickness; x_delta++)
{ {
for (int y_delta = -2; y_delta <= 2; y_delta++) for (int y_delta = -thickness; y_delta <= thickness; y_delta++)
{ {
if (x_delta == 0 || y_delta == 0) continue; if (x_delta == 0 || y_delta == 0) continue;
draw2DImage(texture, dest + core::position2d<float> draw2DImage(texture, dest + core::position2d<float>

View File

@ -69,6 +69,11 @@ void ScalableFont::setColoredBorder(const irr::video::SColor &col)
m_font_settings->setBorderColor(col); m_font_settings->setBorderColor(col);
} // setColoredBorder } // setColoredBorder
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void ScalableFont::setThinBorder(bool thin)
{
m_font_settings->setThinBorder(thin);
} // setThinBorder
// ----------------------------------------------------------------------------
void ScalableFont::disableColoredBorder() void ScalableFont::disableColoredBorder()
{ {
m_font_settings->setColoredBorder(false); m_font_settings->setColoredBorder(false);

View File

@ -61,6 +61,8 @@ public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void setColoredBorder(const irr::video::SColor &col); void setColoredBorder(const irr::video::SColor &col);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void setThinBorder(bool thin);
// ------------------------------------------------------------------------
void disableColoredBorder(); void disableColoredBorder();
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void updateRTL(); void updateRTL();

View File

@ -683,7 +683,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
return; return;
int x_base = 10; int x_base = 10;
int y_base = 20; int y_base = 25;
unsigned int y_space = irr_driver->getActualScreenSize().Height - bottom_margin - y_base; unsigned int y_space = irr_driver->getActualScreenSize().Height - bottom_margin - y_base;
// Special case : when 3 players play, use 4th window to display such stuff // Special case : when 3 players play, use 4th window to display such stuff
if (race_manager->getIfEmptyScreenSpaceExists()) if (race_manager->getIfEmptyScreenSpaceExists())
@ -835,7 +835,11 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
pos_top.LowerRightCorner = pos_top.UpperLeftCorner; pos_top.LowerRightCorner = pos_top.UpperLeftCorner;
//I18N: When some GlobalPlayerIcons are hidden, write "Top 10" to show it //I18N: When some GlobalPlayerIcons are hidden, write "Top 10" to show it
font->setBlackBorder(true);
font->setThinBorder(true);
font->draw(_("Top %i", position-1 ), pos_top, color); font->draw(_("Top %i", position-1 ), pos_top, color);
font->setThinBorder(false);
font->setBlackBorder(false);
break; break;
} }
@ -851,8 +855,12 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
} }
else else
{ {
font->setBlackBorder(true);
font->setThinBorder(true);
font->draw(info.m_text, pos, info.m_color, false, false, NULL, font->draw(info.m_text, pos, info.m_color, false, false, NULL,
true/*ignore RTL*/); true/*ignore RTL*/);
font->setThinBorder(false);
font->setBlackBorder(false);
} }
} }
@ -861,8 +869,12 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5, core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5,
x+ICON_PLAYER_WIDTH, y+5); x+ICON_PLAYER_WIDTH, y+5);
core::stringw s(info.special_title.c_str()); core::stringw s(info.special_title.c_str());
font->setBlackBorder(true);
font->setThinBorder(true);
font->draw(s.c_str(), pos, info.m_color, false, false, NULL, font->draw(s.c_str(), pos, info.m_color, false, false, NULL,
true /* ignore RTL */); true /* ignore RTL */);
font->setThinBorder(false);
font->setBlackBorder(false);
} }
int w = kart->getController() int w = kart->getController()