[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")) { | ||||
| 				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)) { | ||||
| 				for (size_t i = 1; i < m_recentProjects.size(); ++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_REQUIRE_M(fs, keel::loadRomFs(path.view())); | ||||
| 	m_project.reset(); | ||||
| 	m_openFiles.clear(); | ||||
| 	m_editors.clear(); | ||||
| 	keel::DuplicateSet ds; | ||||
| 	OX_RETURN_ERROR(keel::setRomFs(keelCtx(m_tctx), std::move(fs), ds)); | ||||
| 	if (ds.size()) { | ||||
| @@ -649,8 +655,8 @@ ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept { | ||||
| 		m_messagePopup.show(msg); | ||||
| 	} | ||||
| 	OX_RETURN_ERROR( | ||||
| 			ox::make_unique_catch<Project>(keelCtx(m_tctx), std::move(path), m_projectDataDir) | ||||
| 			        .moveTo(m_project)); | ||||
| 		ox::make_unique_catch<Project>(keelCtx(m_tctx), std::move(path), m_projectDataDir) | ||||
| 				.moveTo(m_project)); | ||||
| 	m_sctx.project = m_project.get(); | ||||
| 	m_activeEditor = nullptr; | ||||
| 	m_activeEditorOnLastDraw = nullptr; | ||||
| @@ -665,8 +671,6 @@ ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept { | ||||
| 	m_project->dirDeleted.connect(this, &StudioUI::handleDeleteDir); | ||||
| 	m_project->fileDeleted.connect(this, &StudioUI::handleDeleteFile); | ||||
| 	m_project->fileMoved.connect(this, &StudioUI::handleMoveFile); | ||||
| 	m_openFiles.clear(); | ||||
| 	m_editors.clear(); | ||||
| 	studio::editConfig<StudioConfig>(keelCtx(m_tctx), [&](StudioConfig &config) { | ||||
| 		auto const pcIt = std::find_if( | ||||
| 			config.projects.begin(), config.projects.end(), | ||||
|   | ||||
| @@ -185,10 +185,15 @@ ox::Error Project::writeObj(ox::StringViewCR path, T const &obj) noexcept { | ||||
|  | ||||
| template<typename T> | ||||
| 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>) { | ||||
| 		return keel::readAsset(m_typeStore, buff); | ||||
| 	} 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); | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user