880ccb7fde9b97dace6dc50501678c16de50b336
[supertux.git] / src / console.hpp
1 //  $Id: worldmap.hpp 3209 2006-04-02 22:19:22Z sommer $
2 // 
3 //  SuperTux - Console
4 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 // 
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20 #ifndef SUPERTUX_CONSOLE_H
21 #define SUPERTUX_CONSOLE_H
22
23 #include <list>
24 #include <string>
25 #include <sstream>
26 #include <iostream>
27
28 class Console;
29 class ConsoleStreamBuffer;
30 class DrawingContext;
31 class Surface;
32
33 class Console 
34 {
35   public:
36     Console(DrawingContext* context);
37     ~Console();
38
39     static std::ostream output;
40
41     static void flush();
42
43     void draw();
44
45   protected:
46     static std::list<std::string> lines;
47     DrawingContext* context;
48     Surface* background;
49     static int height;
50
51     static ConsoleStreamBuffer outputBuffer;
52 };
53
54 class ConsoleStreamBuffer : public std::stringbuf 
55 {
56   public:
57     int sync() 
58     {
59       Console::flush();
60       return std::stringbuf::sync();
61     }
62 };
63
64 #endif
65
66