Finally!!
[supertux.git] / src / button.cpp
index 82d0489..500471c 100644 (file)
@@ -38,21 +38,21 @@ Button::Button(std::string icon_file, std::string ninfo, SDLKey nshortcut, int x
 
   if(mw != -1 || mh != -1)
     {
-      texture_load(&icon,filename,USE_ALPHA);
+      icon = new Surface(filename,USE_ALPHA);
       if(mw != -1)
-        icon.w = mw;
+        icon->w = mw;
       if(mh != -1)
-        icon.h = mh;
+        icon->h = mh;
 
       SDL_Rect dest;
       dest.x = 0;
       dest.y = 0;
-      dest.w = icon.w;
-      dest.h = icon.h;
-      SDL_SoftStretch(icon.sdl_surface, NULL, icon.sdl_surface, &dest);
+      dest.w = icon->w;
+      dest.h = icon->h;
+      SDL_SoftStretch(icon->impl->sdl_surface, NULL, icon->impl->sdl_surface, &dest);
     }
   else
-    texture_load(&icon,filename,USE_ALPHA);
+    icon = new Surface(filename,USE_ALPHA);
 
   info = ninfo;
 
@@ -60,15 +60,15 @@ Button::Button(std::string icon_file, std::string ninfo, SDLKey nshortcut, int x
 
   rect.x = x;
   rect.y = y;
-  rect.w = icon.w;
-  rect.h = icon.h;
+  rect.w = icon->w;
+  rect.h = icon->h;
   tag = -1;
   state = BUTTON_NONE;
   show_info = false;
   bkgd = NULL;
 }
 
-void Button::change_icon(std::string icon_file, int mw, int mh)
+void Button::change_icon(std::string icon_file, int /*mw*/, int /*mh*/)
 {
   char filename[1024];
 
@@ -83,8 +83,8 @@ void Button::change_icon(std::string icon_file, int mw, int mh)
       snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str());
     }
 
-  texture_free(&icon);
-  texture_load(&icon,filename,USE_ALPHA);
+  delete icon;
+  icon = new Surface(filename,USE_ALPHA);
 }
 
 void Button::draw()
@@ -97,21 +97,21 @@ void Button::draw()
   fillrect(rect.x+1,rect.y+1,rect.w-2,rect.h-2,175,175,175,200);
   if(bkgd != NULL)
     {
-      texture_draw(bkgd,rect.x,rect.y);
+      bkgd->draw(rect.x,rect.y);
     }
-  texture_draw(&icon,rect.x,rect.y);
+  icon->draw(rect.x,rect.y);
   if(show_info)
     {
       char str[80];
       int i = -32;
 
-      if(0 > rect.x - (int)strlen(info.c_str()) * white_small_text.w)
-        i = rect.w + strlen(info.c_str()) * white_small_text.w;
+      if(0 > rect.x - (int)strlen(info.c_str()) * white_small_text->w)
+        i = rect.w + strlen(info.c_str()) * white_small_text->w;
 
       if(!info.empty())
-        text_draw(&white_small_text, info.c_str(), i + rect.x - strlen(info.c_str()) * white_small_text.w, rect.y, 1);
+        white_small_text->draw(info.c_str(), i + rect.x - strlen(info.c_str()) * white_small_text->w, rect.y, 1);
       sprintf(str,"(%s)", SDL_GetKeyName(shortcut));
-      text_draw(&white_small_text, str, i + rect.x - strlen(str) * white_small_text.w, rect.y + white_small_text.h+2, 1);
+      white_small_text->draw(str, i + rect.x - strlen(str) * white_small_text->w, rect.y + white_small_text->h+2, 1);
     }
   if(state == BUTTON_PRESSED)
     fillrect(rect.x,rect.y,rect.w,rect.h,75,75,75,200);
@@ -121,7 +121,7 @@ void Button::draw()
 
 Button::~Button()
 {
-  texture_free(&icon);
+  delete icon;
 }
 
 void Button::event(SDL_Event &event)