Extract new editor host command session bridge
This commit is contained in:
@@ -377,7 +377,7 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
|
||||
InitializeUIEditorRuntimeTrace(logRoot);
|
||||
SetUnhandledExceptionFilter(&Application::HandleUnhandledException);
|
||||
LogRuntimeTrace("app", "initialize begin");
|
||||
if (!m_editorContext.Initialize(repoRoot, *this)) {
|
||||
if (!m_editorContext.Initialize(repoRoot)) {
|
||||
LogRuntimeTrace(
|
||||
"app",
|
||||
"shell asset validation failed: " + m_editorContext.GetValidationMessage());
|
||||
@@ -417,6 +417,11 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
|
||||
m_windowDpi = QueryWindowDpi(m_hwnd);
|
||||
m_dpiScale = GetDpiScale();
|
||||
m_renderer.SetDpiScale(m_dpiScale);
|
||||
m_editorContext.SetExitRequestHandler([this]() {
|
||||
if (m_hwnd != nullptr) {
|
||||
PostMessageW(m_hwnd, WM_CLOSE, 0, 0);
|
||||
}
|
||||
});
|
||||
|
||||
std::ostringstream dpiTrace = {};
|
||||
dpiTrace << "initial dpi=" << m_windowDpi << " scale=" << m_dpiScale;
|
||||
@@ -811,69 +816,6 @@ LONG WINAPI Application::HandleUnhandledException(EXCEPTION_POINTERS* exceptionI
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
UIEditorHostCommandEvaluationResult Application::EvaluateHostCommand(
|
||||
std::string_view commandId) const {
|
||||
UIEditorHostCommandEvaluationResult result = {};
|
||||
if (commandId == "file.exit") {
|
||||
result.executable = true;
|
||||
result.message = "Exit command is ready.";
|
||||
return result;
|
||||
}
|
||||
|
||||
if (commandId == "help.about") {
|
||||
result.executable = true;
|
||||
result.message = "About placeholder is ready.";
|
||||
return result;
|
||||
}
|
||||
|
||||
if (commandId.rfind("file.", 0u) == 0u) {
|
||||
result.message = "Document command bridge is not attached yet.";
|
||||
return result;
|
||||
}
|
||||
if (commandId.rfind("edit.", 0u) == 0u) {
|
||||
result.message = "Edit route bridge is not attached yet.";
|
||||
return result;
|
||||
}
|
||||
if (commandId.rfind("assets.", 0u) == 0u) {
|
||||
result.message = "Asset pipeline bridge is not attached yet.";
|
||||
return result;
|
||||
}
|
||||
if (commandId.rfind("run.", 0u) == 0u) {
|
||||
result.message = "Runtime bridge is not attached yet.";
|
||||
return result;
|
||||
}
|
||||
if (commandId.rfind("scripts.", 0u) == 0u) {
|
||||
result.message = "Script pipeline bridge is not attached yet.";
|
||||
return result;
|
||||
}
|
||||
|
||||
result.message = "Host command is not attached yet.";
|
||||
return result;
|
||||
}
|
||||
|
||||
UIEditorHostCommandDispatchResult Application::DispatchHostCommand(
|
||||
std::string_view commandId) {
|
||||
UIEditorHostCommandDispatchResult result = {};
|
||||
if (commandId == "file.exit") {
|
||||
result.commandExecuted = true;
|
||||
result.message = "Exit requested.";
|
||||
if (m_hwnd != nullptr) {
|
||||
PostMessageW(m_hwnd, WM_CLOSE, 0, 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (commandId == "help.about") {
|
||||
result.commandExecuted = true;
|
||||
result.message = "About dialog will be wired after modal layer lands.";
|
||||
m_editorContext.SetStatus("About", result.message);
|
||||
return result;
|
||||
}
|
||||
|
||||
result.message = "Host command dispatch rejected.";
|
||||
return result;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK Application::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
|
||||
if (message == WM_NCCREATE) {
|
||||
TryEnableNonClientDpiScaling(hwnd);
|
||||
|
||||
Reference in New Issue
Block a user