[nostalgia/studio] Update for new model type store system

This commit is contained in:
Gary Talent 2022-05-28 20:00:28 -05:00
parent 885f4a8713
commit 717bbd2e0f

View File

@ -103,15 +103,22 @@ ox::Error Project::writeObj(const ox::String &path, auto *obj) const noexcept {
// write to FS
oxReturnError(writeBuff(path, buff));
// write type descriptor
oxRequire(type, ox::buildTypeDef(obj));
oxRequireM(typeOut, ox::writeClaw(type.get(), ox::ClawFormat::Organic));
// replace garbage last character with new line
typeOut.back().value = '\n';
// write to FS
ox::TypeStore typeStore;
oxReturnError(ox::buildTypeDef(&typeStore, obj));
// write out type store
static constexpr auto descPath = "/.nostalgia/type_descriptors";
const auto typePath = ox::sfmt("{}/{}", descPath, type->typeName);
oxReturnError(mkdir(descPath));
oxReturnError(writeBuff(typePath, typeOut));
for (const auto t : typeStore.typeList()) {
if (t->typeName.beginsWith("B:")) {
continue;
}
oxRequireM(typeOut, ox::writeClaw(t, ox::ClawFormat::Organic));
// replace garbage last character with new line
typeOut.back().value = '\n';
// write to FS
const auto typePath = ox::sfmt("{}/{}", descPath, t->typeName);
oxReturnError(writeBuff(typePath, typeOut));
}
fileUpdated.emit(path);
return OxError(0);
}