level.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #ifndef HEADER_SUPERTUX_SUPERTUX_LEVEL_HPP
  17. #define HEADER_SUPERTUX_SUPERTUX_LEVEL_HPP
  18. #include "supertux/statistics.hpp"
  19. class Player;
  20. class ReaderMapping;
  21. class Sector;
  22. class Writer;
  23. /** Represents a collection of Sectors running in a single GameSession.
  24. Each Sector in turn contains GameObjects, e.g. Badguys and Players. */
  25. class Level final
  26. {
  27. friend class LevelParser;
  28. public:
  29. static Level* current() { return s_current; }
  30. private:
  31. static Level* s_current;
  32. public:
  33. explicit Level(bool m_is_worldmap);
  34. ~Level();
  35. // saves to a levelfile
  36. void save(const std::string& filename, bool retry = false);
  37. void save(std::ostream& stream);
  38. void add_sector(std::unique_ptr<Sector> sector);
  39. const std::string& get_name() const { return m_name; }
  40. const std::string& get_author() const { return m_author; }
  41. Sector* get_sector(const std::string& name) const;
  42. size_t get_sector_count() const;
  43. Sector* get_sector(size_t num) const;
  44. const std::vector<std::unique_ptr<Sector> >& get_sectors() const { return m_sectors; }
  45. std::vector<Player*> get_players() const;
  46. std::string get_tileset() const { return m_tileset; }
  47. int get_total_coins() const;
  48. int get_total_badguys() const;
  49. int get_total_secrets() const;
  50. void reactivate();
  51. bool is_worldmap() const { return m_is_worldmap; }
  52. std::string get_license() const { return m_license; }
  53. private:
  54. void initialize();
  55. void save(Writer& writer);
  56. void load_old_format(const ReaderMapping& reader);
  57. public:
  58. bool m_is_worldmap;
  59. std::string m_name;
  60. std::string m_author;
  61. std::string m_contact;
  62. std::string m_license;
  63. std::string m_filename;
  64. std::string m_note;
  65. std::vector<std::unique_ptr<Sector> > m_sectors;
  66. Statistics m_stats;
  67. float m_target_time;
  68. std::string m_tileset;
  69. bool m_suppress_pause_menu;
  70. bool m_is_in_cutscene;
  71. bool m_skip_cutscene;
  72. std::string m_icon;
  73. std::string m_icon_locked;
  74. std::string m_wmselect_bkg;
  75. private:
  76. Level(const Level&) = delete;
  77. Level& operator=(const Level&) = delete;
  78. };
  79. #endif
  80. /* EOF */