-
-
Notifications
You must be signed in to change notification settings - Fork 292
/
Copy pathD3D12.cpp
76 lines (61 loc) · 1.97 KB
/
D3D12.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <stdafx.h>
#include "D3D12.h"
#include "CET.h"
#include <imgui_impl/dx12.h>
#include <imgui_impl/win32.h>
#include <scripting/GameHooks.h>
void D3D12::SetTrapInputInImGui(const bool acEnabled)
{
static const RED4ext::CName cReason = "ImGui";
static RED4ext::UniversalRelocFunc<void (*)(RED4ext::CBaseEngine::UnkD0* apThis, RED4ext::CName aReason, bool aShow)>
forceCursor(CyberEngineTweaks::AddressHashes::InputSystemWin32Base_ForceCursor);
forceCursor(RED4ext::CGameEngine::Get()->unkD0, cReason, acEnabled);
m_trapInputInImGui = acEnabled;
}
void D3D12::DelayedSetTrapInputInImGui(const bool acEnabled)
{
m_delayedTrapInputState = acEnabled;
m_delayedTrapInput = true;
}
LRESULT D3D12::OnWndProc(HWND ahWnd, UINT auMsg, WPARAM awParam, LPARAM alParam) const
{
auto& d3d12 = CET::Get().GetD3D12();
if (d3d12.IsInitialized())
{
if (const auto res = ImGui_ImplWin32_WndProcHandler(ahWnd, auMsg, awParam, alParam))
return res;
if (d3d12.m_delayedTrapInput)
{
d3d12.SetTrapInputInImGui(m_delayedTrapInputState);
d3d12.m_delayedTrapInput = false;
}
if (d3d12.m_trapInputInImGui) // TODO: look into io.WantCaptureMouse and io.WantCaptureKeyboard
{
// ignore mouse & keyboard events
if ((auMsg >= WM_MOUSEFIRST && auMsg <= WM_MOUSELAST) || (auMsg >= WM_KEYFIRST && auMsg <= WM_KEYLAST))
return 1;
// ignore input messages
if (auMsg == WM_INPUT)
return 1;
}
}
return 0;
}
D3D12::D3D12(Window& aWindow, Paths& aPaths, Options& aOptions)
: m_paths(aPaths)
, m_window(aWindow)
, m_options(aOptions)
{
Hook();
// add repeated task which prepares next ImGui frame for update
GameMainThread::Get().AddGenericTask(
[this]
{
PrepareUpdate();
return false;
});
}
D3D12::~D3D12()
{
assert(!m_initialized);
}