Back to index

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

#include <help_page_one.hpp>

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

List of all members.

Public Member Functions

 HelpPageOne ()
 ~HelpPageOne ()
void select ()
void update (float dt)
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

ssgContext * m_context
ssgTransform * m_box
ssgTransform * m_banana
ssgTransform * m_silver_coin
ssgTransform * m_gold_coin
float m_clock

Detailed Description

Definition at line 29 of file help_page_one.hpp.


Constructor & Destructor Documentation

Definition at line 46 of file help_page_one.cpp.

{
    //The ssgContext constructor calls makeCurrent(), it has to be restored
    ssgContext* oldContext = ssgGetCurrentContext();
    m_context = new ssgContext;
    oldContext->makeCurrent();

    m_box = 0;
    m_silver_coin = 0;
    m_gold_coin = 0;
    m_banana = 0;

       m_clock = 0;

    //FIXME: instead of using setInitialTextState, the gui & widget manager macros should improve it's design
    widget_manager->setInitialTextState
    (
        false,
        "",
        WGT_FNT_SML,
        WGT_FONT_GUI,
        WGT_WHITE,
        true
    );
    widget_manager->addTextWgt( WTOK_MSG1, 50, 7,
        _("Force your rivals bite *your* dust!") );
    widget_manager->breakLine();

    widget_manager->addTextWgt( WTOK_MSG2, 60, 7,
        _("Grab blue boxes and coins") );
    widget_manager->addTextWgt( WTOK_MSG3, 30, 7, _("Avoid bananas") );
    widget_manager->breakLine();

    /*Rotating 3D models*/
       ssgEntity* hm = herring_manager->getHerringModel(HE_RED);
    ssgDeRefDelete(m_box);
    m_box = new ssgTransform;
    m_box->ref();
    m_box->addKid(hm);

    hm = herring_manager->getHerringModel(HE_SILVER);
    ssgDeRefDelete(m_silver_coin);
    m_silver_coin = new ssgTransform;
    m_silver_coin->ref();
    m_silver_coin->addKid(hm);

    hm = herring_manager->getHerringModel(HE_GOLD);
    ssgDeRefDelete(m_gold_coin);
    m_gold_coin = new ssgTransform;
    m_gold_coin->ref();
    m_gold_coin->addKid(hm);

    hm = herring_manager->getHerringModel(HE_GREEN);
    ssgDeRefDelete(m_banana);
    m_banana = new ssgTransform;
    m_banana->ref();
    m_banana->addKid(hm);

    /*Empty widget to cover the space for the 3D models*/
    widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 100, 15);
    widget_manager->breakLine();

    widget_manager->addTextWgt(WTOK_MSG4, 100, 13,
//Next line starts at column 0 to avoid spaces in the GUI
_("At high speeds wheelies drive you faster, but you can't steer. If you\n\
get stuck or fall too far, use the rescue button to get back on track."));
    widget_manager->setWgtResizeToText( WTOK_MSG4, false );
    widget_manager->breakLine();

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

    widget_manager->addTextWgt(WTOK_MSG5, 80, 10,
        _("The current key bindings can be seen/changed in the\nOptions->Player Config menu."));
    widget_manager->breakLine();
    widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 100, 1);
    widget_manager->breakLine();

    widget_manager->addTextWgt(WTOK_MSG6, 100, 17,
_("Collecting coins increases the number of collectables you receive.\n\
After 5 silver coins, each blue box will yield 2 collectables,\nafter 10,\
 3 collectables and so on.\nEach gold coin is worth 3 silver coins, \
so look out for them!"));
    widget_manager->setWgtResizeToText( WTOK_MSG6, false);
    widget_manager->breakLine();
    widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 100, 1);
    widget_manager->breakLine();

    widget_manager->addTextWgt(WTOK_MSG7, 87, 8,
_("If you see a button with a lock like the one to the right,\n\
you need to complete a challenge to unlock it."));

    widget_manager->addImgWgt(WTOK_LOCK, 6, 8, 0);
    widget_manager->setWgtTexture(WTOK_LOCK, "gui_help_lock.rgb", false);
    widget_manager->breakLine();

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

    /*Buttons at the bottom*/
    widget_manager->addTextButtonWgt(WTOK_SECOND_PAGE, 20, 7,
        _("Next help screen"));
    widget_manager->breakLine();

    widget_manager->addTextButtonWgt(WTOK_QUIT, 40, 7,
        _("Go back to the menu"));

    widget_manager->layout( WGT_AREA_TOP );
}   // HelpPageOne

