#ifndef HEADER_SUPERTUX_SUPERTUX_WORLD_HPP
#define HEADER_SUPERTUX_SUPERTUX_WORLD_HPP
+#include <memory>
#include <squirrel.h>
#include <string>
#include <vector>
-class PlayerStatus;
+#include "supertux/savegame.hpp"
class World
{
+private:
+ World();
+
+ void load_(const std::string& directory);
+
public:
- static World* current()
- {
- return current_;
- }
+ /**
+ Load a World
-private:
- static World* current_;
+ @param directory Directory containing the info file, e.g. "levels/world1"
+ */
+ static std::unique_ptr<World> load(const std::string& directory);
public:
- World();
~World();
- void set_savegame_filename(const std::string& filename);
- void load(const std::string& filename);
-
- void save_state();
- void load_state();
+ std::string get_basedir() const;
+ std::string get_title() const;
- unsigned int get_num_levels() const;
- int get_num_solved_levels() const;
+ bool hide_from_contribs() const { return m_hide_from_contribs; }
- const std::string& get_level_filename(unsigned int i) const;
- const std::string& get_basedir() const;
- const std::string& get_title() const;
- /** returns player status */
- PlayerStatus* get_player_status() const { return player_status.get(); }
+ bool is_levelset() const { return m_is_levelset; }
+ bool is_worldmap() const { return !m_is_levelset; }
- void run();
+ std::string get_worldmap_filename() const { return m_worldmap_filename; }
+ std::string get_savegame_filename() const { return m_savegame_filename; }
private:
- std::string worldname;
- struct Level
- {
- std::string fullpath;
- std::string name;
- };
-
- std::vector<Level> levels;
- std::string basedir;
- std::string savegame_filename;
- /// squirrel table that saves persistent state (about the world)
- HSQOBJECT state_table;
- HSQOBJECT world_thread;
- std::string title;
- std::string description;
- std::unique_ptr<PlayerStatus> player_status;
-
-public:
- bool hide_from_contribs;
- bool is_levelset;
+ std::string m_basedir;
+ std::string m_worldmap_filename;
+ std::string m_savegame_filename;
+
+ std::string m_title;
+ std::string m_description;
+ bool m_hide_from_contribs;
+ bool m_is_levelset;
private:
World(const World&) = delete;