Moved menu code frome GameSession and Worldmap into the proper Menu::check_menu(...
[supertux.git] / src / gui / menu.hpp
index 5c97fa1..3027506 100644 (file)
@@ -21,6 +21,7 @@
 #include <memory>
 #include <SDL.h>
 
+#include "math/vector.hpp"
 #include "video/color.hpp"
 #include "video/surface_ptr.hpp"
 
@@ -36,6 +37,7 @@ class Menu
   static Color inactive_color;
   static Color label_color;
   static Color field_color;
+
 private:
   /* Action done on the menu */
   enum MenuAction {
@@ -72,10 +74,6 @@ public:
   /** Remove all entries from the menu */
   void clear();
 
-  /** Return the index of the menu item that was 'hit' (ie. the user
-      clicked on it) in the last event() call */
-  int check ();
-
   virtual void check_menu() =0;
 
   MenuItem& get_item(int index)
@@ -97,10 +95,12 @@ public:
   bool is_toggled(int id) const;
   void set_toggled(int id, bool toggled);
 
-  Menu* get_parent() const;
-
 protected:
-  void additem(MenuItem* pmenu_item);
+  /** Return the index of the menu item that was 'hit' (ie. the user
+      clicked on it) in the last event() call */
+  int check ();
+
+  MenuItem* add_item(std::unique_ptr<MenuItem> menu_item);
   float get_width() const;
   float get_height() const;
 
@@ -114,8 +114,7 @@ private:
   int hit_item;
 
   // position of the menu (ie. center of the menu, not top/left)
-  float pos_x;
-  float pos_y;
+  Vector pos;
 
   /** input event for the menu (up, down, left, right, etc.) */
   MenuAction menuaction;
@@ -128,7 +127,7 @@ private:
 public:
   bool close;
 
-  std::vector<MenuItem*> items;
+  std::vector<std::unique_ptr<MenuItem> > items;
 
 public:
   float effect_progress;
@@ -137,12 +136,6 @@ public:
 private:
   int arrange_left;
   int active_item;
-
-  SurfacePtr checkbox;
-  SurfacePtr checkbox_checked;
-  SurfacePtr back;
-  SurfacePtr arrow_left;
-  SurfacePtr arrow_right;
 };
 
 #endif