mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 06:21:50 +00:00
world/content added to packs search paths
This commit is contained in:
parent
01121b6d27
commit
6198ca22f6
3 changed files with 21 additions and 11 deletions
|
|
@ -71,20 +71,25 @@ std::vector<std::string> ContentPack::worldPacksList(fs::path folder) {
|
||||||
return files::read_list(listfile);
|
return files::read_list(listfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::path ContentPack::findPack(const EnginePaths* paths, std::string name) {
|
fs::path ContentPack::findPack(const EnginePaths* paths, fs::path worldDir, std::string name) {
|
||||||
auto folder = paths->getResources() / fs::path("content") / fs::path(name);
|
fs::path folder = worldDir / fs::path("content") / fs::path(name);
|
||||||
if (!fs::is_directory(folder)) {
|
if (fs::is_directory(folder)) {
|
||||||
throw contentpack_error(name, folder,
|
return folder;
|
||||||
"could not to find pack '"+name+"'");
|
|
||||||
}
|
}
|
||||||
return folder;
|
folder = paths->getResources() / fs::path("content") / fs::path(name);
|
||||||
|
if (fs::is_directory(folder)) {
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
|
throw contentpack_error(name, folder,
|
||||||
|
"could not to find pack '"+name+"'");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentPack::readPacks(const EnginePaths* paths,
|
void ContentPack::readPacks(const EnginePaths* paths,
|
||||||
std::vector<ContentPack>& packs,
|
std::vector<ContentPack>& packs,
|
||||||
const std::vector<std::string>& packnames) {
|
const std::vector<std::string>& packnames,
|
||||||
|
std::filesystem::path worldDir) {
|
||||||
for (const auto& name : packnames) {
|
for (const auto& name : packnames) {
|
||||||
fs::path packfolder = ContentPack::findPack(paths, name);
|
fs::path packfolder = ContentPack::findPack(paths, worldDir, name);
|
||||||
packs.push_back(ContentPack::read(packfolder));
|
packs.push_back(ContentPack::read(packfolder));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,15 @@ struct ContentPack {
|
||||||
static void scan(std::filesystem::path folder,
|
static void scan(std::filesystem::path folder,
|
||||||
std::vector<ContentPack>& packs);
|
std::vector<ContentPack>& packs);
|
||||||
static std::vector<std::string> worldPacksList(std::filesystem::path folder);
|
static std::vector<std::string> worldPacksList(std::filesystem::path folder);
|
||||||
static std::filesystem::path findPack(const EnginePaths* paths, std::string name);
|
|
||||||
|
static std::filesystem::path findPack(
|
||||||
|
const EnginePaths* paths,
|
||||||
|
std::filesystem::path worldDir,
|
||||||
|
std::string name);
|
||||||
static void readPacks(const EnginePaths* paths,
|
static void readPacks(const EnginePaths* paths,
|
||||||
std::vector<ContentPack>& packs,
|
std::vector<ContentPack>& packs,
|
||||||
const std::vector<std::string>& names);
|
const std::vector<std::string>& names,
|
||||||
|
std::filesystem::path worldDir);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTENT_CONTENT_PACK_H_
|
#endif // CONTENT_CONTENT_PACK_H_
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ void open_world(std::string name, Engine* engine) {
|
||||||
packs.clear();
|
packs.clear();
|
||||||
try {
|
try {
|
||||||
auto packNames = ContentPack::worldPacksList(folder);
|
auto packNames = ContentPack::worldPacksList(folder);
|
||||||
ContentPack::readPacks(paths, packs, packNames);
|
ContentPack::readPacks(paths, packs, packNames, folder);
|
||||||
} catch (contentpack_error& error) {
|
} catch (contentpack_error& error) {
|
||||||
// could not to find or read pack
|
// could not to find or read pack
|
||||||
guiutil::alert(engine->getGUI(),
|
guiutil::alert(engine->getGUI(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue