/** Displays the rank and the lap of the kart. * \param info Info object c */ void RaceGUI::drawRankLap(const KartIconDisplayInfo* info, const AbstractKart* kart, const core::recti &viewport) { // Don't display laps or ranks if the kart has already finished the race. if (kart->hasFinishedRace()) return; core::recti pos; pos.UpperLeftCorner.Y = viewport.UpperLeftCorner.Y; // If the time display in the top right is in this viewport, // move the lap/rank display down a little bit so that it is // displayed under the time. 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.X = viewport.LowerRightCorner.X - m_rank_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); static video::SColor color = video::SColor(255, 255, 255, 255); WorldWithRank *world = (WorldWithRank*)(World::getWorld()); if (world->displayRank()) { const int rank = kart->getPosition(); font->draw(m_string_rank.c_str(), pos, color); pos.UpperLeftCorner.Y += font_height; pos.LowerRightCorner.Y += font_height; char str[256]; const unsigned int kart_amount = world->getCurrentNumKarts(); sprintf(str, "%d/%d", rank, kart_amount); font->draw(core::stringw(str).c_str(), pos, color); pos.UpperLeftCorner.Y += font_height; pos.LowerRightCorner.Y += font_height; } // Don't display laps in follow the leader mode if(world->raceHasLaps()) { const int lap = info[kart->getWorldKartId()].lap; // 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
/** Displays the rank and the lap of the kart. * \param info Info object c */ void MinimalRaceGUI::drawRankLap(const KartIconDisplayInfo* info, const AbstractKart* kart, const core::recti &viewport) { // Don't display laps or ranks if the kart has already finished the race. if (kart->hasFinishedRace()) return; core::recti pos; gui::ScalableFont* font = (race_manager->getNumLocalPlayers() > 2 ? GUIEngine::getSmallFont() : GUIEngine::getFont()); float scale = font->getScale(); font->setScale(m_font_scale); // Add a black shadow to make the text better readable on // 'white' tracks (e.g. with snow and ice). font->setShadow(video::SColor(255, 0, 0, 0)); static video::SColor color = video::SColor(255, 255, 255, 255); WorldWithRank *world = (WorldWithRank*)(World::getWorld()); if (world->displayRank()) { pos.UpperLeftCorner.Y = viewport.UpperLeftCorner.Y; pos.LowerRightCorner.Y = viewport.UpperLeftCorner.Y+50; // Split screen 3 or 4 players, left side: if(viewport.LowerRightCorner.X < UserConfigParams::m_width) { pos.UpperLeftCorner.X = 10; pos.LowerRightCorner.X = viewport.LowerRightCorner.X; } else { pos.UpperLeftCorner.X = viewport.LowerRightCorner.X - m_rank_width-10; pos.LowerRightCorner.X = viewport.LowerRightCorner.X; } char str[256]; sprintf(str, "%d/%d", kart->getPosition(), world->getCurrentNumKarts()); font->draw(str, pos, color); } // Don't display laps in follow the leader mode if(world->raceHasLaps()) { const int lap = info[kart->getWorldKartId()].lap; // don't display 'lap 0/...' if(lap>=0) { pos.LowerRightCorner.Y = viewport.LowerRightCorner.Y; pos.UpperLeftCorner.Y = viewport.LowerRightCorner.Y-60; pos.LowerRightCorner.X = viewport.LowerRightCorner.X; // Split screen 3 or 4 players, left side: if(viewport.LowerRightCorner.X < UserConfigParams::m_width) { pos.UpperLeftCorner.X = 10; } else { pos.UpperLeftCorner.X = (int)(viewport.LowerRightCorner.X - m_lap_width -10 ); } char str[256]; sprintf(str, "%d/%d", lap+1, race_manager->getNumLaps()); core::stringw s = m_string_lap+" "+str; font->draw(s.c_str(), pos, color); } } font->setScale(scale); font->disableShadow(); } // drawRankLap