Back to index

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

#include <joystickconfig.h>

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

List of all members.

Public Member Functions

 JoystickConfig ()
 ~JoystickConfig ()
void setWidgetPositions ()
void apply ()
void checkboxClicked ()
void paddleClicked ()
void brakeClicked ()
void jumpClicked ()
void trickClicked ()
void customLoop (double TimeStep)
void loop (float timeStep)
void drawTextandWidgets ()
bool keyPressEvent (SDLKey key)
void cancel ()
virtual void customLoop (float timeStep)
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 setTitle (const char *title)
void drawSnow (float timeStep, bool windy=false)
 custom function for drawing snow in the ui

Protected Attributes

pp::Buttonmp_cancelBtn
pp::Buttonmp_applyBtn
pp::Labelmp_titleLbl
std::string m_title

Private Member Functions

void createButtonList (std::list< button_t > &list)
void setButton (int button, pp::Listbox< button_t > *listbox)
void updateWidgetsEnabledStates ()

Private Attributes

pp::CheckBoxmp_enableJoystickBox
pp::Labelmp_enableJoystickLbl
pp::Labelmp_paddleLbl
pp::Listbox< button_t > * mp_paddleListbox
std::list< button_tm_paddleList
pp::Labelmp_brakeLbl
pp::Listbox< button_t > * mp_brakeListbox
std::list< button_tm_brakeList
pp::Labelmp_jumpLbl
pp::Listbox< button_t > * mp_jumpListbox
std::list< button_tm_jumpList
pp::Labelmp_trickLbl
pp::Listbox< button_t > * mp_trickListbox
std::list< button_tm_trickList

Detailed Description

Definition at line 34 of file joystickconfig.h.


Constructor & Destructor Documentation

Definition at line 27 of file joystickconfig.cpp.

{      
       setTitle(_("Joystick Configuration"));
       pp::Vec2d pos(0,0);
       
       mp_enableJoystickLbl = new pp::Label(pos, "button_label",
                                                                       _("Enable Joystick"));
       
       mp_enableJoystickBox = new pp::CheckBox(pos, pp::Vec2d(32, 32) );
       mp_enableJoystickBox->setState( !getparam_disable_joystick());
    mp_enableJoystickBox->signalClicked.Connect(pp::CreateSlot(this,&JoystickConfig::checkboxClicked));
       
       
       //paddle button
       mp_paddleLbl = new pp::Label(pos,"button_label",_("Paddle:"));
       mp_paddleLbl->setInsensitiveFont("button_label_disabled");
       
       createButtonList(m_paddleList);
       mp_paddleListbox = new pp::Listbox<button_t>(pos,
                               pp::Vec2d(96, 32),
                               "listbox_item",
                               m_paddleList);
       mp_paddleListbox->setInsensitiveFont("listbox_item_insensitive");
       mp_paddleListbox->signalClicked.Connect(pp::CreateSlot(this,&JoystickConfig::paddleClicked));
       setButton(getparam_joystick_paddle_button(), mp_paddleListbox);
              
       //brake button
       mp_brakeLbl = new pp::Label(pos,"button_label",_("Brake:"));
       mp_brakeLbl->setInsensitiveFont("button_label_disabled");

       createButtonList(m_brakeList);
       mp_brakeListbox = new pp::Listbox<button_t>(pos,
                               pp::Vec2d(96, 32),
                               "listbox_item",
                               m_brakeList);
       mp_brakeListbox->setInsensitiveFont("listbox_item_insensitive");
       mp_brakeListbox->signalClicked.Connect(pp::CreateSlot(this,&JoystickConfig::brakeClicked));
       setButton(getparam_joystick_brake_button(), mp_brakeListbox);
       
       //jump button
       mp_jumpLbl = new pp::Label(pos,"button_label",_("Jump:"));
       mp_jumpLbl->setInsensitiveFont("button_label_disabled");

       createButtonList(m_jumpList);
       mp_jumpListbox = new pp::Listbox<button_t>(pos,
                               pp::Vec2d(96, 32),
                               "listbox_item",
                               m_jumpList);
       mp_jumpListbox->setInsensitiveFont("listbox_item_insensitive");
       mp_jumpListbox->signalClicked.Connect(pp::CreateSlot(this,&JoystickConfig::jumpClicked));
       setButton(getparam_joystick_jump_button(), mp_jumpListbox);
       
       //trick button
       mp_trickLbl = new pp::Label(pos,"button_label",_("Trick:"));
       mp_trickLbl->setInsensitiveFont("button_label_disabled");
       
       createButtonList(m_trickList);
       mp_trickListbox = new pp::Listbox<button_t>(pos,
                               pp::Vec2d(96, 32),
                               "listbox_item",
                               m_trickList);
       mp_trickListbox->setInsensitiveFont("listbox_item_insensitive");
       mp_trickListbox->signalClicked.Connect(pp::CreateSlot(this,&JoystickConfig::trickClicked));
       setButton(getparam_joystick_trick_button(), mp_trickListbox);
       
       updateWidgetsEnabledStates();
}

