Back to index

extremetuxracer  0.5beta
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes
EventSelect Class Reference

#include <event_select.h>

Inheritance diagram for EventSelect:
Inheritance graph
[legend]
Collaboration diagram for EventSelect:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 EventSelect ()
 ~EventSelect ()
void loop (float timeStep)
void cupChanged ()
void eventChanged ()
void listboxModelChange ()
void buttonModelChange ()
void back ()
void apply ()
bool keyPressEvent (SDLKey key)
virtual bool keyboardEvent (SDLKey key, bool release)
virtual bool keyReleaseEvent (SDLKey key)
virtual bool mouseButtonEvent (int button, int x, int y, bool pressed)
virtual bool mouseButtonPressEvent (int button, int x, int y)
virtual bool mouseButtonReleaseEvent (int button, int x, int y)

Static Public Attributes

static GameModecurrentMode = NULL
static game_mode_t mode
static game_mode_t prevmode

Protected Member Functions

void drawSnow (float timeStep, bool windy=false)
 custom function for drawing snow in the ui

Private Member Functions

void updateCupStates ()
void updateButtonEnabledStates ()

Private Attributes

pp::Listbox< EventData > * mp_eventListbox
pp::Listbox< CupData > * mp_cupListbox
pp::Vec2d mp_cupListbox_pos
pp::Vec2d mp_cupListbox_size
std::list< EventData >::iterator m_curEvent
std::list< CupData >::iterator m_curCup
bool m_curCupComplete
bool m_curCupPlayable
pp::Buttonmp_backBtn
pp::Buttonmp_continueBtn
std::list< model_tm_modelList
pp::SSButtonmp_modelSSBtn
pp::Listbox< model_t > * mp_modelEnt
pp::Labelmp_titleLbl
pp::Labelmp_eventLbl
pp::Labelmp_cupLbl
pp::Labelmp_statusLbl
pp::Labelmp_nameLbl
pp::Entrymp_nameEnt

Detailed Description

Definition at line 35 of file event_select.h.


Constructor & Destructor Documentation

Definition at line 31 of file event_select.cpp.

{
       if(GameMode::prevmode==EVENT_RACE_SELECT){
              m_curEvent = gameMgr->currentEvent;
              m_curCup = gameMgr->currentCup;
              if(players[0].isCupComplete((*m_curEvent).name,(*m_curCup).name)){
                     if(m_curCup != --(*m_curEvent).cupList.end()){
                            m_curCup++;
                     }                           
              }
       }else{
              m_curEvent = eventList.begin();
              m_curCup = (*m_curEvent).cupList.begin();
       }
       
              
       pp::Vec2d pos( getparam_x_resolution()/2,
                               getparam_y_resolution()/2+90);
       
       mp_titleLbl = new pp::Label(pos,"menu_label",_("Select campaign and cup"));
       mp_titleLbl->alignment.center();
       
       
       pos.x-=200;
       pos.y-=40;
       mp_eventLbl = new pp::Label(pos,"event_and_cup_label",_("Campaign:"));       
       
       pos.y-=50;
       mp_eventListbox = new pp::Listbox<EventData>( pos,
                               pp::Vec2d(400, 40),
                               "listbox_item",
                               eventList);
       mp_eventListbox->setCurrentItem( m_curEvent );
       mp_eventListbox->signalChange.Connect(pp::CreateSlot(this,&EventSelect::eventChanged));
       
       pos.y-=40;
       mp_cupLbl = new pp::Label(pos,"event_and_cup_label",_("Cup:"));
              
       pos.y-=50;
       mp_cupListbox_size = pp::Vec2d(400, 40);
       mp_cupListbox_pos = pos;
       mp_cupListbox = new pp::Listbox<CupData>( mp_cupListbox_pos,
                               mp_cupListbox_size,
                               "listbox_item",
                               (*m_curEvent).cupList );
       mp_cupListbox->setCurrentItem( m_curCup );       
    mp_cupListbox->signalChange.Connect(pp::CreateSlot(this,&EventSelect::cupChanged));

       pos.y-=30;
       mp_statusLbl = new pp::Label( pp::Vec2d(pos.x+200,pos.y),
                                                          "cup_status","");
       mp_statusLbl->alignment.center();

     pos.y-=80;
     pp::Vec2d size(176,32);
     pp::Vec2d pos2(pos.x+150,pos.y-10);
     mp_nameLbl = new pp::Label( pos,"event_and_cup_label",_("Player name:"));
       mp_nameEnt = new pp::Entry(pos2,size,"event_and_cup_label",players[0].name.c_str());
       mp_nameEnt->setMaxChars(13);

     pos.y-=65;
       pos.x-=50;    
       mp_backBtn = new pp::Button( pos,
                           pp::Vec2d(150, 40), 
                           "button_label", 
                           _("Back") );
    mp_backBtn->setHilitFontBinding( "button_label_hilit" );
    mp_backBtn->signalClicked.Connect(pp::CreateSlot(this,&EventSelect::back));

       pos.x+=350;   
       mp_continueBtn = new pp::Button( pos,
                            pp::Vec2d(150, 40),
                            "button_label",
                            _("Continue") );
    mp_continueBtn->setHilitFontBinding( "button_label_hilit" );
    mp_continueBtn->setDisabledFontBinding( "button_label_disabled" );
    mp_continueBtn->signalClicked.Connect(pp::CreateSlot(this,&EventSelect::apply));
    
    
    pos.x+=50;
    pos.y+=50;
    
    #define MODELID_TUX 0
    #define MODELID_SAMUEL 1
    #define MODELID_TRIXI 2
    #define MODELID_SPEEDY 3
    // model icon
       mp_modelSSBtn = new pp::SSButton( pos,
                                  pp::Vec2d(89, 99),
                                  4 );
    mp_modelSSBtn->setStateImage(MODELID_TUX,"modelpreviews_button",
                              pp::Vec2d( 0.0, 0.0 ),
                              pp::Vec2d( 0.25, 1.0 ),
                              pp::Color::white );
       mp_modelSSBtn->setStateImage(MODELID_SAMUEL,"modelpreviews_button",
                              pp::Vec2d( 0.25, 0.0 ),
                              pp::Vec2d( 0.50, 1.0 ),
                              pp::Color::white );

       mp_modelSSBtn->setStateImage(MODELID_TRIXI,"modelpreviews_button",
                              pp::Vec2d( 0.50, 0.0 ),
                              pp::Vec2d( 0.75, 1.0 ),
                              pp::Color::white );
                  
    mp_modelSSBtn->setStateImage(MODELID_SPEEDY,"modelpreviews_button",
                              pp::Vec2d( 0.75, 0.0 ),
                              pp::Vec2d( 1.0, 1.0 ),
                              pp::Color::white );
    mp_modelSSBtn->signalClicked.Connect(pp::CreateSlot(this,&EventSelect::buttonModelChange));

    m_modelList = ModelHndl->l_models;
    pos.y -= -45;
    pos.x -= 200;
    mp_modelEnt = new pp::Listbox<model_t>( pos, pp::Vec2d(139, 32), "listbox_item", m_modelList);
    mp_modelEnt->signalChange.Connect(pp::CreateSlot(this,&EventSelect::listboxModelChange));
    std::list<model_t>::iterator modelit = mp_modelEnt->getCurrentItem();
    mp_modelSSBtn->setState(modelit->id);
    
       
       updateCupStates();
       updateButtonEnabledStates();
}

Here is the call graph for this function:

Definition at line 154 of file event_select.cpp.

{
       delete mp_backBtn;
       delete mp_continueBtn;      
       delete mp_eventListbox;
       delete mp_cupListbox;
       
       delete mp_titleLbl;
       delete mp_eventLbl;
       delete mp_cupLbl;    
       delete mp_statusLbl;
       delete mp_nameLbl;
    
    //if we don't delete the buttons, the game just crashes when the player leaves the event selection screen
    delete mp_modelSSBtn;
    delete mp_modelEnt;
       
       delete mp_nameEnt;
}

Member Function Documentation

Definition at line 269 of file event_select.cpp.

{
       if(mp_continueBtn->getSensitive()) {
              players[0].name = mp_nameEnt->getContent();
            m_curEvent = mp_eventListbox->getCurrentItem();
              m_curCup = mp_cupListbox->getCurrentItem();
        


              gameMgr->setupEventAndCup(  m_curEvent,
                                                               m_curCup );

              if(!getparam_always_save_event_race_data()){     
                     if(!players[0].isCupComplete((*m_curEvent).name, (*m_curCup).name )){
                            players[0].clearCupData((*m_curEvent).name, (*m_curCup).name);
                     }
              }
              players[0].resetLives();
        std::list<model_t>::iterator modelit = mp_modelEnt->getCurrentItem();
        ModelHndl->load_model((*modelit).id);
           set_game_mode( EVENT_RACE_SELECT );
           UIMgr.setDirty();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 262 of file event_select.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 251 of file event_select.cpp.

                                    {
    std::list<model_t>::iterator modelit = mp_modelEnt->getCurrentItem();
    modelit++;
    if(modelit!=mp_modelEnt->getItemList().end()) {
        mp_modelEnt->setCurrentItem(modelit);
    } else {
        mp_modelEnt->setCurrentItem(mp_modelEnt->getItemList().begin());
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 223 of file event_select.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void GameMode::drawSnow ( float  timeStep,
bool  windy = false 
) [protected, inherited]

custom function for drawing snow in the ui

Definition at line 203 of file loop.cpp.

{
       // check wether ui snow is 
       if(getparam_ui_snow()){
              // update and draw snow
              update_ui_snow( timeStep, windy );
              draw_ui_snow();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 231 of file event_select.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool GameMode::keyboardEvent ( SDLKey  key,
bool  release 
) [inline, virtual, inherited]

Reimplemented in Racing.

Definition at line 90 of file loop.h.

{return false;};
bool EventSelect::keyPressEvent ( SDLKey  key) [virtual]

Reimplemented from GameMode.

Definition at line 295 of file event_select.cpp.

{
       switch (key){
              case SDLK_UP:
                     mp_cupListbox->gotoPrevItem();
              return true;
              case SDLK_DOWN:
                     mp_cupListbox->gotoNextItem();
              return true;
              case SDLK_LEFT:
                     mp_eventListbox->gotoPrevItem();
              return true;
              case SDLK_RIGHT:
                     mp_eventListbox->gotoPrevItem();
              return true;
              case SDLK_RETURN: 
              mp_continueBtn->simulateMouseClick();
                     UIMgr.setDirty();
                     return true;
              case SDLK_ESCAPE: 
              mp_backBtn->simulateMouseClick();
                     UIMgr.setDirty();
                     return true;
              default:
                     return false;
       }      
}

Here is the call graph for this function:

virtual bool GameMode::keyReleaseEvent ( SDLKey  key) [inline, virtual, inherited]

Reimplemented in HighscoreShow, and SplashScreen.

Definition at line 92 of file loop.h.

{return false;};

Definition at line 246 of file event_select.cpp.

                                     {
    std::list<model_t>::iterator modelit = mp_modelEnt->getCurrentItem();
    mp_modelSSBtn->setState(modelit->id);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void EventSelect::loop ( float  timeStep) [virtual]

Implements GameMode.

Definition at line 175 of file event_select.cpp.

{
    update_audio();
    set_gl_options( GUI );
    clear_rendering_context();
    UIMgr.setupDisplay();
       drawSnow(timeStep);
    theme.drawMenuDecorations();
    UIMgr.draw();
    reshape( getparam_x_resolution(), getparam_y_resolution() );
    winsys_swap_buffers();
}

Here is the call graph for this function:

virtual bool GameMode::mouseButtonEvent ( int  button,
int  x,
int  y,
bool  pressed 
) [inline, virtual, inherited]

Reimplemented in GameOver.

Definition at line 94 of file loop.h.

{return false;};
virtual bool GameMode::mouseButtonPressEvent ( int  button,
int  x,
int  y 
) [inline, virtual, inherited]

Definition at line 95 of file loop.h.

{return false;};
virtual bool GameMode::mouseButtonReleaseEvent ( int  button,
int  x,
int  y 
) [inline, virtual, inherited]

Reimplemented in CreditsTrans, and SplashScreen.

Definition at line 96 of file loop.h.

{return false;};

Definition at line 213 of file event_select.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void EventSelect::updateCupStates ( ) [private]

Definition at line 189 of file event_select.cpp.

{
       m_curCupComplete=false;
       m_curCupPlayable=false;
       
       if ( players[0].isCupComplete( (*m_curEvent).name, (*m_curCup).name) ) {
              m_curCupComplete=true;
              m_curCupPlayable=true;
    } else if ( players[0].isFirstIncompleteCup( m_curEvent, m_curCup ) ) {
              m_curCupPlayable=true;
    }
       
       const char* string;
       if(m_curCupComplete){
              string = _("You've won this cup!");
       }else if (m_curCupPlayable){
              string = _("You must complete this cup next");
       }else{
              string = _("You cannot enter this cup yet"); 
       }
       mp_statusLbl->setText(string);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

GameMode * GameMode::currentMode = NULL [static, inherited]

Definition at line 96 of file loop.h.

std::list<CupData>::iterator EventSelect::m_curCup [private]

Definition at line 43 of file event_select.h.

Definition at line 45 of file event_select.h.

Definition at line 46 of file event_select.h.

std::list<EventData>::iterator EventSelect::m_curEvent [private]

Definition at line 42 of file event_select.h.

std::list<model_t> EventSelect::m_modelList [private]

Definition at line 51 of file event_select.h.

game_mode_t GameMode::mode [static, inherited]

Definition at line 99 of file loop.h.

Definition at line 48 of file event_select.h.

Definition at line 49 of file event_select.h.

Definition at line 58 of file event_select.h.

Definition at line 38 of file event_select.h.

Definition at line 39 of file event_select.h.

Definition at line 40 of file event_select.h.

Definition at line 57 of file event_select.h.

Definition at line 37 of file event_select.h.

Definition at line 54 of file event_select.h.

Definition at line 53 of file event_select.h.

Definition at line 62 of file event_select.h.

Definition at line 60 of file event_select.h.

Definition at line 59 of file event_select.h.

Definition at line 56 of file event_select.h.

game_mode_t GameMode::prevmode [static, inherited]

Definition at line 100 of file loop.h.


The documentation for this class was generated from the following files: