-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (37 loc) · 1.03 KB
/
Copy pathmain.cpp
File metadata and controls
49 lines (37 loc) · 1.03 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
#include <thread>
#include <chrono>
#include <ApGame/Core/Application.hpp>
const static auto sleep_time = std::chrono::milliseconds(1);
void NetworkThread(ApGame::Core::Application *app)
{
while (PRESENT_PTR(app) && app->IsRunning())
{
app->network->AsyncRun();
std::this_thread::sleep_for(sleep_time);
}
}
int run_overlay(ApGame::Core::Application& app)
{
MSG msg = { nullptr };
while(msg.message != WM_QUIT)
{
app.IsRunning() ? app.Run() : PostQuitMessage(0);
// If there are Window messages then process them.
if(PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ))
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
std::this_thread::sleep_for(sleep_time);
}
return (int)msg.wParam;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
ApGame::Core::Application app(hInstance);
std::thread(NetworkThread, &app).detach();
run_overlay(app);
return 0;
}