OptionMenu Class Reference

#include <options_menu.h>

Inheritance diagram for OptionMenu:

Inheritance graph
[legend]
Collaboration diagram for OptionMenu:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 OptionMenu ()
 ~OptionMenu ()

Private Member Functions

void SaveOptions ()
void OnClic (const Point2i &mousePosition, int button)
void Draw (const Point2i &mousePosition)
void __sig_ok ()
void __sig_cancel ()

Private Attributes

Fontnormal_font
ListBoxlbox_video_mode
CheckBoxopt_display_wind_particles
CheckBoxopt_display_energy
CheckBoxopt_display_name
CheckBoxfull_screen
SpinButtonBigopt_max_fps
ListBoxlbox_sound_freq
CheckBoxopt_music
CheckBoxopt_sound_effects

Detailed Description

Definition at line 29 of file options_menu.h.


Constructor & Destructor Documentation

OptionMenu::OptionMenu (  ) 

Definition at line 45 of file options_menu.cpp.

00045                        :
00046   Menu("menu/bg_option")
00047 {
00048   Profile *res = resource_manager.LoadXMLProfile( "graphism.xml", false);
00049   Rectanglei stdRect (0, 0, 140, 30);
00050 
00051   normal_font = Font::GetInstance(Font::FONT_NORMAL);
00052 
00053   /* Grapic options */
00054   Box * graphic_options = new HBox( Rectanglei(GRAPHIC_X, GRAPHIC_Y, GRAPHIC_W, GRAPHIC_H));
00055 
00056   graphic_options->AddWidget(new PictureWidget(Rectanglei(0,0,40,136), "menu/video_label"));
00057 
00058   Box * top_n_bottom_graphic_options = new VBox( Rectanglei(0, 0, GRAPHIC_W-40, GRAPHIC_H),false);
00059 
00060   Box * top_graphic_options = new HBox ( Rectanglei(GRAPHIC_X, GRAPHIC_Y, GRAPHIC_W, GRAPHIC_H/2 - 20), false);
00061   Box * bottom_graphic_options = new HBox ( Rectanglei(GRAPHIC_X, GRAPHIC_Y, GRAPHIC_W, GRAPHIC_H/2 - 20), false);
00062   top_graphic_options->SetMargin(25);
00063   bottom_graphic_options->SetMargin(25);
00064 
00065   opt_display_wind_particles = new PictureTextCBox(_("Wind particles?"), "menu/display_wind_particles", stdRect);
00066   top_graphic_options->AddWidget(opt_display_wind_particles);
00067 
00068   opt_display_energy = new PictureTextCBox(_("Player energy?"), "menu/display_energy", stdRect);
00069   top_graphic_options->AddWidget(opt_display_energy);
00070 
00071   opt_display_name = new PictureTextCBox(_("Player's name?"), "menu/display_name", stdRect);
00072   top_graphic_options->AddWidget(opt_display_name);
00073 
00074   full_screen = new PictureTextCBox(_("Fullscreen?"), "menu/fullscreen", stdRect);
00075   bottom_graphic_options->AddWidget(full_screen);
00076 
00077   opt_max_fps = new SpinButtonBig(_("Maximum FPS"), stdRect,
00078                                50, 5,
00079                                20, 120);
00080   bottom_graphic_options->AddWidget(opt_max_fps);
00081 
00082   lbox_video_mode = new ListBoxWithLabel(_("Resolution"), stdRect );
00083   bottom_graphic_options->AddWidget(lbox_video_mode);
00084 
00085   top_n_bottom_graphic_options->AddWidget(top_graphic_options);
00086   top_n_bottom_graphic_options->AddWidget(bottom_graphic_options);
00087   graphic_options->AddWidget(top_n_bottom_graphic_options);
00088 
00089   widgets.AddWidget(graphic_options);
00090 
00091   /* Sound options */
00092   Box * sound_options = new HBox( Rectanglei(SOUND_X, SOUND_Y, SOUND_W, SOUND_H));
00093   sound_options->AddWidget(new PictureWidget(Rectanglei(0,0,40,138), "menu/audio_label"));
00094 
00095   Box * all_sound_options = new HBox( Rectanglei(SOUND_X, SOUND_Y, SOUND_W, SOUND_H-20),false);
00096   all_sound_options->SetMargin(25);
00097   all_sound_options->SetBorder(Point2i(10,10));
00098 
00099   opt_music = new PictureTextCBox(_("Music?"), "menu/music_enable", stdRect);
00100   all_sound_options->AddWidget(opt_music);
00101 
00102   opt_sound_effects = new PictureTextCBox(_("Sound effects?"), "menu/sound_effects_enable", stdRect);
00103   all_sound_options->AddWidget(opt_sound_effects);
00104 
00105   lbox_sound_freq = new ListBoxWithLabel(_("Sound frequency"), stdRect );
00106   all_sound_options->AddWidget(lbox_sound_freq);
00107 
00108   sound_options->AddWidget(all_sound_options);
00109   widgets.AddWidget(sound_options);
00110 
00111   /* Center the widgets */
00112   AppWormux * app = AppWormux::GetInstance();
00113   uint center_x = app->video.window.GetWidth()/2;
00114 
00115   graphic_options->SetXY(center_x - graphic_options->GetSizeX()/2, graphic_options->GetPositionY());
00116   sound_options->SetXY(center_x - sound_options->GetSizeX()/2, sound_options->GetPositionY());
00117 
00118   // Values initialization
00119 
00120   // Get available video resolution
00121   std::list<Point2i>& video_res = app->video.GetAvailableConfigs();
00122   std::list<Point2i>::iterator mode;
00123 
00124   for(mode=video_res.begin(); mode!=video_res.end(); ++mode) {
00125       std::ostringstream ss;
00126       bool is_current;
00127       std::string text;
00128       ss << mode->GetX() << "x" << mode->GetY() ;
00129       text = ss.str();
00130       if (app->video.window.GetWidth() == mode->GetX() && app->video.window.GetHeight() == mode->GetY())
00131       {
00132           ss << " " << _("(current)");
00133           is_current = true;
00134       } else {
00135           is_current = false;
00136       }
00137       lbox_video_mode->AddItem(is_current, ss.str(), text);
00138   }
00139 
00140   // Generate sound mode list
00141   uint current_freq = jukebox.GetFrequency();
00142   lbox_sound_freq->AddItem (current_freq == 11025, "11 kHz", "11025");
00143   lbox_sound_freq->AddItem (current_freq == 22050, "22 kHz", "22050");
00144   lbox_sound_freq->AddItem (current_freq == 44100, "44 kHz", "44100");
00145 
00146   resource_manager.UnLoadXMLProfile( res);
00147 
00148   Config * config = Config::GetInstance();
00149 
00150   opt_max_fps->SetValue (app->video.GetMaxFps());
00151   opt_display_wind_particles->SetValue (config->GetDisplayWindParticles());
00152   opt_display_energy->SetValue (config->GetDisplayEnergyCharacter());
00153   opt_display_name->SetValue (config->GetDisplayNameCharacter());
00154   full_screen->SetValue (app->video.IsFullScreen());
00155 
00156 
00157   opt_music->SetValue( jukebox.UseMusic() );
00158   opt_sound_effects->SetValue( jukebox.UseEffects() );
00159 }

