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