20130313
[gdash.git] / src / cave / caveset.hpp
blob70274cd2785ba756cfa5495abf2bfc4ee065f520
1 /*
2 * Copyright (c) 2007-2013, Czirkos Zoltan http://code.google.com/p/gdash/
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 #ifndef _GD_CAVESET
17 #define _GD_CAVESET
19 #include "config.h"
21 #include <stdexcept>
22 #include "cave/cavetypes.hpp"
23 #include "cave/helper/cavehighscore.hpp"
24 #include "cave/caverendered.hpp"
25 #include "cave/helper/reflective.hpp"
26 #include "cave/helper/adoptingcontainer.hpp"
27 #include "cave/cavestored.hpp"
29 /// @ingroup Cave
30 class CaveSet : public Reflective {
31 public:
32 CaveSet();
34 /* variables */
35 GdString name; ///< Name of caveset
36 GdString description; ///< Some words about the caveset
37 GdString author; ///< Author
38 GdString difficulty; ///< difficulty of the caveset, for info purposes
39 GdString www; ///< link to author's webpage
40 GdString date; ///< date of creation
42 GdString story; ///< story for the caves
43 GdString remark; ///< notes about the game
45 GdString title_screen; ///< base64-encoded title screen image
46 GdString title_screen_scroll; ///< scrolling background for title screen image
48 GdString charset;
49 GdString fontset;
51 GdInt initial_lives; ///< initial lives at game start
52 GdInt maximum_lives; ///< maximum lives
53 GdInt bonus_life_score; ///< bonus life / number of points
54 HighScoreTable highscore; ///< highscore table for caveset
56 GdBool edited; ///< changed since last save
57 GdInt last_selected_cave;
58 GdInt last_selected_level;
59 GdString filename; ///< Loaded from file
61 AdoptingContainer<CaveStored> caves;
63 /* highscore in config directory */
64 void save_highscore(const char* directory) const;
65 bool load_highscore(const char* directory);
67 void save_to_file(const char *filename) throw (std::runtime_error);
68 void set_name_from_filename(const char *filename);
70 bool has_replays();
71 bool has_caves() const { return !caves.empty(); }
72 CaveStored& cave(unsigned i) const { return *(caves.at(i)); }
73 int cave_index(CaveStored const *cave) const;
74 int first_selectable_cave_index() const;
76 private:
77 const char *filename_for_cave_highscores(const char *directory) const;
78 unsigned checksum() const;
80 // for reflective
81 public:
82 static PropertyDescription const descriptor[];
83 virtual PropertyDescription const *get_description_array() const { return descriptor; }
86 extern const char *gd_caveset_extensions[];
88 #endif /* _CAVESET_H */