Back to index

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

#include <keyboardconfig.h>

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

List of all members.

Public Member Functions

 KeyboardConfig ()
 ~KeyboardConfig ()
void setWidgetPositions ()
void apply ()
void setKey (KeyEntry *widget, SDLKey key)
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 Attributes

KeyEntrymp_left
KeyEntrymp_right
KeyEntrymp_paddle
KeyEntrymp_brake
KeyEntrymp_jump
KeyEntrymp_trick
KeyEntrymp_reset

Detailed Description

Definition at line 44 of file keyboardconfig.h.


Constructor & Destructor Documentation

Definition at line 53 of file keyboardconfig.cpp.

{
       setTitle(_("Keyboard Configuration"));
       
       pp::Vec2d pos(0,0);
       pp::Vec2d size(150,32);
       
       mp_left = new KeyEntry(pos, size, "listbox_item");
       mp_left->setEditable(false);
       mp_left->signalKeyPressed.Connect(pp::CreateSlot(this, &KeyboardConfig::setKey));
       setKey( mp_left, SDLKey(getparam_turn_left_key()) );
       
       mp_right = new KeyEntry(pos, size,
                                 "listbox_item");
       mp_right->setEditable(false);
       mp_right->signalKeyPressed.Connect(pp::CreateSlot(this,&KeyboardConfig::setKey));
       setKey( mp_right, SDLKey(getparam_turn_right_key()) );
       
       mp_paddle = new KeyEntry(pos, size,
                                 "listbox_item");
       mp_paddle->setEditable(false);
       mp_paddle->signalKeyPressed.Connect(pp::CreateSlot(this,&KeyboardConfig::setKey));
       setKey( mp_paddle, SDLKey(getparam_paddle_key()) );
              
       mp_brake = new KeyEntry(pos, size,
                                 "listbox_item");
       mp_brake->setEditable(false);
       mp_brake->signalKeyPressed.Connect(pp::CreateSlot(this,&KeyboardConfig::setKey));
       setKey( mp_brake, SDLKey(getparam_brake_key()) );
       
       mp_jump = new KeyEntry(pos, size,
                                 "listbox_item");
       mp_jump->setEditable(false);
       mp_jump->signalKeyPressed.Connect(pp::CreateSlot(this,&KeyboardConfig::setKey));
       setKey( mp_jump, SDLKey(getparam_jump_key()) );
       
       mp_trick = new KeyEntry(pos, size,
                                 "listbox_item");
       mp_trick->setEditable(false);
       mp_trick->signalKeyPressed.Connect(pp::CreateSlot(this,&KeyboardConfig::setKey));
       setKey( mp_trick, SDLKey(getparam_trick_modifier_key()) );
       
       mp_reset = new KeyEntry(pos, size,
                                 "listbox_item");
       mp_reset->setEditable(false);
       mp_reset->signalKeyPressed.Connect(pp::CreateSlot(this,&KeyboardConfig::setKey));
       setKey( mp_reset, SDLKey(getparam_reset_key()) );
}

Here is the call graph for this function:

Definition at line 102 of file keyboardconfig.cpp.

{
       delete mp_left;
       delete mp_right;
       delete mp_paddle;
       delete mp_brake;
       delete mp_jump;
       delete mp_trick;
       delete mp_reset;
}

Member Function Documentation

void KeyboardConfig::apply ( ) [virtual]

Implements ConfigMode.

Definition at line 153 of file keyboardconfig.cpp.

{
       setparam_turn_left_key( mp_left->getKeySym() );
       setparam_turn_right_key( mp_right->getKeySym() );              
       setparam_paddle_key( mp_paddle->getKeySym() );          
       setparam_brake_key( mp_brake->getKeySym() );            
       setparam_jump_key( mp_jump->getKeySym() );              
       setparam_trick_modifier_key( mp_trick->getKeySym() );          
       setparam_reset_key( mp_reset->getKeySym() );            
       
       write_config_file();
       set_game_mode( GameMode::prevmode );
    UIMgr.setDirty();
}

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

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 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:

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;};
void KeyboardConfig::setKey ( KeyEntry widget,
SDLKey  key 
)

Definition at line 169 of file keyboardconfig.cpp.

{
       std::string content="";
       
       if(key==SDLK_BACKSPACE){
              widget->setContent(content);
              return;
       }else{
              content = SDL_GetKeyName(key);
       }
       
       if (content!=""){
              widget->setContent(content);
              widget->setKeySym(key);
       }
}

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 114 of file keyboardconfig.cpp.

{
       int width = 500;
       int height = 240;
              
       pp::Vec2d pos(getparam_x_resolution()/2 - width/2,
                              getparam_y_resolution()/2 + height/2);
       
       pp::Font *font = pp::Font::get("button_label");
       
       font->draw(_("Turn left:"),pos);
       mp_left->setPosition(pp::Vec2d(pos.x+width-150,pos.y));
              
       pos.y-=40;
       font->draw(_("Turn right:"),pos);
       mp_right->setPosition(pp::Vec2d(pos.x+width-150,pos.y));
       
       pos.y-=40;
       font->draw(_("Paddle:"),pos);
       mp_paddle->setPosition(pp::Vec2d(pos.x+width-150,pos.y));
       
       pos.y-=40;
       font->draw(_("Brake:"),pos);
       mp_brake->setPosition(pp::Vec2d(pos.x+width-150,pos.y));
       
       pos.y-=40;
       font->draw(_("Jump:"),pos);
       mp_jump->setPosition(pp::Vec2d(pos.x+width-150,pos.y));
       
       pos.y-=40;
       font->draw(_("Trick:"),pos);
       mp_trick->setPosition(pp::Vec2d(pos.x+width-150,pos.y));

       pos.y-=40;
       font->draw(_("Reset:"),pos);
       mp_reset->setPosition(pp::Vec2d(pos.x+width-150,pos.y));
}

Here is the call graph for this function:


Member Data Documentation

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

Definition at line 96 of file loop.h.

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

Definition at line 38 of file configmode.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 49 of file keyboardconfig.h.

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

Definition at line 34 of file configmode.h.

Definition at line 50 of file keyboardconfig.h.

Definition at line 46 of file keyboardconfig.h.

Definition at line 48 of file keyboardconfig.h.

Definition at line 52 of file keyboardconfig.h.

Definition at line 47 of file keyboardconfig.h.

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

Definition at line 36 of file configmode.h.

Definition at line 51 of file keyboardconfig.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: