Inject editor viewport shader paths at runtime
This commit is contained in:
@@ -33,6 +33,11 @@ constexpr const wchar_t* kWindowTitle = L"Main Scene * - Main.xx - XCEngine Edit
|
||||
constexpr DWORD kBorderlessWindowStyle = WS_POPUP | WS_THICKFRAME;
|
||||
constexpr int kDefaultSmokeTestDurationSeconds = 12;
|
||||
|
||||
bool HasEditorRepoMarkers(const std::filesystem::path& root) {
|
||||
return std::filesystem::exists(root / "editor" / "AGENTS.md") &&
|
||||
std::filesystem::exists(root / "project");
|
||||
}
|
||||
|
||||
void EnableDpiAwareness() {
|
||||
const HMODULE user32 = GetModuleHandleW(L"user32.dll");
|
||||
if (user32 != nullptr) {
|
||||
@@ -106,16 +111,12 @@ int RunXCEditor(HINSTANCE hInstance, int nCmdShow) {
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
|
||||
#ifndef XCUIEDITOR_REPO_ROOT
|
||||
#define XCUIEDITOR_REPO_ROOT "."
|
||||
#endif
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
|
||||
m_hInstance = hInstance;
|
||||
m_repoRoot = ResolveRepoRootPath();
|
||||
m_resourceService = std::make_unique<Host::Win32EditorResourceService>(m_hInstance);
|
||||
m_repoRoot = ResolveRepoRootPath(m_resourceService->GetExecutableDirectory());
|
||||
EnableDpiAwareness();
|
||||
|
||||
const std::filesystem::path logRoot = m_resourceService->GetExecutableDirectory() / "logs";
|
||||
@@ -265,12 +266,28 @@ void Application::Shutdown() {
|
||||
ShutdownUIEditorRuntimeTrace();
|
||||
}
|
||||
|
||||
std::filesystem::path Application::ResolveRepoRootPath() {
|
||||
std::string root = XCUIEDITOR_REPO_ROOT;
|
||||
if (root.size() >= 2u && root.front() == '"' && root.back() == '"') {
|
||||
root = root.substr(1u, root.size() - 2u);
|
||||
std::filesystem::path Application::ResolveRepoRootPath(
|
||||
const std::filesystem::path& executableDirectory) {
|
||||
std::error_code errorCode = {};
|
||||
std::filesystem::path current =
|
||||
std::filesystem::weakly_canonical(executableDirectory, errorCode);
|
||||
if (errorCode) {
|
||||
current = executableDirectory.lexically_normal();
|
||||
}
|
||||
return std::filesystem::path(root).lexically_normal();
|
||||
|
||||
while (!current.empty()) {
|
||||
if (HasEditorRepoMarkers(current)) {
|
||||
return current.lexically_normal();
|
||||
}
|
||||
|
||||
const std::filesystem::path parent = current.parent_path();
|
||||
if (parent == current) {
|
||||
break;
|
||||
}
|
||||
current = parent;
|
||||
}
|
||||
|
||||
return executableDirectory.lexically_normal();
|
||||
}
|
||||
|
||||
LONG WINAPI Application::HandleUnhandledException(EXCEPTION_POINTERS* exceptionInfo) {
|
||||
|
||||
Reference in New Issue
Block a user