Skip to content

Commit 6297006

Browse files
committed
Remove Server requirement and PostBuild evens
1 parent 762712e commit 6297006

File tree

5 files changed

+42
-21
lines changed

5 files changed

+42
-21
lines changed

Manager/Global.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace Global {
66
inline bool HasUpdaterExe = false;
77

8+
inline bool serverAvailable = false;
9+
810
inline std::pair<unsigned char*, size_t> myAvatar;
911
inline std::pair<unsigned char*, size_t> ddma;
1012
inline std::pair<unsigned char*, size_t> fontRegular;

Manager/Manager.cpp

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,42 @@ void RenderThread() {
2020
Global::HasUpdaterExe = fs::exists("updater.exe");
2121
{ // To minimize exe size
2222
httplib::Client cli("http://decodercoder.xyz");
23+
cli.set_connection_timeout(2);
2324
auto res = cli.Get("/about/my_avatar.png");
24-
Global::myAvatar.second = res->body.size();
25-
Global::myAvatar.first = (unsigned char*)malloc(Global::myAvatar.second);
26-
memcpy(Global::myAvatar.first, res->body.data(), Global::myAvatar.second);
25+
if (res.error() == httplib::Error::Success) {
26+
Global::serverAvailable = true;
27+
Global::myAvatar.second = res->body.size();
28+
Global::myAvatar.first = (unsigned char*)malloc(Global::myAvatar.second);
29+
memcpy(Global::myAvatar.first, res->body.data(), Global::myAvatar.second);
2730

28-
res = cli.Get("/about/ddma.png");
29-
Global::ddma.second = res->body.size();
30-
Global::ddma.first = (unsigned char*)malloc(Global::ddma.second);
31-
memcpy(Global::ddma.first, res->body.data(), Global::ddma.second);
31+
res = cli.Get("/about/ddma.png");
32+
Global::ddma.second = res->body.size();
33+
Global::ddma.first = (unsigned char*)malloc(Global::ddma.second);
34+
memcpy(Global::ddma.first, res->body.data(), Global::ddma.second);
3235

33-
res = cli.Get("/about/fontRegular.ttf");
34-
Global::fontRegular.second = res->body.size();
35-
Global::fontRegular.first = (unsigned char*)malloc(Global::fontRegular.second);
36-
memcpy(Global::fontRegular.first, res->body.data(), Global::fontRegular.second);
36+
res = cli.Get("/about/fontRegular.ttf");
37+
Global::fontRegular.second = res->body.size();
38+
Global::fontRegular.first = (unsigned char*)malloc(Global::fontRegular.second);
39+
memcpy(Global::fontRegular.first, res->body.data(), Global::fontRegular.second);
3740

38-
res = cli.Get("/about/fontMedium.ttf");
39-
Global::fontMedium.second = res->body.size();
40-
Global::fontMedium.first = (unsigned char*)malloc(Global::fontMedium.second);
41-
memcpy(Global::fontMedium.first, res->body.data(), Global::fontMedium.second);
41+
res = cli.Get("/about/fontMedium.ttf");
42+
Global::fontMedium.second = res->body.size();
43+
Global::fontMedium.first = (unsigned char*)malloc(Global::fontMedium.second);
44+
memcpy(Global::fontMedium.first, res->body.data(), Global::fontMedium.second);
45+
}
4246
}
4347

4448
OleInitialize(NULL);
4549
DirectX::Init();
46-
ImGui::GetIO().Fonts->AddFontDefault();
47-
Global::fontRegular16 = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(Global::fontRegular.first, Global::fontRegular.second, 19);
48-
Global::fontMedium32 = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(Global::fontMedium.first, Global::fontMedium.second, 39);
49-
ImGui::GetIO().Fonts->Build();
50-
DirectX::LoadTextureFromMemory(Global::myAvatar.first, Global::myAvatar.second, Global::myAvatarImage);
51-
DirectX::LoadTextureFromMemory(Global::ddma.first, Global::ddma.second, Global::ddmaImage);
50+
if (Global::serverAvailable) {
51+
ImGui::GetIO().Fonts->AddFontDefault();
52+
Global::fontRegular16 = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(Global::fontRegular.first, Global::fontRegular.second, 19);
53+
Global::fontMedium32 = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(Global::fontMedium.first, Global::fontMedium.second, 39);
54+
ImGui::GetIO().Fonts->Build();
55+
DirectX::LoadTextureFromMemory(Global::myAvatar.first, Global::myAvatar.second, Global::myAvatarImage);
56+
DirectX::LoadTextureFromMemory(Global::ddma.first, Global::ddma.second, Global::ddmaImage);
57+
}
58+
5259
//downloadAbout = std::async(std::launch::async, [&]() {
5360

5461
//});

Manager/Manager.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@
6767
<GenerateDebugInformation>true</GenerateDebugInformation>
6868
<AdditionalDependencies>libcrypto.lib;libssl.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
6969
</Link>
70+
<PostBuildEvent>
71+
<Command>copy "$(SolutionDir)vcpkg\installed\x64-windows\bin\libcrypto-3-x64.dll" "$(TargetDir)"
72+
copy "$(SolutionDir)vcpkg\installed\x64-windows\bin\libssl-3-x64.dll" "$(TargetDir)"</Command>
73+
</PostBuildEvent>
7074
</ItemDefinitionGroup>
7175
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
7276
<ClCompile>

Manager/Windows/MainWindow/MainWindow.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ bool MainWindow::Render()
275275
//if (ImGui::MenuItem("Change theme")) {
276276
// Settings::darkMode = !Settings::darkMode;
277277
//}
278+
if (!Global::serverAvailable)
279+
ImGui::BeginDisabled();
278280
if (ImGui::MenuItem("About")) {
279281
AboutWindow* aboutWindow = nullptr;
280282
for (Window*& obj : DirectX::Windows) {
@@ -292,6 +294,8 @@ bool MainWindow::Render()
292294
aboutWindow->Show();
293295
}
294296
}
297+
if (!Global::serverAvailable)
298+
ImGui::EndDisabled();
295299
ImGui::EndMenu();
296300
}
297301
if (selectedApp < 0 || !Global::HasUpdaterExe)

updater/updater.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@
121121
<GenerateDebugInformation>true</GenerateDebugInformation>
122122
<AdditionalDependencies>libcrypto.lib;libssl.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
123123
</Link>
124+
<PostBuildEvent>
125+
<Command>copy "$(SolutionDir)vcpkg\installed\x64-windows\bin\libcrypto-3-x64.dll" "$(TargetDir)"
126+
copy "$(SolutionDir)vcpkg\installed\x64-windows\bin\libssl-3-x64.dll" "$(TargetDir)"</Command>
127+
</PostBuildEvent>
124128
</ItemDefinitionGroup>
125129
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
126130
<ClCompile>

0 commit comments

Comments
 (0)