|
|
|
@@ -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);
|
|
|
|
|