Here is the call graph for this function:

OptionMenu::~OptionMenu (  ) 

Definition at line 161 of file options_menu.cpp.

00162 {
00163 }


Member Function Documentation

void OptionMenu::__sig_cancel (  )  [private, virtual]

Implements Menu.

Definition at line 209 of file options_menu.cpp.

00210 {
00211   // Nothing to do
00212 }

void OptionMenu::__sig_ok (  )  [private, virtual]

Implements Menu.

Definition at line 204 of file options_menu.cpp.

00205 {
00206   SaveOptions();
00207 }

Here is the call graph for this function:

void OptionMenu::Draw ( const Point2i mousePosition  )  [private, virtual]

Implements Menu.

Definition at line 214 of file options_menu.cpp.

00215 {
00216 }

void OptionMenu::OnClic ( const Point2i mousePosition,
int  button 
) [private, virtual]

Implements Menu.

Definition at line 165 of file options_menu.cpp.

00166 {
00167   widgets.Clic(mousePosition, button);
00168 }

Here is the call graph for this function:

void OptionMenu::SaveOptions (  )  [private]

Definition at line 170 of file options_menu.cpp.

00171 {
00172   // Save values
00173   Config * config = Config::GetInstance();
00174   config->SetDisplayWindParticles(opt_display_wind_particles->GetValue());
00175   config->SetDisplayEnergyCharacter(opt_display_energy->GetValue());
00176   config->SetDisplayNameCharacter(opt_display_name->GetValue());
00177 
00178   AppWormux * app = AppWormux::GetInstance();
00179   app->video.SetMaxFps(opt_max_fps->GetValue());
00180   // Video mode
00181   std::string s_mode = lbox_video_mode->ReadValue();
00182   int w, h;
00183   sscanf(s_mode.c_str(),"%dx%d", &w, &h);
00184   app->video.SetConfig(w, h, full_screen->GetValue());
00185 
00186   uint x = app->video.window.GetWidth() / 2;
00187   uint y = app->video.window.GetHeight() - 50;
00188 
00189   SetActionButtonsXY(x, y);
00190 
00191   // Sound
00192   jukebox.ActiveMusic( opt_music->GetValue() );
00193   jukebox.ActiveEffects( opt_sound_effects->GetValue() );
00194   std::string sfreq = lbox_sound_freq->ReadValue();
00195   long freq;
00196   if (str2long(sfreq,freq)) jukebox.SetFrequency (freq);
00197 
00198   jukebox.Init(); // commit modification on sound options
00199 
00200   //Save options in XML
00201   config->Save();
00202 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

CheckBox* OptionMenu::full_screen [private]

Definition at line 44 of file options_menu.h.

ListBox* OptionMenu::lbox_sound_freq [private]

Definition at line 48 of file options_menu.h.

ListBox* OptionMenu::lbox_video_mode [private]

Definition at line 40 of file options_menu.h.

Font* OptionMenu::normal_font [private]

Definition at line 31 of file options_menu.h.

CheckBox* OptionMenu::opt_display_energy [private]

Definition at line 42 of file options_menu.h.

CheckBox* OptionMenu::opt_display_name [private]

Definition at line 43 of file options_menu.h.

CheckBox* OptionMenu::opt_display_wind_particles [private]

Definition at line 41 of file options_menu.h.

SpinButtonBig* OptionMenu::opt_max_fps [private]

Definition at line 45 of file options_menu.h.

CheckBox* OptionMenu::opt_music [private]

Definition at line 49 of file options_menu.h.

CheckBox* OptionMenu::opt_sound_effects [private]

Definition at line 50 of file options_menu.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 14:04:52 2007 for Wormux by  doxygen 1.4.7