|
|
@@ -13,6 +13,7 @@
|
|
|
#include "danmaku/level.hpp"
|
|
|
#include "danmaku/player.hpp"
|
|
|
#include "danmaku/serial.hpp"
|
|
|
+#include "game/engine/game_dispatch.hpp"
|
|
|
#include "game/util/env.hpp"
|
|
|
|
|
|
using namespace danmaku;
|
|
|
@@ -29,14 +30,23 @@ level_from_path(Json::Value const & json, std::string const & path,
|
|
|
return std::make_shared<level>(json["name"].asString(), level_json, game);
|
|
|
}
|
|
|
|
|
|
-world::world(std::string const & player_file, std::string const & path,
|
|
|
- Json::Value const & json,
|
|
|
- std::shared_ptr<engine::game_dispatch> game)
|
|
|
- : engine::scene("world", game),
|
|
|
- player_(to_player(player_json(player_file), graphics_manager())),
|
|
|
- levels_(to_vector(json["levels"], level_from_path, path, game)) {}
|
|
|
+world::world(std::shared_ptr<engine::game_dispatch> game,
|
|
|
+ std::unique_ptr<player> player,
|
|
|
+ std::vector<std::shared_ptr<level>> levels)
|
|
|
+ : engine::scene("world", game), player_(std::move(player)),
|
|
|
+ levels_(levels) {}
|
|
|
|
|
|
world::~world() {}
|
|
|
|
|
|
+std::shared_ptr<world>
|
|
|
+world::load_world(std::string const & path,
|
|
|
+ std::shared_ptr<engine::game_dispatch> game) {
|
|
|
+ std::string const directory = path.substr(0, path.find_last_of('/') + 1);
|
|
|
+ Json::Value const json = engine::read_file(env::resource_file(path));
|
|
|
+ return std::make_shared<world>(
|
|
|
+ game, to_player(player_json("player.json"), game->graphics_manager()),
|
|
|
+ to_vector(json["levels"], level_from_path, directory, game));
|
|
|
+}
|
|
|
+
|
|
|
// to_vector(Json::Value const &, ...)
|
|
|
#include "danmaku/serial.tpp"
|