-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManager.cpp
More file actions
79 lines (66 loc) · 2.58 KB
/
Manager.cpp
File metadata and controls
79 lines (66 loc) · 2.58 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
#define CPPHTTPLIB_OPENSSL_SUPPORT
#define WIN32_LEAN_AND_MEAN
#include "UpdateManager/Utils/httplib/httplib.h" // if I want to use it, I use it
#include "Manager.h"
#include <vector>
#include <string>
#include <filesystem>
#include <fstream>
MainWindow* mainWindow;
void Main() {
//UpdateManager::GetExecutableFolder();
}
//std::future<void> downloadAbout;
void RenderThread() {
Settings::LoadSettings();
Global::HasUpdaterExe = fs::exists("updater.exe");
{ // To minimize exe size
httplib::Client cli("http://decodercoder.xyz");
cli.set_connection_timeout(2);
auto res = cli.Get("/about/my_avatar.png");
if (res.error() == httplib::Error::Success) {
Global::serverAvailable = true;
Global::myAvatar.second = res->body.size();
Global::myAvatar.first = (unsigned char*)malloc(Global::myAvatar.second);
memcpy(Global::myAvatar.first, res->body.data(), Global::myAvatar.second);
res = cli.Get("/about/ddma.png");
Global::ddma.second = res->body.size();
Global::ddma.first = (unsigned char*)malloc(Global::ddma.second);
memcpy(Global::ddma.first, res->body.data(), Global::ddma.second);
res = cli.Get("/about/fontRegular.ttf");
Global::fontRegular.second = res->body.size();
Global::fontRegular.first = (unsigned char*)malloc(Global::fontRegular.second);
memcpy(Global::fontRegular.first, res->body.data(), Global::fontRegular.second);
res = cli.Get("/about/fontMedium.ttf");
Global::fontMedium.second = res->body.size();
Global::fontMedium.first = (unsigned char*)malloc(Global::fontMedium.second);
memcpy(Global::fontMedium.first, res->body.data(), Global::fontMedium.second);
}
}
OleInitialize(NULL);
DirectX::Init();
if (Global::serverAvailable) {
ImGui::GetIO().Fonts->AddFontDefault();
Global::fontRegular16 = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(Global::fontRegular.first, Global::fontRegular.second, 19);
Global::fontMedium32 = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(Global::fontMedium.first, Global::fontMedium.second, 39);
ImGui::GetIO().Fonts->Build();
DirectX::LoadTextureFromMemory(Global::myAvatar.first, Global::myAvatar.second, Global::myAvatarImage);
DirectX::LoadTextureFromMemory(Global::ddma.first, Global::ddma.second, Global::ddmaImage);
}
//downloadAbout = std::async(std::launch::async, [&]() {
//});
while (DirectX::Windows.size() > 0) {
DirectX::Render();
}
}
int main()
{
mainWindow = new MainWindow();
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)RenderThread, NULL, NULL, NULL);
while (!GetAsyncKeyState(VK_END)) {
Sleep(1);
if (DirectX::Windows.size() == 0)
return 0;
}
DirectX::Deinit();
}