world.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_WORLD_HPP
  17. #define HEADER_SUPERTUX_SUPERTUX_WORLD_HPP
  18. #include <memory>
  19. #include <string>
  20. #include "supertux/gameconfig.hpp"
  21. #include "supertux/globals.hpp"
  22. class World final
  23. {
  24. friend class EditorLevelsetMenu;
  25. public:
  26. /** Load a World
  27. @param directory Directory containing the info file, e.g. "levels/world1" */
  28. static std::unique_ptr<World> from_directory(const std::string& directory);
  29. static std::unique_ptr<World> create(const std::string& title, const std::string& desc);
  30. private:
  31. World(const std::string& directory);
  32. public:
  33. std::string get_basename() const;
  34. std::string get_basedir() const { return m_basedir; }
  35. std::string get_title() const { return m_title; }
  36. std::string get_description() const { return m_description; }
  37. bool hide_from_contribs() const { return m_hide_from_contribs && !g_config->developer_mode; }
  38. bool is_levelset() const { return m_is_levelset; }
  39. bool is_worldmap() const { return !m_is_levelset; }
  40. std::string get_contrib_type() const { return m_contrib_type; }
  41. std::string get_title_level() const { return m_title_level; }
  42. std::string get_worldmap_filename() const;
  43. void save(bool retry = false);
  44. private:
  45. std::string m_title;
  46. std::string m_description;
  47. bool m_is_levelset;
  48. std::string m_basedir;
  49. bool m_hide_from_contribs;
  50. std::string m_contrib_type; // Type of world if it is contrib: official, community, user
  51. std::string m_title_level; // Level, which should be used for the title screen, after exiting the world
  52. private:
  53. World(const World&) = delete;
  54. World& operator=(const World&) = delete;
  55. };
  56. #endif
  57. /* EOF */