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