Here is the call graph for this function:

Definition at line 95 of file joystickconfig.cpp.


Member Function Documentation

void JoystickConfig::apply ( ) [virtual]

Implements ConfigMode.

Definition at line 219 of file joystickconfig.cpp.

{
       setparam_disable_joystick(!bool(mp_enableJoystickBox->getState() ));
              
       std::list<button_t>::iterator it;
       
       it = mp_paddleListbox->getCurrentItem();
       setparam_joystick_paddle_button((*it).data);
       
       it = mp_brakeListbox->getCurrentItem();
       setparam_joystick_brake_button((*it).data);
       
       it = mp_jumpListbox->getCurrentItem();
       setparam_joystick_jump_button((*it).data);
       
       it = mp_trickListbox->getCurrentItem();
       setparam_joystick_trick_button((*it).data);      
       
       write_config_file();
       set_game_mode( GameMode::prevmode );
    UIMgr.setDirty();       
}

Here is the call graph for this function:

Definition at line 249 of file joystickconfig.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void ConfigMode::cancel ( ) [inherited]

Definition at line 112 of file configmode.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 161 of file joystickconfig.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void JoystickConfig::createButtonList ( std::list< button_t > &  list) [private]

Definition at line 114 of file joystickconfig.cpp.

{
       button_t button;
       char buff[8];
       
       for(int i=0; i<MAX_JOY_BUTTON; i++){
              sprintf(buff,"%d",i);
              button.name=buff;
              button.data=i;              
              list.push_back(button);                   
       }      
}

Here is the caller graph for this function:

virtual void ConfigMode::customLoop ( float  timeStep) [inline, virtual, inherited]

Definition at line 53 of file configmode.h.

{};

Here is the caller graph for this function:

void JoystickConfig::customLoop ( double  TimeStep)

Definition at line 167 of file joystickconfig.cpp.

{
       // Check joystick
    if ( is_joystick_active() ){
              update_joystick();

              int button = get_joystick_down_button();
              if(button>-1){
                     if(mp_paddleListbox->hasFocus()){
                            setButton(button, mp_paddleListbox);
                     }else if(mp_brakeListbox->hasFocus()){
                            setButton(button, mp_brakeListbox);
                     }else if(mp_jumpListbox->hasFocus()){
                            setButton(button, mp_jumpListbox);
                     }else if(mp_trickListbox->hasFocus()){
                            setButton(button, mp_trickListbox);
                     }
              }
    }
}

Here is the call 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:

void ConfigMode::drawTextandWidgets ( ) [inherited]

Definition at line 86 of file configmode.cpp.

