Content menu, content-pack dependencies
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user