Here is the call graph for this function:

Definition at line 157 of file help_page_one.cpp.

{
    widget_manager->reset();

       if (m_box != NULL && m_silver_coin != NULL && m_gold_coin != NULL
        && m_banana != NULL )
       {
              ssgDeRefDelete(m_box);
              ssgDeRefDelete(m_silver_coin);
              ssgDeRefDelete(m_gold_coin);
              ssgDeRefDelete(m_banana);
       }

    delete m_context;

}   // ~HelpPageOne

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

Implements BaseGUI.

Definition at line 220 of file help_page_one.cpp.

{
    switch ( widget_manager->getSelectedWgt() )
    {
        case WTOK_SECOND_PAGE:
            //This switches the first page with the second page, so they
            //are not stacked by the menu manager, and the menu that called
            //this help is the one that gets called back when the next page
            //is popped.
            menu_manager->popMenu();
            menu_manager->pushMenu(MENUID_HELP2);
            break;

        case WTOK_QUIT:
            menu_manager->popMenu();
            break;
    }
}   // 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 HelpPageOne::update ( float  dt) [virtual]

Reimplemented from BaseGUI.

Definition at line 175 of file help_page_one.cpp.

{
    m_clock += dt * 40.0f;

    if (m_box != NULL && m_silver_coin != NULL && m_gold_coin != NULL
        && m_banana != NULL )
    {
        ssgContext* oldContext = ssgGetCurrentContext();
        m_context -> makeCurrent();

        glClear(GL_DEPTH_BUFFER_BIT);

        sgCoord cam_pos;
        sgSetCoord(&cam_pos, 0, 0, 0, 0, 0, 0);
        m_context -> setCamera ( &cam_pos ) ;

        glEnable (GL_DEPTH_TEST);
        sgCoord trans;
        sgSetCoord(&trans, -4, 10, 1.85f, m_clock, 0, 0);
        m_box->setTransform (&trans);

        sgSetCoord(&trans, -2, 8, 1.5f, m_clock, 0, 0);
        m_silver_coin->setTransform (&trans);

        sgSetCoord(&trans, -1, 8, 1.5f, m_clock, 0, 0);
        m_gold_coin->setTransform (&trans);

        sgSetCoord(&trans, 5, 15, 3, m_clock, 0, 0);
        m_banana->setTransform (&trans);

        //glShadeModel(GL_SMOOTH);
        ssgCullAndDraw ( m_box ) ;
        ssgCullAndDraw ( m_silver_coin ) ;
        ssgCullAndDraw ( m_gold_coin ) ;
        ssgCullAndDraw ( m_banana ) ;
        glViewport ( 0, 0, user_config->m_width, user_config->m_height ) ;

        glDisable (GL_DEPTH_TEST);
        oldContext->makeCurrent();
    }

    widget_manager->update(dt);
}

Here is the call graph for this function:


Member Data Documentation

ssgTransform* HelpPageOne::m_banana [private]

Definition at line 34 of file help_page_one.hpp.

ssgTransform* HelpPageOne::m_box [private]

Definition at line 33 of file help_page_one.hpp.

float HelpPageOne::m_clock [private]

Definition at line 37 of file help_page_one.hpp.

ssgContext* HelpPageOne::m_context [private]

Definition at line 32 of file help_page_one.hpp.

ssgTransform* HelpPageOne::m_gold_coin [private]

Definition at line 36 of file help_page_one.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.

ssgTransform* HelpPageOne::m_silver_coin [private]

Definition at line 35 of file help_page_one.hpp.


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