New grow and skid sounds from remaxim
[supertux.git] / src / textscroller.hpp
index 01615c1..ede1e6b 100644 (file)
@@ -1,7 +1,7 @@
 //  $Id$
-// 
+//
 //  SuperTux
-//  Copyright (C) 2005 Matthias Braun <matze@braunis.de>
+//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
 //
 //  This program is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU General Public License
@@ -12,7 +12,7 @@
 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 //  GNU General Public License for more details.
-// 
+//
 //  You should have received a copy of the GNU General Public License
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #include <vector>
 #include <string>
 #include <map>
+#include <memory>
 
-#include "video/surface.hpp"
+#include "screen.hpp"
+#include "math/vector.hpp"
+#include "math/rect.hpp"
+#include "video/color.hpp"
 
 class DrawingContext;
+class Surface;
+class Font;
+
+/**
+ * Helper class for InfoBox: Represents a line of text
+ */
+class InfoBoxLine
+{
+public:
+  enum LineType { NORMAL, NORMAL_LEFT, SMALL, HEADING, REFERENCE, IMAGE};
+
+  InfoBoxLine(char format_char, const std::string& text);
+  ~InfoBoxLine();
+
+  void draw(DrawingContext& context, const Rect& bbox, int layer);
+  float get_height();
+
+  static const std::vector<InfoBoxLine*> split(const std::string& text, float width);
+
+private:
+  InfoBoxLine::LineType lineType;
+  Font* font;
+  Color color;
+  std::string text;
+  Surface* image;
+};
 
 /** This class is displaying a box with information text inside the game
  */
@@ -42,19 +72,40 @@ public:
   void scrollup();
   void pagedown();
   void pageup();
-  
+
 private:
   size_t firstline;
-  std::vector<std::string> lines;
+  std::vector<InfoBoxLine*> lines;
   std::map<std::string, Surface*> images;
+  Surface* arrow_scrollup;
+  Surface* arrow_scrolldown;
 };
 
-/** Reads a text file (using LispReader, so it as to be in its formatting)
- * and scroll it over the screen
- * (this call blocks until all text scrolled through or the user aborted the
- *  textscrolling)
+/**
+ * Screen that displays intro text, extro text, etc.
  */
-void display_text_file(const std::string& file);
+class TextScroller : public Screen
+{
+public:
+  TextScroller(const std::string& file);
+  virtual ~TextScroller();
 
-#endif
+  void setup();
+  void draw(DrawingContext& context);
+  void update(float elapsed_time);
 
+  static Color small_color;
+  static Color heading_color;
+  static Color reference_color;
+  static Color normal_color;
+private:
+  float defaultspeed;
+  float speed;
+  std::string music;
+  std::auto_ptr<Surface> background;
+  std::vector<InfoBoxLine*> lines;
+  float scroll;
+  bool fading;
+};
+
+#endif