Move the rank indicator to the top-left and clarify it

This commit is contained in:
Alayan 2018-09-26 18:57:13 +02:00
parent 871ee40053
commit f5abd2c798
2 changed files with 74 additions and 24 deletions

View File

@ -285,11 +285,14 @@ void RaceGUI::renderGlobal(float dt)
} }
} }
if (!m_is_tutorial) if (!m_is_tutorial &&
(race_manager->getNumLocalPlayers() == 1 ||
(race_manager->getNumLocalPlayers() == 2 &&
UserConfigParams::split_screen_horizontally == true)))
{ {
if(UserConfigParams::m_minimap_display == 0 || /*map in the bottom-left*/ if(UserConfigParams::m_minimap_display == 0 || /*map in the bottom-left*/
(UserConfigParams::m_minimap_display == 1 && (UserConfigParams::m_minimap_display == 1 &&
race_manager->getNumLocalPlayers() >= 2)) race_manager->getNumLocalPlayers() == 2))
drawGlobalPlayerIcons(m_map_height + m_map_bottom); drawGlobalPlayerIcons(m_map_height + m_map_bottom);
else // map hidden or on the right side else // map hidden or on the right side
drawGlobalPlayerIcons(0); drawGlobalPlayerIcons(0);
@ -334,7 +337,8 @@ void RaceGUI::renderPlayerView(const Camera *camera, float dt)
if (m_multitouch_gui == NULL) if (m_multitouch_gui == NULL)
{ {
drawPowerupIcons(kart, viewport, scaling); drawPowerupIcons(kart, viewport, scaling);
drawSpeedEnergyRank(kart, viewport, scaling, dt); drawSpeedEnergy(kart, viewport, scaling, dt);
drawRank(kart, viewport, scaling, dt);
} }
if (!m_is_tutorial) if (!m_is_tutorial)
@ -653,7 +657,7 @@ void RaceGUI::drawGlobalMiniMap()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Energy meter that gets filled with nitro. This function is called from /** Energy meter that gets filled with nitro. This function is called from
* drawSpeedEnergyRank, which defines the correct position of the energy * drawSpeedEnergy, which defines the correct position of the energy
* meter. * meter.
* \param x X position of the meter. * \param x X position of the meter.
* \param y Y position of the meter. * \param y Y position of the meter.
@ -771,7 +775,7 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart,
} // drawEnergyMeter } // drawEnergyMeter
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Draws the rank of a player. /** Draws misc. info inside the meters circle.
* \param kart The kart of the player. * \param kart The kart of the player.
* \param offset Offset of top left corner for this display (for splitscreen). * \param offset Offset of top left corner for this display (for splitscreen).
* \param min_ratio Scaling of the screen (for splitscreen). * \param min_ratio Scaling of the screen (for splitscreen).
@ -779,13 +783,15 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart,
* \param meter_height Height of the meter (inside which the rank is shown). * \param meter_height Height of the meter (inside which the rank is shown).
* \param dt Time step size. * \param dt Time step size.
*/ */
void RaceGUI::drawRank(const AbstractKart *kart, void RaceGUI::drawMiscInfo(const AbstractKart *kart,
const core::vector2df &offset, const core::vector2df &offset,
float min_ratio, int meter_width, float min_ratio, int meter_width,
int meter_height, float dt) int meter_height, float dt)
{ {
static video::SColor color = video::SColor(255, 255, 255, 255); static video::SColor color = video::SColor(255, 255, 255, 255);
// Draw hit or capture limit in network game // Draw hit or capture limit in network game
if ((race_manager->getMajorMode() == RaceManager::MAJOR_MODE_FREE_FOR_ALL || if ((race_manager->getMajorMode() == RaceManager::MAJOR_MODE_FREE_FOR_ALL ||
race_manager->getMajorMode() == RaceManager::MAJOR_MODE_CAPTURE_THE_FLAG) && race_manager->getMajorMode() == RaceManager::MAJOR_MODE_CAPTURE_THE_FLAG) &&
race_manager->getHitCaptureLimit() != std::numeric_limits<int>::max()) race_manager->getHitCaptureLimit() != std::numeric_limits<int>::max())
@ -806,6 +812,22 @@ void RaceGUI::drawRank(const AbstractKart *kart,
font->setScale(1.0f); font->setScale(1.0f);
return; return;
} }
} // drawMiscInfo
//-----------------------------------------------------------------------------
/** Draws the rank of a player.
* \param kart The kart of the player.
* \param viewport The viewport to use.
* \param scaling Which scaling to apply to the rank indicator
* \param dt Time step size.
*/
void RaceGUI::drawRank(const AbstractKart *kart, const core::recti &viewport,
const core::vector2df &scaling, float dt)
{
#ifndef SERVER_ONLY
float min_ratio = std::min(scaling.X, scaling.Y);
static video::SColor color = video::SColor(255, 255, 255, 255);
// Draw rank // Draw rank
WorldWithRank *world = dynamic_cast<WorldWithRank*>(World::getWorld()); WorldWithRank *world = dynamic_cast<WorldWithRank*>(World::getWorld());
@ -861,30 +883,56 @@ void RaceGUI::drawRank(const AbstractKart *kart,
} }
gui::ScalableFont* font = GUIEngine::getHighresDigitFont(); gui::ScalableFont* font = GUIEngine::getHighresDigitFont();
int rank_offset = 8;
if(race_manager->getNumLocalPlayers() == 1 ||
(race_manager->getNumLocalPlayers() == 2 &&
UserConfigParams::split_screen_horizontally == true))
rank_offset = 22;
// First draw the total number of karts
std::ostringstream oss2;
oss2 << "/" << world->getNumKarts();
float offset = font->getDimension(world->getNumKarts() < 10 ? L"/9" : L"/19").Width;
int middle_x = viewport.UpperLeftCorner.X +
int(irr_driver->getActualScreenSize().Width*rank_offset/100);
int middle_y = viewport.UpperLeftCorner.Y +
int(irr_driver->getActualScreenSize().Height*5/100);
core::recti pos;
pos.LowerRightCorner = core::vector2di(middle_x, middle_y);
pos.UpperLeftCorner = core::vector2di(middle_x, middle_y);
font->draw(oss2.str().c_str(), pos, color, true, true);
font->setScale(min_ratio * scale); font->setScale(min_ratio * scale);
font->setShadow(video::SColor(255, 128, 0, 0)); font->setShadow(video::SColor(255, 128, 0, 0));
std::ostringstream oss; std::ostringstream oss;
oss << rank; // the current font has no . :( << "."; oss << rank; // the current font has no . :( << ".";
core::recti pos; offset += font->getDimension(rank < 10 ? L"9" : L"19").Width;
pos.LowerRightCorner = core::vector2di(int(offset.X + 0.64f*meter_width), offset = offset/2;
int(offset.Y - 0.49f*meter_height)); middle_x -= offset;
pos.UpperLeftCorner = core::vector2di(int(offset.X + 0.64f*meter_width),
int(offset.Y - 0.49f*meter_height)); pos.LowerRightCorner = core::vector2di(middle_x, middle_y);
pos.UpperLeftCorner = core::vector2di(middle_x, middle_y);
font->draw(oss.str().c_str(), pos, color, true, true); font->draw(oss.str().c_str(), pos, color, true, true);
font->setScale(1.0f); font->setScale(1.0f);
#endif
} // drawRank } // drawRank
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Draws the speedometer, the display of available nitro, and /** Draws the speedometer and the display of available nitro.
* the rank of the kart (inside the speedometer).
* \param kart The kart for which to show the data. * \param kart The kart for which to show the data.
* \param viewport The viewport to use. * \param viewport The viewport to use.
* \param scaling Which scaling to apply to the speedometer. * \param scaling Which scaling to apply to the speedometer.
* \param dt Time step size. * \param dt Time step size.
*/ */
void RaceGUI::drawSpeedEnergyRank(const AbstractKart* kart, void RaceGUI::drawSpeedEnergy(const AbstractKart* kart,
const core::recti &viewport, const core::recti &viewport,
const core::vector2df &scaling, const core::vector2df &scaling,
float dt) float dt)
@ -919,8 +967,7 @@ void RaceGUI::drawSpeedEnergyRank(const AbstractKart* kart,
const float speed = kart->getSpeed(); const float speed = kart->getSpeed();
drawRank(kart, offset, min_ratio, meter_width, meter_height, dt); drawMiscInfo(kart, offset, min_ratio, meter_width, meter_height, dt);
if(speed <=0) return; // Nothing to do if speed is negative. if(speed <=0) return; // Nothing to do if speed is negative.
@ -1005,7 +1052,7 @@ void RaceGUI::drawSpeedEnergyRank(const AbstractKart* kart,
drawMeterTexture(m_speed_bar_icon->getTexture(), vertices, count); drawMeterTexture(m_speed_bar_icon->getTexture(), vertices, count);
#endif #endif
} // drawSpeedEnergyRank } // drawSpeedEnergy
void RaceGUI::drawMeterTexture(video::ITexture *meter_texture, video::S3DVertex vertices[], unsigned int count) void RaceGUI::drawMeterTexture(video::ITexture *meter_texture, video::S3DVertex vertices[], unsigned int count)
{ {

View File

@ -118,13 +118,16 @@ 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 drawSpeedEnergyRank (const AbstractKart* kart, void drawSpeedEnergy (const AbstractKart* kart,
const core::recti &viewport, const core::recti &viewport,
const core::vector2df &scaling, float dt); const core::vector2df &scaling, float dt);
void drawLap (const AbstractKart* kart, void drawLap (const AbstractKart* kart,
const core::recti &viewport, const core::recti &viewport,
const core::vector2df &scaling); const core::vector2df &scaling);
void drawRank (const AbstractKart *kart, void drawRank (const AbstractKart *kart,
const core::recti &viewport,
const core::vector2df &scaling, float dt);
void drawMiscInfo (const AbstractKart *kart,
const core::vector2df &offset, const core::vector2df &offset,
float min_ratio, int meter_width, float min_ratio, int meter_width,
int meter_height, float dt); int meter_height, float dt);