void TrackInfoScreen::updateHighScores() { if (!race_manager->modeHasHighscores()) return; std::string game_mode_ident = RaceManager::getIdentOf( race_manager->getMinorMode() ); const Highscores::HighscoreType type = "HST_" + game_mode_ident; Highscores* highscores = highscore_manager->getHighscores(type, race_manager->getNumberOfKarts(), race_manager->getDifficulty(), m_track->getIdent(), race_manager->getNumLaps(), race_manager->getReverseTrack() ); const int amount = highscores->getNumberEntries(); std::string kart_name; core::stringw name; float time; // fill highscore entries for (int n=0; n<HIGHSCORE_COUNT; n++) { irr::core::stringw line; // Check if this entry is filled or still empty if (n < amount) { highscores->getEntry(n, kart_name, name, &time); std::string time_string = StringUtils::timeToString(time); const KartProperties* prop = kart_properties_manager->getKart(kart_name); if (prop != NULL) { const std::string &icon_path = prop->getAbsoluteIconFile(); ITexture* kart_icon_texture = irr_driver->getTexture( icon_path ); m_kart_icons[n]->setImage(kart_icon_texture); } line = name + "\t" + core::stringw(time_string.c_str()); } else { //I18N: for empty highscores entries line = _("(Empty)"); ITexture* no_kart_texture = irr_driver->getTexture( file_manager->getAsset(FileManager::GUI, "random_kart.png") ); m_kart_icons[n]->setImage(no_kart_texture); } m_highscore_entries[n]->setText( line.c_str(), false ); } } // updateHighScores
// ---------------------------------------------------------------------------- void RaceResultGUI::displayHighScores() { // This happens in demo world if(!World::getWorld()) return; Highscores* scores = World::getWorld()->getHighscores(); // In some case for exemple FTL they will be no highscores if (scores != NULL) { video::SColor white_color = video::SColor(255,255,255,255); int x = (int)(UserConfigParams::m_width*0.55f); int y = m_top; // First draw title GUIEngine::getFont()->draw(_("Highscores"), core::recti(x, y, 0, 0), white_color, false, false, NULL, true /* ignoreRTL */); std::string kart_name; irr::core::stringw player_name; // prevent excessive long name unsigned int max_characters = 15; float time; for (int i = 0; i < scores->getNumberEntries(); i++) { scores->getEntry(i,kart_name,player_name, &time); if (player_name.size() > max_characters) { int begin = (int(m_timer/0.4f)) % ( player_name.size() - max_characters ); player_name = player_name.subString(begin,max_characters,false); } video::SColor text_color = white_color; if (m_highscore_rank-1 == i) { text_color = video::SColor(255,255,0, 0 ); } int current_x = x; int current_y = y+(i+1)*50; const KartProperties* prop = kart_properties_manager->getKart(kart_name); if (prop != NULL) { const std::string &icon_path = prop->getAbsoluteIconFile(); video::ITexture* kart_icon_texture = irr_driver->getTexture( icon_path ); if (kart_icon_texture != NULL) { core::recti source_rect(core::vector2di(0,0), kart_icon_texture->getSize()); core::recti dest_rect(current_x, current_y, current_x+m_width_icon, current_y+m_width_icon); draw2DImage( kart_icon_texture, dest_rect, source_rect, NULL, NULL, true); current_x += m_width_icon + m_width_column_space; } } // draw the player name GUIEngine::getSmallFont()->draw(player_name.c_str(), core::recti(current_x, current_y, current_x+150, current_y+10), text_color, false, false, NULL, true /* ignoreRTL */); current_x += 180; // Finally draw the time std::string time_string = StringUtils::timeToString(time); GUIEngine::getSmallFont()->draw(time_string.c_str(), core::recti(current_x, current_y, current_x+100, current_y+10), text_color, false, false, NULL, true /* ignoreRTL */); } } }