preparing tracks_screen by adding a randon GP icon

This commit is contained in:
konstin 2014-05-08 20:57:19 +02:00
parent 58950f6b94
commit 5ea5de69cf
2 changed files with 76 additions and 85 deletions

View File

@ -57,13 +57,7 @@ GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const floa
m_gp_ident = gpIdent; m_gp_ident = gpIdent;
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(gpIdent); const GrandPrixData* gp = grand_prix_manager->getGrandPrix(gpIdent);
if (gp == NULL) assert (gp != NULL);
{
assert(false);
std::cerr << "ERROR at " << __FILE__ << " : " << __LINE__ << "; trying to continue\n";
ModalDialog::dismiss();
return;
}
// ---- GP Name // ---- GP Name
core::rect< s32 > area_top(0, 0, m_area.getWidth(), y1); core::rect< s32 > area_top(0, 0, m_area.getWidth(), y1);

View File

@ -64,32 +64,31 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, const
if (name == "tracks") if (name == "tracks")
{ {
DynamicRibbonWidget* w2 = dynamic_cast<DynamicRibbonWidget*>(widget); DynamicRibbonWidget* w2 = dynamic_cast<DynamicRibbonWidget*>(widget);
if (w2 != NULL) if (w2 == NULL)
{ return;
const std::string selection = w2->getSelectionIDString(PLAYER_ID_GAME_MASTER); const std::string selection = w2->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if(UserConfigParams::logGUI()) if(UserConfigParams::logGUI())
std::cout << "Clicked on track " << selection.c_str() Log::debug("Clicked on track %s\n", selection.c_str());
<< std::endl;
UserConfigParams::m_last_track = selection; UserConfigParams::m_last_track = selection;
if (selection == "random_track") if (selection == "random_track")
{ {
RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups"); RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups");
assert( tabs != NULL ); assert(tabs != NULL);
if (m_random_track_list.empty()) return; if (m_random_track_list.empty()) return;
std::string track = m_random_track_list.front(); std::string track = m_random_track_list.front();
m_random_track_list.pop_front(); m_random_track_list.pop_front();
m_random_track_list.push_back(track); m_random_track_list.push_back(track);
Track* clickedTrack = track_manager->getTrack( track ); Track* clickedTrack = track_manager->getTrack( track );
if (clickedTrack != NULL) if (clickedTrack != NULL)
{ {
ITexture* screenshot = ITexture* screenshot =
irr_driver->getTexture( clickedTrack->getScreenshotFile(), irr_driver->getTexture(clickedTrack->getScreenshotFile(),
"While loading screenshot for track '%s':", "While loading screenshot for track '%s':",
clickedTrack->getFilename() ); clickedTrack->getFilename() );
@ -121,28 +120,16 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, const
screenshot, 0.8f, 0.7f); screenshot, 0.8f, 0.7f);
} }
} }
} } // if (name == "tracks")
}
else if (name == "gps") else if (name == "gps")
{ {
DynamicRibbonWidget* gps_widget = dynamic_cast<DynamicRibbonWidget*>(widget); DynamicRibbonWidget* gps_widget = dynamic_cast<DynamicRibbonWidget*>(widget);
if (gps_widget != NULL)
{
std::string selection = gps_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER); std::string selection = gps_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (selection == "locked") if (selection == "locked")
{
unlock_manager->playLockSound(); unlock_manager->playLockSound();
}
else else
{ new GPInfoDialog(selection, 0.8f, 0.7f);
new GPInfoDialog( selection, 0.8f, 0.7f );
}
}
else
{
assert(false);
}
} }
else if (name == "trackgroups") else if (name == "trackgroups")
{ {
@ -217,7 +204,7 @@ void TracksScreen::init()
const std::vector<std::string> tracks = gp->getTrackNames(true); const std::vector<std::string> tracks = gp->getTrackNames(true);
std::vector<std::string> sshot_files; std::vector<std::string> screenshots;
for (unsigned int t=0; t<tracks.size(); t++) for (unsigned int t=0; t<tracks.size(); t++)
{ {
Track* curr = track_manager->getTrack(tracks[t]); Track* curr = track_manager->getTrack(tracks[t]);
@ -228,29 +215,39 @@ void TracksScreen::init()
} }
else else
{ {
sshot_files.push_back(curr->getScreenshotFile()); screenshots.push_back(curr->getScreenshotFile());
} }
} }
if (sshot_files.size() == 0) if (screenshots.size() == 0)
{ {
std::cerr << "/!\\ WARNING: Grand Prix '" << gp->getId() std::cerr << "/!\\ WARNING: Grand Prix '" << gp->getId()
<< "' does not contain any valid track.\n"; << "' does not contain any valid track.\n";
sshot_files.push_back("gui/main_help.png"); screenshots.push_back("gui/main_help.png");
} }
if (PlayerManager::getCurrentPlayer()->isLocked(gp->getId())) if (PlayerManager::getCurrentPlayer()->isLocked(gp->getId()))
{ {
gps_widget->addAnimatedItem(_("Locked!"), gps_widget->addAnimatedItem(_("Locked!"), "locked",
"locked", sshot_files, 1.5f, LOCKED_BADGE | TROPHY_BADGE, screenshots, 1.5f,
LOCKED_BADGE | TROPHY_BADGE,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE); IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
} }
else else
{ {
gps_widget->addAnimatedItem(translations->fribidize(gp->getName()), gp->getId(), gps_widget->addAnimatedItem(translations->fribidize(gp->getName()),
sshot_files, 1.5f, TROPHY_BADGE, gp->getId(), screenshots, 1.5f,
TROPHY_BADGE,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
}
}
// Random GP
std::vector<std::string> screenshots;
screenshots.push_back("gui/main_help.png");
gps_widget->addAnimatedItem(translations->fribidize("Random"), "Random",
screenshots, 1.5f, 0,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE ); IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE );
}
}
gps_widget->updateItemDisplay(); gps_widget->updateItemDisplay();