Massive copyright update. I'm sorry if I'm crediting Matze for something he didn...
[supertux.git] / src / statistics.hpp
1 //  $Id$
2 //
3 //  SuperTux (Statistics module)
4 //  Copyright (C) 2004 Ricardo Cruz <rick2@aeiou.pt>
5 //  Copyright (C) 2006 Ondrej Hosek <ondra.hosek@gmail.com>
6 //
7 //  This program is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU General Public License
9 //  as published by the Free Software Foundation; either version 2
10 //  of the License, or (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU General Public License for more details.
16 //
17 //  You should have received a copy of the GNU General Public License
18 //  along with this program; if not, write to the Free Software
19 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 #ifndef SUPERTUX_STATISTICS_H
22 #define SUPERTUX_STATISTICS_H
23
24 #include "timer.hpp"
25 #include "lisp/lisp.hpp"
26 #include "lisp/writer.hpp"
27 #include "video/surface.hpp"
28 #include "video/drawing_context.hpp"
29
30 #define SPLAYER 0
31 #define STOTAL  1
32
33 enum {
34 //  SCORE_STAT,
35   COINS_COLLECTED_STAT,
36   BADGUYS_KILLED_STAT,
37   TIME_NEEDED_STAT,
38   NUM_STATS
39 };
40
41 /** This class is a layer between level and worldmap to keep
42  *  track of stuff like scores, and minor, but funny things, like
43  *  number of jumps and stuff */
44
45 class Statistics
46 {
47 public:
48   // don't forget to call reset() to init stat
49   Statistics();
50   ~Statistics();
51
52   /// read statistics from lisp file
53   void parse(const lisp::Lisp& lisp);
54   /// write statistics to lisp file
55   void write(lisp::Writer& writer);
56
57   /* Draw to the worldmap or a game message */
58   // TODO: make this functions working
59   void draw_worldmap_info(DrawingContext& context);
60   void draw_message_info(DrawingContext& context, std::string title);
61   void draw_endseq_panel(DrawingContext& context, Statistics* best_stats, Surface* backdrop); /**< draw panel shown during level's end sequence */
62
63   /* Add / Set / Get points to/from one of the stats this can keep track of */
64   void add_points(int stat, int points);
65   void set_points(int stat, int points);
66   int get_points(int stat);
67
68   void set_total_points(int stat, int points);
69
70   /* Reset statistics */
71   void reset();
72
73   /* Give another Statistics object, find the best of each one */
74   void merge(Statistics& stats);
75
76   /* Add two statistic objects */
77   void operator+=(const Statistics& o);
78
79 private:
80   int stats[NUM_STATS][2];
81
82   Timer timer;
83   int display_stat;
84 };
85
86 extern Statistics global_stats;
87
88 #endif /*SUPERTUX_STATISTICS_H*/