add generator 'caption' property
This commit is contained in:
@@ -54,7 +54,9 @@ static void detect_defs(
|
||||
continue;
|
||||
}
|
||||
if (fs::is_regular_file(file) && files::is_data_file(file)) {
|
||||
detected.push_back(prefix.empty() ? name : prefix + ":" + name);
|
||||
auto map = files::read_object(file);
|
||||
std::string id = prefix.empty() ? name : prefix + ":" + name;
|
||||
detected.emplace_back(id);
|
||||
} else if (fs::is_directory(file) &&
|
||||
file.extension() != fs::u8path(".files")) {
|
||||
detect_defs(file, name, detected);
|
||||
@@ -63,11 +65,38 @@ static void detect_defs(
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> ContentLoader::scanContent(
|
||||
static void detect_defs_pairs(
|
||||
const fs::path& folder,
|
||||
const std::string& prefix,
|
||||
std::vector<std::tuple<std::string, std::string>>& detected
|
||||
) {
|
||||
if (fs::is_directory(folder)) {
|
||||
for (const auto& entry : fs::directory_iterator(folder)) {
|
||||
const fs::path& file = entry.path();
|
||||
std::string name = file.stem().string();
|
||||
if (name[0] == '_') {
|
||||
continue;
|
||||
}
|
||||
if (fs::is_regular_file(file) && files::is_data_file(file)) {
|
||||
auto map = files::read_object(file);
|
||||
std::string id = prefix.empty() ? name : prefix + ":" + name;
|
||||
std::string caption = util::id_to_caption(id);
|
||||
map.at("caption").get(caption);
|
||||
detected.emplace_back(id, name);
|
||||
} else if (fs::is_directory(file) &&
|
||||
file.extension() != fs::u8path(".files")) {
|
||||
detect_defs_pairs(file, name, detected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::tuple<std::string, std::string>> ContentLoader::scanContent(
|
||||
const ContentPack& pack, ContentType type
|
||||
) {
|
||||
std::vector<std::string> detected;
|
||||
detect_defs(pack.folder / ContentPack::getFolderFor(type), pack.id, detected);
|
||||
std::vector<std::tuple<std::string, std::string>> detected;
|
||||
detect_defs_pairs(
|
||||
pack.folder / ContentPack::getFolderFor(type), pack.id, detected);
|
||||
return detected;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
const std::string& contentSection
|
||||
);
|
||||
|
||||
static std::vector<std::string> scanContent(
|
||||
static std::vector<std::tuple<std::string, std::string>> scanContent(
|
||||
const ContentPack& pack, ContentType type
|
||||
);
|
||||
|
||||
|
||||
@@ -193,6 +193,7 @@ void ContentLoader::loadGenerator(
|
||||
return;
|
||||
}
|
||||
auto map = files::read_toml(generatorsDir / fs::u8path(name + ".toml"));
|
||||
map.at("caption").get(def.caption);
|
||||
map.at("biome_parameters").get(def.biomeParameters);
|
||||
map.at("biome-bpd").get(def.biomesBPD);
|
||||
map.at("heights-bpd").get(def.heightsBPD);
|
||||
|
||||
Reference in New Issue
Block a user