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

Diff of /enigma/menus.cc

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

revision 1.2 by dheck, Sat Dec 14 23:50:06 2002 UTC revision 1.3 by dheck, Mon Dec 16 20:45:41 2002 UTC
# Line 44  namespace Line 44  namespace
44    
45      class LevelWidget : public Widget {      class LevelWidget : public Widget {
46      public:      public:
47          LevelWidget(LevelPack *lp);          LevelWidget(LevelPack *lp, int w, int h);
48          bool manage ();          bool manage ();
49          int selected_level() const { return iselected; }          int selected_level() const { return iselected; }
50    
# Line 142  namespace Line 142  namespace
142    
143          // Variables.          // Variables.
144          Widget *newgame;          Widget *newgame;
145            Widget *playenigma;
146            Widget *playoxyd;
147          Widget *leveled;          Widget *leveled;
148          Widget *options;          Widget *options;
149          Widget *credits;          Widget *credits;
# Line 153  namespace Line 155  namespace
155  //----------------------------------------------------------------------  //----------------------------------------------------------------------
156  // LevelWidget implementation  // LevelWidget implementation
157  //----------------------------------------------------------------------  //----------------------------------------------------------------------
158  LevelWidget::LevelWidget(LevelPack *lp)  LevelWidget::LevelWidget(LevelPack *lp, int w, int h)
159      : level_pack(*lp),      : level_pack(*lp),
160        ifirst(0), iselected(0),        ifirst(0), iselected(0),
161        width(4), height(3),        width(w), height(h),
162        areas(),        areas(),
163        show_filenames_p(false),        show_filenames_p(false),
164        listener(0)        listener(0)
165  {}  {}
166    
167  void LevelWidget::scroll_up(int nlines)  void
168    LevelWidget::scroll_up(int nlines)
169  {  {
170      for (; nlines; --nlines) {      for (; nlines; --nlines) {
171          if (ifirst+width*height > (int)level_pack.levels.size())          if (ifirst+width*height >= (int)level_pack.levels.size())
172              break;              break;
173          ifirst += width;          ifirst += width;
174          if (iselected < ifirst)          if (iselected < ifirst)
175              iselected += width;              iselected += width;
         redraw();  
176      }      }
177        redraw();
178  }  }
179    
180  void  void
# Line 183  LevelWidget::scroll_down(int nlines) Line 186  LevelWidget::scroll_down(int nlines)
186          ifirst -= width;          ifirst -= width;
187          if (iselected >= ifirst+width*height)          if (iselected >= ifirst+width*height)
188              iselected -= width;              iselected -= width;
         redraw();  
189      }      }
190        redraw();
191  }  }
192    
193  void  void
# Line 201  LevelWidget::draw (px::GC &gc, const px: Line 204  LevelWidget::draw (px::GC &gc, const px:
204      const int hgap = 20, vgap=30;      const int hgap = 20, vgap=30;
205    
206      const int x0 = get_x()+(get_w() - width*(imgw+hgap)+hgap)/2;      const int x0 = get_x()+(get_w() - width*(imgw+hgap)+hgap)/2;
207      const int y0 = get_y()+(get_h() - height*(imgh+vgap)+vgap)/2; //get_y(); //30;      const int y0 = get_y()+(get_h() - height*(imgh+vgap))/2; //get_y(); //30;
208    
209      unsigned i=ifirst;      unsigned i=ifirst;
210      vector<LevelInfo> &levels = level_pack.levels;      vector<LevelInfo> &levels = level_pack.levels;
# Line 526  void OptionsMenu::draw_background(px::GC Line 529  void OptionsMenu::draw_background(px::GC
529  // Level menu  // Level menu
530  //----------------------------------------------------------------------  //----------------------------------------------------------------------
531  LevelMenu::LevelMenu(LevelPack *lp, unsigned ilevel_pack)  LevelMenu::LevelMenu(LevelPack *lp, unsigned ilevel_pack)
532      : newgame(new TextButton("New Game", this)),      : newgame(new TextButton("Start Game", this)),
533        quit(new TextButton("Quit", this)),        quit(new TextButton("Back", this)),
534        levelwidget(new LevelWidget(lp)),        levelwidget(new LevelWidget(lp, 3, 4)),
535        level_pack(lp)        level_pack(lp)
536  {  {
537      {      {
538          BuildHList hlist(this, Rect(30,10,100,28), 10);  //        BuildHList hlist(this, Rect(30,10,100,28), 10);
539            BuildVList hlist(this, Rect(510,20,100,28), 5);
540          pgup   = hlist.add(new TextButton("Up", this));          pgup   = hlist.add(new TextButton("Up", this));
541          pgdown = hlist.add(new TextButton("Down", this));          pgdown = hlist.add(new TextButton("Down", this));
542          start  = hlist.add(new TextButton("Start", this));          start  = hlist.add(new TextButton("Top", this));
543          end    = hlist.add(new TextButton("End", this));          end    = hlist.add(new TextButton("Bottom", this));
544        }
545        {
546            BuildVList vlist(this, Rect(510,400,100,28), 5);
547    //        vlist.add(new TextButton("Timer on"));
548            vlist.add(newgame);
549            vlist.add(quit);
550      }      }
551  #if 0  #if 0
552      HList *hlist = new HList;      HList *hlist = new HList;
# Line 548  LevelMenu::LevelMenu(LevelPack *lp, unsi Line 558  LevelMenu::LevelMenu(LevelPack *lp, unsi
558      y0=10;      y0=10;
559      add(new TextButton("Hard"),         Rect(x0,     y0, 100,28));      add(new TextButton("Hard"),         Rect(x0,     y0, 100,28));
560      add(new TextButton("Time Game"),    Rect(x0+110, y0, 100,28));      add(new TextButton("Time Game"),    Rect(x0+110, y0, 100,28));
     add(new TextButton("Sound on"),     Rect(x0+220, y0, 100,28));  
     add(new TextButton("Music on"),     Rect(x0+330, y0, 100,28));  
     add(new TextButton("Mouse Speed"),  Rect(x0+440, y0, 100,28));  
561  #endif  #endif
562            
563      // Add levelwidget at the center      // Add levelwidget at the center
564      add(levelwidget, Rect(0,48,640,480-48*2));  //    add(levelwidget, Rect(0,48,640,480-48*2));
565        add(levelwidget, Rect(10,10,500,480));
566      levelwidget->set_listener(this);      levelwidget->set_listener(this);
567  }  }
568    
# Line 638  LevelPackMenu::draw_background(px::GC &g Line 646  LevelPackMenu::draw_background(px::GC &g
646  MainMenu::MainMenu()  MainMenu::MainMenu()
647  {  {
648      BuildVList b(this, Rect((640-150)/2,200,150,40), 5);      BuildVList b(this, Rect((640-150)/2,200,150,40), 5);
649      newgame = b.add(new TextButton("New Game", this));      newgame = 0; //b.add(new TextButton("New Game", this));
650      leveled = b.add(new TextButton("Editor", this));      playenigma = b.add(new TextButton("Play Enigma", this));
651        playoxyd = b.add(new TextButton("Play Oxyd & Co", this));
652        leveled = 0; //b.add(new TextButton("Editor", this));
653      options = b.add(new TextButton("Options", this));      options = b.add(new TextButton("Options", this));
654      credits = b.add(new TextButton("Credits", this));      credits = b.add(new TextButton("Credits", this));
655      quit    = b.add(new TextButton("Quit", this));      quit    = b.add(new TextButton("Quit", this));
# Line 668  MainMenu::on_action(Widget *w) Line 678  MainMenu::on_action(Widget *w)
678          LevelPackMenu m;          LevelPackMenu m;
679          m.center(video::GetScreen());          m.center(video::GetScreen());
680          m.manage(video::GetScreen());          m.manage(video::GetScreen());
681      } else if (w == credits) {      }
682        else if (w == playenigma) {
683            LevelMenu m(enigma::LevelPacks[0], 0);
684            m.manage(video::GetScreen());
685            invalidate_all();
686        }
687        else if (w == playoxyd) {
688            LevelMenu m(enigma::LevelPacks[1], 0);
689            m.manage(video::GetScreen());
690            invalidate_all();
691        }
692        else if (w == credits) {
693          show_credits ();          show_credits ();
694      } else if (w == options) {      } else if (w == options) {
695          GUI_OptionsMenu();          GUI_OptionsMenu();

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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