2026-03-20 17:08:06 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
2026-03-26 23:52:05 +08:00
|
|
|
#include "Platform/D3D12WindowRenderer.h"
|
2026-03-26 22:10:43 +08:00
|
|
|
#include "UI/ImGuiBackendBridge.h"
|
|
|
|
|
#include "UI/ImGuiSession.h"
|
|
|
|
|
|
2026-03-28 16:50:04 +08:00
|
|
|
#include <XCEngine/Rendering/RenderContext.h>
|
2026-03-20 17:08:06 +08:00
|
|
|
#include <memory>
|
2026-03-26 01:26:26 +08:00
|
|
|
#include <string>
|
2026-03-26 23:52:05 +08:00
|
|
|
#include <windows.h>
|
2026-03-20 17:08:06 +08:00
|
|
|
|
2026-03-25 01:23:08 +08:00
|
|
|
#include <XCEngine/Core/LayerStack.h>
|
|
|
|
|
|
2026-03-24 20:02:38 +08:00
|
|
|
namespace XCEngine {
|
2026-03-28 16:50:04 +08:00
|
|
|
namespace RHI {
|
|
|
|
|
class RHIDevice;
|
|
|
|
|
class RHISwapChain;
|
|
|
|
|
} // namespace RHI
|
|
|
|
|
|
2026-03-24 20:02:38 +08:00
|
|
|
namespace Editor {
|
2026-03-20 17:08:06 +08:00
|
|
|
|
2026-03-25 01:23:08 +08:00
|
|
|
class EditorLayer;
|
2026-03-25 15:35:00 +08:00
|
|
|
class IEditorContext;
|
2026-03-25 01:23:08 +08:00
|
|
|
|
2026-03-20 17:08:06 +08:00
|
|
|
class Application {
|
|
|
|
|
public:
|
|
|
|
|
static Application& Get();
|
|
|
|
|
|
|
|
|
|
bool Initialize(HWND hwnd);
|
|
|
|
|
void Shutdown();
|
|
|
|
|
void Render();
|
|
|
|
|
void OnResize(int width, int height);
|
2026-03-28 16:19:15 +08:00
|
|
|
bool SwitchProject(const std::string& projectPath);
|
|
|
|
|
void SaveProjectState();
|
2026-03-28 16:50:04 +08:00
|
|
|
Rendering::RenderContext GetMainRenderContext() const { return m_windowRenderer.GetRenderContext(); }
|
|
|
|
|
RHI::RHIDevice* GetMainRHIDevice() const { return m_windowRenderer.GetRHIDevice(); }
|
|
|
|
|
RHI::RHISwapChain* GetMainSwapChain() const { return m_windowRenderer.GetSwapChain(); }
|
2026-03-28 15:07:19 +08:00
|
|
|
bool IsRenderReady() const { return m_renderReady; }
|
2026-03-26 01:26:26 +08:00
|
|
|
HWND GetWindowHandle() const { return m_hwnd; }
|
2026-03-20 17:08:06 +08:00
|
|
|
|
2026-03-25 15:35:00 +08:00
|
|
|
IEditorContext& GetEditorContext() const { return *m_editorContext; }
|
|
|
|
|
|
2026-03-20 17:08:06 +08:00
|
|
|
private:
|
|
|
|
|
Application() = default;
|
|
|
|
|
~Application() = default;
|
2026-03-27 12:06:24 +08:00
|
|
|
bool InitializeWindowRenderer(HWND hwnd);
|
|
|
|
|
void InitializeEditorContext(const std::string& projectPath);
|
|
|
|
|
void InitializeImGui(HWND hwnd);
|
|
|
|
|
void AttachEditorLayer();
|
|
|
|
|
void DetachEditorLayer();
|
|
|
|
|
void ShutdownEditorContext();
|
|
|
|
|
void RenderEditorFrame();
|
2026-03-26 01:26:26 +08:00
|
|
|
void UpdateWindowTitle();
|
2026-03-20 17:08:06 +08:00
|
|
|
|
|
|
|
|
HWND m_hwnd = nullptr;
|
|
|
|
|
|
2026-03-25 01:23:08 +08:00
|
|
|
Core::LayerStack m_layerStack;
|
|
|
|
|
EditorLayer* m_editorLayer = nullptr;
|
2026-03-25 15:35:00 +08:00
|
|
|
std::shared_ptr<IEditorContext> m_editorContext;
|
2026-03-26 23:52:05 +08:00
|
|
|
Platform::D3D12WindowRenderer m_windowRenderer;
|
2026-03-26 22:10:43 +08:00
|
|
|
UI::ImGuiBackendBridge m_imguiBackend;
|
|
|
|
|
UI::ImGuiSession m_imguiSession;
|
2026-03-26 21:18:33 +08:00
|
|
|
uint64_t m_exitRequestedHandlerId = 0;
|
2026-03-26 01:26:26 +08:00
|
|
|
std::wstring m_lastWindowTitle;
|
2026-03-28 15:07:19 +08:00
|
|
|
bool m_renderReady = false;
|
2026-03-20 17:08:06 +08:00
|
|
|
};
|
|
|
|
|
|
2026-03-24 20:02:38 +08:00
|
|
|
}
|
2026-03-26 01:26:26 +08:00
|
|
|
}
|