added paths 'world:' entry point
This commit is contained in:
@@ -76,6 +76,10 @@ void EnginePaths::setResources(fs::path folder) {
|
|||||||
this->resources = folder;
|
this->resources = folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EnginePaths::setWorldFolder(fs::path folder) {
|
||||||
|
this->worldFolder = folder;
|
||||||
|
}
|
||||||
|
|
||||||
void EnginePaths::setContentPacks(std::vector<ContentPack>* contentPacks) {
|
void EnginePaths::setContentPacks(std::vector<ContentPack>* contentPacks) {
|
||||||
this->contentPacks = contentPacks;
|
this->contentPacks = contentPacks;
|
||||||
}
|
}
|
||||||
@@ -96,6 +100,10 @@ fs::path EnginePaths::resolve(std::string path) {
|
|||||||
return userfiles/fs::path(filename);
|
return userfiles/fs::path(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prefix == "world") {
|
||||||
|
return worldFolder/fs::path(filename);
|
||||||
|
}
|
||||||
|
|
||||||
if (contentPacks) {
|
if (contentPacks) {
|
||||||
for (auto& pack : *contentPacks) {
|
for (auto& pack : *contentPacks) {
|
||||||
if (pack.id == prefix) {
|
if (pack.id == prefix) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace fs = std::filesystem;
|
|||||||
class EnginePaths {
|
class EnginePaths {
|
||||||
fs::path userfiles {"."};
|
fs::path userfiles {"."};
|
||||||
fs::path resources {"res"};
|
fs::path resources {"res"};
|
||||||
|
fs::path worldFolder {""};
|
||||||
std::vector<ContentPack>* contentPacks = nullptr;
|
std::vector<ContentPack>* contentPacks = nullptr;
|
||||||
public:
|
public:
|
||||||
fs::path getUserfiles() const;
|
fs::path getUserfiles() const;
|
||||||
@@ -24,6 +25,7 @@ public:
|
|||||||
void setUserfiles(fs::path folder);
|
void setUserfiles(fs::path folder);
|
||||||
void setResources(fs::path folder);
|
void setResources(fs::path folder);
|
||||||
void setContentPacks(std::vector<ContentPack>* contentPacks);
|
void setContentPacks(std::vector<ContentPack>* contentPacks);
|
||||||
|
void setWorldFolder(fs::path folder);
|
||||||
|
|
||||||
std::vector<fs::path> scanForWorlds();
|
std::vector<fs::path> scanForWorlds();
|
||||||
|
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ void open_world(std::string name, Engine* engine) {
|
|||||||
L": "+util::str2wstr_utf8(error.what()));
|
L": "+util::str2wstr_utf8(error.what()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
paths->setWorldFolder(folder);
|
||||||
|
|
||||||
auto& packs = engine->getContentPacks();
|
auto& packs = engine->getContentPacks();
|
||||||
auto* content = engine->getContent();
|
auto* content = engine->getContent();
|
||||||
@@ -303,6 +304,7 @@ void create_new_world_panel(Engine* engine, PagesControl* menu) {
|
|||||||
try {
|
try {
|
||||||
engine->loadAllPacks();
|
engine->loadAllPacks();
|
||||||
engine->loadContent();
|
engine->loadContent();
|
||||||
|
paths->setWorldFolder(folder);
|
||||||
} catch (const contentpack_error& error) {
|
} catch (const contentpack_error& error) {
|
||||||
guiutil::alert(engine->getGUI(),
|
guiutil::alert(engine->getGUI(),
|
||||||
langs::get(L"Content Error", L"menu")+
|
langs::get(L"Content Error", L"menu")+
|
||||||
|
|||||||
Reference in New Issue
Block a user