[keel,nostalgia,studio,turbine] Make turbine::Context have a keel::Context instead of being one

This commit is contained in:
2023-06-20 00:56:55 -05:00
parent d4eaade326
commit c5233e0d1d
24 changed files with 134 additions and 79 deletions

View File

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

View File

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

View File

@@ -27,7 +27,7 @@ class ProjectExplorer: public studio::Widget {
[[nodiscard]]
constexpr ox::FileSystem *romFs() noexcept {
return m_ctx->rom.get();
return rom(*m_ctx);
}
// slots

View File

@@ -42,7 +42,7 @@ StudioUI::StudioUI(turbine::Context *ctx, ox::String projectDir) noexcept:
ImGui::GetIO().IniFilename = nullptr;
loadModules();
// open project and files
const auto [config, err] = studio::readConfig<StudioConfig>(ctx);
const auto [config, err] = studio::readConfig<StudioConfig>(&ctx->keelCtx);
m_showProjectExplorer = config.showProjectExplorer;
if (!err) {
oxIgnoreError(openProject(config.projectPath));
@@ -215,7 +215,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, [&](StudioConfig *config) {
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
config->activeTabItemName = m_activeEditor->itemName();
});
}
@@ -268,7 +268,7 @@ void StudioUI::loadModules() noexcept {
void StudioUI::toggleProjectExplorer() noexcept {
m_showProjectExplorer = !m_showProjectExplorer;
studio::editConfig<StudioConfig>(m_ctx, [&](StudioConfig *config) {
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
config->showProjectExplorer = m_showProjectExplorer;
});
}
@@ -295,16 +295,16 @@ void StudioUI::save() noexcept {
ox::Error StudioUI::openProject(ox::CRStringView path) noexcept {
oxRequireM(fs, keel::loadRomFs(path));
oxReturnError(keel::setRomFs(m_ctx, std::move(fs)));
turbine::setWindowTitle(*m_ctx, ox::sfmt("{} - {}", m_ctx->appName, path));
m_project = ox::make_unique<studio::Project>(m_ctx, path, m_projectDir);
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, 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, [&](StudioConfig *config) {
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
config->projectPath = path;
config->openFiles.clear();
});
@@ -354,7 +354,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
m_activeEditorUpdatePending = editor;
}
// save to config
studio::editConfig<StudioConfig>(m_ctx, [&](StudioConfig *config) {
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
if (!config->openFiles.contains(path)) {
config->openFiles.emplace_back(path);
}
@@ -368,7 +368,7 @@ ox::Error StudioUI::closeFile(const ox::String &path) noexcept {
}
oxIgnoreError(m_openFiles.erase(std::remove(m_openFiles.begin(), m_openFiles.end(), path)));
// save to config
studio::editConfig<StudioConfig>(m_ctx, [&](StudioConfig *config) {
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
oxIgnoreError(config->openFiles.erase(std::remove(config->openFiles.begin(), config->openFiles.end(), path)));
});
return OxError(0);

View File

@@ -50,7 +50,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, path, ox::UUID::generate().unwrap());
keel::createUuidMapping(&ctx->keelCtx, path, ox::UUID::generate().unwrap());
return sctx->project->writeObj(path, &item, fmt);
}
};