#pragma once #include "Features/Project/ProjectBrowserModel.h" #include "State/EditorSelectionService.h" #include "State/EditorSession.h" #include #include #include #include #include namespace XCEngine::UI::Editor::App { class EditorProjectRuntime { public: struct EditCommandTarget { std::string itemId = {}; std::filesystem::path absolutePath = {}; std::string displayName = {}; ProjectBrowserModel::ItemKind itemKind = ProjectBrowserModel::ItemKind::File; bool directory = false; bool assetsRoot = false; }; struct AssetCommandTarget { const ProjectBrowserModel::FolderEntry* currentFolder = nullptr; const ProjectBrowserModel::FolderEntry* containerFolder = nullptr; const ProjectBrowserModel::FolderEntry* subjectFolder = nullptr; const ProjectBrowserModel::AssetEntry* subjectAsset = nullptr; std::string subjectItemId = {}; std::filesystem::path subjectPath = {}; std::string subjectDisplayName = {}; std::string subjectRelativePath = {}; bool showInExplorerSelectTarget = false; }; bool Initialize(const std::filesystem::path& repoRoot); void BindSelectionService(EditorSelectionService* selectionService); void SetFolderIcon(const ::XCEngine::UI::UITextureHandle& icon); void Refresh(); const ProjectBrowserModel& GetBrowserModel() const; ProjectBrowserModel& GetBrowserModel(); bool HasSelection() const; const EditorSelectionState& GetSelection() const; std::uint64_t GetSelectionStamp() const; bool SetSelection(std::string_view itemId); void ClearSelection(); bool NavigateToFolder(std::string_view itemId); bool OpenItem(std::string_view itemId); std::optional ConsumePendingSceneOpenPath(); const ProjectBrowserModel::FolderEntry* FindFolderEntry( std::string_view itemId) const; const ProjectBrowserModel::AssetEntry* FindAssetEntry( std::string_view itemId) const; AssetCommandTarget ResolveAssetCommandTarget( std::string_view explicitItemId = {}, bool forceCurrentFolder = false) const; std::optional ResolveEditCommandTarget( std::string_view explicitItemId = {}, bool forceCurrentFolder = false) const; bool CreateFolder( std::string_view parentFolderId, std::string_view requestedName, std::string* createdFolderId = nullptr); bool CreateMaterial( std::string_view parentFolderId, std::string_view requestedName, std::string* createdItemId = nullptr); bool RenameItem( std::string_view itemId, std::string_view newName, std::string* renamedItemId = nullptr); bool DeleteItem(std::string_view itemId); bool CanMoveItemToFolder( std::string_view itemId, std::string_view targetFolderId) const; bool MoveItemToFolder( std::string_view itemId, std::string_view targetFolderId, std::string* movedItemId = nullptr); std::optional GetParentFolderId(std::string_view itemId) const; bool CanReparentFolder( std::string_view sourceFolderId, std::string_view targetParentId) const; bool ReparentFolder( std::string_view sourceFolderId, std::string_view targetParentId, std::string* movedFolderId = nullptr); bool MoveFolderToRoot( std::string_view sourceFolderId, std::string* movedFolderId = nullptr); private: EditorSelectionService& SelectionService(); const EditorSelectionService& SelectionService() const; void ApplySelection(const ProjectBrowserModel::AssetEntry& asset); void RevalidateSelection(); bool SelectionTargetsItem(std::string_view itemId) const; ProjectBrowserModel m_browserModel = {}; EditorSelectionService m_ownedSelectionService = {}; EditorSelectionService* m_selectionService = &m_ownedSelectionService; std::optional m_pendingSceneOpenPath = std::nullopt; }; } // namespace XCEngine::UI::Editor::App