Add XCUI new editor sandbox phase 1
This commit is contained in:
148
new_editor/src/XCUIBackend/XCUIAssetDocumentSource.h
Normal file
148
new_editor/src/XCUIBackend/XCUIAssetDocumentSource.h
Normal file
@@ -0,0 +1,148 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/Resources/UI/UIDocumentCompiler.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Editor {
|
||||
namespace XCUIBackend {
|
||||
|
||||
class XCUIAssetDocumentSource {
|
||||
public:
|
||||
static constexpr const char* kProjectAssetRoot = "Assets/XCUI/NewEditor";
|
||||
static constexpr const char* kLegacyResourceRoot = "new_editor/resources";
|
||||
|
||||
enum class PathOrigin {
|
||||
None,
|
||||
ProjectAssets,
|
||||
LegacyMirror
|
||||
};
|
||||
|
||||
enum class LoadBackend {
|
||||
None,
|
||||
ResourceManager,
|
||||
CompilerFallback
|
||||
};
|
||||
|
||||
struct ResolutionCandidate {
|
||||
std::string requestPath = {};
|
||||
std::filesystem::path resolvedPath = {};
|
||||
PathOrigin origin = PathOrigin::None;
|
||||
};
|
||||
|
||||
struct RepositoryProbe {
|
||||
std::filesystem::path searchRoot = {};
|
||||
std::filesystem::path matchedRoot = {};
|
||||
std::string matchedRelativePath = {};
|
||||
bool matched = false;
|
||||
};
|
||||
|
||||
struct RepositoryDiscovery {
|
||||
std::filesystem::path repositoryRoot = {};
|
||||
std::vector<RepositoryProbe> probes = {};
|
||||
std::string statusMessage = {};
|
||||
};
|
||||
|
||||
struct DocumentPathSpec {
|
||||
Resources::UIDocumentKind kind = Resources::UIDocumentKind::View;
|
||||
std::string expectedRootTag = {};
|
||||
std::string primaryRelativePath = {};
|
||||
std::string legacyRelativePath = {};
|
||||
};
|
||||
|
||||
struct PathSet {
|
||||
std::string setName = {};
|
||||
DocumentPathSpec view = {};
|
||||
DocumentPathSpec theme = {};
|
||||
};
|
||||
|
||||
struct DocumentLoadState {
|
||||
Resources::UIDocumentKind kind = Resources::UIDocumentKind::View;
|
||||
std::string expectedRootTag = {};
|
||||
std::string primaryRelativePath = {};
|
||||
std::string legacyRelativePath = {};
|
||||
std::string requestedPath = {};
|
||||
std::filesystem::path resolvedPath = {};
|
||||
std::string sourcePath = {};
|
||||
std::string statusMessage = {};
|
||||
std::string errorMessage = {};
|
||||
std::vector<ResolutionCandidate> candidatePaths = {};
|
||||
std::vector<std::string> attemptMessages = {};
|
||||
LoadBackend backend = LoadBackend::None;
|
||||
PathOrigin pathOrigin = PathOrigin::None;
|
||||
Resources::UIDocumentCompileResult compileResult = {};
|
||||
bool succeeded = false;
|
||||
bool usedLegacyFallback = false;
|
||||
};
|
||||
|
||||
struct LoadState {
|
||||
PathSet paths = {};
|
||||
DocumentLoadState view = {};
|
||||
DocumentLoadState theme = {};
|
||||
std::vector<std::string> trackedSourcePaths = {};
|
||||
std::vector<std::string> missingTrackedSourcePaths = {};
|
||||
std::string statusMessage = {};
|
||||
std::string errorMessage = {};
|
||||
std::string trackingStatusMessage = {};
|
||||
std::filesystem::path repositoryRoot = {};
|
||||
RepositoryDiscovery repositoryDiscovery = {};
|
||||
bool succeeded = false;
|
||||
bool changeTrackingReady = false;
|
||||
bool usedLegacyFallback = false;
|
||||
};
|
||||
|
||||
struct TrackedWriteTime {
|
||||
std::filesystem::path path = {};
|
||||
std::filesystem::file_time_type writeTime = {};
|
||||
};
|
||||
|
||||
XCUIAssetDocumentSource();
|
||||
explicit XCUIAssetDocumentSource(PathSet paths);
|
||||
|
||||
void SetPathSet(PathSet paths);
|
||||
const PathSet& GetPathSet() const;
|
||||
|
||||
bool Reload();
|
||||
bool ReloadIfChanged();
|
||||
bool HasTrackedChanges() const;
|
||||
bool IsLoaded() const;
|
||||
|
||||
const LoadState& GetState() const;
|
||||
|
||||
static PathSet MakePathSet(const std::string& setName);
|
||||
static PathSet MakeDemoPathSet();
|
||||
static PathSet MakeLayoutLabPathSet();
|
||||
|
||||
static std::vector<ResolutionCandidate> CollectCandidatePaths(
|
||||
const DocumentPathSpec& spec,
|
||||
const std::filesystem::path& repositoryRoot);
|
||||
static std::vector<ResolutionCandidate> CollectCandidatePaths(
|
||||
const DocumentPathSpec& spec,
|
||||
const std::filesystem::path& repositoryRoot,
|
||||
const std::filesystem::path& resourceRoot);
|
||||
static RepositoryDiscovery DiagnoseRepositoryRoot(const PathSet& paths);
|
||||
static RepositoryDiscovery DiagnoseRepositoryRoot(
|
||||
const PathSet& paths,
|
||||
const std::vector<std::filesystem::path>& searchRoots,
|
||||
bool includeDefaultSearchRoots);
|
||||
|
||||
static std::string BuildProjectAssetViewPath(const std::string& setName);
|
||||
static std::string BuildProjectAssetThemePath(const std::string& setName);
|
||||
static std::string BuildLegacyViewPath(const std::string& setName);
|
||||
static std::string BuildLegacyThemePath(const std::string& setName);
|
||||
|
||||
private:
|
||||
PathSet m_paths = {};
|
||||
LoadState m_state = {};
|
||||
std::vector<TrackedWriteTime> m_trackedWriteTimes = {};
|
||||
};
|
||||
|
||||
const char* ToString(XCUIAssetDocumentSource::PathOrigin origin);
|
||||
const char* ToString(XCUIAssetDocumentSource::LoadBackend backend);
|
||||
|
||||
} // namespace XCUIBackend
|
||||
} // namespace Editor
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user