/[enigma]/enigma/src/menus.cc
ViewVC logotype

Diff of /enigma/src/menus.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.33 by reallysoft, Sun Jun 1 18:49:35 2003 UTC revision 1.34 by reallysoft, Mon Jun 2 22:49:13 2003 UTC
# Line 27  Line 27 
27  #include "config.h"  #include "config.h"
28  #include "help.hh"  #include "help.hh"
29  #include "display.hh"  #include "display.hh"
30    #include "oxyd.hh"
31    
32  #include <cassert>  #include <cassert>
33    
# Line 96  namespace Line 97  namespace
97          bool handle_keydown (const SDL_Event *e);          bool handle_keydown (const SDL_Event *e);
98          bool handle_mousedown (const SDL_Event *e);          bool handle_mousedown (const SDL_Event *e);
99    
   
100          // Variables.          // Variables.
101          ImageCache cache;          ImageCache  cache;
102          LevelPack *level_pack;  // The level pack          LevelPack  *level_pack; // The level pack
103          int ifirst;             // Index of "upper left" level  
104          int iselected;          // Index of selected level          int               ifirst; // Index of "upper left" level
105          int width, height;          int               iselected; // Index of selected level
106          vector<px::Rect> areas;     // Screen areas occupied by level previews          int               width, height;
107          ActionListener *listener;          vector<px::Rect>  areas; // Screen areas occupied by level previews
108            ActionListener   *listener;
109      };      };
110    
111      class LevelMenu : public Menu {      class LevelMenu : public Menu {
# Line 144  namespace Line 145  namespace
145    
146      };      };
147    
     class LevelPackMenu : public Menu {  
     public:  
         LevelPackMenu();  
   
         void on_action(Widget *w);  
         void draw_background(px::GC &gc);  
     private:  
         vector<Widget *> buttons;  
         Widget *back;  
     };  
   
148      class MainMenu : public Menu {      class MainMenu : public Menu {
149      public:      public:
150          MainMenu();          MainMenu();
# Line 229  LevelWidget::scroll_down(int nlines) Line 219  LevelWidget::scroll_down(int nlines)
219  void  void
220  LevelWidget::change_levelpack (LevelPack *lp)  LevelWidget::change_levelpack (LevelPack *lp)
221  {  {
222      iselected = 0;      iselected  = 0;
223      ifirst = 0;      ifirst     = 0;
224      level_pack = lp;      level_pack = lp;
225        oxyd::ChangeSoundset(options::SoundSet, level_pack->get_default_SoundSet());
226      cache.clear();      cache.clear();
227      redraw();      redraw();
228  }  }
# Line 715  namespace Line 706  namespace
706          InGameMusicButton() : TextButton("", this) { update(); }          InGameMusicButton() : TextButton("", this) { update(); }
707      };      };
708    
709        class SoundSetButton : public TextButton {
710            void update() {
711                string sound_set;
712                switch (SoundSet) {
713                    case 0: sound_set = "Default"; break;
714                    case 1: sound_set = "Enigma"; break;
715                    default :
716                        switch (OxydVersion(SoundSet-2)) {
717                            case OxydVersion_Oxyd1:          sound_set = "Oxyd"; break;
718                            case OxydVersion_OxydMagnum:     sound_set = "Magnum"; break;
719                            case OxydVersion_OxydMagnumGold: sound_set = "Mag.Gold"; break;
720                            case OxydVersion_OxydExtra:      sound_set = "Extra"; break;
721                            case OxydVersion_PerOxyd:        sound_set = "Per.Oxyd"; break;
722                            default :
723                                fprintf(stderr, "Invalid soundset %i\n", SoundSet);
724                                break;
725                        }
726                        break;
727                }
728    
729                sound_set += " sound";
730                set_text(sound_set);
731            }
732            void on_action(Widget *) {
733                ++SoundSet;
734                if (SoundSet >= 2) { // test if oxyd pack is installed
735                    while (1) {
736                        if ((SoundSet-2) > OxydVersion_Last) {
737                            SoundSet = 0;
738                            break;
739                        }
740                        if (oxyd::FoundOxyd(OxydVersion(SoundSet-2))) {
741                            break;
742                        }
743                        ++SoundSet;
744                    }
745                }
746                oxyd::ChangeSoundset(SoundSet, -1);
747                update();
748            }
749        public:
750            SoundSetButton() : TextButton("", this) { update(); }
751        };
752    
753      class SkipSolvedButton : public TextButton {      class SkipSolvedButton : public TextButton {
754          void update() {          void update() {
755              if (SkipSolvedLevels)              if (SkipSolvedLevels)
# Line 817  OptionsMenu::OptionsMenu() Line 852  OptionsMenu::OptionsMenu()
852      left.add (new DifficultyButton);      left.add (new DifficultyButton);
853    
854      right.add (new SoundVolumeButton);      right.add (new SoundVolumeButton);
855        right.add (new SoundSetButton);
856      right.add (new MusicVolumeButton);      right.add (new MusicVolumeButton);
857      right.add (new InGameMusicButton);      right.add (new InGameMusicButton);
858      right.add (new StereoButton);      right.add (new StereoButton);
# Line 1004  LevelMenu::draw_background(px::GC &gc) Line 1040  LevelMenu::draw_background(px::GC &gc)
1040    
1041    
1042  //----------------------------------------------------------------------  //----------------------------------------------------------------------
 // Level pack menu  
 //----------------------------------------------------------------------  
   
 LevelPackMenu::LevelPackMenu()  
 {  
     //BuildVList vlist(this, Rect(510,400,100,28), 5);  
     //vlist.add( new TextButton("Back", this));  
   
     BuildVList b(this, Rect((640-150)/2,200,150,40), 5);  
   
     for (unsigned i=0; i<enigma::LevelPacks.size(); ++i) {  
         LevelPack *lp = enigma::LevelPacks[i];  
         if (lp->size() > 0)  
             buttons.push_back(b.add(new TextButton(lp->get_name(), this)));  
     }  
   
     BuildVList vlist(this, Rect(510,433,100,28), 5);  
     back = new TextButton("Back", this);  
     vlist.add( back);  
 }  
   
 void  
 LevelPackMenu::on_action(Widget *w)  
 {  
     for (unsigned i=0; i<buttons.size(); ++i)  
         if (buttons[i]==w) {  
             LevelMenu m(enigma::LevelPacks[i], 0);  
             m.manage(video::GetScreen());  
             invalidate_all();  
         }  
   
     if (w == back)  
         Menu::quit();  
 }  
   
 void  
 LevelPackMenu::draw_background(px::GC &gc)  
 {  
     video::SetCaption("Enigma - Level Pack Menu");  
     sound::PlayMusic( MenuMusicFile.c_str());  
   
     blit(gc, 0,0, enigma::GetImage("menu_bg"));  
 }  
   
   
   
 //----------------------------------------------------------------------  
1043  // Main menu  // Main menu
1044  //----------------------------------------------------------------------  //----------------------------------------------------------------------
1045    

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26