[studio] Add File -> Reload Project menu item
This commit is contained in:
@@ -250,6 +250,9 @@ void StudioUI::drawMenu() noexcept {
|
|||||||
if (ImGui::MenuItem("Open Project...", STUDIO_CTRL "+O")) {
|
if (ImGui::MenuItem("Open Project...", STUDIO_CTRL "+O")) {
|
||||||
m_taskRunner.add(*ox::make<FileDialogManager>(this, &StudioUI::openProjectPath));
|
m_taskRunner.add(*ox::make<FileDialogManager>(this, &StudioUI::openProjectPath));
|
||||||
}
|
}
|
||||||
|
if (ImGui::MenuItem("Reload Project")) {
|
||||||
|
oxLogError(openProjectPath(m_project->projectPath()));
|
||||||
|
}
|
||||||
if (ImGui::BeginMenu("Recent Projects", m_recentProjects.size() > 1)) {
|
if (ImGui::BeginMenu("Recent Projects", m_recentProjects.size() > 1)) {
|
||||||
for (size_t i = 1; i < m_recentProjects.size(); ++i) {
|
for (size_t i = 1; i < m_recentProjects.size(); ++i) {
|
||||||
auto const &p = m_recentProjects[i];
|
auto const &p = m_recentProjects[i];
|
||||||
@@ -636,6 +639,9 @@ ox::Error StudioUI::createOpenProject(ox::StringViewCR path) noexcept {
|
|||||||
|
|
||||||
ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
|
ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
|
||||||
OX_REQUIRE_M(fs, keel::loadRomFs(path.view()));
|
OX_REQUIRE_M(fs, keel::loadRomFs(path.view()));
|
||||||
|
m_project.reset();
|
||||||
|
m_openFiles.clear();
|
||||||
|
m_editors.clear();
|
||||||
keel::DuplicateSet ds;
|
keel::DuplicateSet ds;
|
||||||
OX_RETURN_ERROR(keel::setRomFs(keelCtx(m_tctx), std::move(fs), ds));
|
OX_RETURN_ERROR(keel::setRomFs(keelCtx(m_tctx), std::move(fs), ds));
|
||||||
if (ds.size()) {
|
if (ds.size()) {
|
||||||
@@ -665,8 +671,6 @@ ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
|
|||||||
m_project->dirDeleted.connect(this, &StudioUI::handleDeleteDir);
|
m_project->dirDeleted.connect(this, &StudioUI::handleDeleteDir);
|
||||||
m_project->fileDeleted.connect(this, &StudioUI::handleDeleteFile);
|
m_project->fileDeleted.connect(this, &StudioUI::handleDeleteFile);
|
||||||
m_project->fileMoved.connect(this, &StudioUI::handleMoveFile);
|
m_project->fileMoved.connect(this, &StudioUI::handleMoveFile);
|
||||||
m_openFiles.clear();
|
|
||||||
m_editors.clear();
|
|
||||||
studio::editConfig<StudioConfig>(keelCtx(m_tctx), [&](StudioConfig &config) {
|
studio::editConfig<StudioConfig>(keelCtx(m_tctx), [&](StudioConfig &config) {
|
||||||
auto const pcIt = std::find_if(
|
auto const pcIt = std::find_if(
|
||||||
config.projects.begin(), config.projects.end(),
|
config.projects.begin(), config.projects.end(),
|
||||||
|
@@ -185,10 +185,15 @@ ox::Error Project::writeObj(ox::StringViewCR path, T const &obj) noexcept {
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ox::Result<T> Project::loadObj(ox::StringViewCR path) const noexcept {
|
ox::Result<T> Project::loadObj(ox::StringViewCR path) const noexcept {
|
||||||
OX_REQUIRE(buff, loadBuff(path));
|
OX_REQUIRE_M(buff, loadBuff(path));
|
||||||
if constexpr(ox::is_same_v<T, ox::ModelObject>) {
|
if constexpr(ox::is_same_v<T, ox::ModelObject>) {
|
||||||
return keel::readAsset(m_typeStore, buff);
|
return keel::readAsset(m_typeStore, buff);
|
||||||
} else {
|
} else {
|
||||||
|
OX_REQUIRE(typeId, keel::readAssetTypeId(buff));
|
||||||
|
if (typeId != ox::ModelTypeId_v<T>) {
|
||||||
|
OX_REQUIRE(ah, keel::readAssetHeader(buff));
|
||||||
|
OX_RETURN_ERROR(keel::convertBuffToBuff<T>(m_kctx, buff, ah.clawHdr.fmt).moveTo(buff));
|
||||||
|
}
|
||||||
return keel::readAsset<T>(buff);
|
return keel::readAsset<T>(buff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user