X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fstatistics.hpp;h=1fe64604e4742fa379be3cd924dff53e811355eb;hb=2cc6d246e1ff259b7580707847abf9f139d3d22c;hp=d2655eb82b6a60ed58946e3e6f06da0d38b444c4;hpb=acb7eebc740130088f5a13ad637661cf3bb28ab4;p=supertux.git diff --git a/src/statistics.hpp b/src/statistics.hpp index d2655eb82..1fe64604e 100644 --- a/src/statistics.hpp +++ b/src/statistics.hpp @@ -22,44 +22,64 @@ #ifndef SUPERTUX_STATISTICS_H #define SUPERTUX_STATISTICS_H -#include "timer.hpp" -#include "lisp/lisp.hpp" -#include "lisp/writer.hpp" -#include "video/surface.hpp" -#include "video/drawing_context.hpp" +#include + +namespace lisp { class Writer; } +namespace lisp { class Lisp; } +class Surface; +class DrawingContext; /** This class is a layer between level and worldmap to keep * track of stuff like scores, and minor, but funny things, like * number of jumps and stuff */ class Statistics -{ +{ public: int coins; /**< coins collected */ int total_coins; /**< coins in level */ int badguys; /**< badguys actively killed */ int total_badguys; /**< (vincible) badguys in level */ float time; /**< seconds needed */ + int secrets; /**< secret areas found */ + int total_secrets; /**< secret areas in level */ public: Statistics(); /**< Creates new statistics, call reset() before counting */ ~Statistics(); /// read statistics from lisp file - void parse(const lisp::Lisp& lisp); + //void parse(const lisp::Lisp& lisp); /// write statistics to lisp file - void write(lisp::Writer& writer); + //void write(lisp::Writer& writer); + + /** + * serialize statistics object as squirrel table "statistics" + */ + void serialize_to_squirrel(HSQUIRRELVM vm); + + /** + * unserialize statistics object from squirrel table "statistics" + */ + void unserialize_from_squirrel(HSQUIRRELVM vm); void draw_worldmap_info(DrawingContext& context); /**< draw worldmap stat HUD */ - void draw_message_info(DrawingContext& context, std::string title); /**< draw stats at level start */ void draw_endseq_panel(DrawingContext& context, Statistics* best_stats, Surface* backdrop); /**< draw panel shown during level's end sequence */ + void zero(); /**< Set stats to zero */ void reset(); /**< Set stats (but not totals) to zero */ - void merge(Statistics& stats); /**< Given another Statistics object finds the best of each one */ + void merge(const Statistics& stats); /**< Given another Statistics object finds the best of each one */ void operator+=(const Statistics& o); /**< Add two Statistics objects */ + void declare_invalid(); /**< marks statistics as invalid for their entire lifetime (e.g. after cheating). Invalid statistics will not be merged or drawn. */ + + static std::string coins_to_string(int coins, int total_coins); + static std::string frags_to_string(int badguys, int total_badguys); + static std::string time_to_string(float time); + static std::string secrets_to_string(int secrets, int total_secrets); + private: - Timer timer; /**< for draw_worldmap_info: time until switching to next stat */ - int display_stat; /**< for draw_worldmap_info: which stat is currently displayed */ + bool valid; /**< stores whether these statistics can be trusted */ + }; #endif /*SUPERTUX_STATISTICS_H*/