00001 // SuperTux (Statistics module) 00002 // Copyright (C) 2004 Ricardo Cruz <rick2@aeiou.pt> 00003 // Copyright (C) 2006 Ondrej Hosek <ondra.hosek@gmail.com> 00004 // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de> 00005 // 00006 // This program is free software: you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation, either version 3 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 00019 #ifndef HEADER_SUPERTUX_SUPERTUX_STATISTICS_HPP 00020 #define HEADER_SUPERTUX_SUPERTUX_STATISTICS_HPP 00021 00022 #include <squirrel.h> 00023 00024 #include "video/color.hpp" 00025 #include "video/surface_ptr.hpp" 00026 00027 namespace lisp { class Writer; } 00028 namespace lisp { class Lisp; } 00029 class DrawingContext; 00030 00034 class Statistics 00035 { 00036 static Color header_color; 00037 static Color text_color; 00038 public: 00039 int coins; 00040 int total_coins; 00041 int badguys; 00042 int total_badguys; 00043 float time; 00044 int secrets; 00045 int total_secrets; 00047 public: 00048 Statistics(); 00049 ~Statistics(); 00050 00052 //void parse(const Reader& lisp); 00054 //void write(Writer& writer); 00055 00059 void serialize_to_squirrel(HSQUIRRELVM vm); 00060 00064 void unserialize_from_squirrel(HSQUIRRELVM vm); 00065 00066 void draw_worldmap_info(DrawingContext& context); 00067 void draw_endseq_panel(DrawingContext& context, Statistics* best_stats, SurfacePtr backdrop); 00069 void zero(); 00070 void reset(); 00071 void merge(const Statistics& stats); 00072 void operator+=(const Statistics& o); 00074 void declare_invalid(); 00076 static std::string coins_to_string(int coins, int total_coins); 00077 static std::string frags_to_string(int badguys, int total_badguys); 00078 static std::string time_to_string(float time); 00079 static std::string secrets_to_string(int secrets, int total_secrets); 00080 00081 private: 00082 bool valid; 00084 }; 00085 00086 #endif /*SUPERTUX_STATISTICS_H*/ 00087 00088 /* EOF */