2026-04-05 04:55:25 +08:00
|
|
|
#include "Application.h"
|
2026-04-05 06:15:24 +08:00
|
|
|
|
2026-04-06 03:17:53 +08:00
|
|
|
#include <XCEngine/Input/InputTypes.h>
|
2026-04-05 04:55:25 +08:00
|
|
|
|
|
|
|
|
#include <algorithm>
|
2026-04-05 20:46:24 +08:00
|
|
|
#include <chrono>
|
|
|
|
|
#include <filesystem>
|
2026-04-05 21:27:00 +08:00
|
|
|
#include <sstream>
|
2026-04-05 20:46:24 +08:00
|
|
|
#include <string>
|
|
|
|
|
#include <system_error>
|
|
|
|
|
#include <unordered_set>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#ifndef XCNEWEDITOR_REPO_ROOT
|
|
|
|
|
#define XCNEWEDITOR_REPO_ROOT "."
|
2026-04-05 16:11:08 +08:00
|
|
|
#endif
|
|
|
|
|
|
2026-04-06 03:17:53 +08:00
|
|
|
namespace XCEngine::NewEditor {
|
2026-04-05 04:55:25 +08:00
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
using ::XCEngine::UI::UIColor;
|
|
|
|
|
using ::XCEngine::UI::UIDrawData;
|
|
|
|
|
using ::XCEngine::UI::UIDrawList;
|
2026-04-05 21:27:00 +08:00
|
|
|
using ::XCEngine::UI::UIInputEvent;
|
|
|
|
|
using ::XCEngine::UI::UIInputEventType;
|
2026-04-05 20:46:24 +08:00
|
|
|
using ::XCEngine::UI::UIPoint;
|
2026-04-05 22:35:24 +08:00
|
|
|
using ::XCEngine::UI::UIPointerButton;
|
2026-04-05 20:46:24 +08:00
|
|
|
using ::XCEngine::UI::UIRect;
|
|
|
|
|
using ::XCEngine::UI::Runtime::UIScreenFrameInput;
|
2026-04-06 03:17:53 +08:00
|
|
|
using ::XCEngine::Input::KeyCode;
|
2026-04-05 20:46:24 +08:00
|
|
|
|
2026-04-06 03:17:53 +08:00
|
|
|
constexpr const wchar_t* kWindowClassName = L"XCNewEditorShellHost";
|
|
|
|
|
constexpr const wchar_t* kWindowTitle = L"XCUI New Editor";
|
2026-04-05 20:46:24 +08:00
|
|
|
constexpr auto kReloadPollInterval = std::chrono::milliseconds(150);
|
|
|
|
|
|
|
|
|
|
constexpr UIColor kOverlayBgColor(0.10f, 0.10f, 0.10f, 0.95f);
|
|
|
|
|
constexpr UIColor kOverlayBorderColor(0.25f, 0.25f, 0.25f, 1.0f);
|
|
|
|
|
constexpr UIColor kOverlayTextPrimary(0.93f, 0.93f, 0.93f, 1.0f);
|
|
|
|
|
constexpr UIColor kOverlayTextMuted(0.70f, 0.70f, 0.70f, 1.0f);
|
|
|
|
|
constexpr UIColor kOverlaySuccess(0.82f, 0.82f, 0.82f, 1.0f);
|
|
|
|
|
constexpr UIColor kOverlayFallback(0.56f, 0.56f, 0.56f, 1.0f);
|
|
|
|
|
|
|
|
|
|
Application* GetApplicationFromWindow(HWND hwnd) {
|
|
|
|
|
return reinterpret_cast<Application*>(GetWindowLongPtrW(hwnd, GWLP_USERDATA));
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
std::string TruncateText(const std::string& text, std::size_t maxLength) {
|
|
|
|
|
if (text.size() <= maxLength) {
|
|
|
|
|
return text;
|
2026-04-05 14:05:46 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
if (maxLength <= 3u) {
|
|
|
|
|
return text.substr(0, maxLength);
|
2026-04-05 17:41:31 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
return text.substr(0, maxLength - 3u) + "...";
|
2026-04-05 14:05:46 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 22:35:24 +08:00
|
|
|
std::string ExtractStateKeyTail(const std::string& stateKey) {
|
|
|
|
|
if (stateKey.empty()) {
|
|
|
|
|
return "-";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::size_t separator = stateKey.find_last_of('/');
|
|
|
|
|
if (separator == std::string::npos || separator + 1u >= stateKey.size()) {
|
|
|
|
|
return stateKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return stateKey.substr(separator + 1u);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 21:27:00 +08:00
|
|
|
std::string FormatFloat(float value) {
|
|
|
|
|
std::ostringstream stream;
|
|
|
|
|
stream.setf(std::ios::fixed, std::ios::floatfield);
|
|
|
|
|
stream.precision(1);
|
|
|
|
|
stream << value;
|
|
|
|
|
return stream.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string FormatPoint(const UIPoint& point) {
|
|
|
|
|
return "(" + FormatFloat(point.x) + ", " + FormatFloat(point.y) + ")";
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-06 03:17:53 +08:00
|
|
|
std::int32_t MapVirtualKeyToUIKeyCode(WPARAM wParam) {
|
|
|
|
|
switch (wParam) {
|
|
|
|
|
case 'A': return static_cast<std::int32_t>(KeyCode::A);
|
|
|
|
|
case 'B': return static_cast<std::int32_t>(KeyCode::B);
|
|
|
|
|
case 'C': return static_cast<std::int32_t>(KeyCode::C);
|
|
|
|
|
case 'D': return static_cast<std::int32_t>(KeyCode::D);
|
|
|
|
|
case 'E': return static_cast<std::int32_t>(KeyCode::E);
|
|
|
|
|
case 'F': return static_cast<std::int32_t>(KeyCode::F);
|
|
|
|
|
case 'G': return static_cast<std::int32_t>(KeyCode::G);
|
|
|
|
|
case 'H': return static_cast<std::int32_t>(KeyCode::H);
|
|
|
|
|
case 'I': return static_cast<std::int32_t>(KeyCode::I);
|
|
|
|
|
case 'J': return static_cast<std::int32_t>(KeyCode::J);
|
|
|
|
|
case 'K': return static_cast<std::int32_t>(KeyCode::K);
|
|
|
|
|
case 'L': return static_cast<std::int32_t>(KeyCode::L);
|
|
|
|
|
case 'M': return static_cast<std::int32_t>(KeyCode::M);
|
|
|
|
|
case 'N': return static_cast<std::int32_t>(KeyCode::N);
|
|
|
|
|
case 'O': return static_cast<std::int32_t>(KeyCode::O);
|
|
|
|
|
case 'P': return static_cast<std::int32_t>(KeyCode::P);
|
|
|
|
|
case 'Q': return static_cast<std::int32_t>(KeyCode::Q);
|
|
|
|
|
case 'R': return static_cast<std::int32_t>(KeyCode::R);
|
|
|
|
|
case 'S': return static_cast<std::int32_t>(KeyCode::S);
|
|
|
|
|
case 'T': return static_cast<std::int32_t>(KeyCode::T);
|
|
|
|
|
case 'U': return static_cast<std::int32_t>(KeyCode::U);
|
|
|
|
|
case 'V': return static_cast<std::int32_t>(KeyCode::V);
|
|
|
|
|
case 'W': return static_cast<std::int32_t>(KeyCode::W);
|
|
|
|
|
case 'X': return static_cast<std::int32_t>(KeyCode::X);
|
|
|
|
|
case 'Y': return static_cast<std::int32_t>(KeyCode::Y);
|
|
|
|
|
case 'Z': return static_cast<std::int32_t>(KeyCode::Z);
|
|
|
|
|
case '0': return static_cast<std::int32_t>(KeyCode::Zero);
|
|
|
|
|
case '1': return static_cast<std::int32_t>(KeyCode::One);
|
|
|
|
|
case '2': return static_cast<std::int32_t>(KeyCode::Two);
|
|
|
|
|
case '3': return static_cast<std::int32_t>(KeyCode::Three);
|
|
|
|
|
case '4': return static_cast<std::int32_t>(KeyCode::Four);
|
|
|
|
|
case '5': return static_cast<std::int32_t>(KeyCode::Five);
|
|
|
|
|
case '6': return static_cast<std::int32_t>(KeyCode::Six);
|
|
|
|
|
case '7': return static_cast<std::int32_t>(KeyCode::Seven);
|
|
|
|
|
case '8': return static_cast<std::int32_t>(KeyCode::Eight);
|
|
|
|
|
case '9': return static_cast<std::int32_t>(KeyCode::Nine);
|
|
|
|
|
case VK_SPACE: return static_cast<std::int32_t>(KeyCode::Space);
|
|
|
|
|
case VK_TAB: return static_cast<std::int32_t>(KeyCode::Tab);
|
|
|
|
|
case VK_RETURN: return static_cast<std::int32_t>(KeyCode::Enter);
|
|
|
|
|
case VK_ESCAPE: return static_cast<std::int32_t>(KeyCode::Escape);
|
|
|
|
|
case VK_SHIFT: return static_cast<std::int32_t>(KeyCode::LeftShift);
|
|
|
|
|
case VK_CONTROL: return static_cast<std::int32_t>(KeyCode::LeftCtrl);
|
|
|
|
|
case VK_MENU: return static_cast<std::int32_t>(KeyCode::LeftAlt);
|
|
|
|
|
case VK_UP: return static_cast<std::int32_t>(KeyCode::Up);
|
|
|
|
|
case VK_DOWN: return static_cast<std::int32_t>(KeyCode::Down);
|
|
|
|
|
case VK_LEFT: return static_cast<std::int32_t>(KeyCode::Left);
|
|
|
|
|
case VK_RIGHT: return static_cast<std::int32_t>(KeyCode::Right);
|
|
|
|
|
case VK_HOME: return static_cast<std::int32_t>(KeyCode::Home);
|
|
|
|
|
case VK_END: return static_cast<std::int32_t>(KeyCode::End);
|
|
|
|
|
case VK_PRIOR: return static_cast<std::int32_t>(KeyCode::PageUp);
|
|
|
|
|
case VK_NEXT: return static_cast<std::int32_t>(KeyCode::PageDown);
|
|
|
|
|
case VK_DELETE: return static_cast<std::int32_t>(KeyCode::Delete);
|
|
|
|
|
case VK_BACK: return static_cast<std::int32_t>(KeyCode::Backspace);
|
|
|
|
|
case VK_F1: return static_cast<std::int32_t>(KeyCode::F1);
|
|
|
|
|
case VK_F2: return static_cast<std::int32_t>(KeyCode::F2);
|
|
|
|
|
case VK_F3: return static_cast<std::int32_t>(KeyCode::F3);
|
|
|
|
|
case VK_F4: return static_cast<std::int32_t>(KeyCode::F4);
|
|
|
|
|
case VK_F5: return static_cast<std::int32_t>(KeyCode::F5);
|
|
|
|
|
case VK_F6: return static_cast<std::int32_t>(KeyCode::F6);
|
|
|
|
|
case VK_F7: return static_cast<std::int32_t>(KeyCode::F7);
|
|
|
|
|
case VK_F8: return static_cast<std::int32_t>(KeyCode::F8);
|
|
|
|
|
case VK_F9: return static_cast<std::int32_t>(KeyCode::F9);
|
|
|
|
|
case VK_F10: return static_cast<std::int32_t>(KeyCode::F10);
|
|
|
|
|
case VK_F11: return static_cast<std::int32_t>(KeyCode::F11);
|
|
|
|
|
case VK_F12: return static_cast<std::int32_t>(KeyCode::F12);
|
|
|
|
|
default: return static_cast<std::int32_t>(KeyCode::None);
|
|
|
|
|
}
|
2026-04-05 21:27:00 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-06 03:17:53 +08:00
|
|
|
bool IsRepeatKeyMessage(LPARAM lParam) {
|
|
|
|
|
return (static_cast<unsigned long>(lParam) & (1ul << 30)) != 0ul;
|
2026-04-05 21:27:00 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 04:55:25 +08:00
|
|
|
} // namespace
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
Application::Application()
|
|
|
|
|
: m_screenPlayer(m_documentHost) {
|
2026-04-05 12:50:55 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
int Application::Run(HINSTANCE hInstance, int nCmdShow) {
|
|
|
|
|
if (!Initialize(hInstance, nCmdShow)) {
|
|
|
|
|
Shutdown();
|
|
|
|
|
return 1;
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MSG message = {};
|
2026-04-05 20:46:24 +08:00
|
|
|
while (message.message != WM_QUIT) {
|
|
|
|
|
if (PeekMessageW(&message, nullptr, 0U, 0U, PM_REMOVE)) {
|
2026-04-05 04:55:25 +08:00
|
|
|
TranslateMessage(&message);
|
|
|
|
|
DispatchMessageW(&message);
|
2026-04-05 20:46:24 +08:00
|
|
|
continue;
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
RenderFrame();
|
|
|
|
|
Sleep(8);
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
Shutdown();
|
2026-04-05 04:55:25 +08:00
|
|
|
return static_cast<int>(message.wParam);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
|
|
|
|
|
m_hInstance = hInstance;
|
2026-04-06 03:17:53 +08:00
|
|
|
m_shellAssetDefinition = BuildDefaultEditorShellAsset(ResolveRepoRootPath());
|
2026-04-05 04:55:25 +08:00
|
|
|
|
|
|
|
|
WNDCLASSEXW windowClass = {};
|
|
|
|
|
windowClass.cbSize = sizeof(windowClass);
|
|
|
|
|
windowClass.style = CS_HREDRAW | CS_VREDRAW;
|
2026-04-05 20:46:24 +08:00
|
|
|
windowClass.lpfnWndProc = &Application::WndProc;
|
|
|
|
|
windowClass.hInstance = hInstance;
|
2026-04-05 04:55:25 +08:00
|
|
|
windowClass.hCursor = LoadCursorW(nullptr, IDC_ARROW);
|
|
|
|
|
windowClass.lpszClassName = kWindowClassName;
|
2026-04-05 20:46:24 +08:00
|
|
|
|
|
|
|
|
m_windowClassAtom = RegisterClassExW(&windowClass);
|
|
|
|
|
if (m_windowClassAtom == 0) {
|
2026-04-05 04:55:25 +08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_hwnd = CreateWindowExW(
|
|
|
|
|
0,
|
|
|
|
|
kWindowClassName,
|
|
|
|
|
kWindowTitle,
|
2026-04-05 20:46:24 +08:00
|
|
|
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
2026-04-05 04:55:25 +08:00
|
|
|
CW_USEDEFAULT,
|
|
|
|
|
CW_USEDEFAULT,
|
2026-04-05 20:46:24 +08:00
|
|
|
1440,
|
|
|
|
|
900,
|
2026-04-05 04:55:25 +08:00
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
2026-04-05 20:46:24 +08:00
|
|
|
hInstance,
|
2026-04-05 04:55:25 +08:00
|
|
|
this);
|
|
|
|
|
if (m_hwnd == nullptr) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ShowWindow(m_hwnd, nCmdShow);
|
|
|
|
|
UpdateWindow(m_hwnd);
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
if (!m_renderer.Initialize(m_hwnd)) {
|
2026-04-05 04:55:25 +08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
m_startTime = std::chrono::steady_clock::now();
|
|
|
|
|
m_lastFrameTime = m_startTime;
|
2026-04-06 03:17:53 +08:00
|
|
|
m_autoScreenshot.Initialize(m_shellAssetDefinition.captureRootPath);
|
2026-04-05 20:46:24 +08:00
|
|
|
LoadStructuredScreen("startup");
|
|
|
|
|
return true;
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
void Application::Shutdown() {
|
|
|
|
|
m_autoScreenshot.Shutdown();
|
|
|
|
|
m_screenPlayer.Unload();
|
|
|
|
|
m_trackedFiles.clear();
|
|
|
|
|
m_screenAsset = {};
|
|
|
|
|
m_useStructuredScreen = false;
|
|
|
|
|
m_runtimeStatus.clear();
|
|
|
|
|
m_runtimeError.clear();
|
|
|
|
|
m_frameIndex = 0;
|
2026-04-05 04:55:25 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
m_renderer.Shutdown();
|
2026-04-05 04:55:25 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
if (m_hwnd != nullptr && IsWindow(m_hwnd)) {
|
|
|
|
|
DestroyWindow(m_hwnd);
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
2026-04-05 20:46:24 +08:00
|
|
|
m_hwnd = nullptr;
|
2026-04-05 04:55:25 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
if (m_windowClassAtom != 0 && m_hInstance != nullptr) {
|
|
|
|
|
UnregisterClassW(kWindowClassName, m_hInstance);
|
|
|
|
|
m_windowClassAtom = 0;
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
2026-04-05 20:46:24 +08:00
|
|
|
}
|
2026-04-05 04:55:25 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
void Application::RenderFrame() {
|
|
|
|
|
if (m_hwnd == nullptr) {
|
|
|
|
|
return;
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
RECT clientRect = {};
|
|
|
|
|
GetClientRect(m_hwnd, &clientRect);
|
|
|
|
|
const float width = static_cast<float>((std::max)(clientRect.right - clientRect.left, 1L));
|
|
|
|
|
const float height = static_cast<float>((std::max)(clientRect.bottom - clientRect.top, 1L));
|
|
|
|
|
|
|
|
|
|
const auto now = std::chrono::steady_clock::now();
|
|
|
|
|
double deltaTimeSeconds = std::chrono::duration<double>(now - m_lastFrameTime).count();
|
|
|
|
|
if (deltaTimeSeconds <= 0.0) {
|
|
|
|
|
deltaTimeSeconds = 1.0 / 60.0;
|
|
|
|
|
}
|
|
|
|
|
m_lastFrameTime = now;
|
|
|
|
|
|
|
|
|
|
RefreshStructuredScreen();
|
2026-04-05 21:27:00 +08:00
|
|
|
std::vector<UIInputEvent> frameEvents = std::move(m_pendingInputEvents);
|
|
|
|
|
m_pendingInputEvents.clear();
|
2026-04-05 20:46:24 +08:00
|
|
|
|
|
|
|
|
UIDrawData drawData = {};
|
|
|
|
|
if (m_useStructuredScreen && m_screenPlayer.IsLoaded()) {
|
|
|
|
|
UIScreenFrameInput input = {};
|
|
|
|
|
input.viewportRect = UIRect(0.0f, 0.0f, width, height);
|
2026-04-05 21:27:00 +08:00
|
|
|
input.events = std::move(frameEvents);
|
2026-04-05 20:46:24 +08:00
|
|
|
input.deltaTimeSeconds = deltaTimeSeconds;
|
|
|
|
|
input.frameIndex = ++m_frameIndex;
|
|
|
|
|
input.focused = GetForegroundWindow() == m_hwnd;
|
|
|
|
|
|
|
|
|
|
const auto& frame = m_screenPlayer.Update(input);
|
|
|
|
|
for (const auto& drawList : frame.drawData.GetDrawLists()) {
|
|
|
|
|
drawData.AddDrawList(drawList);
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-06 03:17:53 +08:00
|
|
|
m_runtimeStatus = "XCUI Editor Shell";
|
2026-04-05 20:46:24 +08:00
|
|
|
m_runtimeError = frame.errorMessage;
|
2026-04-06 03:17:53 +08:00
|
|
|
} else {
|
|
|
|
|
m_runtimeStatus = "Editor Shell | Load Error";
|
2026-04-05 20:46:24 +08:00
|
|
|
if (m_runtimeError.empty() && !m_screenPlayer.IsLoaded()) {
|
|
|
|
|
m_runtimeError = m_screenPlayer.GetLastError();
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
AppendRuntimeOverlay(drawData, width, height);
|
2026-04-05 04:55:25 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
const bool framePresented = m_renderer.Render(drawData);
|
|
|
|
|
m_autoScreenshot.CaptureIfRequested(
|
|
|
|
|
m_renderer,
|
|
|
|
|
drawData,
|
|
|
|
|
static_cast<unsigned int>(width),
|
|
|
|
|
static_cast<unsigned int>(height),
|
|
|
|
|
framePresented);
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
void Application::OnResize(UINT width, UINT height) {
|
|
|
|
|
if (width == 0 || height == 0) {
|
|
|
|
|
return;
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
m_renderer.Resize(width, height);
|
|
|
|
|
}
|
2026-04-05 04:55:25 +08:00
|
|
|
|
2026-04-05 22:35:24 +08:00
|
|
|
void Application::QueuePointerEvent(UIInputEventType type, UIPointerButton button, WPARAM wParam, LPARAM lParam) {
|
|
|
|
|
UIInputEvent event = {};
|
|
|
|
|
event.type = type;
|
|
|
|
|
event.pointerButton = button;
|
|
|
|
|
event.position = UIPoint(
|
|
|
|
|
static_cast<float>(GET_X_LPARAM(lParam)),
|
|
|
|
|
static_cast<float>(GET_Y_LPARAM(lParam)));
|
2026-04-06 03:17:53 +08:00
|
|
|
event.modifiers = m_inputModifierTracker.BuildPointerModifiers(static_cast<std::size_t>(wParam));
|
2026-04-05 22:35:24 +08:00
|
|
|
m_pendingInputEvents.push_back(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Application::QueuePointerLeaveEvent() {
|
|
|
|
|
UIInputEvent event = {};
|
|
|
|
|
event.type = UIInputEventType::PointerLeave;
|
|
|
|
|
if (m_hwnd != nullptr) {
|
|
|
|
|
POINT clientPoint = {};
|
|
|
|
|
GetCursorPos(&clientPoint);
|
|
|
|
|
ScreenToClient(m_hwnd, &clientPoint);
|
|
|
|
|
event.position = UIPoint(static_cast<float>(clientPoint.x), static_cast<float>(clientPoint.y));
|
|
|
|
|
}
|
|
|
|
|
m_pendingInputEvents.push_back(event);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 21:27:00 +08:00
|
|
|
void Application::QueuePointerWheelEvent(short wheelDelta, WPARAM wParam, LPARAM lParam) {
|
|
|
|
|
if (m_hwnd == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
POINT screenPoint = {
|
|
|
|
|
GET_X_LPARAM(lParam),
|
|
|
|
|
GET_Y_LPARAM(lParam)
|
|
|
|
|
};
|
|
|
|
|
ScreenToClient(m_hwnd, &screenPoint);
|
|
|
|
|
|
|
|
|
|
UIInputEvent event = {};
|
|
|
|
|
event.type = UIInputEventType::PointerWheel;
|
|
|
|
|
event.position = UIPoint(static_cast<float>(screenPoint.x), static_cast<float>(screenPoint.y));
|
|
|
|
|
event.wheelDelta = static_cast<float>(wheelDelta);
|
2026-04-06 03:17:53 +08:00
|
|
|
event.modifiers = m_inputModifierTracker.BuildPointerModifiers(static_cast<std::size_t>(wParam));
|
|
|
|
|
m_pendingInputEvents.push_back(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Application::QueueKeyEvent(UIInputEventType type, WPARAM wParam, LPARAM lParam) {
|
|
|
|
|
UIInputEvent event = {};
|
|
|
|
|
event.type = type;
|
|
|
|
|
event.keyCode = MapVirtualKeyToUIKeyCode(wParam);
|
|
|
|
|
event.modifiers = m_inputModifierTracker.ApplyKeyMessage(type, wParam, lParam);
|
|
|
|
|
event.repeat = IsRepeatKeyMessage(lParam);
|
|
|
|
|
m_pendingInputEvents.push_back(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Application::QueueCharacterEvent(WPARAM wParam, LPARAM) {
|
|
|
|
|
UIInputEvent event = {};
|
|
|
|
|
event.type = UIInputEventType::Character;
|
|
|
|
|
event.character = static_cast<std::uint32_t>(wParam);
|
|
|
|
|
event.modifiers = m_inputModifierTracker.GetCurrentModifiers();
|
|
|
|
|
m_pendingInputEvents.push_back(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Application::QueueWindowFocusEvent(UIInputEventType type) {
|
|
|
|
|
UIInputEvent event = {};
|
|
|
|
|
event.type = type;
|
2026-04-05 21:27:00 +08:00
|
|
|
m_pendingInputEvents.push_back(event);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
bool Application::LoadStructuredScreen(const char* triggerReason) {
|
2026-04-06 03:17:53 +08:00
|
|
|
(void)triggerReason;
|
2026-04-05 20:46:24 +08:00
|
|
|
m_screenAsset = {};
|
2026-04-06 03:17:53 +08:00
|
|
|
m_screenAsset.screenId = m_shellAssetDefinition.screenId;
|
|
|
|
|
m_screenAsset.documentPath = m_shellAssetDefinition.documentPath.string();
|
|
|
|
|
m_screenAsset.themePath = m_shellAssetDefinition.themePath.string();
|
2026-04-05 20:46:24 +08:00
|
|
|
|
|
|
|
|
const bool loaded = m_screenPlayer.Load(m_screenAsset);
|
|
|
|
|
m_useStructuredScreen = loaded;
|
2026-04-06 03:17:53 +08:00
|
|
|
m_runtimeStatus = loaded ? "XCUI Editor Shell" : "Editor Shell | Load Error";
|
2026-04-05 20:46:24 +08:00
|
|
|
m_runtimeError = loaded ? std::string() : m_screenPlayer.GetLastError();
|
|
|
|
|
RebuildTrackedFileStates();
|
|
|
|
|
return loaded;
|
|
|
|
|
}
|
2026-04-05 04:55:25 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
void Application::RefreshStructuredScreen() {
|
|
|
|
|
const auto now = std::chrono::steady_clock::now();
|
|
|
|
|
if (m_lastReloadPollTime.time_since_epoch().count() != 0 &&
|
|
|
|
|
now - m_lastReloadPollTime < kReloadPollInterval) {
|
|
|
|
|
return;
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
m_lastReloadPollTime = now;
|
|
|
|
|
if (DetectTrackedFileChange()) {
|
|
|
|
|
LoadStructuredScreen("reload");
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
void Application::RebuildTrackedFileStates() {
|
|
|
|
|
namespace fs = std::filesystem;
|
2026-04-05 04:55:25 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
m_trackedFiles.clear();
|
|
|
|
|
std::unordered_set<std::string> seenPaths = {};
|
|
|
|
|
std::error_code errorCode = {};
|
2026-04-05 04:55:25 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
auto appendTrackedPath = [&](const std::string& rawPath) {
|
|
|
|
|
if (rawPath.empty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-04-05 16:38:00 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
const fs::path normalizedPath = fs::path(rawPath).lexically_normal();
|
|
|
|
|
const std::string key = normalizedPath.string();
|
|
|
|
|
if (!seenPaths.insert(key).second) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-04-05 14:05:46 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
TrackedFileState state = {};
|
|
|
|
|
state.path = normalizedPath;
|
|
|
|
|
state.exists = fs::exists(normalizedPath, errorCode);
|
|
|
|
|
errorCode.clear();
|
|
|
|
|
if (state.exists) {
|
|
|
|
|
state.writeTime = fs::last_write_time(normalizedPath, errorCode);
|
|
|
|
|
errorCode.clear();
|
|
|
|
|
}
|
|
|
|
|
m_trackedFiles.push_back(std::move(state));
|
|
|
|
|
};
|
2026-04-05 14:05:46 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
appendTrackedPath(m_screenAsset.documentPath);
|
|
|
|
|
appendTrackedPath(m_screenAsset.themePath);
|
2026-04-05 14:05:46 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
if (const auto* document = m_screenPlayer.GetDocument(); document != nullptr) {
|
|
|
|
|
for (const std::string& dependency : document->dependencies) {
|
|
|
|
|
appendTrackedPath(dependency);
|
|
|
|
|
}
|
2026-04-05 14:05:46 +08:00
|
|
|
}
|
2026-04-05 20:46:24 +08:00
|
|
|
}
|
2026-04-05 14:05:46 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
bool Application::DetectTrackedFileChange() const {
|
|
|
|
|
namespace fs = std::filesystem;
|
2026-04-05 14:05:46 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
std::error_code errorCode = {};
|
|
|
|
|
for (const TrackedFileState& trackedFile : m_trackedFiles) {
|
|
|
|
|
const bool existsNow = fs::exists(trackedFile.path, errorCode);
|
|
|
|
|
errorCode.clear();
|
|
|
|
|
if (existsNow != trackedFile.exists) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2026-04-05 14:05:46 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
if (!existsNow) {
|
2026-04-05 14:05:46 +08:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
const auto writeTimeNow = fs::last_write_time(trackedFile.path, errorCode);
|
|
|
|
|
errorCode.clear();
|
|
|
|
|
if (writeTimeNow != trackedFile.writeTime) {
|
|
|
|
|
return true;
|
2026-04-05 17:41:31 +08:00
|
|
|
}
|
2026-04-05 14:05:46 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
return false;
|
2026-04-05 14:05:46 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
void Application::AppendRuntimeOverlay(UIDrawData& drawData, float width, float height) const {
|
|
|
|
|
const bool authoredMode = m_useStructuredScreen && m_screenPlayer.IsLoaded();
|
2026-04-06 03:17:53 +08:00
|
|
|
const float panelWidth = authoredMode ? 430.0f : 380.0f;
|
2026-04-05 20:46:24 +08:00
|
|
|
std::vector<std::string> detailLines = {};
|
|
|
|
|
detailLines.push_back(
|
|
|
|
|
authoredMode
|
2026-04-06 03:17:53 +08:00
|
|
|
? "Hot reload watches editor shell resources."
|
|
|
|
|
: "Authored editor shell failed to load.");
|
|
|
|
|
detailLines.push_back("Document: editor_shell.xcui");
|
2026-04-05 20:46:24 +08:00
|
|
|
|
2026-04-05 21:27:00 +08:00
|
|
|
if (authoredMode) {
|
2026-04-05 22:35:24 +08:00
|
|
|
const auto& inputDebug = m_documentHost.GetInputDebugSnapshot();
|
2026-04-05 21:27:00 +08:00
|
|
|
detailLines.push_back(
|
2026-04-05 22:35:24 +08:00
|
|
|
"Hover | Focus: " +
|
|
|
|
|
ExtractStateKeyTail(inputDebug.hoveredStateKey) +
|
|
|
|
|
" | " +
|
|
|
|
|
ExtractStateKeyTail(inputDebug.focusedStateKey));
|
|
|
|
|
detailLines.push_back(
|
|
|
|
|
"Active | Capture: " +
|
|
|
|
|
ExtractStateKeyTail(inputDebug.activeStateKey) +
|
|
|
|
|
" | " +
|
|
|
|
|
ExtractStateKeyTail(inputDebug.captureStateKey));
|
|
|
|
|
if (!inputDebug.lastEventType.empty()) {
|
2026-04-06 03:17:53 +08:00
|
|
|
const std::string eventPosition = inputDebug.lastEventType == "KeyDown" ||
|
|
|
|
|
inputDebug.lastEventType == "KeyUp" ||
|
|
|
|
|
inputDebug.lastEventType == "Character" ||
|
|
|
|
|
inputDebug.lastEventType == "FocusGained" ||
|
|
|
|
|
inputDebug.lastEventType == "FocusLost"
|
|
|
|
|
? std::string()
|
|
|
|
|
: " at " + FormatPoint(inputDebug.pointerPosition);
|
2026-04-05 21:27:00 +08:00
|
|
|
detailLines.push_back(
|
2026-04-05 22:35:24 +08:00
|
|
|
"Last input: " +
|
|
|
|
|
inputDebug.lastEventType +
|
2026-04-06 03:17:53 +08:00
|
|
|
eventPosition);
|
2026-04-05 22:35:24 +08:00
|
|
|
detailLines.push_back(
|
|
|
|
|
"Route: " +
|
|
|
|
|
inputDebug.lastTargetKind +
|
|
|
|
|
" -> " +
|
|
|
|
|
ExtractStateKeyTail(inputDebug.lastTargetStateKey));
|
2026-04-05 21:27:00 +08:00
|
|
|
detailLines.push_back(
|
2026-04-06 03:17:53 +08:00
|
|
|
"Last event result: " +
|
2026-04-05 22:35:24 +08:00
|
|
|
(inputDebug.lastResult.empty() ? std::string("n/a") : inputDebug.lastResult));
|
2026-04-05 21:27:00 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
if (m_autoScreenshot.HasPendingCapture()) {
|
|
|
|
|
detailLines.push_back("Shot pending...");
|
|
|
|
|
} else if (!m_autoScreenshot.GetLastCaptureSummary().empty()) {
|
|
|
|
|
detailLines.push_back(TruncateText(m_autoScreenshot.GetLastCaptureSummary(), 78u));
|
2026-04-05 22:35:24 +08:00
|
|
|
} else {
|
2026-04-06 03:17:53 +08:00
|
|
|
detailLines.push_back("Screenshots: F12 -> new_editor/captures/");
|
2026-04-05 20:46:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_runtimeError.empty()) {
|
|
|
|
|
detailLines.push_back(TruncateText(m_runtimeError, 78u));
|
|
|
|
|
} else if (!m_autoScreenshot.GetLastCaptureError().empty()) {
|
|
|
|
|
detailLines.push_back(TruncateText(m_autoScreenshot.GetLastCaptureError(), 78u));
|
2026-04-06 03:17:53 +08:00
|
|
|
} else if (!authoredMode) {
|
|
|
|
|
detailLines.push_back("No fallback sandbox is rendered in this host.");
|
2026-04-05 20:46:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float panelHeight = 38.0f + static_cast<float>(detailLines.size()) * 18.0f;
|
|
|
|
|
const UIRect panelRect(width - panelWidth - 16.0f, height - panelHeight - 42.0f, panelWidth, panelHeight);
|
|
|
|
|
|
|
|
|
|
UIDrawList& overlay = drawData.EmplaceDrawList("NewEditor Runtime Overlay");
|
|
|
|
|
overlay.AddFilledRect(panelRect, kOverlayBgColor, 10.0f);
|
|
|
|
|
overlay.AddRectOutline(panelRect, kOverlayBorderColor, 1.0f, 10.0f);
|
|
|
|
|
overlay.AddFilledRect(
|
|
|
|
|
UIRect(panelRect.x + 12.0f, panelRect.y + 14.0f, 8.0f, 8.0f),
|
|
|
|
|
authoredMode ? kOverlaySuccess : kOverlayFallback,
|
|
|
|
|
4.0f);
|
|
|
|
|
overlay.AddText(
|
|
|
|
|
UIPoint(panelRect.x + 28.0f, panelRect.y + 10.0f),
|
2026-04-06 03:17:53 +08:00
|
|
|
m_runtimeStatus.empty() ? "XCUI Editor Shell" : m_runtimeStatus,
|
2026-04-05 20:46:24 +08:00
|
|
|
kOverlayTextPrimary,
|
|
|
|
|
14.0f);
|
|
|
|
|
|
|
|
|
|
float detailY = panelRect.y + 30.0f;
|
|
|
|
|
for (std::size_t index = 0; index < detailLines.size(); ++index) {
|
|
|
|
|
const bool lastLine = index + 1u == detailLines.size();
|
|
|
|
|
overlay.AddText(
|
|
|
|
|
UIPoint(panelRect.x + 28.0f, detailY),
|
|
|
|
|
detailLines[index],
|
|
|
|
|
lastLine && (!m_runtimeError.empty() || !m_autoScreenshot.GetLastCaptureError().empty())
|
|
|
|
|
? kOverlayFallback
|
|
|
|
|
: kOverlayTextMuted,
|
|
|
|
|
12.0f);
|
|
|
|
|
detailY += 18.0f;
|
2026-04-05 14:05:46 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-06 03:17:53 +08:00
|
|
|
std::filesystem::path Application::ResolveRepoRootPath() {
|
|
|
|
|
std::string root = XCNEWEDITOR_REPO_ROOT;
|
|
|
|
|
if (root.size() >= 2u && root.front() == '"' && root.back() == '"') {
|
|
|
|
|
root = root.substr(1u, root.size() - 2u);
|
|
|
|
|
}
|
|
|
|
|
return std::filesystem::path(root).lexically_normal();
|
2026-04-05 20:46:24 +08:00
|
|
|
}
|
2026-04-05 04:55:25 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
LRESULT CALLBACK Application::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
|
|
|
|
|
if (message == WM_NCCREATE) {
|
|
|
|
|
const auto* createStruct = reinterpret_cast<CREATESTRUCTW*>(lParam);
|
|
|
|
|
auto* application = reinterpret_cast<Application*>(createStruct->lpCreateParams);
|
|
|
|
|
SetWindowLongPtrW(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(application));
|
|
|
|
|
return TRUE;
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
Application* application = GetApplicationFromWindow(hwnd);
|
|
|
|
|
switch (message) {
|
|
|
|
|
case WM_SIZE:
|
|
|
|
|
if (application != nullptr && wParam != SIZE_MINIMIZED) {
|
|
|
|
|
application->OnResize(static_cast<UINT>(LOWORD(lParam)), static_cast<UINT>(HIWORD(lParam)));
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
2026-04-05 20:46:24 +08:00
|
|
|
return 0;
|
|
|
|
|
case WM_PAINT:
|
|
|
|
|
if (application != nullptr) {
|
|
|
|
|
PAINTSTRUCT paintStruct = {};
|
|
|
|
|
BeginPaint(hwnd, &paintStruct);
|
|
|
|
|
application->RenderFrame();
|
|
|
|
|
EndPaint(hwnd, &paintStruct);
|
|
|
|
|
return 0;
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
2026-04-05 20:46:24 +08:00
|
|
|
break;
|
2026-04-05 22:35:24 +08:00
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
|
if (application != nullptr) {
|
|
|
|
|
if (!application->m_trackingMouseLeave) {
|
|
|
|
|
TRACKMOUSEEVENT trackMouseEvent = {};
|
|
|
|
|
trackMouseEvent.cbSize = sizeof(trackMouseEvent);
|
|
|
|
|
trackMouseEvent.dwFlags = TME_LEAVE;
|
|
|
|
|
trackMouseEvent.hwndTrack = hwnd;
|
|
|
|
|
if (TrackMouseEvent(&trackMouseEvent)) {
|
|
|
|
|
application->m_trackingMouseLeave = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
application->QueuePointerEvent(UIInputEventType::PointerMove, UIPointerButton::None, wParam, lParam);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WM_MOUSELEAVE:
|
|
|
|
|
if (application != nullptr) {
|
|
|
|
|
application->m_trackingMouseLeave = false;
|
|
|
|
|
application->QueuePointerLeaveEvent();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
|
if (application != nullptr) {
|
|
|
|
|
SetFocus(hwnd);
|
|
|
|
|
SetCapture(hwnd);
|
|
|
|
|
application->QueuePointerEvent(UIInputEventType::PointerButtonDown, UIPointerButton::Left, wParam, lParam);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
|
if (application != nullptr) {
|
|
|
|
|
if (GetCapture() == hwnd) {
|
|
|
|
|
ReleaseCapture();
|
|
|
|
|
}
|
|
|
|
|
application->QueuePointerEvent(UIInputEventType::PointerButtonUp, UIPointerButton::Left, wParam, lParam);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2026-04-05 21:27:00 +08:00
|
|
|
case WM_MOUSEWHEEL:
|
|
|
|
|
if (application != nullptr) {
|
|
|
|
|
application->QueuePointerWheelEvent(GET_WHEEL_DELTA_WPARAM(wParam), wParam, lParam);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2026-04-06 03:17:53 +08:00
|
|
|
case WM_SETFOCUS:
|
|
|
|
|
if (application != nullptr) {
|
|
|
|
|
application->m_inputModifierTracker.SyncFromSystemState();
|
|
|
|
|
application->QueueWindowFocusEvent(UIInputEventType::FocusGained);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WM_KILLFOCUS:
|
|
|
|
|
if (application != nullptr) {
|
|
|
|
|
application->m_inputModifierTracker.Reset();
|
|
|
|
|
application->QueueWindowFocusEvent(UIInputEventType::FocusLost);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2026-04-05 22:35:24 +08:00
|
|
|
case WM_KEYDOWN:
|
2026-04-06 03:17:53 +08:00
|
|
|
case WM_SYSKEYDOWN:
|
|
|
|
|
if (application != nullptr) {
|
|
|
|
|
if (wParam == VK_F12) {
|
|
|
|
|
application->m_autoScreenshot.RequestCapture("manual_f12");
|
|
|
|
|
}
|
|
|
|
|
application->QueueKeyEvent(UIInputEventType::KeyDown, wParam, lParam);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WM_KEYUP:
|
|
|
|
|
case WM_SYSKEYUP:
|
|
|
|
|
if (application != nullptr) {
|
|
|
|
|
application->QueueKeyEvent(UIInputEventType::KeyUp, wParam, lParam);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WM_CHAR:
|
|
|
|
|
if (application != nullptr) {
|
|
|
|
|
application->QueueCharacterEvent(wParam, lParam);
|
2026-04-05 22:35:24 +08:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2026-04-05 20:46:24 +08:00
|
|
|
case WM_ERASEBKGND:
|
|
|
|
|
return 1;
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
|
if (application != nullptr) {
|
|
|
|
|
application->m_hwnd = nullptr;
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
2026-04-05 20:46:24 +08:00
|
|
|
PostQuitMessage(0);
|
|
|
|
|
return 0;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
return DefWindowProcW(hwnd, message, wParam, lParam);
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
int RunNewEditor(HINSTANCE hInstance, int nCmdShow) {
|
2026-04-06 03:17:53 +08:00
|
|
|
Application application;
|
2026-04-05 20:46:24 +08:00
|
|
|
return application.Run(hInstance, nCmdShow);
|
2026-04-05 04:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-06 03:17:53 +08:00
|
|
|
} // namespace XCEngine::NewEditor
|