1 // SuperTux (Statistics module)
2 // Copyright (C) 2004 Ricardo Cruz <rick2@aeiou.pt>
3 // Copyright (C) 2006 Ondrej Hosek <ondra.hosek@gmail.com>
4 // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
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.
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef HEADER_SUPERTUX_SUPERTUX_STATISTICS_HPP
20 #define HEADER_SUPERTUX_SUPERTUX_STATISTICS_HPP
24 #include "video/color.hpp"
26 namespace lisp { class Writer; }
27 namespace lisp { class Lisp; }
31 /** This class is a layer between level and worldmap to keep
32 * track of stuff like scores, and minor, but funny things, like
33 * number of jumps and stuff */
36 static Color header_color;
37 static Color text_color;
39 int coins; /**< coins collected */
40 int total_coins; /**< coins in level */
41 int badguys; /**< badguys actively killed */
42 int total_badguys; /**< (vincible) badguys in level */
43 float time; /**< seconds needed */
44 int secrets; /**< secret areas found */
45 int total_secrets; /**< secret areas in level */
48 Statistics(); /**< Creates new statistics, call reset() before counting */
51 /// read statistics from lisp file
52 //void parse(const Reader& lisp);
53 /// write statistics to lisp file
54 //void write(lisp::Writer& writer);
57 * serialize statistics object as squirrel table "statistics"
59 void serialize_to_squirrel(HSQUIRRELVM vm);
62 * unserialize statistics object from squirrel table "statistics"
64 void unserialize_from_squirrel(HSQUIRRELVM vm);
66 void draw_worldmap_info(DrawingContext& context); /**< draw worldmap stat HUD */
67 void draw_endseq_panel(DrawingContext& context, Statistics* best_stats, Surface* backdrop); /**< draw panel shown during level's end sequence */
69 void zero(); /**< Set stats to zero */
70 void reset(); /**< Set stats (but not totals) to zero */
71 void merge(const Statistics& stats); /**< Given another Statistics object finds the best of each one */
72 void operator+=(const Statistics& o); /**< Add two Statistics objects */
74 void declare_invalid(); /**< marks statistics as invalid for their entire lifetime (e.g. after cheating). Invalid statistics will not be merged or drawn. */
76 static std::string coins_to_string(int coins, int total_coins);
77 static std::string frags_to_string(int badguys, int total_badguys);
78 static std::string time_to_string(float time);
79 static std::string secrets_to_string(int secrets, int total_secrets);
82 bool valid; /**< stores whether these statistics can be trusted */
86 #endif /*SUPERTUX_STATISTICS_H*/