2026-04-05 04:55:25 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
#ifndef NOMINMAX
|
|
|
|
|
#define NOMINMAX
|
|
|
|
|
#endif
|
2026-04-05 12:50:55 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
#include "AutoScreenshot.h"
|
|
|
|
|
#include "NativeRenderer.h"
|
|
|
|
|
|
|
|
|
|
#include <XCEngine/UI/Runtime/UIScreenDocumentHost.h>
|
|
|
|
|
#include <XCEngine/UI/Runtime/UIScreenPlayer.h>
|
|
|
|
|
|
|
|
|
|
#include <windows.h>
|
2026-04-05 21:27:00 +08:00
|
|
|
#include <windowsx.h>
|
2026-04-05 04:55:25 +08:00
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
|
#include <cstdint>
|
2026-04-05 20:46:24 +08:00
|
|
|
#include <filesystem>
|
2026-04-05 04:55:25 +08:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace NewEditor {
|
|
|
|
|
|
|
|
|
|
class Application {
|
|
|
|
|
public:
|
2026-04-05 16:11:08 +08:00
|
|
|
Application();
|
2026-04-05 12:50:55 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
int Run(HINSTANCE hInstance, int nCmdShow);
|
2026-04-05 04:55:25 +08:00
|
|
|
|
|
|
|
|
private:
|
2026-04-05 20:46:24 +08:00
|
|
|
struct TrackedFileState {
|
|
|
|
|
std::filesystem::path path = {};
|
|
|
|
|
std::filesystem::file_time_type writeTime = {};
|
|
|
|
|
bool exists = false;
|
2026-04-05 04:55:25 +08:00
|
|
|
};
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
2026-04-05 04:55:25 +08:00
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
bool Initialize(HINSTANCE hInstance, int nCmdShow);
|
|
|
|
|
void Shutdown();
|
|
|
|
|
void RenderFrame();
|
|
|
|
|
void OnResize(UINT width, UINT height);
|
2026-04-05 22:35:24 +08:00
|
|
|
void QueuePointerEvent(::XCEngine::UI::UIInputEventType type, ::XCEngine::UI::UIPointerButton button, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
void QueuePointerLeaveEvent();
|
2026-04-05 21:27:00 +08:00
|
|
|
void QueuePointerWheelEvent(short wheelDelta, WPARAM wParam, LPARAM lParam);
|
2026-04-05 20:46:24 +08:00
|
|
|
bool LoadStructuredScreen(const char* triggerReason);
|
|
|
|
|
void RefreshStructuredScreen();
|
|
|
|
|
void RebuildTrackedFileStates();
|
|
|
|
|
bool DetectTrackedFileChange() const;
|
|
|
|
|
void AppendRuntimeOverlay(::XCEngine::UI::UIDrawData& drawData, float width, float height) const;
|
|
|
|
|
static std::filesystem::path ResolveRepoRelativePath(const char* relativePath);
|
2026-04-05 04:55:25 +08:00
|
|
|
|
|
|
|
|
HWND m_hwnd = nullptr;
|
2026-04-05 20:46:24 +08:00
|
|
|
HINSTANCE m_hInstance = nullptr;
|
|
|
|
|
ATOM m_windowClassAtom = 0;
|
|
|
|
|
NativeRenderer m_renderer;
|
|
|
|
|
AutoScreenshotController m_autoScreenshot;
|
|
|
|
|
::XCEngine::UI::Runtime::UIDocumentScreenHost m_documentHost;
|
|
|
|
|
::XCEngine::UI::Runtime::UIScreenPlayer m_screenPlayer;
|
|
|
|
|
::XCEngine::UI::Runtime::UIScreenAsset m_screenAsset = {};
|
|
|
|
|
std::vector<TrackedFileState> m_trackedFiles = {};
|
2026-04-05 04:55:25 +08:00
|
|
|
std::chrono::steady_clock::time_point m_startTime = {};
|
2026-04-05 20:46:24 +08:00
|
|
|
std::chrono::steady_clock::time_point m_lastFrameTime = {};
|
|
|
|
|
std::chrono::steady_clock::time_point m_lastReloadPollTime = {};
|
|
|
|
|
std::uint64_t m_frameIndex = 0;
|
2026-04-05 21:27:00 +08:00
|
|
|
std::vector<::XCEngine::UI::UIInputEvent> m_pendingInputEvents = {};
|
2026-04-05 22:35:24 +08:00
|
|
|
bool m_trackingMouseLeave = false;
|
2026-04-05 20:46:24 +08:00
|
|
|
bool m_useStructuredScreen = false;
|
|
|
|
|
std::string m_runtimeStatus = {};
|
|
|
|
|
std::string m_runtimeError = {};
|
2026-04-05 04:55:25 +08:00
|
|
|
};
|
|
|
|
|
|
2026-04-05 20:46:24 +08:00
|
|
|
int RunNewEditor(HINSTANCE hInstance, int nCmdShow);
|
|
|
|
|
|
2026-04-05 04:55:25 +08:00
|
|
|
} // namespace NewEditor
|
|
|
|
|
} // namespace XCEngine
|