supertux
level.hpp
1 // SuperTux
2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_SUPERTUX_LEVEL_HPP
18 #define HEADER_SUPERTUX_SUPERTUX_LEVEL_HPP
19 
20 #include "supertux/statistics.hpp"
21 
22 class Player;
23 class ReaderMapping;
24 class Sector;
25 class Writer;
26 
30 class Level final
31 {
32  friend class LevelParser;
33 
34 public:
35  static Level* current() { return s_current; }
36 
37 private:
38  static Level* s_current;
39 
40 public:
41  explicit Level(bool m_is_worldmap);
42  ~Level();
43 
44  // saves to a levelfile
45  void save(const std::string& filename, bool retry = false);
46  void save(std::ostream& stream);
47 
48  void add_sector(std::unique_ptr<Sector> sector);
49  const std::string& get_name() const { return m_name; }
50  const std::string& get_author() const { return m_author; }
51 
52  Sector* get_sector(const std::string& name) const;
53 
54  size_t get_sector_count() const;
55  Sector* get_sector(size_t num) const;
56  const std::vector<std::unique_ptr<Sector> >& get_sectors() const { return m_sectors; }
57 
58  std::vector<Player*> get_players() const;
59 
60  const std::string& get_tileset() const { return m_tileset; }
61 
62  int get_total_coins() const;
63  int get_total_badguys() const;
64  int get_total_secrets() const;
65 
66  void reactivate();
67 
68  bool is_worldmap() const { return m_is_worldmap; }
69 
70  const std::string& get_license() const { return m_license; }
71 
72 private:
73  void initialize();
74 
75  void save(Writer& writer);
76  void load_old_format(const ReaderMapping& reader);
77 
78 public:
79  bool m_is_worldmap;
80  std::string m_name;
81  std::string m_author;
82  std::string m_contact;
83  std::string m_license;
84  std::string m_filename;
85  std::string m_note;
86  std::vector<std::unique_ptr<Sector> > m_sectors;
87  Statistics m_stats;
88  float m_target_time;
89  std::string m_tileset;
90  bool m_suppress_pause_menu;
91  bool m_is_in_cutscene;
92  bool m_skip_cutscene;
93  std::string m_icon;
94  std::string m_icon_locked;
95  std::string m_wmselect_bkg;
96 
97 private:
98  Level(const Level&) = delete;
99  Level& operator=(const Level&) = delete;
100 };
101 
102 #endif
103 
104 /* EOF */
Definition: level_parser.hpp:27
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.
Definition: statistics.hpp:36
Represents one of (potentially) multiple, separate parts of a Level.
Definition: sector.hpp:61
Represents a collection of Sectors running in a single GameSession.
Definition: level.hpp:30
Definition: reader_mapping.hpp:32
This module contains methods controlling the player.
Definition: player.hpp:47
Definition: writer.cpp:23