Improve text legibility

This commit is contained in:
auria.mg 2018-01-07 19:09:42 -05:00
parent 196117c41e
commit 6a21ca75fb
6 changed files with 38 additions and 9 deletions

View File

@ -52,12 +52,16 @@ void ScalableFont::setShadow(const irr::video::SColor &col)
m_font_settings->setShadow(true);
m_font_settings->setShadowColor(col);
} // setShadow
// ----------------------------------------------------------------------------
void ScalableFont::disableShadow()
{
m_font_settings->setShadow(false);
} // setShadow
// ----------------------------------------------------------------------------
void ScalableFont::setBlackBorder(bool enabled)
{
m_font_settings->setBlackBorder(enabled);
} // setShadow
// ----------------------------------------------------------------------------
void ScalableFont::setScale(float scale)

View File

@ -57,6 +57,8 @@ public:
// ------------------------------------------------------------------------
void disableShadow();
// ------------------------------------------------------------------------
void setBlackBorder(bool enabled);
// ------------------------------------------------------------------------
void updateRTL();
// ------------------------------------------------------------------------
void draw(const core::stringw& text, const core::rect<s32>& position,

View File

@ -239,9 +239,11 @@ void LocalPlayerController::displayPenaltyWarning()
if (m)
{
m->addMessage(_("Penalty time!!"), m_kart, 2.0f,
GUIEngine::getSkin()->getColor("font::top"));
GUIEngine::getSkin()->getColor("font::top"), true /* important */,
false /* big font */, true /* outline */);
m->addMessage(_("Don't accelerate before go"), m_kart, 2.0f,
GUIEngine::getSkin()->getColor("font::normal"));
GUIEngine::getSkin()->getColor("font::normal"), true /* important */,
false /* big font */, true /* outline */);
}
m_kart->playSound(m_bzzt_sound);
} // displayPenaltyWarning

View File

@ -225,9 +225,19 @@ void RaceGUIBase::drawAllMessages(const AbstractKart* kart,
if (msg.m_kart && msg.m_kart!=kart) continue;
core::rect<s32> pos(x - w/2, y, x + w/2, y + m_max_font_height);
GUIEngine::getSmallFont()->draw(
gui::ScalableFont* font = GUIEngine::getSmallFont();
if (msg.m_outline)
font->setBlackBorder(true);
font->draw(
core::stringw(msg.m_message.c_str()).c_str(),
pos, msg.m_color, true /* hcenter */, true /* vcenter */);
if (msg.m_outline)
font->setBlackBorder(false);
y -= m_small_font_max_height;
}
}
@ -273,9 +283,16 @@ void RaceGUIBase::drawAllMessages(const AbstractKart* kart,
}
else
{
if (msg.m_outline)
font->setBlackBorder(true);
font->draw(core::stringw(msg.m_message.c_str()).c_str(),
pos, msg.m_color, true /* hcenter */,
true /* vcenter */);
if (msg.m_outline)
font->setBlackBorder(false);
y += font_height;
}
} // for i in all messages
@ -460,9 +477,9 @@ void RaceGUIBase::renderPlayerView(const Camera *camera, float dt)
void RaceGUIBase::addMessage(const core::stringw &msg,
const AbstractKart *kart,
float time, const video::SColor &color,
bool important, bool big_font)
bool important, bool big_font, bool outline)
{
m_messages.push_back(TimedMessage(msg, kart, time, color, important, big_font));
m_messages.push_back(TimedMessage(msg, kart, time, color, important, big_font, outline));
} // addMessage
//-----------------------------------------------------------------------------

View File

@ -88,6 +88,8 @@ private:
bool m_important;
bool m_big_font;
bool m_outline;
// -----------------------------------------------------
// std::vector needs standard copy-ctor and std-assignment op.
// let compiler create defaults .. they'll do the job, no
@ -95,7 +97,7 @@ private:
TimedMessage(const irr::core::stringw &message,
const AbstractKart *kart, float time,
const video::SColor &color, const bool important,
bool big_font)
bool big_font, bool outline)
{
m_message = message;
m_kart = kart;
@ -103,6 +105,7 @@ private:
m_color = color;
m_important = important;
m_big_font = big_font;
m_outline = outline;
} // TimedMessage
// -----------------------------------------------------
// in follow leader the clock counts backwards
@ -229,7 +232,7 @@ public:
const video::SColor &color=
video::SColor(255, 255, 0, 255),
bool important=true,
bool big_font=false);
bool big_font=false, bool outline=false);
virtual void update(float dt);
virtual void preRenderCallback(const Camera *camera);
// ------------------------------------------------------------------------

View File

@ -237,7 +237,8 @@ public:
const video::SColor &color=
video::SColor(255, 255, 0, 255),
bool important=true,
bool big_font=false) OVERRIDE { }
bool big_font=false,
bool outline=false) OVERRIDE { }
void nextPhase();