Back to index

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

#include <track_sel.hpp>

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

List of all members.

Public Member Functions

 TrackSel ()
 ~TrackSel ()
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

Detailed Description

Definition at line 25 of file track_sel.hpp.


Constructor & Destructor Documentation

Definition at line 47 of file track_sel.cpp.

{
    //    widget_manager->addTitleWgt( WTOK_TITLE, 40, 7, _("Choose a track") );
    widget_manager->addEmptyWgt(WTOK_TITLE, 40, 7);
    widget_manager->breakLine();

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

    for (unsigned int i = 0; i != track_manager->getTrackCount(); ++i)
    {
        // snowtuxpeak must be unlocked
        const Track *track = track_manager->getTrack(i);
        bool isAvailable = !unlock_manager->isLocked(track->getIdent());
        widget_manager->addTextButtonWgt( WTOK_TRACK0 + i, 40, 6, track->getName());
        widget_manager->setWgtTextSize( WTOK_TRACK0 + i, WGT_FNT_SML );
        if(!isAvailable)
        {
            widget_manager->hideWgtText(WTOK_TRACK0 + i);
//            widget_manager->deactivateWgt(WTOK_TRACK0 + i);

            widget_manager->setWgtColor( WTOK_TRACK0 + i, WGT_GRAY );
            widget_manager->setWgtTexture( WTOK_TRACK0 + i, "gui_lock.rgb", false );
            widget_manager->showWgtTexture( WTOK_TRACK0 + i );
            widget_manager->setWgtText(WTOK_TRACK0+i, _("Fulfil challenge to unlock"));
        }
        if( i%2 != 0 ) widget_manager->breakLine();
        else if (i + 1 == track_manager->getTrackCount() )
        {
            widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 40, 6 );
            widget_manager->breakLine();
        }
    }

    widget_manager->addImgWgt(WTOK_IMG0, 35, 35, 0);

    widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 5, 35 );

    widget_manager->addImgWgt(WTOK_IMG1, 35, 35, 0);
    widget_manager->breakLine();

    widget_manager->addTextWgt( WTOK_AUTHOR, 80, 9, _("No track selected") );
    widget_manager->hideWgtRect(WTOK_AUTHOR);
    widget_manager->layout(WGT_AREA_TOP);
}

Here is the call graph for this function:

Definition at line 94 of file track_sel.cpp.

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 TrackSel::select ( ) [virtual]

Implements BaseGUI.

Definition at line 186 of file track_sel.cpp.

{
    const int CLICKED_TOKEN = widget_manager->getSelectedWgt();
    unsigned int track_number = CLICKED_TOKEN - WTOK_TRACK0;
    if(track_number<0 || track_number >= track_manager->getTrackCount())
    {
        return;   // not clicked on a track, ignore
    }

    const Track* TRACK = track_manager->getTrack(CLICKED_TOKEN - WTOK_TRACK0);
    bool isAvailable = !unlock_manager->isLocked(TRACK->getIdent());

    if( isAvailable )
    {
        race_manager->setTrack(TRACK->getIdent());
        menu_manager->pushMenu(MENUID_RACE_OPTIONS);
    }

    else
    {
        widget_manager->showWgtText( CLICKED_TOKEN );
        widget_manager->setWgtTextColor( CLICKED_TOKEN, WGT_TRANS_GRAY);
        widget_manager->setWgtColor( CLICKED_TOKEN, WGT_TRANS_GRAY);
    }
}   // 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 TrackSel::update ( float  dt) [virtual]

Reimplemented from BaseGUI.

Definition at line 100 of file track_sel.cpp.

{
    const int SELECTED_TRACK = widget_manager->getSelectedWgt() - WTOK_TRACK0;
    if( widget_manager->selectionChanged() &&
        SELECTED_TRACK >= 0 &&
        SELECTED_TRACK < (int)track_manager->getTrackCount() )
    {
        const Track* TRACK = track_manager->getTrack( SELECTED_TRACK );
        bool isAvailable = !unlock_manager->isLocked(TRACK->getIdent());

        if( isAvailable )
        {

            const std::string& description = TRACK->getDescription();
            if(description!="")
            {
                widget_manager->setWgtText( WTOK_AUTHOR, TRACK->getDescription() );
            }
            else
            {
                char designedby[MAX_MESSAGE_LENGTH];
                snprintf(designedby, MAX_MESSAGE_LENGTH, 
                         "Designed by %s", TRACK->getDesigner().c_str());
                widget_manager->setWgtText( WTOK_AUTHOR, designedby );
            }
            const std::string& screenshot = TRACK->getScreenshotFile();
            const std::string& topview    = TRACK->getTopviewFile();

            if( !screenshot.empty() && !topview.empty() )
            {
                widget_manager->setWgtColor( WTOK_IMG0, WGT_WHITE);
                widget_manager->showWgtRect( WTOK_IMG0 );
                widget_manager->setWgtTexture( WTOK_IMG0, screenshot.c_str() );
                widget_manager->showWgtTexture( WTOK_IMG0 );
                widget_manager->hideWgtTrack( WTOK_IMG0 );

                widget_manager->setWgtColor( WTOK_IMG1, WGT_WHITE);
                widget_manager->showWgtRect( WTOK_IMG1 );
                widget_manager->setWgtTexture( WTOK_IMG1, topview.c_str() );
                widget_manager->showWgtTexture( WTOK_IMG1 );
                widget_manager->hideWgtTrack( WTOK_IMG1 );
            }
            else if( topview.empty() )
            {
                widget_manager->setWgtColor( WTOK_IMG0, WGT_WHITE);
                widget_manager->showWgtRect( WTOK_IMG0 );
                widget_manager->setWgtTexture( WTOK_IMG0, screenshot.c_str() );
                widget_manager->showWgtTexture( WTOK_IMG0 );
                widget_manager->hideWgtTrack( WTOK_IMG0 );

                widget_manager->hideWgtRect( WTOK_IMG1 );
                widget_manager->hideWgtTexture( WTOK_IMG1 );
                widget_manager->setWgtTrackNum( WTOK_IMG1, SELECTED_TRACK );
                widget_manager->showWgtTrack( WTOK_IMG1 );
            }
            else if( screenshot.empty() )
            {
                widget_manager->hideWgtRect( WTOK_IMG0 );
                widget_manager->hideWgtTexture( WTOK_IMG0 );
                widget_manager->setWgtTrackNum( WTOK_IMG0, SELECTED_TRACK );
                widget_manager->showWgtTrack( WTOK_IMG0 );

                widget_manager->setWgtColor( WTOK_IMG1, WGT_WHITE);
                widget_manager->showWgtRect( WTOK_IMG1 );
                widget_manager->setWgtTexture( WTOK_IMG1, topview.c_str() );
                widget_manager->showWgtTexture( WTOK_IMG1 );
                widget_manager->hideWgtTrack( WTOK_IMG1 );
            }
            else //if( screenshot.empty() && topview.empty() )
            {
                widget_manager->hideWgtRect( WTOK_IMG0 );
                widget_manager->hideWgtTexture( WTOK_IMG0 );
                widget_manager->setWgtTrackNum( WTOK_IMG0, SELECTED_TRACK );
                widget_manager->showWgtTrack( WTOK_IMG0 );

                widget_manager->hideWgtRect( WTOK_IMG1 );
                widget_manager->hideWgtTexture( WTOK_IMG1 );
                widget_manager->hideWgtTrack( WTOK_IMG1 );
            }
        }
    }

    widget_manager->update(dt);
}

Here is the call graph for this function:


Member Data Documentation

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.


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