[nostalgia] Integrate Ox Preloader

This commit is contained in:
2022-11-30 01:47:33 -06:00
parent cbb496c59f
commit 090fe28b44
41 changed files with 404 additions and 159 deletions

View File

@@ -13,9 +13,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleVersion</key>
<string>1.2.8</string>
<string>0.0.0</string>
<key>LSMinimumSystemVersion</key>
<string>10.13.0</string>
<string>12.0.0</string>
<!-- HiDPI -->
<key>NSPrincipalClass</key>
@@ -24,6 +24,6 @@
<string>True</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright (c) 2016-2021 Gary Talent &lt;gary@drinkingtea.net&gt;</string>
<string>Copyright (c) 2016-2022 Gary Talent &lt;gary@drinkingtea.net&gt;</string>
</dict>
</plist>

View File

@@ -57,7 +57,8 @@ class NOSTALGIASTUDIO_EXPORT Project {
/**
* Writes a MetalClaw object to the project at the given path.
*/
ox::Error writeObj(const ox::String &path, auto *obj, ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept;
template<typename T>
ox::Error writeObj(const ox::String &path, const T *obj, ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept;
template<typename T>
ox::Result<ox::UniquePtr<T>> loadObj(const ox::String &path) const noexcept;
@@ -99,13 +100,16 @@ class NOSTALGIASTUDIO_EXPORT Project {
};
ox::Error Project::writeObj(const ox::String &path, auto *obj, ox::ClawFormat fmt) noexcept {
template<typename T>
ox::Error Project::writeObj(const ox::String &path, const T *obj, ox::ClawFormat fmt) noexcept {
// write MetalClaw
oxRequireM(buff, ox::writeClaw(obj, fmt));
// write to FS
oxReturnError(writeBuff(path, buff));
// write type descriptor
oxReturnError(ox::buildTypeDef(&m_typeStore, obj));
if (m_typeStore.get<T>().error) {
oxReturnError(ox::buildTypeDef(&m_typeStore, obj));
}
// write out type store
static constexpr auto descPath = "/.nostalgia/type_descriptors";
oxReturnError(mkdir(descPath));
@@ -114,7 +118,7 @@ ox::Error Project::writeObj(const ox::String &path, auto *obj, ox::ClawFormat fm
// replace garbage last character with new line
typeOut.back().value = '\n';
// write to FS
const auto typePath = ox::sfmt("{}/{};{}", descPath, t->typeName, t->typeVersion);
const auto typePath = ox::sfmt("{}/{}", descPath, buildTypeId(*t));
oxReturnError(writeBuff(typePath, typeOut));
}
fileUpdated.emit(path);

View File

@@ -110,7 +110,6 @@ void NewMenu::drawLastPageButtons(core::Context *ctx) noexcept {
void NewMenu::finish(core::Context *ctx) noexcept {
const auto err = m_types[static_cast<std::size_t>(m_selectedType)]->write(ctx, m_itemName.c_str());
if (err) {
oxDebugf("NewMenu::finish() error: {}", toStr(err));
oxLogError(err);
return;
}

View File

@@ -33,6 +33,7 @@ StudioUI::StudioUI(core::Context *ctx) noexcept {
m_ctx = ctx;
m_projectExplorer = ox::make_unique<ProjectExplorer>(m_ctx);
m_projectExplorer->fileChosen.connect(this, &StudioUI::openFile);
ImGui::GetIO().IniFilename = nullptr;
loadModules();
// open project and files
const auto [config, err] = studio::readConfig<StudioConfig>(ctx);