{
       int w = getparam_x_resolution();
    int h = getparam_y_resolution();

       mp_cancelBtn->setPosition(pp::Vec2d(w/2-300,h/2-240));
       mp_applyBtn->setPosition(pp::Vec2d(w/2,h/2-240));
       mp_titleLbl->setPosition(pp::Vec2d(w/2,h/2+200));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 255 of file joystickconfig.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 ConfigMode::keyPressEvent ( SDLKey  key) [virtual, inherited]

Reimplemented from GameMode.

Definition at line 97 of file configmode.cpp.

{
       switch (key){
              case SDLK_ESCAPE:
                     cancel();
              return true;
              case SDLK_RETURN:
                     apply();
              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;};
void ConfigMode::loop ( float  timeStep) [virtual, inherited]

Implements GameMode.

Definition at line 56 of file configmode.cpp.

{
       update_audio();
    set_gl_options( GUI );
    clear_rendering_context();
    UIMgr.setupDisplay();
       
       drawTextandWidgets();
       
       // forces the config mode to update it's widget positions
       // perhaps we should call this only when the screen size changes
       setWidgetPositions();
       
       // calls the custom loop of the derived class (if it exists)
       customLoop( timeStep );
       
       // draw snow if enabled
       drawSnow( timeStep );
       
       theme.drawMenuDecorations();
       
       // draw ui widgets
    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 243 of file joystickconfig.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void JoystickConfig::setButton ( int  button,
pp::Listbox< button_t > *  listbox 
) [private]

Definition at line 128 of file joystickconfig.cpp.

{
       std::list<button_t>::iterator it;
       std::list<button_t> &list = listbox->getItemList();
       
       
       for(it=list.begin(); it!=list.end(); it++){
              if((*it).data==button){
                     listbox->setCurrentItem(it);
                     break;
              }             
       }      
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ConfigMode::setTitle ( const char *  title) [protected, inherited]

Definition at line 119 of file configmode.cpp.

{
       mp_titleLbl->setText(title);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements ConfigMode.

Definition at line 189 of file joystickconfig.cpp.

{
       int width = 500;
       int height = 240;

       pp::Vec2d pos(getparam_x_resolution()/2 - width/2,
                              getparam_y_resolution()/2 + height/2);
       
       mp_enableJoystickLbl->setPosition(pos);
       mp_enableJoystickBox->setPosition(pp::Vec2d(pos.x+width-32,pos.y));
       
       pos.y-=100;
       mp_paddleLbl->setPosition(pos);
       mp_paddleListbox->setPosition(pp::Vec2d(pos.x+width-96,pos.y));
              
       pos.y-=40;
       mp_brakeLbl->setPosition(pos);
       mp_brakeListbox->setPosition(pp::Vec2d(pos.x+width-96,pos.y));
       
       pos.y-=40;
       mp_jumpLbl->setPosition(pos);
       mp_jumpListbox->setPosition(pp::Vec2d(pos.x+width-96,pos.y));
       
       pos.y-=40;
       mp_trickLbl->setPosition(pos);
       mp_trickListbox->setPosition(pp::Vec2d(pos.x+width-96,pos.y));
}

Here is the call graph for this function:

Definition at line 261 of file joystickconfig.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 143 of file joystickconfig.cpp.

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<button_t> JoystickConfig::m_brakeList [private]

Definition at line 46 of file joystickconfig.h.

std::list<button_t> JoystickConfig::m_jumpList [private]

Definition at line 50 of file joystickconfig.h.

std::list<button_t> JoystickConfig::m_paddleList [private]

Definition at line 42 of file joystickconfig.h.

std::string ConfigMode::m_title [protected, inherited]

Definition at line 38 of file configmode.h.

std::list<button_t> JoystickConfig::m_trickList [private]

Definition at line 54 of file joystickconfig.h.

game_mode_t GameMode::mode [static, inherited]

Definition at line 99 of file loop.h.

pp::Button* ConfigMode::mp_applyBtn [protected, inherited]

Definition at line 35 of file configmode.h.

Definition at line 44 of file joystickconfig.h.

Definition at line 45 of file joystickconfig.h.

pp::Button* ConfigMode::mp_cancelBtn [protected, inherited]

Definition at line 34 of file configmode.h.

Definition at line 36 of file joystickconfig.h.

Definition at line 38 of file joystickconfig.h.

Definition at line 48 of file joystickconfig.h.

Definition at line 49 of file joystickconfig.h.

Definition at line 40 of file joystickconfig.h.

Definition at line 41 of file joystickconfig.h.

pp::Label* ConfigMode::mp_titleLbl [protected, inherited]

Definition at line 36 of file configmode.h.

Definition at line 52 of file joystickconfig.h.

Definition at line 53 of file joystickconfig.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: