1) Time-trial and follow-the-leader modes can now be
used in GP as well. 2) Improved game-mode gui to use the new layout engine. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2174 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
0b56f85de6
commit
92efb6ccc7
@ -30,7 +30,8 @@ CityTime::CityTime() : Challenge("citytime", _("Finish the City track in 5:20"))
|
||||
} // CityTime
|
||||
//-----------------------------------------------------------------------------
|
||||
void CityTime::setRace() const {
|
||||
race_manager->setRaceMode(RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setMajorMode(RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode(RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setTrack("city");
|
||||
race_manager->setDifficulty(RaceManager::RD_EASY);
|
||||
race_manager->setNumLaps(3);
|
||||
|
@ -31,7 +31,8 @@ EnergyMathClass::EnergyMathClass() : Challenge("energymathclass", _("Collect Coi
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EnergyMathClass::setRace() const {
|
||||
race_manager->setRaceMode(RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setMajorMode(RaceManager::RM_SINGLE);
|
||||
race_manager->setMajorMode(RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setTrack("olivermath");
|
||||
race_manager->setDifficulty(RaceManager::RD_EASY);
|
||||
race_manager->setNumLaps(3);
|
||||
|
@ -33,7 +33,8 @@ EnergyShiftingSands::EnergyShiftingSands() : Challenge("energyshiftingsands", _(
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EnergyShiftingSands::setRace() const {
|
||||
race_manager->setRaceMode(RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setMajorMode(RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode(RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setTrack("sandtrack");
|
||||
race_manager->setDifficulty(RaceManager::RD_EASY);
|
||||
race_manager->setNumLaps(3);
|
||||
|
@ -33,7 +33,8 @@ IslandFollow::IslandFollow() : Challenge("islandfollow", _("Follow the Leader on
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void IslandFollow::setRace() const {
|
||||
race_manager->setRaceMode(RaceManager::RM_FOLLOW_LEADER);
|
||||
race_manager->setMajorMode(RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode(RaceManager::RM_FOLLOW_LEADER);
|
||||
race_manager->setTrack("islandtrack");
|
||||
race_manager->setDifficulty(RaceManager::RD_EASY);
|
||||
race_manager->setNumLaps(3);
|
||||
|
@ -32,7 +32,8 @@ JungleFollow::JungleFollow() : Challenge("junglefollow", _("Follow the Leader in
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void JungleFollow::setRace() const {
|
||||
race_manager->setRaceMode(RaceManager::RM_FOLLOW_LEADER);
|
||||
race_manager->setMajorMode(RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode(RaceManager::RM_FOLLOW_LEADER);
|
||||
race_manager->setTrack("jungle");
|
||||
race_manager->setDifficulty(RaceManager::RD_EASY);
|
||||
race_manager->setNumLaps(3);
|
||||
|
@ -34,7 +34,8 @@ MoonAndBackGP::MoonAndBackGP() : Challenge("moonandbackgp",_("Win To the Moon an
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void MoonAndBackGP::setRace() const {
|
||||
race_manager->setRaceMode(RaceManager::RM_GRAND_PRIX);
|
||||
race_manager->setMajorMode(RaceManager::RM_GRAND_PRIX);
|
||||
race_manager->setMinorMode(RaceManager::RM_QUICK_RACE);
|
||||
CupData cup("gp2.cup");
|
||||
race_manager->setGrandPrix(cup);
|
||||
race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
@ -45,10 +46,11 @@ void MoonAndBackGP::setRace() const {
|
||||
//-----------------------------------------------------------------------------
|
||||
bool MoonAndBackGP::grandPrixFinished()
|
||||
{
|
||||
if (race_manager->getRaceMode() != RaceManager::RM_GRAND_PRIX ||
|
||||
if (race_manager->getMajorMode() != RaceManager::RM_GRAND_PRIX ||
|
||||
race_manager->getMinorMode() != RaceManager::RM_QUICK_RACE ||
|
||||
race_manager->getGrandPrix()->getName() != _("To the Moon and Back") ||
|
||||
race_manager->getDifficulty()!= RaceManager::RD_HARD ||
|
||||
race_manager->getNumKarts() < 4 ||
|
||||
race_manager->getDifficulty()!= RaceManager::RD_HARD ||
|
||||
race_manager->getNumKarts() < 4 ||
|
||||
race_manager->getNumPlayers() > 1) return false;
|
||||
// Check if the player was in top 3:
|
||||
for(int i=0; i<(int)race_manager->getNumKarts(); i++)
|
||||
|
@ -31,7 +31,8 @@ PenguinPlaygroundGP::PenguinPlaygroundGP() : Challenge("penguinplaygroundgp", _(
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void PenguinPlaygroundGP::setRace() const {
|
||||
race_manager->setRaceMode(RaceManager::RM_GRAND_PRIX);
|
||||
race_manager->setMajorMode(RaceManager::RM_GRAND_PRIX);
|
||||
race_manager->setMinorMode(RaceManager::RM_QUICK_RACE);
|
||||
CupData cup("gp1.cup");
|
||||
race_manager->setGrandPrix(cup);
|
||||
race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
@ -42,10 +43,11 @@ void PenguinPlaygroundGP::setRace() const {
|
||||
//-----------------------------------------------------------------------------
|
||||
bool PenguinPlaygroundGP::grandPrixFinished()
|
||||
{
|
||||
if (race_manager->getRaceMode() != RaceManager::RM_GRAND_PRIX ||
|
||||
if (race_manager->getMajorMode() != RaceManager::RM_GRAND_PRIX ||
|
||||
race_manager->getMinorMode() != RaceManager::RM_QUICK_RACE ||
|
||||
race_manager->getGrandPrix()->getName() != _("Penguin Playground") ||
|
||||
race_manager->getDifficulty()!= RaceManager::RD_HARD ||
|
||||
race_manager->getNumKarts() < 4 ||
|
||||
race_manager->getDifficulty()!= RaceManager::RD_HARD ||
|
||||
race_manager->getNumKarts() < 4 ||
|
||||
race_manager->getNumPlayers() > 1) return false;
|
||||
// Check if the player was in top 3:
|
||||
for(int i=0; i<(int)race_manager->getNumKarts(); i++)
|
||||
|
@ -31,7 +31,8 @@ RaceTrackTime::RaceTrackTime() : Challenge("racetracktime", _("Finish Race track
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RaceTrackTime::setRace() const {
|
||||
race_manager->setRaceMode(RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setMajorMode(RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode(RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setTrack("race");
|
||||
race_manager->setDifficulty(RaceManager::RD_EASY);
|
||||
race_manager->setNumLaps(3);
|
||||
|
@ -30,7 +30,8 @@ TollwayHead2Head::TollwayHead2Head() : Challenge("tollwayhead", _("Win a Head to
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void TollwayHead2Head::setRace() const {
|
||||
race_manager->setRaceMode(RaceManager::RM_TIME_TRIAL);
|
||||
race_manager->setMajorMode(RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode(RaceManager::RM_TIME_TRIAL);
|
||||
race_manager->setTrack("tuxtrack");
|
||||
race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
race_manager->setNumLaps(1);
|
||||
|
@ -30,7 +30,8 @@ TollwayTime::TollwayTime() : Challenge("tollwaytime", _("Finish Tux Tollway trac
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void TollwayTime::setRace() const {
|
||||
race_manager->setRaceMode(RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setMajorMode(RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode(RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setTrack("tuxtrack");
|
||||
race_manager->setDifficulty(RaceManager::RD_EASY);
|
||||
race_manager->setNumLaps(3);
|
||||
|
@ -39,7 +39,8 @@ WorldsEndGP::WorldsEndGP() : Challenge("worldsendgp",_("Win the At World's End\n
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void WorldsEndGP::setRace() const {
|
||||
race_manager->setRaceMode(RaceManager::RM_GRAND_PRIX);
|
||||
race_manager->setMajorMode(RaceManager::RM_GRAND_PRIX);
|
||||
race_manager->setMinorMode(RaceManager::RM_QUICK_RACE);
|
||||
CupData cup("gp4.cup");
|
||||
race_manager->setGrandPrix(cup);
|
||||
race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
@ -50,10 +51,11 @@ void WorldsEndGP::setRace() const {
|
||||
//-----------------------------------------------------------------------------
|
||||
bool WorldsEndGP::grandPrixFinished()
|
||||
{
|
||||
if (race_manager->getRaceMode() != RaceManager::RM_GRAND_PRIX ||
|
||||
if (race_manager->getMajorMode() != RaceManager::RM_GRAND_PRIX ||
|
||||
race_manager->getMinorMode() != RaceManager::RM_QUICK_RACE ||
|
||||
race_manager->getGrandPrix()->getName() != _("At world's end") ||
|
||||
race_manager->getDifficulty()!= RaceManager::RD_HARD ||
|
||||
race_manager->getNumKarts() < 4 ||
|
||||
race_manager->getDifficulty()!= RaceManager::RD_HARD ||
|
||||
race_manager->getNumKarts() < 4 ||
|
||||
race_manager->getNumPlayers() > 1) return false;
|
||||
// Check if the player was first:
|
||||
for(int i=0; i<(int)race_manager->getNumKarts(); i++)
|
||||
|
@ -36,7 +36,7 @@ Collectable::Collectable(Kart* kart_)
|
||||
//-----------------------------------------------------------------------------
|
||||
void Collectable::reset()
|
||||
{
|
||||
if(race_manager->getRaceMode()==RaceManager::RM_TIME_TRIAL)
|
||||
if(race_manager->getMinorMode()==RaceManager::RM_TIME_TRIAL)
|
||||
{
|
||||
m_type = COLLECT_ZIPPER;
|
||||
m_number = race_manager->getNumLaps();
|
||||
|
@ -389,7 +389,7 @@ void CharSel::select()
|
||||
}
|
||||
}
|
||||
|
||||
if (race_manager->getRaceMode() == RaceManager::RM_GRAND_PRIX)
|
||||
if (race_manager->getMajorMode() == RaceManager::RM_GRAND_PRIX)
|
||||
menu_manager->pushMenu(MENUID_GRANDPRIXSELECT);
|
||||
else
|
||||
menu_manager->pushMenu(MENUID_TRACKSEL);
|
||||
|
@ -28,12 +28,15 @@
|
||||
|
||||
enum WidgetTokens
|
||||
{
|
||||
WTOK_TITLE,
|
||||
WTOK_TITLE_SINGLE,
|
||||
WTOK_QUICK_RACE_SINGLE,
|
||||
WTOK_TIMETRIAL_SINGLE,
|
||||
WTOK_FOLLOW_LEADER_SINGLE,
|
||||
|
||||
WTOK_GP,
|
||||
WTOK_QUICKRACE,
|
||||
WTOK_TIMETRIAL,
|
||||
WTOK_FOLLOW_LEADER,
|
||||
WTOK_TITLE_GP,
|
||||
WTOK_QUICK_RACE_GP,
|
||||
WTOK_TIMETRIAL_GP,
|
||||
WTOK_FOLLOW_LEADER_GP,
|
||||
|
||||
WTOK_HELP,
|
||||
WTOK_QUIT
|
||||
@ -41,54 +44,89 @@ enum WidgetTokens
|
||||
|
||||
GameMode::GameMode()
|
||||
{
|
||||
widget_manager->switchOrder();
|
||||
const int HEIGHT = 7;
|
||||
const int WIDTH = 5;
|
||||
|
||||
// First the single race events
|
||||
// ============================
|
||||
Widget *w=widget_manager->addTextWgt(WTOK_TITLE_SINGLE, WIDTH,
|
||||
HEIGHT, _("Single Race"));
|
||||
widget_manager->hideWgtRect(WTOK_TITLE_SINGLE);
|
||||
w->setPosition(WGT_DIR_FROM_LEFT, 0.1f, NULL,
|
||||
WGT_DIR_FROM_TOP, 0.2f, NULL);
|
||||
Widget *w_prev=w;
|
||||
w=widget_manager->addTextButtonWgt(WTOK_QUICK_RACE_SINGLE, WIDTH, HEIGHT,
|
||||
_("Quick Race"));
|
||||
w->setPosition(WGT_DIR_FROM_LEFT, 0.1f, NULL,
|
||||
WGT_DIR_UNDER_WIDGET, 0.0f, w_prev);
|
||||
w_prev=w;
|
||||
w=widget_manager->addTextButtonWgt(WTOK_TIMETRIAL_SINGLE, WIDTH, HEIGHT,
|
||||
_("Time Trial"));
|
||||
w->setPosition(WGT_DIR_FROM_LEFT, 0.1f, NULL,
|
||||
WGT_DIR_UNDER_WIDGET, 0.0f, w_prev);
|
||||
w_prev=w;
|
||||
w=widget_manager->addTextButtonWgt(WTOK_FOLLOW_LEADER_SINGLE, WIDTH, HEIGHT,
|
||||
_("Follow the Leader"));
|
||||
w->setPosition(WGT_DIR_FROM_LEFT, 0.1f, NULL,
|
||||
WGT_DIR_UNDER_WIDGET, 0.0f, w_prev);
|
||||
widget_manager->sameWidth(WTOK_TITLE_SINGLE, WTOK_FOLLOW_LEADER_SINGLE);
|
||||
|
||||
widget_manager->addTextButtonWgt( WTOK_GP, 60, 7, _("Grand Prix"));
|
||||
// Then the GPs
|
||||
// ============
|
||||
w=widget_manager->addTextWgt(WTOK_TITLE_GP, WIDTH,
|
||||
HEIGHT, _("Grand Prix"));
|
||||
widget_manager->hideWgtRect(WTOK_TITLE_GP);
|
||||
w->setPosition(WGT_DIR_FROM_RIGHT, 0.1f, NULL,
|
||||
WGT_DIR_FROM_TOP, 0.2f, NULL);
|
||||
w_prev=w;
|
||||
w=widget_manager->addTextButtonWgt(WTOK_QUICK_RACE_GP, WIDTH, HEIGHT,
|
||||
_("Quick Race"));
|
||||
w->setPosition(WGT_DIR_FROM_RIGHT, 0.1f, NULL,
|
||||
WGT_DIR_UNDER_WIDGET, 0.0f, w_prev);
|
||||
w_prev=w;
|
||||
w=widget_manager->addTextButtonWgt(WTOK_TIMETRIAL_GP, WIDTH, HEIGHT,
|
||||
_("Time Trial"));
|
||||
w->setPosition(WGT_DIR_FROM_RIGHT, 0.1f, NULL,
|
||||
WGT_DIR_UNDER_WIDGET, 0.0f, w_prev);
|
||||
w_prev=w;
|
||||
w=widget_manager->addTextButtonWgt(WTOK_FOLLOW_LEADER_GP, WIDTH, HEIGHT,
|
||||
_("Follow the Leader"));
|
||||
w->setPosition(WGT_DIR_FROM_RIGHT, 0.1f, NULL,
|
||||
WGT_DIR_UNDER_WIDGET, 0.0f, w_prev);
|
||||
w_prev=w;
|
||||
widget_manager->sameWidth(WTOK_TITLE_GP, WTOK_FOLLOW_LEADER_GP);
|
||||
|
||||
if(unlock_manager->isLocked("grandprix"))
|
||||
{
|
||||
widget_manager->hideWgtText( WTOK_GP );
|
||||
widget_manager->deactivateWgt( WTOK_GP );
|
||||
for(int i=WTOK_QUICK_RACE_GP; i<=WTOK_FOLLOW_LEADER_GP; i++)
|
||||
{
|
||||
widget_manager->hideWgtText(i);
|
||||
widget_manager->deactivateWgt(i);
|
||||
|
||||
widget_manager->setWgtColor( WTOK_GP, WGT_WHITE);
|
||||
widget_manager->setWgtTexture( WTOK_GP, "gui_lock.rgb", false );
|
||||
widget_manager->showWgtTexture( WTOK_GP );
|
||||
widget_manager->setWgtColor(i, WGT_WHITE);
|
||||
widget_manager->setWgtTexture(i, "gui_lock.rgb", false);
|
||||
widget_manager->showWgtTexture(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
widget_manager->addTextButtonWgt(WTOK_QUICKRACE, 60, 7, _("Quick Race"));
|
||||
|
||||
if( race_manager->getNumPlayers() == 1 )
|
||||
{
|
||||
widget_manager->addTextButtonWgt(WTOK_TIMETRIAL, 60, 7, _("Time Trial"));
|
||||
}
|
||||
|
||||
|
||||
widget_manager->addTextButtonWgt( WTOK_FOLLOW_LEADER, 60, 7,
|
||||
_("Follow the Leader"));
|
||||
|
||||
if(unlock_manager->isLocked("followleader"))
|
||||
{
|
||||
widget_manager->hideWgtText( WTOK_FOLLOW_LEADER );
|
||||
|
||||
// widget_manager->deactivateWgt( WTOK_FOLLOW_LEADER );
|
||||
|
||||
widget_manager->setWgtColor( WTOK_FOLLOW_LEADER, WGT_GRAY);
|
||||
widget_manager->setWgtTexture( WTOK_FOLLOW_LEADER, "gui_lock.rgb", false );
|
||||
widget_manager->showWgtTexture( WTOK_FOLLOW_LEADER );
|
||||
widget_manager->setWgtText(WTOK_FOLLOW_LEADER,
|
||||
widget_manager->hideWgtText(WTOK_FOLLOW_LEADER_SINGLE);
|
||||
widget_manager->setWgtColor(WTOK_FOLLOW_LEADER_SINGLE, WGT_GRAY);
|
||||
widget_manager->setWgtTexture(WTOK_FOLLOW_LEADER_SINGLE, "gui_lock.rgb", false );
|
||||
widget_manager->showWgtTexture(WTOK_FOLLOW_LEADER_SINGLE);
|
||||
widget_manager->setWgtText(WTOK_FOLLOW_LEADER_SINGLE,
|
||||
_("Fulfil challenge to unlock"));
|
||||
}
|
||||
|
||||
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 1, 7);
|
||||
|
||||
widget_manager->addTextButtonWgt( WTOK_HELP, 60, 7, _("Game mode help"));
|
||||
w=widget_manager->addTextButtonWgt( WTOK_HELP, WIDTH, HEIGHT, _("Game mode help"));
|
||||
widget_manager->setWgtTextSize( WTOK_HELP, WGT_FNT_SML );
|
||||
w->setPosition(WGT_DIR_CENTER, 0.0f, NULL, WGT_DIR_UNDER_WIDGET, 0.1f, w_prev);
|
||||
w_prev=w;
|
||||
|
||||
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 1, 7);
|
||||
|
||||
widget_manager->addTextButtonWgt(WTOK_QUIT, 60, 7, _("Press <ESC> to go back"));
|
||||
w=widget_manager->addTextButtonWgt(WTOK_QUIT, WIDTH, HEIGHT, _("Press <ESC> to go back"));
|
||||
widget_manager->setWgtTextSize( WTOK_QUIT, WGT_FNT_SML );
|
||||
w->setPosition(WGT_DIR_CENTER, 0.0f, NULL, WGT_DIR_FROM_BOTTOM, 0.0f, w_prev);
|
||||
|
||||
widget_manager->layout(WGT_AREA_ALL);
|
||||
}
|
||||
@ -102,41 +140,42 @@ GameMode::~GameMode()
|
||||
//-----------------------------------------------------------------------------
|
||||
void GameMode::select()
|
||||
{
|
||||
switch ( widget_manager->getSelectedWgt() )
|
||||
int mode = widget_manager->getSelectedWgt();
|
||||
switch (mode)
|
||||
{
|
||||
case WTOK_GP:
|
||||
race_manager->setRaceMode(RaceManager::RM_GRAND_PRIX);
|
||||
menu_manager->pushMenu(MENUID_CHARSEL_P1);
|
||||
break;
|
||||
case WTOK_QUICKRACE:
|
||||
race_manager->setRaceMode(RaceManager::RM_QUICK_RACE);
|
||||
menu_manager->pushMenu(MENUID_CHARSEL_P1);
|
||||
break;
|
||||
case WTOK_FOLLOW_LEADER:
|
||||
if(unlock_manager->isLocked("followleader"))
|
||||
{
|
||||
widget_manager->showWgtText( WTOK_FOLLOW_LEADER );
|
||||
widget_manager->setWgtTextColor( WTOK_FOLLOW_LEADER, WGT_TRANS_GRAY);
|
||||
widget_manager->setWgtColor( WTOK_FOLLOW_LEADER, WGT_TRANS_GRAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
race_manager->setRaceMode(RaceManager::RM_FOLLOW_LEADER);
|
||||
menu_manager->pushMenu(MENUID_CHARSEL_P1);
|
||||
}
|
||||
break;
|
||||
case WTOK_TIMETRIAL:
|
||||
race_manager->setRaceMode(RaceManager::RM_TIME_TRIAL);
|
||||
menu_manager->pushMenu(MENUID_CHARSEL_P1);
|
||||
break;
|
||||
case WTOK_QUICK_RACE_SINGLE:
|
||||
race_manager->setMajorMode(RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode(RaceManager::RM_QUICK_RACE);
|
||||
break;
|
||||
case WTOK_TIMETRIAL_SINGLE:
|
||||
race_manager->setMajorMode(RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode(RaceManager::RM_TIME_TRIAL);
|
||||
break;
|
||||
case WTOK_FOLLOW_LEADER_SINGLE:
|
||||
race_manager->setMajorMode(RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode(RaceManager::RM_FOLLOW_LEADER);
|
||||
break;
|
||||
case WTOK_QUICK_RACE_GP:
|
||||
race_manager->setMajorMode(RaceManager::RM_GRAND_PRIX);
|
||||
race_manager->setMinorMode(RaceManager::RM_QUICK_RACE);
|
||||
break;
|
||||
case WTOK_TIMETRIAL_GP:
|
||||
race_manager->setMajorMode(RaceManager::RM_GRAND_PRIX);
|
||||
race_manager->setMinorMode(RaceManager::RM_TIME_TRIAL);
|
||||
break;
|
||||
case WTOK_FOLLOW_LEADER_GP:
|
||||
race_manager->setMajorMode(RaceManager::RM_GRAND_PRIX);
|
||||
race_manager->setMinorMode(RaceManager::RM_FOLLOW_LEADER);
|
||||
break;
|
||||
case WTOK_HELP:
|
||||
menu_manager->pushMenu(MENUID_HELP3);
|
||||
break;
|
||||
menu_manager->pushMenu(MENUID_HELP3);
|
||||
return;
|
||||
case WTOK_QUIT:
|
||||
menu_manager->popMenu();
|
||||
break;
|
||||
menu_manager->popMenu();
|
||||
return;
|
||||
default: break;
|
||||
}
|
||||
menu_manager->pushMenu(MENUID_CHARSEL_P1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +65,9 @@ GrandPrixEnd::GrandPrixEnd()
|
||||
int *scores = new int[NUM_KARTS];
|
||||
int *position = new int[NUM_KARTS];
|
||||
double *race_time = new double[NUM_KARTS];
|
||||
for( unsigned int kart_id = 0; kart_id < NUM_KARTS; ++kart_id )
|
||||
// Ignore the first kart if it's a follow-the-leader race.
|
||||
int start=(race_manager->getMinorMode()==RaceManager::RM_FOLLOW_LEADER) ? 1 : 0;
|
||||
for( unsigned int kart_id = start; kart_id < NUM_KARTS; ++kart_id )
|
||||
{
|
||||
position[kart_id] = kart_id;
|
||||
scores[kart_id] = race_manager->getKartScore(kart_id);
|
||||
@ -77,7 +79,7 @@ GrandPrixEnd::GrandPrixEnd()
|
||||
do
|
||||
{
|
||||
sorted = true;
|
||||
for( unsigned int i = 0; i < NUM_KARTS - 1; ++i )
|
||||
for( unsigned int i = start; i < NUM_KARTS - 1; ++i )
|
||||
{
|
||||
if( scores[i] < scores[i+1] || (scores[i] == scores[i+1]
|
||||
&& race_time[i] > race_time[i+1]))
|
||||
@ -104,7 +106,7 @@ GrandPrixEnd::GrandPrixEnd()
|
||||
|
||||
static char output[MAX_MESSAGE_LENGTH];
|
||||
snprintf(output, sizeof(output),
|
||||
_("The winner is %s!"),race_manager->getKartName(position[0]).c_str());
|
||||
_("The winner is %s!"),race_manager->getKartName(position[start]).c_str());
|
||||
widget_manager->addWgt( WTOK_TITLE, 60, 10);
|
||||
widget_manager->showWgtRect(WTOK_TITLE);
|
||||
widget_manager->showWgtText(WTOK_TITLE);
|
||||
@ -114,12 +116,13 @@ GrandPrixEnd::GrandPrixEnd()
|
||||
|
||||
m_score = new char[MAX_STR_LEN*NUM_KARTS];
|
||||
|
||||
for(unsigned int i=0; i < NUM_KARTS; ++i)
|
||||
for(unsigned int i=start; i < NUM_KARTS; ++i)
|
||||
{
|
||||
char sTime[20];
|
||||
TimeToString(race_time[i], sTime);
|
||||
char sTime[20];sTime[0]=0;
|
||||
if(race_manager->getMinorMode()!=RaceManager::RM_FOLLOW_LEADER)
|
||||
TimeToString(race_time[i], sTime);
|
||||
sprintf((char*)(m_score + MAX_STR_LEN * i), "%d. %s %d %s",
|
||||
i + 1, race_manager->getKartName(position[i]).c_str(), scores[i], sTime );
|
||||
i + 1-start, race_manager->getKartName(position[i]).c_str(), scores[i], sTime );
|
||||
|
||||
widget_manager->addWgt(WTOK_FIRSTKART + i, 40, 5);
|
||||
widget_manager->showWgtRect(WTOK_FIRSTKART + i);
|
||||
@ -129,7 +132,7 @@ GrandPrixEnd::GrandPrixEnd()
|
||||
widget_manager->setWgtTextSize(WTOK_FIRSTKART + i, WGT_FNT_SML);
|
||||
widget_manager->breakLine();
|
||||
}
|
||||
const std::string KART_NAME = race_manager->getKartName(position[0]);
|
||||
const std::string KART_NAME = race_manager->getKartName(position[start]);
|
||||
const KartProperties* WINNING_KART = kart_properties_manager->getKart(KART_NAME);
|
||||
delete []scores;
|
||||
delete []position;
|
||||
|
@ -401,7 +401,7 @@ void RaceGUI::drawPlayerIcons ()
|
||||
font_race->PrintShadow(str, 30, ICON_PLAYER_WIDHT+x, y+5,
|
||||
COLORS);
|
||||
}
|
||||
if(race_manager->getRaceMode()==RaceManager::RM_FOLLOW_LEADER && i==0)
|
||||
if(race_manager->getMinorMode()==RaceManager::RM_FOLLOW_LEADER && i==0)
|
||||
{
|
||||
GLfloat const RED[] = { 1.0f, 0, 0, 1.0f};
|
||||
font_race->PrintShadow(_("Leader"), 30, ICON_PLAYER_WIDHT+x, y+5,
|
||||
@ -1040,12 +1040,12 @@ void RaceGUI::drawStatusText(const float dt)
|
||||
} // for pla
|
||||
drawTimer ();
|
||||
if(world->getTime()<TIME_MUSIC_DESCRIPTION
|
||||
&& race_manager->getRaceMode() != RaceManager::RM_FOLLOW_LEADER)
|
||||
&& race_manager->getMinorMode() != RaceManager::RM_FOLLOW_LEADER)
|
||||
{
|
||||
drawMusicDescription();
|
||||
}
|
||||
else if (world->getTime()>stk_config->m_leader_intervals[0]-TIME_MUSIC_DESCRIPTION
|
||||
&& race_manager->getRaceMode()== RaceManager::RM_FOLLOW_LEADER)
|
||||
&& race_manager->getMinorMode()== RaceManager::RM_FOLLOW_LEADER)
|
||||
drawMusicDescription();
|
||||
|
||||
drawMap ();
|
||||
|
@ -57,7 +57,7 @@ class RaceGUI: public BaseGUI
|
||||
m_font_size = size;
|
||||
m_kart = kart;
|
||||
m_end_time = time>=0.0f
|
||||
? (race_manager->getRaceMode()==RaceManager::RM_FOLLOW_LEADER
|
||||
? (race_manager->getMinorMode()==RaceManager::RM_FOLLOW_LEADER
|
||||
?world->getTime()-time
|
||||
:world->getTime()+time )
|
||||
: -1.0f;
|
||||
@ -65,7 +65,7 @@ class RaceGUI: public BaseGUI
|
||||
}
|
||||
// in follow leader the clock counts backwards
|
||||
bool done() const {return m_end_time<0 ||
|
||||
(race_manager->getRaceMode()==RaceManager::RM_FOLLOW_LEADER
|
||||
(race_manager->getMinorMode()==RaceManager::RM_FOLLOW_LEADER
|
||||
? world->getTime()<m_end_time
|
||||
: world->getTime()>m_end_time);}
|
||||
};
|
||||
|
@ -51,7 +51,7 @@ RaceMenu::RaceMenu()
|
||||
widget_manager->addTextButtonWgt( WTOK_HELP, 50, 7, _("Help") );
|
||||
widget_manager->addTextButtonWgt( WTOK_RESTART_RACE, 50, 7, _("Restart Race") );
|
||||
|
||||
if(race_manager->getRaceMode()==RaceManager::RM_QUICK_RACE)
|
||||
if(race_manager->getMinorMode()==RaceManager::RM_QUICK_RACE)
|
||||
{
|
||||
widget_manager->addTextButtonWgt( WTOK_SETUP_NEW_RACE, 50, 7,
|
||||
_("Setup New Race") );
|
||||
|
@ -59,7 +59,7 @@ RaceOptions::RaceOptions()
|
||||
m_num_laps=race_manager->getNumLaps();
|
||||
// Determine the minimum number of karts
|
||||
m_min_karts = (int)race_manager->getNumPlayers();
|
||||
if(race_manager->getRaceMode() == RaceManager::RM_FOLLOW_LEADER)
|
||||
if(race_manager->getMinorMode() == RaceManager::RM_FOLLOW_LEADER)
|
||||
{
|
||||
// if playing follow the leader single mode, there should be at
|
||||
// least one opponent in addition to the leader
|
||||
@ -107,8 +107,8 @@ RaceOptions::RaceOptions()
|
||||
|
||||
// Number of laps
|
||||
// ==============
|
||||
if( race_manager->getRaceMode() != RaceManager::RM_GRAND_PRIX &&
|
||||
race_manager->getRaceMode() != RaceManager::RM_FOLLOW_LEADER )
|
||||
if( race_manager->getMajorMode() != RaceManager::RM_GRAND_PRIX &&
|
||||
race_manager->getMinorMode() != RaceManager::RM_FOLLOW_LEADER )
|
||||
{
|
||||
widget_manager->addTextWgt( WTOK_LAPS_TITLE, DESC_WIDTH, 7, _("Number of laps") );
|
||||
widget_manager->hideWgtRect(WTOK_LAPS_TITLE);
|
||||
@ -235,8 +235,8 @@ void RaceOptions::select()
|
||||
|
||||
case WTOK_LAPS_DOWN:
|
||||
{
|
||||
m_num_laps--;
|
||||
if(m_num_laps<1) m_num_laps=10;
|
||||
m_num_laps--;
|
||||
if(m_num_laps<1) m_num_laps=10;
|
||||
|
||||
char label[ MAX_MESSAGE_LENGTH ];
|
||||
snprintf( label, MAX_MESSAGE_LENGTH, "%d", m_num_laps );
|
||||
@ -258,8 +258,8 @@ void RaceOptions::select()
|
||||
|
||||
race_manager->setNumKarts(m_num_karts);
|
||||
|
||||
if( race_manager->getRaceMode() != RaceManager::RM_GRAND_PRIX &&
|
||||
race_manager->getRaceMode() != RaceManager::RM_FOLLOW_LEADER )
|
||||
if( race_manager->getMajorMode() != RaceManager::RM_GRAND_PRIX &&
|
||||
race_manager->getMinorMode() != RaceManager::RM_FOLLOW_LEADER )
|
||||
{
|
||||
race_manager->setNumLaps( m_num_laps );
|
||||
}
|
||||
|
@ -32,36 +32,122 @@
|
||||
|
||||
enum WidgetTokens
|
||||
{
|
||||
WTOK_TITLE,
|
||||
WTOK_HIGHSCORES,
|
||||
WTOK_RESULTS,
|
||||
WTOK_CONTINUE,
|
||||
WTOK_RESTART_RACE,
|
||||
WTOK_SETUP_NEW_RACE,
|
||||
WTOK_FIRST_HIGHSCORE,
|
||||
//Add 3 because the maximum number of highscores is 3
|
||||
WTOK_FIRST_RESULT = WTOK_FIRST_HIGHSCORE + 3
|
||||
WTOK_RESULTS,
|
||||
WTOK_FIRST_RESULT,
|
||||
WTOK_FIRST_IMAGE=1000,
|
||||
WTOK_HIGHSCORES=2000,
|
||||
WTOK_FIRST_HIGHSCORE=2001,
|
||||
};
|
||||
|
||||
RaceResultsGUI::RaceResultsGUI()
|
||||
{
|
||||
widget_manager->addTitleWgt( WTOK_TITLE, 60, 7, _("Result") );
|
||||
widget_manager->breakLine();
|
||||
Widget *bottom_of_list;
|
||||
|
||||
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 60, 5 );
|
||||
widget_manager->breakLine();
|
||||
if(race_manager->getMinorMode()==RaceManager::RM_FOLLOW_LEADER)
|
||||
bottom_of_list = displayLeaderResults();
|
||||
else
|
||||
bottom_of_list = displayRaceResults();
|
||||
|
||||
widget_manager->addTextWgt( WTOK_RESULTS, 50, 7, _("Race results") );
|
||||
widget_manager->addTextWgt( WTOK_HIGHSCORES, 50, 7, _("Highscores") );
|
||||
widget_manager->breakLine();
|
||||
// If a new feature was unlocked, only offer 'continue' otherwise add the
|
||||
// full menu choices. The new feature menu returns to this menu, and will
|
||||
// then display the whole menu.
|
||||
if(unlock_manager->getUnlockedFeatures().size()>0)
|
||||
{
|
||||
Widget *w=widget_manager->addTextButtonWgt( WTOK_CONTINUE, 60, 7, _("Continue") );
|
||||
w->setPosition(WGT_DIR_CENTER, 0, NULL, WGT_DIR_UNDER_WIDGET, 0.05f, bottom_of_list);
|
||||
} else
|
||||
{
|
||||
Widget *w;
|
||||
if(race_manager->getMajorMode()==RaceManager::RM_GRAND_PRIX)
|
||||
{
|
||||
w=widget_manager->addTextButtonWgt( WTOK_CONTINUE, 60, 7, _("Continue Grand Prix"));
|
||||
}
|
||||
else
|
||||
{
|
||||
w=widget_manager->addTextButtonWgt( WTOK_CONTINUE, 60, 7, _("Back to the main menu"));
|
||||
}
|
||||
w->setPosition(WGT_DIR_CENTER, 0.0, NULL, WGT_DIR_UNDER_WIDGET, 0.1f, bottom_of_list);
|
||||
Widget *w_prev = w;
|
||||
w=widget_manager->addTextButtonWgt( WTOK_RESTART_RACE, 60, 7, _("Race in this track again"));
|
||||
w->setPosition(WGT_DIR_CENTER, 0.0, NULL, WGT_DIR_UNDER_WIDGET, 0, w_prev);
|
||||
w_prev = w;
|
||||
if(race_manager->getMajorMode()==RaceManager::RM_SINGLE)
|
||||
{
|
||||
w=widget_manager->addTextButtonWgt( WTOK_SETUP_NEW_RACE, 60, 7, _("Setup New Race"));
|
||||
w->setPosition(WGT_DIR_CENTER, 0, NULL, WGT_DIR_UNDER_WIDGET, 0, w_prev);
|
||||
}
|
||||
} // if !unlock_manager has something unlocked*/
|
||||
|
||||
widget_manager->switchOrder();
|
||||
widget_manager->layout(WGT_AREA_ALL);
|
||||
|
||||
} // RaceResultsGUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
Widget *RaceResultsGUI::displayLeaderResults()
|
||||
{
|
||||
const unsigned int MAX_STR_LEN = 60;
|
||||
const unsigned int NUM_KARTS = race_manager->getNumKarts();
|
||||
|
||||
int *scores = new int[NUM_KARTS];
|
||||
int *order = new int[NUM_KARTS];
|
||||
double *race_time = new double[NUM_KARTS];
|
||||
|
||||
// Ignore kart 0, since it was the leader
|
||||
for( unsigned int kart_id = 1; kart_id < NUM_KARTS; ++kart_id )
|
||||
{
|
||||
order[kart_id] = kart_id;
|
||||
scores[kart_id] = race_manager->getKartScore(kart_id);
|
||||
race_time[kart_id] = race_manager->getOverallTime(kart_id);
|
||||
}
|
||||
|
||||
//Bubblesort
|
||||
bool sorted;
|
||||
do
|
||||
{
|
||||
sorted = true;
|
||||
for( unsigned int i = 1; i < NUM_KARTS - 1; ++i )
|
||||
{
|
||||
if( scores[order[i]] < scores[order[i+1]] ||
|
||||
(scores[order[i]] == scores[order[i+1]]
|
||||
&& race_time[order[i]] > race_time[order[i+1]]) )
|
||||
{
|
||||
int tmp = order[i];
|
||||
order[i] = order[i+1];
|
||||
order[i+1] = tmp;
|
||||
sorted = false;
|
||||
}
|
||||
}
|
||||
} while(!sorted);
|
||||
for(unsigned int i=1; i<NUM_KARTS; i++)
|
||||
world->getKart(order[i])->setPosition(i);
|
||||
|
||||
Widget *w_prev=widget_manager->addTextWgt( WTOK_RESULTS, 5, 7, _("Race results") );
|
||||
widget_manager->hideWgtRect(WTOK_RESULTS);
|
||||
w_prev->setPosition(WGT_DIR_CENTER, 0.0f, NULL, WGT_DIR_FROM_TOP, 0.1f, NULL);
|
||||
|
||||
w_prev = displayKartList(1, NUM_KARTS-1, w_prev, order,
|
||||
/* display time*/ false, 0.3f);
|
||||
|
||||
delete []order;
|
||||
delete []scores;
|
||||
delete []race_time;
|
||||
return w_prev;
|
||||
} // displayLeaderResults
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Widget *RaceResultsGUI::displayRaceResults()
|
||||
{
|
||||
Widget *w_prev=widget_manager->addTextWgt( WTOK_RESULTS, 5, 7, _("Race results") );
|
||||
widget_manager->hideWgtRect(WTOK_RESULTS);
|
||||
w_prev->setPosition(WGT_DIR_FROM_LEFT, 0.1f, NULL, WGT_DIR_FROM_TOP, 0.1f, NULL);
|
||||
|
||||
const unsigned int MAX_STR_LEN = 60;
|
||||
const unsigned int NUM_KARTS = race_manager->getNumKarts();
|
||||
|
||||
int* order = new int [NUM_KARTS];
|
||||
m_score = new char[NUM_KARTS * MAX_STR_LEN];
|
||||
unsigned int max_name_len = 1;
|
||||
|
||||
for(unsigned int i=0; i < NUM_KARTS; i++)
|
||||
@ -73,42 +159,21 @@ RaceResultsGUI::RaceResultsGUI()
|
||||
if(l>max_name_len) max_name_len = l;
|
||||
} // for i
|
||||
|
||||
for(unsigned int i = 0; i < NUM_KARTS; ++i)
|
||||
{
|
||||
const Kart *KART = world->getKart(order[i]);
|
||||
const std::string& KART_NAME = KART->getName();
|
||||
char sTime[20];
|
||||
const float T = KART->getFinishTime();
|
||||
TimeToString(T, sTime);
|
||||
|
||||
//This shows position + driver name + time + points earned + total points
|
||||
if(race_manager->getRaceMode()==RaceManager::RM_GRAND_PRIX)
|
||||
{
|
||||
sprintf((char*)(m_score + MAX_STR_LEN * i), "%d. %s %s +%d %d",
|
||||
KART->getPosition(), KART_NAME.c_str(), sTime,
|
||||
race_manager->getPositionScore(i+1),
|
||||
race_manager->getKartScore(order[i]));
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf((char*)(m_score + MAX_STR_LEN * i), "%d. %s %s",
|
||||
KART->getPosition(), KART_NAME.c_str(), sTime);
|
||||
}
|
||||
|
||||
widget_manager->addTextWgt( WTOK_FIRST_RESULT + i, 50, 7,
|
||||
(char*)(m_score + MAX_STR_LEN * i) );
|
||||
}
|
||||
// save bottom of result list for later
|
||||
Widget *bottom_of_list=displayKartList(0, NUM_KARTS-1, w_prev,
|
||||
order, /*displayTime*/ true, 0.1f);
|
||||
|
||||
delete[] order;
|
||||
|
||||
widget_manager->breakLine();
|
||||
widget_manager->switchOrder();
|
||||
w_prev=widget_manager->addTextWgt( WTOK_HIGHSCORES, 5, 7, _("Highscores") );
|
||||
widget_manager->hideWgtRect(WTOK_HIGHSCORES);
|
||||
w_prev->setPosition(WGT_DIR_FROM_RIGHT, 0.1f, NULL, WGT_DIR_FROM_TOP, 0.1f, NULL);
|
||||
|
||||
const Highscores *hs = world->getHighscores();
|
||||
int num_scores = hs->getNumberEntries();
|
||||
m_highscores = new char[num_scores * MAX_STR_LEN];
|
||||
unsigned int num_scores = hs->getNumberEntries();
|
||||
char *highscores = new char[num_scores * MAX_STR_LEN];
|
||||
|
||||
for(int i=0; i<num_scores; i++)
|
||||
for(unsigned int i=0; i<num_scores; i++)
|
||||
{
|
||||
std::string kart_name, name;
|
||||
float T;
|
||||
@ -116,53 +181,69 @@ RaceResultsGUI::RaceResultsGUI()
|
||||
const int MINS = (int) floor ( T / 60.0 ) ;
|
||||
const int SECS = (int) floor ( T - (float) ( 60 * MINS ) ) ;
|
||||
const int TENTHS = (int) floor ( 10.0f * (T - (float)(SECS + 60*MINS)));
|
||||
sprintf((char*)( m_highscores + MAX_STR_LEN * i ),
|
||||
sprintf((char*)( highscores + MAX_STR_LEN * i ),
|
||||
"%s: %3d:%02d.%01d", name.c_str(), MINS, SECS, TENTHS);
|
||||
widget_manager->addTextWgt( WTOK_FIRST_HIGHSCORE + i, 50, 7,
|
||||
(char*)( m_highscores+MAX_STR_LEN*i ) );
|
||||
|
||||
Widget *w=widget_manager->addTextWgt(WTOK_FIRST_HIGHSCORE + i, 5, 7,
|
||||
(char*)( highscores+MAX_STR_LEN*i ) );
|
||||
w->setPosition(WGT_DIR_FROM_RIGHT, 0.1f, NULL, WGT_DIR_UNDER_WIDGET, 0, w_prev);
|
||||
w_prev=w;
|
||||
}
|
||||
widget_manager->breakLine();
|
||||
widget_manager->breakLine();
|
||||
|
||||
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 60, 5 );
|
||||
widget_manager->breakLine();
|
||||
widget_manager->sameWidth(WTOK_HIGHSCORES, WTOK_FIRST_HIGHSCORE+num_scores-1);
|
||||
|
||||
// If a new feature was unlocked, only offer 'continue' otherwise add the
|
||||
// full menu choices. The new feature menu returns to this menu, and will
|
||||
// then display the whole menu.
|
||||
if(unlock_manager->getUnlockedFeatures().size()>0)
|
||||
bottom_of_list = (num_scores > NUM_KARTS) ? w_prev : bottom_of_list;
|
||||
return bottom_of_list;
|
||||
} // displayRaceResults
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Widget *RaceResultsGUI::displayKartList(unsigned int from, unsigned int to,
|
||||
Widget *w_prev, int *order,
|
||||
bool display_time, float horizontal)
|
||||
{
|
||||
const int MAX_STR_LEN=60;
|
||||
char *score = new char[(to-from+1) * MAX_STR_LEN];
|
||||
for(unsigned int i = from; i <= to; ++i)
|
||||
{
|
||||
widget_manager->addTextButtonWgt( WTOK_CONTINUE, 60, 7, _("Continue") );
|
||||
} else
|
||||
{
|
||||
if(race_manager->getRaceMode()==RaceManager::RM_GRAND_PRIX)
|
||||
const Kart *KART = world->getKart(order[i]);
|
||||
const std::string& KART_NAME = KART->getName();
|
||||
char sTime[20];sTime[0]=0;
|
||||
const float T = KART->getFinishTime();
|
||||
if(display_time)
|
||||
TimeToString(T, sTime);
|
||||
|
||||
//This shows position + driver name + time + points earned + total points
|
||||
if(race_manager->getMajorMode()==RaceManager::RM_GRAND_PRIX)
|
||||
{
|
||||
widget_manager->addTextButtonWgt( WTOK_CONTINUE, 60, 7, _("Continue Grand Prix"));
|
||||
sprintf((char*)(score + MAX_STR_LEN * i), "%d. %s %s +%d %d",
|
||||
KART->getPosition(), KART_NAME.c_str(), sTime,
|
||||
race_manager->getKartPrevScore(order[i]),
|
||||
race_manager->getKartScore(order[i]));
|
||||
}
|
||||
else
|
||||
{
|
||||
widget_manager->addTextButtonWgt( WTOK_CONTINUE, 60, 7, _("Back to the main menu"));
|
||||
sprintf((char*)(score + MAX_STR_LEN * i), "%d. %s %s",
|
||||
KART->getPosition(), KART_NAME.c_str(), sTime);
|
||||
}
|
||||
widget_manager->breakLine();
|
||||
|
||||
widget_manager->addTextButtonWgt( WTOK_RESTART_RACE, 60, 7, _("Race in this track again"));
|
||||
widget_manager->breakLine();
|
||||
|
||||
if(race_manager->getRaceMode()==RaceManager::RM_QUICK_RACE)
|
||||
{
|
||||
widget_manager->addTextButtonWgt( WTOK_SETUP_NEW_RACE, 60, 7, _("Setup New Race"));
|
||||
}
|
||||
} // if !unlock_manager has something unlocked*/
|
||||
|
||||
widget_manager->layout(WGT_AREA_ALL);
|
||||
} // RaceResultsGUI
|
||||
Widget *image=widget_manager->addImgButtonWgt(WTOK_FIRST_IMAGE + i, 7, 7,
|
||||
KART->getKartProperties()->getIconFile() );
|
||||
image->setPosition(WGT_DIR_FROM_LEFT, horizontal, NULL,
|
||||
WGT_DIR_UNDER_WIDGET, 0.0f, w_prev);
|
||||
Widget *w=widget_manager->addTextWgt(WTOK_FIRST_RESULT + i, 5, 7,
|
||||
(char*)(score + MAX_STR_LEN * i) );
|
||||
w->setPosition(WGT_DIR_RIGHT_WIDGET, 0.1f, image,
|
||||
WGT_DIR_UNDER_WIDGET, 0.0f, w_prev);
|
||||
w_prev=w;
|
||||
}
|
||||
widget_manager->sameWidth(WTOK_FIRST_RESULT+from, WTOK_FIRST_RESULT+to);
|
||||
return w_prev;
|
||||
} // displayKartList
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
RaceResultsGUI::~RaceResultsGUI()
|
||||
{
|
||||
widget_manager->reset();
|
||||
delete[] m_score;
|
||||
delete[] m_highscores;
|
||||
} // ~RaceResultsGUI
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -194,7 +275,7 @@ void RaceResultsGUI::select()
|
||||
case WTOK_SETUP_NEW_RACE:
|
||||
world->unpause();
|
||||
race_manager->exit_race();
|
||||
menu_manager->pushMenu(MENUID_CHARSEL_P1);
|
||||
menu_manager->pushMenu(MENUID_GAMEMODE);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -20,15 +20,22 @@
|
||||
#ifndef HEADER_RACERESULTSGUI_H
|
||||
#define HEADER_RACERESULTSGUI_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base_gui.hpp"
|
||||
#include "widget.hpp"
|
||||
|
||||
/** GUI that shows the RaceResults, times and such */
|
||||
class RaceResultsGUI : public BaseGUI
|
||||
{
|
||||
private:
|
||||
char* m_score;
|
||||
char* m_highscores;
|
||||
std::vector<int> m_order;
|
||||
|
||||
Widget *displayLeaderResults();
|
||||
Widget *displayRaceResults();
|
||||
Widget *displayKartList(unsigned int from, unsigned int to,
|
||||
Widget *w_prev, int *order, bool display_time,
|
||||
float horizontal);
|
||||
public:
|
||||
RaceResultsGUI();
|
||||
~RaceResultsGUI();
|
||||
|
@ -60,7 +60,7 @@ TrackSel::TrackSel()
|
||||
w = widget_manager->addTextButtonWgt(WTOK_TRACK0+i, 30, HEIGHT, "");
|
||||
widget_manager->setWgtTextSize(WTOK_TRACK0+i, WGT_FNT_SML);
|
||||
w->setPosition(WGT_DIR_FROM_RIGHT, 0.03f*offset, NULL,
|
||||
WGT_DIR_UNDER_WIDGET, 0.15f, prev_widget);
|
||||
WGT_DIR_UNDER_WIDGET, 0.f, prev_widget);
|
||||
prev_widget = w;
|
||||
} // for i
|
||||
widget_manager->sameWidth(WTOK_TRACK0, WTOK_TRACK0+m_max_entries-1);
|
||||
@ -83,7 +83,7 @@ TrackSel::TrackSel()
|
||||
widget_manager->setWgtText(WTOK_AUTHOR, track_manager->getTrack(i)->getDescription());
|
||||
w->resizeToText();
|
||||
}
|
||||
w->setPosition(WGT_DIR_FROM_LEFT, 0.1f, NULL, WGT_DIR_UNDER_WIDGET, 0.05f, prev_widget);
|
||||
w->setPosition(WGT_DIR_FROM_LEFT, 0.1f, NULL, WGT_DIR_FROM_BOTTOM, 0.0f, prev_widget);
|
||||
|
||||
m_offset = 0;
|
||||
m_current_track = -1;
|
||||
|
@ -609,7 +609,7 @@
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
|
@ -396,7 +396,8 @@ void Kart::doLapCounting ()
|
||||
}
|
||||
// Race finished
|
||||
// =============
|
||||
if(m_race_lap>=race_manager->getNumLaps())
|
||||
if(m_race_lap>=race_manager->getNumLaps() &&
|
||||
race_manager->getMinorMode()!=RaceManager::RM_FOLLOW_LEADER)
|
||||
{
|
||||
raceFinished(world->getTime());
|
||||
}
|
||||
@ -447,7 +448,7 @@ void Kart::doLapCounting ()
|
||||
m_lap_start_time = -1.0f;
|
||||
} else
|
||||
{ // Switch to fast music in case of follow the leader when only 3 karts are left
|
||||
if(race_manager->getRaceMode()==RaceManager::RM_FOLLOW_LEADER &&
|
||||
if(race_manager->getMinorMode()==RaceManager::RM_FOLLOW_LEADER &&
|
||||
world->getCurrentNumKarts()==3)
|
||||
{
|
||||
sound_manager->switchToFastMusic();
|
||||
|
@ -421,7 +421,8 @@ void InitTuxkart()
|
||||
// default settings for Quickstart
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setNumLaps (3);
|
||||
race_manager->setRaceMode (RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setMajorMode (RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode (RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
}
|
||||
|
||||
@ -513,7 +514,8 @@ int main(int argc, char *argv[] )
|
||||
// =========
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setPlayerKart(0, kart_properties_manager->getKart("tuxkart")->getIdent());
|
||||
race_manager->setRaceMode (RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setMajorMode (RaceManager::RM_SINGLE);
|
||||
race_manager->setMinorMode (RaceManager::RM_QUICK_RACE);
|
||||
race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
race_manager->startNew();
|
||||
}
|
||||
|
@ -37,7 +37,8 @@ RaceManager::RaceManager()
|
||||
{
|
||||
m_num_karts = user_config->m_karts;
|
||||
m_difficulty = RD_HARD;
|
||||
m_race_mode = RM_QUICK_RACE;
|
||||
m_major_mode = RM_SINGLE;
|
||||
m_minor_mode = RM_QUICK_RACE;
|
||||
m_track_number = 0;
|
||||
m_active_race = false;
|
||||
m_score_for_position = stk_config->m_scores;
|
||||
@ -111,7 +112,7 @@ void RaceManager::setTrack(const std::string& track)
|
||||
//-----------------------------------------------------------------------------
|
||||
void RaceManager::startNew()
|
||||
{
|
||||
if(m_race_mode==RM_GRAND_PRIX) // GP: get tracks and laps from cup object
|
||||
if(m_major_mode==RM_GRAND_PRIX) // GP: get tracks and laps from cup object
|
||||
{
|
||||
m_tracks = m_cup.getTracks();
|
||||
m_num_laps = m_cup.getLaps();
|
||||
@ -163,11 +164,15 @@ void RaceManager::startNextRace()
|
||||
// ==============================================
|
||||
if (m_track_number > 0)
|
||||
{
|
||||
std::sort(m_kart_status.begin(), m_kart_status.end());//sort karts by increasing scor
|
||||
// In follow the leader mode do not change the first kart,
|
||||
// since it's always the leader.
|
||||
int offset = (m_minor_mode==RM_FOLLOW_LEADER) ? 1 : 0;
|
||||
|
||||
std::sort(m_kart_status.begin()+offset, m_kart_status.end());
|
||||
//reverse kart order if flagged in stk_config
|
||||
if (stk_config->m_grid_order)
|
||||
{
|
||||
std::reverse(m_kart_status.begin(), m_kart_status.end());
|
||||
std::reverse(m_kart_status.begin()+offset, m_kart_status.end());
|
||||
}
|
||||
} // not first race
|
||||
|
||||
@ -202,7 +207,7 @@ void RaceManager::exit_race()
|
||||
{
|
||||
// Only display the grand prix result screen if all tracks
|
||||
// were finished, and not when a race is aborted.
|
||||
if(m_race_mode==RM_GRAND_PRIX && m_track_number==(int)m_tracks.size())
|
||||
if(m_major_mode==RM_GRAND_PRIX && m_track_number==(int)m_tracks.size())
|
||||
{
|
||||
unlock_manager->grandPrixFinished();
|
||||
menu_manager->switchToGrandPrixEnding();
|
||||
@ -237,7 +242,7 @@ void RaceManager::RaceFinished(const Kart *kart, float time)
|
||||
// In follow the leader mode, kart 0 does not get any points,
|
||||
// so the position of each kart is actually one better --> decrease pos
|
||||
int pos = kart->getPosition();
|
||||
if(m_race_mode==RM_FOLLOW_LEADER)
|
||||
if(m_minor_mode==RM_FOLLOW_LEADER)
|
||||
{
|
||||
pos--;
|
||||
// If the position is negative (i.e. follow leader and kart on
|
||||
|
@ -46,8 +46,8 @@
|
||||
class RaceManager
|
||||
{
|
||||
public:
|
||||
enum RaceModeType { RM_TIME_TRIAL, RM_QUICK_RACE, RM_GRAND_PRIX,
|
||||
RM_FOLLOW_LEADER };
|
||||
enum RaceModeType { RM_GRAND_PRIX, RM_SINGLE, // The two current major modes
|
||||
RM_QUICK_RACE, RM_TIME_TRIAL, RM_FOLLOW_LEADER };
|
||||
enum Difficulty { RD_EASY, RD_MEDIUM, RD_HARD, RD_SKIDDING };
|
||||
|
||||
private:
|
||||
@ -72,7 +72,7 @@ private:
|
||||
|
||||
std::vector<KartStatus> m_kart_status;
|
||||
Difficulty m_difficulty;
|
||||
RaceModeType m_race_mode;
|
||||
RaceModeType m_major_mode, m_minor_mode;
|
||||
typedef std::vector<std::string> PlayerKarts;
|
||||
PlayerKarts m_player_karts;
|
||||
std::vector<std::string> m_tracks;
|
||||
@ -109,10 +109,12 @@ public:
|
||||
void setDifficulty(Difficulty diff);
|
||||
void setNumLaps(int num) { m_num_laps.clear();
|
||||
m_num_laps.push_back(num); }
|
||||
void setRaceMode(RaceModeType mode) { m_race_mode = mode; }
|
||||
void setMajorMode(RaceModeType mode){ m_major_mode = mode; }
|
||||
void setMinorMode(RaceModeType mode){ m_minor_mode = mode; }
|
||||
void setNumKarts(int num) { m_num_karts = num; }
|
||||
void setCoinTarget(int num) { m_coin_target = num; }
|
||||
RaceModeType getRaceMode() const { return m_race_mode; }
|
||||
RaceModeType getMajorMode() const { return m_major_mode; }
|
||||
RaceModeType getMinorMode() const { return m_minor_mode; }
|
||||
unsigned int getNumKarts() const { return m_num_karts; }
|
||||
unsigned int getNumPlayers() const { return (int)m_player_karts.size();}
|
||||
int getNumLaps() const { return m_num_laps[m_track_number];}
|
||||
@ -128,11 +130,12 @@ public:
|
||||
const std::string&
|
||||
getHerringStyle() const { return m_cup.getHerringStyle(); }
|
||||
int getKartScore(int krt) const { return m_kart_status[krt].m_score;}
|
||||
int getKartPrevScore(int krt)const { return m_kart_status[krt].m_last_score;}
|
||||
int getkartPlayerId(int krt) const { return m_kart_status[krt].m_player_id;}
|
||||
int getPositionScore(int p) const { return m_score_for_position[p-1]; }
|
||||
double getOverallTime(int kart) const { return m_kart_status[kart].m_overall_time;}
|
||||
int getCoinTarget() const { return m_coin_target; }
|
||||
bool raceHasLaps() const { return m_race_mode!=RM_FOLLOW_LEADER;}
|
||||
int getCoinTarget() const { return m_coin_target; }
|
||||
bool raceHasLaps() const { return m_minor_mode!=RM_FOLLOW_LEADER;}
|
||||
int allPlayerFinished() const {return
|
||||
m_num_finished_players==m_player_karts.size(); }
|
||||
int raceIsActive() const { return m_active_race; }
|
||||
|
@ -147,8 +147,8 @@ void DefaultRobot::handle_braking()
|
||||
{
|
||||
// In follow the leader mode, the kart should brake if they are ahead of
|
||||
// the leader (and not the leader, i.e. don't have initial position 1)
|
||||
if(race_manager->getRaceMode()==RaceManager::RM_FOLLOW_LEADER &&
|
||||
getPosition()<world->getKart(0)->getPosition() &&
|
||||
if(race_manager->getMinorMode()==RaceManager::RM_FOLLOW_LEADER &&
|
||||
getPosition()<world->getKart(0)->getPosition() &&
|
||||
getInitialPosition()>1 )
|
||||
{
|
||||
m_controls.brake = true;
|
||||
|
@ -1324,7 +1324,7 @@ void Track::herring_command (sgVec3 *xyz, char htype, int bNeedHeight )
|
||||
if ( htype=='S' || htype=='s' ) { type = HE_SILVER ;}
|
||||
|
||||
// Time trial does not have any red herrings
|
||||
if(type==HE_RED && race_manager->getRaceMode()==RaceManager::RM_TIME_TRIAL)
|
||||
if(type==HE_RED && race_manager->getMinorMode()==RaceManager::RM_TIME_TRIAL)
|
||||
return;
|
||||
Vec3 loc((*xyz));
|
||||
herring_manager->newHerring(type, loc);
|
||||
|
@ -165,7 +165,7 @@ void Widget::layout()
|
||||
case WGT_DIR_ABOVE_WIDGET:
|
||||
m_y = m_widget_vertical->m_y + m_widget_vertical->m_height; break;
|
||||
case WGT_DIR_UNDER_WIDGET:
|
||||
m_y = m_widget_vertical->m_y-m_height; break;
|
||||
m_y = m_widget_vertical->m_y-m_height-(int)(m_percentage_y*user_config->m_height); break;
|
||||
default:
|
||||
break;
|
||||
} // switch
|
||||
|
@ -145,7 +145,7 @@ World::World()
|
||||
//ssgSetBackFaceCollisions ( !not defined! race_manager->mirror ) ;
|
||||
#endif
|
||||
|
||||
Highscores::HighscoreType hst = (race_manager->getRaceMode()==RaceManager::RM_TIME_TRIAL)
|
||||
Highscores::HighscoreType hst = (race_manager->getMinorMode()==RaceManager::RM_TIME_TRIAL)
|
||||
? Highscores::HST_TIMETRIAL_OVERALL_TIME
|
||||
: Highscores::HST_RACE_OVERALL_TIME;
|
||||
|
||||
@ -273,9 +273,10 @@ void World::update(float dt)
|
||||
|
||||
if( getPhase() == FINISH_PHASE )
|
||||
{
|
||||
if(race_manager->getRaceMode()==RaceManager::RM_FOLLOW_LEADER)
|
||||
if(race_manager->getMinorMode()==RaceManager::RM_FOLLOW_LEADER)
|
||||
{
|
||||
menu_manager->pushMenu(MENUID_LEADERRESULT);
|
||||
pause();
|
||||
menu_manager->pushMenu(MENUID_RACERESULT);
|
||||
unlock_manager->raceFinished();
|
||||
return;
|
||||
}
|
||||
@ -352,13 +353,13 @@ void World::updateHighscores()
|
||||
|
||||
PlayerKart *k = (PlayerKart*)m_kart[index[pos]];
|
||||
|
||||
Highscores::HighscoreType hst = (race_manager->getRaceMode()==
|
||||
RaceManager::RM_TIME_TRIAL)
|
||||
? Highscores::HST_TIMETRIAL_OVERALL_TIME
|
||||
: Highscores::HST_RACE_OVERALL_TIME;
|
||||
Highscores::HighscoreType hst = (race_manager->getMinorMode()==
|
||||
RaceManager::RM_TIME_TRIAL)
|
||||
? Highscores::HST_TIMETRIAL_OVERALL_TIME
|
||||
: Highscores::HST_RACE_OVERALL_TIME;
|
||||
if(m_highscores->addData(hst, k->getName(),
|
||||
k->getPlayer()->getName(),
|
||||
k->getFinishTime())>0 )
|
||||
k->getPlayer()->getName(),
|
||||
k->getFinishTime())>0 )
|
||||
{
|
||||
highscore_manager->Save();
|
||||
}
|
||||
@ -466,7 +467,7 @@ void World::updateRaceStatus(float dt)
|
||||
case SET_PHASE : if(m_clock>2.0)
|
||||
{
|
||||
m_phase=GO_PHASE;
|
||||
if(race_manager->getRaceMode()==RaceManager::RM_FOLLOW_LEADER)
|
||||
if(race_manager->getMinorMode()==RaceManager::RM_FOLLOW_LEADER)
|
||||
m_clock=m_leader_intervals[0];
|
||||
else
|
||||
m_clock=0.0f;
|
||||
@ -485,7 +486,7 @@ void World::updateRaceStatus(float dt)
|
||||
}
|
||||
m_clock += dt;
|
||||
return;
|
||||
case GO_PHASE : if(race_manager->getRaceMode()==RaceManager::RM_FOLLOW_LEADER)
|
||||
case GO_PHASE : if(race_manager->getMinorMode()==RaceManager::RM_FOLLOW_LEADER)
|
||||
{
|
||||
// Switch to race if more than 1 second has past
|
||||
if(m_clock<m_leader_intervals[0]-1.0f)
|
||||
@ -514,7 +515,7 @@ void World::updateRaceStatus(float dt)
|
||||
default : break;
|
||||
} // switch
|
||||
|
||||
if(race_manager->getRaceMode()==RaceManager::RM_FOLLOW_LEADER)
|
||||
if(race_manager->getMinorMode()==RaceManager::RM_FOLLOW_LEADER)
|
||||
return updateLeaderMode(dt);
|
||||
|
||||
// The status must now be race mode!
|
||||
@ -698,11 +699,11 @@ void World::updateRacePosition ( int k )
|
||||
// Switch on faster music (except in follow leader mode) if not already
|
||||
// done so, and the first kart is doing its last lap, and the estimated
|
||||
// remaining time is less than 30 seconds.
|
||||
if(!m_faster_music_active &&
|
||||
m_kart[k]->getLap()==race_manager->getNumLaps()-1 &&
|
||||
p==1 &&
|
||||
race_manager->getRaceMode()!=RaceManager::RM_FOLLOW_LEADER &&
|
||||
m_kart[k]->estimateFinishTime()-getTime()<30.0f )
|
||||
if(!m_faster_music_active &&
|
||||
m_kart[k]->getLap()==race_manager->getNumLaps()-1 &&
|
||||
p==1 &&
|
||||
race_manager->getMinorMode()!=RaceManager::RM_FOLLOW_LEADER &&
|
||||
m_kart[k]->estimateFinishTime()-getTime()<30.0f )
|
||||
{
|
||||
sound_manager->switchToFastMusic();
|
||||
m_faster_music_active=true;
|
||||
@ -715,7 +716,7 @@ void World::loadTrack()
|
||||
// remove old herrings (from previous race), and remove old
|
||||
// track specific herring models
|
||||
herring_manager->cleanup();
|
||||
if(race_manager->getRaceMode()== RaceManager::RM_GRAND_PRIX)
|
||||
if(race_manager->getMajorMode()== RaceManager::RM_GRAND_PRIX)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user