mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2025-12-05 11:44:53 +01:00
Update nemirtingas overlay to latest.
This commit is contained in:
parent
1ad2818e28
commit
04022c005f
15 changed files with 187 additions and 95 deletions
|
|
@ -82,7 +82,7 @@ void DX10_Hook::_ResetRenderState()
|
|||
OverlayHookReady(false);
|
||||
|
||||
ImGui_ImplDX10_Shutdown();
|
||||
Windows_Hook::Inst()->_ResetRenderState();
|
||||
Windows_Hook::Inst()->ResetRenderState();
|
||||
ImGui::DestroyContext();
|
||||
|
||||
SafeRelease(mainRenderTargetView);
|
||||
|
|
@ -118,11 +118,13 @@ void DX10_Hook::_PrepareForOverlay(IDXGISwapChain* pSwapChain)
|
|||
ImGui::CreateContext();
|
||||
ImGui_ImplDX10_Init(pDevice);
|
||||
|
||||
Windows_Hook::Inst()->SetInitialWindowSize(desc.OutputWindow);
|
||||
|
||||
_Initialized = true;
|
||||
OverlayHookReady(true);
|
||||
}
|
||||
|
||||
if (ImGui_ImplDX10_NewFrame() && Windows_Hook::Inst()->_PrepareForOverlay(desc.OutputWindow))
|
||||
if (ImGui_ImplDX10_NewFrame() && Windows_Hook::Inst()->PrepareForOverlay(desc.OutputWindow))
|
||||
{
|
||||
ImGui::NewFrame();
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ void DX11_Hook::_ResetRenderState()
|
|||
OverlayHookReady(false);
|
||||
|
||||
ImGui_ImplDX11_Shutdown();
|
||||
Windows_Hook::Inst()->_ResetRenderState();
|
||||
Windows_Hook::Inst()->ResetRenderState();
|
||||
//ImGui::DestroyContext();
|
||||
|
||||
SafeRelease(mainRenderTargetView);
|
||||
|
|
@ -151,11 +151,13 @@ void DX11_Hook::_PrepareForOverlay(IDXGISwapChain* pSwapChain)
|
|||
|
||||
ImGui_ImplDX11_Init(pDevice, pContext);
|
||||
|
||||
Windows_Hook::Inst()->SetInitialWindowSize(desc.OutputWindow);
|
||||
|
||||
_Initialized = true;
|
||||
OverlayHookReady(true);
|
||||
}
|
||||
|
||||
if (ImGui_ImplDX11_NewFrame() && Windows_Hook::Inst()->_PrepareForOverlay(desc.OutputWindow))
|
||||
if (ImGui_ImplDX11_NewFrame() && Windows_Hook::Inst()->PrepareForOverlay(desc.OutputWindow))
|
||||
{
|
||||
ImGui::NewFrame();
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ void DX12_Hook::_ResetRenderState()
|
|||
OverlayHookReady(false);
|
||||
|
||||
ImGui_ImplDX12_Shutdown();
|
||||
Windows_Hook::Inst()->_ResetRenderState();
|
||||
Windows_Hook::Inst()->ResetRenderState();
|
||||
ImGui::DestroyContext();
|
||||
|
||||
OverlayFrames.clear();
|
||||
|
|
@ -271,11 +271,13 @@ void DX12_Hook::_PrepareForOverlay(IDXGISwapChain* pSwapChain, ID3D12CommandQueu
|
|||
//heaps.cpu_handle,
|
||||
//heaps.gpu_handle);
|
||||
|
||||
Windows_Hook::Inst()->SetInitialWindowSize(sc_desc.OutputWindow);
|
||||
|
||||
_Initialized = true;
|
||||
OverlayHookReady(true);
|
||||
}
|
||||
|
||||
if (ImGui_ImplDX12_NewFrame() && Windows_Hook::Inst()->_PrepareForOverlay(sc_desc.OutputWindow))
|
||||
if (ImGui_ImplDX12_NewFrame() && Windows_Hook::Inst()->PrepareForOverlay(sc_desc.OutputWindow))
|
||||
{
|
||||
ImGui::NewFrame();
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ void DX9_Hook::_ResetRenderState()
|
|||
OverlayHookReady(false);
|
||||
|
||||
ImGui_ImplDX9_Shutdown();
|
||||
Windows_Hook::Inst()->_ResetRenderState();
|
||||
Windows_Hook::Inst()->ResetRenderState();
|
||||
ImGui::DestroyContext();
|
||||
|
||||
SafeRelease(_pDevice);
|
||||
|
|
@ -137,11 +137,14 @@ void DX9_Hook::_PrepareForOverlay(IDirect3DDevice9 *pDevice, HWND destWindow)
|
|||
ImGui_ImplDX9_Init(pDevice);
|
||||
|
||||
_LastWindow = destWindow;
|
||||
|
||||
Windows_Hook::Inst()->SetInitialWindowSize(destWindow);
|
||||
|
||||
_Initialized = true;
|
||||
OverlayHookReady(true);
|
||||
}
|
||||
|
||||
if (ImGui_ImplDX9_NewFrame() && Windows_Hook::Inst()->_PrepareForOverlay(destWindow))
|
||||
if (ImGui_ImplDX9_NewFrame() && Windows_Hook::Inst()->PrepareForOverlay(destWindow))
|
||||
{
|
||||
ImGui::NewFrame();
|
||||
|
||||
|
|
|
|||
|
|
@ -464,43 +464,24 @@ enum class IDirect3DDevice9VTable
|
|||
GetDisplayModeEx,
|
||||
};
|
||||
|
||||
struct IDirect3DSwapChain9VTable
|
||||
enum class IDirect3DSwapChain9VTable
|
||||
{
|
||||
enum class Index
|
||||
{
|
||||
// IUnknown
|
||||
QueryInterface,
|
||||
AddRef,
|
||||
Release,
|
||||
// IUnknown
|
||||
QueryInterface,
|
||||
AddRef,
|
||||
Release,
|
||||
|
||||
// IDirect3DSwapChain9
|
||||
Present,
|
||||
GetFrontBufferData,
|
||||
GetBackBuffer,
|
||||
GetRasterStatus,
|
||||
GetDisplayMode,
|
||||
GetDevice,
|
||||
GetPresentParameters,
|
||||
// IDirect3DSwapChain9
|
||||
Present,
|
||||
GetFrontBufferData,
|
||||
GetBackBuffer,
|
||||
GetRasterStatus,
|
||||
GetDisplayMode,
|
||||
GetDevice,
|
||||
GetPresentParameters,
|
||||
|
||||
// IDirect3DSwapChain9Ex
|
||||
GetLastPresentCount,
|
||||
GetPresentStats,
|
||||
GetDisplayModeEx,
|
||||
};
|
||||
|
||||
decltype(&IDirect3DSwapChain9::QueryInterface) pQueryInterface;
|
||||
decltype(&IDirect3DSwapChain9::AddRef) pAddRef;
|
||||
decltype(&IDirect3DSwapChain9::Release) pRelease;
|
||||
|
||||
decltype(&IDirect3DSwapChain9::Present) pPresent;
|
||||
decltype(&IDirect3DSwapChain9::GetFrontBufferData) pGetFrontBufferData;
|
||||
decltype(&IDirect3DSwapChain9::GetBackBuffer) pGetBackBuffer;
|
||||
decltype(&IDirect3DSwapChain9::GetRasterStatus) pGetRasterStatus;
|
||||
decltype(&IDirect3DSwapChain9::GetDisplayMode) pGetDisplayMode;
|
||||
decltype(&IDirect3DSwapChain9::GetDevice) pGetDevice;
|
||||
decltype(&IDirect3DSwapChain9::GetPresentParameters) pGetPresentParameters;
|
||||
|
||||
decltype(&IDirect3DSwapChain9Ex::GetLastPresentCount) pGetLastPresentCount;
|
||||
decltype(&IDirect3DSwapChain9Ex::GetPresentStats) pGetPresentStats;
|
||||
decltype(&IDirect3DSwapChain9Ex::GetDisplayModeEx) pGetDisplayModeEx;
|
||||
// IDirect3DSwapChain9Ex
|
||||
GetLastPresentCount,
|
||||
GetPresentStats,
|
||||
GetDisplayModeEx,
|
||||
};
|
||||
|
|
@ -68,10 +68,10 @@ void OpenGL_Hook::_ResetRenderState()
|
|||
OverlayHookReady(false);
|
||||
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
Windows_Hook::Inst()->_ResetRenderState();
|
||||
Windows_Hook::Inst()->ResetRenderState();
|
||||
ImGui::DestroyContext();
|
||||
|
||||
last_window = nullptr;
|
||||
_LastWindow = nullptr;
|
||||
_Initialized = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ void OpenGL_Hook::_PrepareForOverlay(HDC hDC)
|
|||
{
|
||||
HWND hWnd = WindowFromDC(hDC);
|
||||
|
||||
if (hWnd != last_window)
|
||||
if (hWnd != _LastWindow)
|
||||
_ResetRenderState();
|
||||
|
||||
if (!_Initialized)
|
||||
|
|
@ -89,12 +89,15 @@ void OpenGL_Hook::_PrepareForOverlay(HDC hDC)
|
|||
ImGui::CreateContext();
|
||||
ImGui_ImplOpenGL3_Init();
|
||||
|
||||
last_window = hWnd;
|
||||
_LastWindow = hWnd;
|
||||
|
||||
Windows_Hook::Inst()->SetInitialWindowSize(hWnd);
|
||||
|
||||
_Initialized = true;
|
||||
OverlayHookReady(true);
|
||||
}
|
||||
|
||||
if (ImGui_ImplOpenGL3_NewFrame() && Windows_Hook::Inst()->_PrepareForOverlay(hWnd))
|
||||
if (ImGui_ImplOpenGL3_NewFrame() && Windows_Hook::Inst()->PrepareForOverlay(hWnd))
|
||||
{
|
||||
ImGui::NewFrame();
|
||||
|
||||
|
|
@ -117,7 +120,7 @@ OpenGL_Hook::OpenGL_Hook():
|
|||
_Hooked(false),
|
||||
_WindowsHooked(false),
|
||||
_Initialized(false),
|
||||
last_window(nullptr),
|
||||
_LastWindow(nullptr),
|
||||
wglSwapBuffers(nullptr)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ private:
|
|||
bool _Hooked;
|
||||
bool _WindowsHooked;
|
||||
bool _Initialized;
|
||||
HWND last_window;
|
||||
HWND _LastWindow;
|
||||
std::set<std::shared_ptr<uint64_t>> _ImageResources;
|
||||
|
||||
// Functions
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ bool Windows_Hook::StartHook(std::function<bool(bool)>& _key_combination_callbac
|
|||
return true;
|
||||
}
|
||||
|
||||
void Windows_Hook::_ResetRenderState()
|
||||
void Windows_Hook::ResetRenderState()
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
|
|
@ -100,10 +100,17 @@ void Windows_Hook::_ResetRenderState()
|
|||
}
|
||||
}
|
||||
|
||||
bool Windows_Hook::_PrepareForOverlay(HWND hWnd)
|
||||
void Windows_Hook::SetInitialWindowSize(HWND hWnd)
|
||||
{
|
||||
RECT rect = { 0, 0, 0, 0 };
|
||||
::GetClientRect(hWnd, &rect);
|
||||
ImGui::GetIO().DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
|
||||
}
|
||||
|
||||
bool Windows_Hook::PrepareForOverlay(HWND hWnd)
|
||||
{
|
||||
if (_GameHwnd != hWnd)
|
||||
_ResetRenderState();
|
||||
ResetRenderState();
|
||||
|
||||
if (!_Initialized)
|
||||
{
|
||||
|
|
@ -374,7 +381,7 @@ Windows_Hook::~Windows_Hook()
|
|||
{
|
||||
SPDLOG_INFO("Windows Hook removed");
|
||||
|
||||
_ResetRenderState();
|
||||
ResetRenderState();
|
||||
|
||||
_inst = nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,8 +68,9 @@ public:
|
|||
|
||||
virtual ~Windows_Hook();
|
||||
|
||||
void _ResetRenderState();
|
||||
bool _PrepareForOverlay(HWND hWnd);
|
||||
void ResetRenderState();
|
||||
void SetInitialWindowSize(HWND hWnd);
|
||||
bool PrepareForOverlay(HWND hWnd);
|
||||
|
||||
HWND GetGameHwnd() const;
|
||||
WNDPROC GetGameWndProc() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue