Content menu, content-pack dependencies

This commit is contained in:
MihailRis
2024-01-27 00:36:18 +03:00
parent abc3e47feb
commit c57b2d0de3
25 changed files with 230 additions and 21 deletions
+18 -1
View File
@@ -453,13 +453,18 @@ void WorldFiles::write(const World* world, const Content* content) {
}
void WorldFiles::writePacks(const World* world) {
auto packsFile = getPacksFile();
if (fs::is_regular_file(packsFile)) {
return;
}
const auto& packs = world->getPacks();
std::stringstream ss;
ss << "# autogenerated; do not modify\n";
for (const auto& pack : packs) {
ss << pack.id << "\n";
}
files::write_string(getPacksFile(), ss.str());
files::write_string(packsFile, ss.str());
}
void WorldFiles::writeIndices(const ContentIndices* indices) {
@@ -574,3 +579,15 @@ bool WorldFiles::readPlayer(Player* player) {
}
return true;
}
void WorldFiles::addPack(const std::string& id) {
auto packs = files::read_list(getPacksFile());
packs.push_back(id);
std::stringstream ss;
ss << "# autogenerated; do not modify\n";
for (const auto& pack : packs) {
ss << pack << "\n";
}
files::write_string(getPacksFile(), ss.str());
}