/[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.46 by reallysoft, Thu Jun 26 10:48:23 2003 UTC revision 1.47 by dheck, Thu Jun 26 17:22:57 2003 UTC
# Line 104  namespace Line 104  namespace
104          bool handle_keydown (const SDL_Event *e);          bool handle_keydown (const SDL_Event *e);
105          bool handle_mousedown (const SDL_Event *e);          bool handle_mousedown (const SDL_Event *e);
106    
107          // Variables.          /*
108            ** Variables.
109            */
110          ImageCache  cache;          ImageCache  cache;
111          LevelPack  *level_pack; // The level pack          LevelPack  *level_pack; // The current level pack
112    
113          int               ifirst; // Index of "upper left" level          int               ifirst; // Index of "upper left" level
114          int               iselected; // Index of selected level          int               iselected; // Index of selected level
# Line 147  namespace Line 149  namespace
149          void set_levelpack (unsigned index);          void set_levelpack (unsigned index);
150    
151          // Menu interface.          // Menu interface.
152            void tick (double time);
153          void draw_background(px::GC &gc);          void draw_background(px::GC &gc);
154    
155          // Widget interface.          // Widget interface.
# Line 639  namespace Line 642  namespace
642      class FullscreenButton : public TextButton {      class FullscreenButton : public TextButton {
643          // ActionListener interface.          // ActionListener interface.
644          void on_action(Widget *) {          void on_action(Widget *) {
645                bool old = FullScreen;
646              FullScreen = video::ToggleFullscreen();              FullScreen = video::ToggleFullscreen();
647              update();              if (old != FullScreen)
648                    update();
649                else
650                    options::MustRestart = true;
651          }          }
652      public:      public:
653          FullscreenButton() : TextButton("", this) { update(); }          FullscreenButton() : TextButton("", this) { update(); }
# Line 840  namespace Line 847  namespace
847              int mode = get_mode() + 1;              int mode = get_mode() + 1;
848              if (mode >= video::VM_COUNT) mode = 0;              if (mode >= video::VM_COUNT) mode = 0;
849              options::VideoMode = mode;              options::VideoMode = mode;
850                options::MustRestart = true;
851              update();              update();
852          }          }
853      public:      public:
# Line 901  namespace Line 909  namespace
909  // Options menu  // Options menu
910  //----------------------------------------------------------------------  //----------------------------------------------------------------------
911  OptionsMenu::OptionsMenu()  OptionsMenu::OptionsMenu()
912      : back(new TextButton("Back", this))  : back(new TextButton("Back", this)),
913      , fullscreen(new FullscreenButton)    fullscreen(new FullscreenButton),
914      m_restartinfo (new Label(""))
915  {  {
916      const int spacing     = 5;      const int spacing     = 5;
917      const int big_spacing = 60;      const int big_spacing = 60;
# Line 912  OptionsMenu::OptionsMenu() Line 921  OptionsMenu::OptionsMenu()
921      BuildVList left (this, Rect(0, 0, but_width, but_height), spacing);      BuildVList left (this, Rect(0, 0, but_width, but_height), spacing);
922      BuildVList right(this, Rect(but_width+big_spacing, 0, but_width, but_height), spacing);      BuildVList right(this, Rect(but_width+big_spacing, 0, but_width, but_height), spacing);
923    
924      left.add(fullscreen);      left.add (fullscreen);
925      left.add (new MouseSpeedButton);      left.add (new MouseSpeedButton);
926      left.add (new SkipSolvedButton);      left.add (new SkipSolvedButton);
927      left.add (new DifficultyButton);      left.add (new DifficultyButton);
# Line 928  OptionsMenu::OptionsMenu() Line 937  OptionsMenu::OptionsMenu()
937          Rect l = left.pos();          Rect l = left.pos();
938          Rect r = right.pos();          Rect r = right.pos();
939    
940            add (m_restartinfo, Rect (l.x, l.y + 15, 400, 20));
941            m_restartinfo->set_alignment (HALIGN_LEFT);
942            update_info();
943    
944          l.x = (l.x+r.x)/2;          l.x = (l.x+r.x)/2;
945          l.y = Max(l.y, r.y)+big_spacing;          l.y = Max(l.y, r.y)+big_spacing;
946    
# Line 935  OptionsMenu::OptionsMenu() Line 948  OptionsMenu::OptionsMenu()
948      }      }
949  }  }
950    
951  bool  void OptionsMenu::update_info()
 OptionsMenu::on_event (const SDL_Event &e)  
952  {  {
953        if (options::MustRestart)
954            m_restartinfo->set_text ("Please restart Enigma to activate your changes!");
955        else
956            m_restartinfo->set_text ("");
957    }
958    
959    bool OptionsMenu::on_event (const SDL_Event &e)
960    {
961        bool handled=false;
962      if (e.type == SDL_MOUSEBUTTONDOWN      if (e.type == SDL_MOUSEBUTTONDOWN
963          && e.button.button == SDL_BUTTON_RIGHT)          && e.button.button == SDL_BUTTON_RIGHT)
964      {      {
965          Menu::quit();          Menu::quit();
966          return true;          handled = true;
967      }      }
968      else if (e.type == SDL_KEYDOWN) {      else if (e.type == SDL_KEYDOWN) {
969          if ((e.key.keysym.sym==SDLK_RETURN) &&          if ((e.key.keysym.sym==SDLK_RETURN) &&
# Line 950  OptionsMenu::on_event (const SDL_Event & Line 971  OptionsMenu::on_event (const SDL_Event &
971          {          {
972              // update state of FullscreenButton :              // update state of FullscreenButton :
973              dynamic_cast<FullscreenButton*>(fullscreen)->update();              dynamic_cast<FullscreenButton*>(fullscreen)->update();
974              return true;              handled = true;
975          }          }
   
976      }      }
977        return handled;
     return false;  
978  }  }
979    
980  void OptionsMenu::on_action(Widget *w)  void OptionsMenu::on_action(Widget *w)
# Line 964  void OptionsMenu::on_action(Widget *w) Line 983  void OptionsMenu::on_action(Widget *w)
983          Menu::quit();          Menu::quit();
984  }  }
985    
986    void OptionsMenu::tick (double)
987    {
988        update_info();
989    }
990    
991  void OptionsMenu::draw_background(px::GC &gc)  void OptionsMenu::draw_background(px::GC &gc)
992  {  {
993      video::SetCaption("Enigma - Options Menu");      video::SetCaption("Enigma - Options Menu");
# Line 1037  LevelMenu::LevelMenu(LevelPack *lp, unsi Line 1061  LevelMenu::LevelMenu(LevelPack *lp, unsi
1061      levelwidget->set_listener(this);      levelwidget->set_listener(this);
1062    
1063      set_position(pos);      set_position(pos);
1064    }
1065    
1066    void LevelMenu::tick(double)
1067    {
1068      update_info();      update_info();
1069  }  }
1070    
# Line 1056  LevelMenu::on_event (const SDL_Event &e) Line 1084  LevelMenu::on_event (const SDL_Event &e)
1084          else          else
1085              handled = Menu::on_event (e);              handled = Menu::on_event (e);
1086      }      }
     else  
         update_info();  
1087      return handled;      return handled;
1088  }  }
1089    
# Line 1088  LevelMenu::on_action(Widget *w) Line 1114  LevelMenu::on_action(Widget *w)
1114      else if (w == m_nextlp) {      else if (w == m_nextlp) {
1115          set_levelpack (m_ilevelpack+1);          set_levelpack (m_ilevelpack+1);
1116      }      }
     update_info();  
1117  }  }
1118    
1119  void  void

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

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