X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsupertux%2Finfo_box.cpp;h=46c4da9c9dc12b7ee40567e56e03fb70253be89d;hb=eb9172b9d625b0c333d7ad406433d5d14129a2e6;hp=323bbfc90be96f602386b62bb9b94208dc337c42;hpb=1cda2772a8bd261ef8746e13e10d5d8abbe741d6;p=supertux.git diff --git a/src/supertux/info_box.cpp b/src/supertux/info_box.cpp index 323bbfc90..46c4da9c9 100644 --- a/src/supertux/info_box.cpp +++ b/src/supertux/info_box.cpp @@ -16,7 +16,7 @@ #include "supertux/info_box.hpp" -#include "supertux/main.hpp" +#include "supertux/globals.hpp" #include "supertux/info_box_line.hpp" #include "util/log.hpp" #include "video/drawing_context.hpp" @@ -24,36 +24,31 @@ InfoBox::InfoBox(const std::string& text) : firstline(0), - lines(), + // Split text string lines into a vector + lines(InfoBoxLine::split(text, 400)), images(), arrow_scrollup(), arrow_scrolldown() { - // Split text string lines into a vector - lines = InfoBoxLine::split(text, 400); - try { // get the arrow sprites - arrow_scrollup = new Surface("images/engine/menu/scroll-up.png"); - arrow_scrolldown = new Surface("images/engine/menu/scroll-down.png"); + arrow_scrollup = Surface::create("images/engine/menu/scroll-up.png"); + arrow_scrolldown = Surface::create("images/engine/menu/scroll-down.png"); } catch (std::exception& e) { log_warning << "Could not load scrolling images: " << e.what() << std::endl; - arrow_scrollup = 0; - arrow_scrolldown = 0; + arrow_scrollup.reset(); + arrow_scrolldown.reset(); } } InfoBox::~InfoBox() { for(std::vector::iterator i = lines.begin(); - i != lines.end(); i++) + i != lines.end(); ++i) delete *i; - - delete arrow_scrollup; - delete arrow_scrolldown; } void @@ -75,18 +70,18 @@ InfoBox::draw(DrawingContext& context) break; } - lines[i]->draw(context, Rect(x1, y, x1+width, y), LAYER_GUI); + lines[i]->draw(context, Rectf(x1, y, x1+width, y), LAYER_GUI); y += lines[i]->get_height(); } { // draw the scrolling arrows - if (arrow_scrollup && firstline > 0) + if (arrow_scrollup.get() && firstline > 0) context.draw_surface(arrow_scrollup, Vector( x1 + width - arrow_scrollup->get_width(), // top-right corner of box y1), LAYER_GUI); - if (arrow_scrolldown && linesLeft && firstline < lines.size()-1) + if (arrow_scrolldown.get() && linesLeft && firstline < lines.size()-1) context.draw_surface(arrow_scrolldown, Vector( x1 + width - arrow_scrolldown->get_width(), // bottom-light corner of box y1 + height - arrow_scrolldown->get_height()),