#include <string.h>
#include <stdlib.h>
#include "setup.h"
-#include "screen.h"
+#include "screen/screen.h"
#include "globals.h"
#include "button.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;
tag = -1;
state = BUTTON_NONE;
show_info = false;
- game_object = NULL;
+ 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];
for(std::vector<Surface*>::iterator it = icon.begin(); it != icon.end(); ++it)
(*it)->draw(rect.x,rect.y);
- if(game_object != NULL)
+ if(drawable)
{
- game_object->draw_on_screen(rect.x,rect.y);
+ Camera viewport;
+ viewport.set_translation(Vector(rect.x, rect.y));
+ drawable->draw(viewport, 0);
}
if(show_info)
for(std::vector<Surface*>::iterator it = icon.begin(); it != icon.end(); ++it)
delete (*it);
icon.clear();
- delete game_object;
+ // 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)
{
hlast = b;
}
+#endif