[keel,nostalgia,studio,turbine] Cleanup structure of Turbine

This commit is contained in:
2023-12-08 23:59:02 -06:00
parent 1298051a1a
commit facde6bdce
60 changed files with 669 additions and 557 deletions

View File

@@ -10,7 +10,7 @@
namespace studio {
AboutPopup::AboutPopup(turbine::Context &ctx) noexcept {
m_text = ox::sfmt("{} - dev build", ctx.keelCtx.appName);
m_text = ox::sfmt("{} - dev build", keelCtx(ctx).appName);
}
void AboutPopup::open() noexcept {

View File

@@ -47,7 +47,7 @@ static ox::Error runApp(
ox::CRStringView projectDataDir,
ox::UniquePtr<ox::FileSystem> fs) noexcept {
oxRequireM(ctx, turbine::init(std::move(fs), appName));
turbine::setWindowTitle(*ctx, ctx->keelCtx.appName);
turbine::setWindowTitle(*ctx, keelCtx(*ctx).appName);
turbine::setUpdateHandler(*ctx, updateHandler);
turbine::setKeyEventHandler(*ctx, keyEventHandler);
turbine::setConstantRefresh(*ctx, false);

View File

@@ -26,7 +26,7 @@ class ProjectExplorer: public studio::Widget {
ox::Error refreshProjectTreeModel(ox::CRStringView = {}) noexcept;
[[nodiscard]]
constexpr ox::FileSystem *romFs() noexcept {
inline ox::FileSystem *romFs() noexcept {
return rom(*m_ctx);
}

View File

@@ -42,7 +42,7 @@ StudioUI::StudioUI(turbine::Context *ctx, ox::StringView projectDir) noexcept:
ImGui::GetIO().IniFilename = nullptr;
loadModules();
// open project and files
const auto [config, err] = studio::readConfig<StudioConfig>(&ctx->keelCtx);
const auto [config, err] = studio::readConfig<StudioConfig>(&keelCtx(*ctx));
m_showProjectExplorer = config.showProjectExplorer;
if (!err) {
oxIgnoreError(openProject(config.projectPath));
@@ -223,7 +223,7 @@ void StudioUI::drawTabs() noexcept {
if (ImGui::BeginTabItem(e->itemDisplayName().c_str(), &open, flags)) {
if (m_activeEditor != e.get()) {
m_activeEditor = e.get();
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
studio::editConfig<StudioConfig>(&keelCtx(*m_ctx), [&](StudioConfig *config) {
config->activeTabItemName = m_activeEditor->itemName();
});
}
@@ -276,7 +276,7 @@ void StudioUI::loadModules() noexcept {
void StudioUI::toggleProjectExplorer() noexcept {
m_showProjectExplorer = !m_showProjectExplorer;
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
studio::editConfig<StudioConfig>(&keelCtx(*m_ctx), [&](StudioConfig *config) {
config->showProjectExplorer = m_showProjectExplorer;
});
}
@@ -303,16 +303,16 @@ void StudioUI::save() noexcept {
ox::Error StudioUI::openProject(ox::CRStringView path) noexcept {
oxRequireM(fs, keel::loadRomFs(path));
oxReturnError(keel::setRomFs(m_ctx->keelCtx, std::move(fs)));
turbine::setWindowTitle(*m_ctx, ox::sfmt("{} - {}", m_ctx->keelCtx.appName, path));
m_project = ox::make_unique<studio::Project>(m_ctx->keelCtx, ox::String(path), m_projectDir);
oxReturnError(keel::setRomFs(keelCtx(*m_ctx), std::move(fs)));
turbine::setWindowTitle(*m_ctx, ox::sfmt("{} - {}", keelCtx(*m_ctx).appName, path));
m_project = ox::make_unique<studio::Project>(keelCtx(*m_ctx), ox::String(path), m_projectDir);
auto sctx = applicationData<studio::StudioContext>(*m_ctx);
sctx->project = m_project.get();
m_project->fileAdded.connect(m_projectExplorer.get(), &ProjectExplorer::refreshProjectTreeModel);
m_project->fileDeleted.connect(m_projectExplorer.get(), &ProjectExplorer::refreshProjectTreeModel);
m_openFiles.clear();
m_editors.clear();
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
studio::editConfig<StudioConfig>(&keelCtx(*m_ctx), [&](StudioConfig *config) {
config->projectPath = ox::String(path);
config->openFiles.clear();
});
@@ -362,7 +362,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
m_activeEditorUpdatePending = editor;
}
// save to config
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
studio::editConfig<StudioConfig>(&keelCtx(*m_ctx), [&](StudioConfig *config) {
if (!config->openFiles.contains(path)) {
config->openFiles.emplace_back(path);
}
@@ -376,7 +376,7 @@ ox::Error StudioUI::closeFile(ox::CRStringView path) noexcept {
}
oxIgnoreError(m_openFiles.erase(std::remove(m_openFiles.begin(), m_openFiles.end(), path)));
// save to config
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
studio::editConfig<StudioConfig>(&keelCtx(*m_ctx), [&](StudioConfig *config) {
oxIgnoreError(config->openFiles.erase(std::remove(config->openFiles.begin(), config->openFiles.end(), path)));
});
return OxError(0);

View File

@@ -33,7 +33,7 @@ class ItemMakerT: public ItemMaker {
const T item;
const ox::ClawFormat fmt;
public:
constexpr explicit ItemMakerT(
constexpr ItemMakerT(
ox::StringView pDisplayName,
ox::StringView pParentDir,
ox::StringView fileExt,
@@ -64,7 +64,7 @@ class ItemMakerT: public ItemMaker {
ox::Error write(turbine::Context *ctx, ox::CRStringView pName) const noexcept override {
const auto path = ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt);
auto sctx = turbine::applicationData<studio::StudioContext>(*ctx);
keel::createUuidMapping(ctx->keelCtx, path, ox::UUID::generate().unwrap());
keel::createUuidMapping(keelCtx(*ctx), path, ox::UUID::generate().unwrap());
return sctx->project->writeObj(path, item, fmt);
}
};