Back to index

supertuxkart  0.5+dfsg1
game_mode.cpp
Go to the documentation of this file.
00001 //  $Id: game_mode.cpp 2111 2008-05-31 07:04:30Z cosmosninja $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2006 SuperTuxKart-Team
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #include "game_mode.hpp"
00021 #include "widget_manager.hpp"
00022 #include "race_manager.hpp"
00023 #include "material_manager.hpp"
00024 #include "menu_manager.hpp"
00025 #include "translation.hpp"
00026 #include "user_config.hpp"
00027 #include "unlock_manager.hpp"
00028 
00029 enum WidgetTokens
00030 {
00031     WTOK_TITLE,
00032 
00033     WTOK_GP,
00034     WTOK_QUICKRACE,
00035     WTOK_TIMETRIAL,
00036     WTOK_FOLLOW_LEADER,
00037 
00038     WTOK_HELP,
00039     WTOK_QUIT
00040 };
00041 
00042 GameMode::GameMode()
00043 {
00044     widget_manager->switchOrder();
00045 
00046     widget_manager->addTextButtonWgt( WTOK_GP, 60, 7, _("Grand Prix"));
00047 
00048     if(unlock_manager->isLocked("grandprix"))
00049     {
00050         widget_manager->hideWgtText( WTOK_GP );
00051         widget_manager->deactivateWgt( WTOK_GP );
00052 
00053         widget_manager->setWgtColor( WTOK_GP, WGT_WHITE);
00054         widget_manager->setWgtTexture( WTOK_GP, "gui_lock.rgb", false );
00055         widget_manager->showWgtTexture( WTOK_GP );
00056     }
00057 
00058 
00059     widget_manager->addTextButtonWgt(WTOK_QUICKRACE, 60, 7, _("Quick Race"));
00060 
00061     if( race_manager->getNumPlayers() == 1 )
00062     {
00063         widget_manager->addTextButtonWgt(WTOK_TIMETRIAL, 60, 7, _("Time Trial"));
00064     }
00065 
00066 
00067     widget_manager->addTextButtonWgt( WTOK_FOLLOW_LEADER, 60, 7,
00068         _("Follow the Leader"));
00069 
00070     if(unlock_manager->isLocked("followleader"))
00071     {
00072         widget_manager->hideWgtText( WTOK_FOLLOW_LEADER );
00073 
00074 //        widget_manager->deactivateWgt( WTOK_FOLLOW_LEADER );
00075 
00076         widget_manager->setWgtColor( WTOK_FOLLOW_LEADER, WGT_GRAY);
00077         widget_manager->setWgtTexture( WTOK_FOLLOW_LEADER, "gui_lock.rgb", false );
00078         widget_manager->showWgtTexture( WTOK_FOLLOW_LEADER );
00079         widget_manager->setWgtText(WTOK_FOLLOW_LEADER,
00080                                         _("Fulfil challenge to unlock"));
00081     }
00082 
00083     widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 1, 7);
00084 
00085     widget_manager->addTextButtonWgt( WTOK_HELP, 60, 7, _("Game mode help"));
00086     widget_manager->setWgtTextSize( WTOK_HELP, WGT_FNT_SML );
00087 
00088     widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 1, 7);
00089 
00090     widget_manager->addTextButtonWgt(WTOK_QUIT, 60, 7, _("Press <ESC> to go back"));
00091     widget_manager->setWgtTextSize( WTOK_QUIT, WGT_FNT_SML );
00092 
00093     widget_manager->layout(WGT_AREA_ALL);
00094 }
00095 
00096 //-----------------------------------------------------------------------------
00097 GameMode::~GameMode()
00098 {
00099     widget_manager->reset();
00100 }
00101 
00102 //-----------------------------------------------------------------------------
00103 void GameMode::select()
00104 {
00105     switch ( widget_manager->getSelectedWgt() )
00106     {
00107     case WTOK_GP:
00108         race_manager->setRaceMode(RaceManager::RM_GRAND_PRIX);
00109         menu_manager->pushMenu(MENUID_CHARSEL_P1);
00110         break;
00111     case WTOK_QUICKRACE:
00112         race_manager->setRaceMode(RaceManager::RM_QUICK_RACE);
00113         menu_manager->pushMenu(MENUID_CHARSEL_P1);
00114         break;
00115     case WTOK_FOLLOW_LEADER:
00116         if(unlock_manager->isLocked("followleader"))
00117         {
00118             widget_manager->showWgtText( WTOK_FOLLOW_LEADER );
00119             widget_manager->setWgtTextColor( WTOK_FOLLOW_LEADER, WGT_TRANS_GRAY);
00120             widget_manager->setWgtColor( WTOK_FOLLOW_LEADER, WGT_TRANS_GRAY);
00121         }
00122         else
00123         {
00124             race_manager->setRaceMode(RaceManager::RM_FOLLOW_LEADER);
00125             menu_manager->pushMenu(MENUID_CHARSEL_P1);
00126         }
00127         break;
00128     case WTOK_TIMETRIAL:
00129         race_manager->setRaceMode(RaceManager::RM_TIME_TRIAL);
00130         menu_manager->pushMenu(MENUID_CHARSEL_P1);
00131         break;
00132     case WTOK_HELP:
00133         menu_manager->pushMenu(MENUID_HELP3);
00134         break;
00135     case WTOK_QUIT:
00136         menu_manager->popMenu();
00137         break;
00138     default: break;
00139     }
00140 }
00141 
00142 
00143