- change subimage loading syntax to be more usefull, ie. now its (images "somefile...
[supertux.git] / src / button.h
index 552fd22..a42254e 100644 (file)
 #define SUPERTUX_BUTTON_H
 
 #include <vector>
-#include "texture.h"
+
+#include "screen/surface.h"
+#include "timer.h"
 
 enum ButtonState {
   BUTTON_NONE = -1,
   BUTTON_CLICKED,
   BUTTON_PRESSED,
-  BUTTON_HOVER
+  BUTTON_HOVER,
+  BUTTON_WHEELUP,
+  BUTTON_WHEELDOWN,
+  BUTTON_DEACTIVE
 };
 
 class ButtonPanel;
@@ -38,22 +43,26 @@ class Button
   friend class ButtonPanel;
 
 public:
-  Button(std::string icon_file, std::string info, SDLKey shortcut, int x, int y, int mw = -1, int h = -1);
+  Button(Surface* icon_file, const std::string& info, SDLKey shortcut,
+      int x, int y, int mw = -1, int h = -1);
+  Button(const std::string& icon_name, const std::string& info, SDLKey shortcut,
+      int x, int y, int mw = -1, int h = -1);
+  
   ~Button();
   void event(SDL_Event& event);
-  void draw();
+  void draw(DrawingContext& context);
   int get_state();
-  void change_icon(std::string icon_file, int mw, int mh);
+  void set_active(bool active) { active ? state = BUTTON_NONE : state = BUTTON_DEACTIVE; };
+  void add_icon(const std::string& imagefile, int mw, int mh);
   SDL_Rect get_pos() { return rect; }
   int get_tag(){return tag; }
-  void set_game_object(GameObject* game_object_) { game_object = game_object_; }
-  GameObject* get_game_object() { return game_object; };
+//  void set_drawable(Drawable* newdrawable)
+//  { drawable = newdrawable; }
 
 private:
   static Timer popup_timer;
-  GameObject* game_object;
-  Surface* icon;
-  Surface* bkgd;
+//  Drawable* drawable;
+  std::vector<Surface*> icon;
   std::string info;
   SDLKey shortcut;
   SDL_Rect rect;
@@ -67,18 +76,23 @@ class ButtonPanel
 public:
   ButtonPanel(int x, int y, int w, int h);
   ~ButtonPanel();
-  void draw();
+  void draw(DrawingContext& context);
   Button* event(SDL_Event &event);
   void additem(Button* pbutton, int tag);
   Button* button_panel_event(SDL_Event& event);
   void set_button_size(int w, int h);
   Button* manipulate_button(int i);
+  void highlight_last(bool b);
+  void set_last_clicked(unsigned int last)
+  { if(hlast) { if(item.size() >= last) { last_clicked = item.begin() + last; } } };
 
 private:
   int bw, bh;
+  bool hlast;
   bool hidden;
   SDL_Rect rect;
   std::vector<Button*> item;
+  std::vector<Button*>::iterator last_clicked;
 };
 
 #endif /*SUPERTUX_BUTTON_H*/