Files
XCEngine/editor/src/Managers/ProjectManager.h
2026-03-29 01:36:53 +08:00

61 lines
2.4 KiB
C++

#pragma once
#include "Core/AssetItem.h"
#include "Core/IProjectManager.h"
#include <vector>
#include <string>
#include <memory>
namespace XCEngine {
namespace Editor {
class ProjectManager : public IProjectManager {
public:
const std::vector<AssetItemPtr>& GetCurrentItems() const override;
AssetItemPtr GetRootFolder() const override { return m_rootFolder; }
AssetItemPtr GetCurrentFolder() const override { return m_path.empty() ? nullptr : m_path.back(); }
AssetItemPtr GetSelectedItem() const override;
const std::string& GetSelectedItemPath() const override { return m_selectedItemPath; }
int GetSelectedIndex() const override;
void SetSelectedIndex(int index) override;
void SetSelectedItem(const AssetItemPtr& item) override;
void ClearSelection() override;
int FindCurrentItemIndex(const std::string& fullPath) const override;
void NavigateToFolder(const AssetItemPtr& folder) override;
void NavigateBack() override;
void NavigateToIndex(size_t index) override;
bool CanNavigateBack() const override { return m_path.size() > 1; }
std::string GetCurrentPath() const override;
size_t GetPathDepth() const override { return m_path.size(); }
std::string GetPathName(size_t index) const override;
void Initialize(const std::string& projectPath) override;
void RefreshCurrentFolder() override;
AssetItemPtr CreateFolder(const std::string& name) override;
bool DeleteItem(const std::string& fullPath) override;
bool MoveItem(const std::string& sourceFullPath, const std::string& destFolderFullPath) override;
bool RenameItem(const std::string& sourceFullPath, const std::string& newName) override;
const std::string& GetProjectPath() const override { return m_projectPath; }
private:
bool BuildPathToFolder(const AssetItemPtr& current, const std::string& fullPath, std::vector<AssetItemPtr>& outPath) const;
void RebuildTreePreservingPath();
AssetItemPtr FindCurrentItemByPath(const std::string& fullPath) const;
void SyncSelection();
AssetItemPtr ScanDirectory(const std::wstring& path);
AssetItemPtr CreateAssetItem(const std::wstring& path, const std::wstring& nameW, bool isFolder);
std::wstring GetCurrentFullPathW() const;
AssetItemPtr m_rootFolder;
std::vector<AssetItemPtr> m_path;
std::string m_selectedItemPath;
std::string m_projectPath;
};
}
}