Back to index

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

#include <audioconfig.h>

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

List of all members.

Public Member Functions

 AudioConfig ()
 ~AudioConfig ()
void setWidgetPositions ()
void apply ()
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

pp::Listbox< bps_t > * mp_bpsListbox
pp::Listbox< freq_t > * mp_freqListbox
std::list< bps_tm_bpsList
std::list< freq_tm_freqList
pp::CheckBoxmp_audioBox
pp::CheckBoxmp_soundBox
pp::CheckBoxmp_musicBox
pp::CheckBoxmp_stereoBox

Detailed Description

Definition at line 32 of file audioconfig.h.


Constructor & Destructor Documentation

Definition at line 34 of file audioconfig.cpp.

{
       setTitle(_("Audio Configuration"));
       pp::Vec2d pos(0,0);
       
       mp_audioBox = new pp::CheckBox(pos, pp::Vec2d(32, 32) );
       mp_audioBox->setState( getparam_no_audio());
       
       mp_soundBox = new pp::CheckBox(pos, pp::Vec2d(32, 32) );
       mp_soundBox->setState( getparam_sound_enabled());
              
       mp_musicBox = new pp::CheckBox(pos, pp::Vec2d(32, 32) );
       mp_musicBox->setState( getparam_music_enabled());       
       
       mp_stereoBox = new pp::CheckBox(pos, pp::Vec2d(32, 32) );
       mp_stereoBox->setState( getparam_audio_stereo());

       //frequency
       std::list<freq_t>::iterator freqit;
       bool found=false;
       
       for (unsigned int i=0; i<sizeof(freqs)/sizeof(freq_t); i++) {
              m_freqList.push_back(freqs[i]);    
              if (freqs[i].data==getparam_audio_freq_mode()){
                     freqit = --m_freqList.end();
                     found=true;
              }
    }
       if(!found) freqit = m_freqList.begin();
       
       mp_freqListbox = new pp::Listbox<freq_t>( pos,
                               pp::Vec2d(150, 32),
                               "listbox_item",
                               m_freqList);
    mp_freqListbox->setCurrentItem( freqit );
       
       //bits per sample
       std::list<freq_t>::iterator bpsit;
       found=false;
       
       for (unsigned int i=0; i<sizeof(bps)/sizeof(bps_t); i++) {
              m_bpsList.push_back(bps[i]);       
              if (bps[i].data==getparam_audio_format_mode()){
                     bpsit = --m_bpsList.end();
                     found=true;
              }
    }
       if(!found) bpsit = m_bpsList.begin();
       
       mp_bpsListbox = new pp::Listbox<bps_t>( pos,
                               pp::Vec2d(150, 32),
                               "listbox_item",
                               m_bpsList);
    mp_bpsListbox->setCurrentItem( bpsit );

}

Here is the call graph for this function:

Definition at line 91 of file audioconfig.cpp.

{
       delete mp_audioBox;
       delete mp_soundBox;
       delete mp_musicBox;
       delete mp_stereoBox;
       delete mp_bpsListbox;
       delete mp_freqListbox;
}

Member Function Documentation

void AudioConfig::apply ( ) [virtual]

Implements ConfigMode.

Definition at line 139 of file audioconfig.cpp.

{
       setparam_no_audio(bool( mp_audioBox->getState() ));
       setparam_sound_enabled(bool( mp_soundBox->getState() ));
       setparam_music_enabled(bool( mp_musicBox->getState() ));
       setparam_audio_stereo(bool( mp_stereoBox->getState() ));
       
       std::list<bps_t>::iterator bpsit = mp_bpsListbox->getCurrentItem();
       setparam_audio_format_mode((*bpsit).data);
              
       std::list<freq_t>::iterator freqit = mp_freqListbox->getCurrentItem();
       setparam_audio_freq_mode((*freqit).data);
              
       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 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:

void AudioConfig::setWidgetPositions ( ) [virtual]

Implements ConfigMode.

Definition at line 102 of file audioconfig.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(_("Sound Effects:"),pos);
       mp_soundBox->setPosition(pp::Vec2d(pos.x+width-32,pos.y));
       
       pos.y-=40;
       font->draw(_("Music:"),pos);
       mp_musicBox->setPosition(pp::Vec2d(pos.x+width-32,pos.y));
       
       pos.y-=80;
       font->draw(_("(needs restart)"),pos);
       pos.y-=40;
       font->draw(_("Disable Audio:"),pos);
       mp_audioBox->setPosition(pp::Vec2d(pos.x+width-32,pos.y));
       
       pos.y-=40;
       font->draw(_("Stereo:"),pos);
       mp_stereoBox->setPosition(pp::Vec2d(pos.x+width-32,pos.y));
       
       pos.y-=40;
       font->draw(_("Bits Per Sample:"),pos);
       mp_bpsListbox->setPosition(pp::Vec2d(pos.x+width-150,pos.y));
       
       pos.y-=40;
       font->draw(_("Samples Per Second:"),pos);
       mp_freqListbox->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::list<bps_t> AudioConfig::m_bpsList [private]

Definition at line 37 of file audioconfig.h.

std::list<freq_t> AudioConfig::m_freqList [private]

Definition at line 38 of file audioconfig.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 40 of file audioconfig.h.

Definition at line 34 of file audioconfig.h.

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

Definition at line 34 of file configmode.h.

Definition at line 35 of file audioconfig.h.

Definition at line 42 of file audioconfig.h.

Definition at line 41 of file audioconfig.h.

Definition at line 43 of file audioconfig.h.

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

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