Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Protected Attributes | Private Attributes
GrandPrixSelect Class Reference

#include <grand_prix_select.hpp>

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

List of all members.

Public Member Functions

 GrandPrixSelect ()
 ~GrandPrixSelect ()
void update (float dt)
void select ()
virtual void handle (GameAction, int)
virtual void inputKeyboard (SDLKey, int)
virtual void countdown ()
void inputPointer (int x, int y)
void lockInput ()
void unlockInput ()
void TimeToString (const double time, char *s)

Protected Attributes

bool m_locked
int m_menu_id

Private Attributes

std::vector< CupDatam_all_cups
std::vector< std::string > m_cup_tracks
std::vector< int > m_track_imgs
unsigned int m_curr_track_img
float m_clock

Detailed Description

Definition at line 27 of file grand_prix_select.hpp.


Constructor & Destructor Documentation

Definition at line 47 of file grand_prix_select.cpp.

                                 : m_curr_track_img(0), m_clock(0.0f)
{
    widget_manager->switchOrder();
    widget_manager->addEmptyWgt(WTOK_TITLE, 60, 7);

    // Findout which grand prixs are available and load them
    std::set<std::string> result;
    file_manager->listFiles(result, "data");
    int nId = 0;
    for(std::set<std::string>::iterator i  = result.begin();
            i != result.end()  ; i++)
        {
            if (StringUtils::has_suffix(*i, ".cup"))
            {
                CupData cup(*i);
                if(unlock_manager->isLocked(cup.getName())) continue;
                m_all_cups.push_back(cup);
                widget_manager->addTextButtonWgt(WTOK_FIRSTPRIX + nId, 60, 7, cup.getName() );
                nId++;
            }   // if
        }   // for i

    widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 100, 1 );

    widget_manager->addTextWgt( WTOK_DESCRIPTION, 80, 7, _("No Grand Prix selected") );
    widget_manager->setWgtTextSize(WTOK_DESCRIPTION, WGT_FNT_SML);
    widget_manager->hideWgtRect(WTOK_DESCRIPTION);
    widget_manager->breakLine();
    widget_manager->breakLine();

    widget_manager->addTextWgt( WTOK_TRACKS, 60, 40, _("No Grand Prix selected"));
    widget_manager->enableWgtScroll( WTOK_TRACKS );
    widget_manager->setWgtYScrollSpeed( WTOK_TRACKS, -60 );

    widget_manager->addImgWgt( WTOK_IMG, 40, 40, 0 );
    widget_manager->setWgtColor( WTOK_IMG, WGT_BLACK );
    widget_manager->breakLine();

    widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 100, 1 );
    widget_manager->breakLine();

    widget_manager->addTextButtonWgt(WTOK_QUIT, 40, 7, _("Press <ESC> to go back") );
    widget_manager->setWgtTextSize(WTOK_QUIT, WGT_FNT_SML);

    widget_manager->layout(WGT_AREA_ALL);
}   // GrandPrixSelect

Here is the call graph for this function:

Definition at line 95 of file grand_prix_select.cpp.

{
    widget_manager->reset();
}   // GrandPrixSelect

Here is the call graph for this function:


Member Function Documentation

void BaseGUI::countdown ( ) [virtual, inherited]

Reimplemented in DisplayResConfirm.

Definition at line 147 of file base_gui.cpp.

{
}
void BaseGUI::handle ( GameAction  action,
int  value 
) [virtual, inherited]

Reimplemented in RaceGUI, LeaderResult, PlayerControls, RaceResultsGUI, DisplayResConfirm, MainMenu, Options, and RaceMenu.

Definition at line 43 of file base_gui.cpp.

{
    if( m_locked ) return;

    // Skip on keypress, act on keyrelease only.
    if (value) return;

       int previous = widget_manager->getSelectedWgt();

    switch ( action )
    {
    case GA_CURSOR_LEFT:
              animateWidget(previous,
                                     widget_manager->handleLeft());

              break;
    case GA_CURSOR_RIGHT:
              animateWidget(previous,
                                     widget_manager->handleRight());
              break;
    case GA_CURSOR_UP:
              animateWidget(previous,
                                     widget_manager->handleUp());
              break;
    case GA_CURSOR_DOWN:
              animateWidget(previous,
                                     widget_manager->handleDown());
              break;
       case GA_INC_SCROLL_SPEED:
              widget_manager->increaseScrollSpeed();
              break;
       case GA_INC_SCROLL_SPEED_FAST:
              widget_manager->increaseScrollSpeed(true);
              break;
       case GA_DEC_SCROLL_SPEED:
              widget_manager->decreaseScrollSpeed();
              break;
       case GA_DEC_SCROLL_SPEED_FAST:
              widget_manager->decreaseScrollSpeed(true);
              break;
    case GA_ENTER:
        select();
        break;
    case GA_LEAVE:
        if (menu_manager->getMenuStackSize() > 1)
        {
           if(menu_manager->isCurrentMenu(MENUID_RACEMENU))
             world->unpause();

           menu_manager->popMenu();
        }
        break;

    default:
        break;
    }   // switch
}   // handle

Here is the call graph for this function:

Here is the caller graph for this function:

void BaseGUI::inputKeyboard ( SDLKey  ,
int   
) [virtual, inherited]

Reimplemented in PlayerControls.

Definition at line 139 of file base_gui.cpp.

{
       // This method is not supposed to be called since BaseGUI does not
       // handle low-level keyboard input.
       assert(false);
}

Here is the caller graph for this function:

void BaseGUI::inputPointer ( int  x,
int  y 
) [inherited]

Definition at line 102 of file base_gui.cpp.

{
    if( m_locked ) return;

    const int PREV_SELECTED_WGT = widget_manager->getSelectedWgt();
    const int SELECTED_WGT = widget_manager->handlePointer( x, y );

    if( SELECTED_WGT != WidgetManager::WGT_NONE )
    {
        if( PREV_SELECTED_WGT != WidgetManager::WGT_NONE )
        {
            widget_manager->darkenWgtColor( PREV_SELECTED_WGT );
        }

        widget_manager->lightenWgtColor( SELECTED_WGT );
        widget_manager->pulseWgt( SELECTED_WGT );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void BaseGUI::lockInput ( ) [inline, inherited]

Definition at line 49 of file base_gui.hpp.

{ m_locked = true; }
void GrandPrixSelect::select ( ) [virtual]

Implements BaseGUI.

Definition at line 185 of file grand_prix_select.cpp.

{
    const int CLICKED_TOKEN = widget_manager->getSelectedWgt();
    if(CLICKED_TOKEN == WTOK_QUIT)
    {
        menu_manager->popMenu();
        return;
    }
    race_manager->setGrandPrix(m_all_cups[CLICKED_TOKEN-WTOK_FIRSTPRIX]);
    menu_manager->pushMenu(MENUID_RACE_OPTIONS);
}   // select

Here is the call graph for this function:

void BaseGUI::TimeToString ( const double  time,
char *  s 
) [inherited]

Definition at line 130 of file base_gui.cpp.

{
    int min     = (int) floor ( TIME / 60.0 ) ;
    int sec     = (int) floor ( TIME - (double) ( 60 * min ) ) ;
    int tenths  = (int) floor ( 10.0f * (TIME - (double)(sec + 60* min)));
    sprintf ( s, "%d:%02d:%d", min,  sec,  tenths ) ;
}   // TimeToString

Here is the caller graph for this function:

void BaseGUI::unlockInput ( ) [inline, inherited]

Definition at line 50 of file base_gui.hpp.

{ m_locked = false; }
void GrandPrixSelect::update ( float  dt) [virtual]

Reimplemented from BaseGUI.

Definition at line 101 of file grand_prix_select.cpp.

{
    const int SELECTED_TOKEN = widget_manager->getSelectedWgt();

    if( widget_manager->selectionChanged() &&
        !( SELECTED_TOKEN < WTOK_FIRSTPRIX ))
    {
        const int CUP_NUM = SELECTED_TOKEN - WTOK_FIRSTPRIX;
        const int NUM_TRACKS = (int)m_all_cups[CUP_NUM].getTrackCount();

        const CupData &cup = m_all_cups[CUP_NUM];
        widget_manager->setWgtText(WTOK_DESCRIPTION, cup.getDescription());


        std::string track_list;
        m_cup_tracks = m_all_cups[CUP_NUM].getTracks();

        for( int i = 0; i < NUM_TRACKS; ++i )
        {
            track_list.append( track_manager->getTrack( m_cup_tracks[i] )->getName() );
            track_list.push_back('\n');
        }
        widget_manager->setWgtText( WTOK_TRACKS, track_list );


        std::string img_filename;
        Material *mat;

        m_track_imgs.clear();

        for( int i = 0; i < NUM_TRACKS; ++i )
        {
            img_filename = track_manager->getTrack( m_cup_tracks[i] )->getTopviewFile();
            if( img_filename.empty() )
            {
                img_filename = track_manager->getTrack( m_cup_tracks[i] )->getScreenshotFile();
                if( img_filename.empty() ) continue;
            }

            mat = material_manager->getMaterial( img_filename, true );

            m_track_imgs.push_back(mat->getState()->getTextureHandle());
        }

        if( !( m_track_imgs.empty() ))
        {
            m_clock = 0.0f;
            m_curr_track_img = 0;

            widget_manager->showWgtTexture( WTOK_IMG );
            widget_manager->setWgtTexture( WTOK_IMG,
                m_track_imgs[ m_curr_track_img ] );
            widget_manager->setWgtColor( WTOK_IMG, WGT_WHITE );
        }
        else
        {
            widget_manager->hideWgtTexture( WTOK_IMG );
            widget_manager->setWgtColor( WTOK_IMG, WGT_BLACK );
        }
    }

    if( !( m_track_imgs.empty() ))
    {
        m_clock += dt;

        if( m_clock > 1.0f )
        {
            m_clock = 0.0f;

            ++m_curr_track_img;
            if( m_curr_track_img >= m_track_imgs.size() ) m_curr_track_img = 0;

            widget_manager->setWgtTexture( WTOK_IMG,
                m_track_imgs[ m_curr_track_img ] );
        }
    }

    widget_manager->update(dt);

    return;
}

Here is the call graph for this function:


Member Data Documentation

std::vector<CupData> GrandPrixSelect::m_all_cups [private]

Definition at line 30 of file grand_prix_select.hpp.

float GrandPrixSelect::m_clock [private]

Definition at line 34 of file grand_prix_select.hpp.

std::vector<std::string> GrandPrixSelect::m_cup_tracks [private]

Definition at line 31 of file grand_prix_select.hpp.

unsigned int GrandPrixSelect::m_curr_track_img [private]

Definition at line 33 of file grand_prix_select.hpp.

bool BaseGUI::m_locked [protected, inherited]

Definition at line 55 of file base_gui.hpp.

int BaseGUI::m_menu_id [protected, inherited]

Definition at line 56 of file base_gui.hpp.

std::vector<int> GrandPrixSelect::m_track_imgs [private]

Definition at line 32 of file grand_prix_select.hpp.


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