refactor & add test.new_world

This commit is contained in:
MihailRis
2024-12-10 18:41:39 +03:00
parent 8f37704530
commit 9b4dd8f65e
9 changed files with 57 additions and 8 deletions
+6 -5
View File
@@ -150,9 +150,7 @@ static void load_world(Engine* engine, const std::shared_ptr<WorldFiles>& worldF
auto& settings = engine->getSettings();
auto level = World::load(worldFiles, settings, content, packs);
engine->setScreen(
std::make_shared<LevelScreen>(engine, std::move(level))
);
engine->onWorldOpen(std::move(level));
} catch (const world_load_error& error) {
guiutil::alert(
engine->getGUI(),
@@ -229,7 +227,10 @@ void EngineController::createWorld(
EnginePaths* paths = engine->getPaths();
auto folder = paths->getWorldsFolder() / fs::u8path(name);
if (!menus::call(engine, [this, paths, folder]() {
if (engine->isHeadless()) {
engine->loadContent();
paths->setCurrentWorldFolder(folder);
} else if (!menus::call(engine, [this, paths, folder]() {
engine->loadContent();
paths->setCurrentWorldFolder(folder);
})) {
@@ -244,7 +245,7 @@ void EngineController::createWorld(
engine->getContent(),
engine->getContentPacks()
);
engine->setScreen(std::make_shared<LevelScreen>(engine, std::move(level)));
engine->onWorldOpen(std::move(level));
}
void EngineController::reopenWorld(World* world) {