a first implementation of doors to switch between sectors
[supertux.git] / src / button.cpp
index 6467474..15b2be1 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include "setup.h"
-#include "screen.h"
+#include "screen/screen.h"
 #include "globals.h"
 #include "button.h"
-#include "viewport.h"
+#include "camera.h"
+
+// TODO
+#if 0
 
 Timer Button::popup_timer;
 
-Button::Button(std::string icon_file, std::string ninfo, SDLKey nshortcut, int x, int y, int mw, int mh)
+Button::Button(Surface* button_image, const std::string& ninfo,
+    SDLKey nshortcut, int x, int y, int mw, int mh)
 {
   popup_timer.init(false);
 
-  add_icon(icon_file,mw,mh);
+  if(button_image)
+    icon.push_back(button_image);
+
+  info = ninfo;
+
+  shortcut = nshortcut;
+
+  rect.x = x;
+  rect.y = y;
+  rect.w = icon[0]->w;
+  rect.h = icon[0]->h;
+  tag = -1;
+  state = BUTTON_NONE;
+  show_info = false;
+  drawable = NULL;
+}
+
+Button::Button(const std::string& imagefilename, const std::string& ninfo,
+    SDLKey nshortcut, int x, int y, int mw, int mh)
+{
+  popup_timer.init(false);
 
+  add_icon(imagefilename, mw, mh);
+  
   info = ninfo;
 
   shortcut = nshortcut;
@@ -48,7 +74,7 @@ Button::Button(std::string icon_file, std::string ninfo, SDLKey nshortcut, int x
   drawable = NULL;
 }
 
-void Button::add_icon(std::string icon_file, int mw, int mh)
+void Button::add_icon(const std::string& icon_file, int mw, int mh)
 {
   char filename[1024];
 
@@ -87,7 +113,7 @@ void Button::draw()
 
   if(drawable)
   {
-    ViewPort viewport;
+    Camera viewport;
     viewport.set_translation(Vector(rect.x, rect.y));
     drawable->draw(viewport, 0);
   }
@@ -116,7 +142,9 @@ Button::~Button()
   for(std::vector<Surface*>::iterator it = icon.begin(); it != icon.end(); ++it)
     delete (*it);
   icon.clear();
-  delete drawable;
+  // FIXME TODO XXX: commenting this out fixes the leveleditor quit crash
+  //   probably should be deleted somehow, though
+  //delete drawable;
 }
 
 void Button::event(SDL_Event &event)
@@ -298,5 +326,6 @@ void ButtonPanel::highlight_last(bool b)
 {
   hlast = b;
 }
+#endif