-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathGfxOverlay.cpp
More file actions
89 lines (68 loc) · 1.38 KB
/
Copy pathGfxOverlay.cpp
File metadata and controls
89 lines (68 loc) · 1.38 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "hacklib/GfxOverlay.h"
using namespace hl;
GfxOverlay::GfxOverlay(ModuleHandle hModule) : m_hModule(hModule)
{
impl_construct();
}
GfxOverlay::~GfxOverlay()
{
close();
impl_destruct();
}
GfxOverlay::Error GfxOverlay::create(int posX, int posY, int width, int height)
{
// dont allow displaying twice
close();
m_posX = posX;
m_posY = posY;
m_width = width;
m_height = height;
// promise of return value of initialization
std::promise<Error> p;
auto ret = p.get_future();
m_thread = std::thread(&GfxOverlay::impl_windowThread, this, std::ref(p));
// wait for initialization to be done and return false on error
auto err = ret.get();
if (err == Error::Okay)
m_isOpen = true;
return err;
}
void GfxOverlay::close()
{
if (m_isOpen)
{
impl_close();
}
if (m_thread.joinable())
{
m_thread.join();
}
}
void GfxOverlay::setTargetRefreshRate(int rate)
{
m_frameTime = std::chrono::nanoseconds(1000000000ull / rate);
}
bool GfxOverlay::isOpen() const
{
return m_isOpen;
}
int GfxOverlay::getPosX() const
{
return m_posX;
}
int GfxOverlay::getPosY() const
{
return m_posY;
}
int GfxOverlay::getWidth() const
{
return m_width;
}
int GfxOverlay::getHeight() const
{
return m_height;
}
void GfxOverlay::cbWindowLoop()
{
// Empty default implementation.
}