refactor: More init sequence refactors

This commit is contained in:
WerWolv
2023-11-28 00:47:03 +01:00
parent 284f8534ab
commit f6d4d5ab22
4 changed files with 59 additions and 47 deletions

View File

@@ -596,21 +596,25 @@ namespace hex::plugin::builtin {
const auto infoBannerPath = defaultPath / "info_banner.png";
if (wolv::io::fs::exists(infoBannerPath)) {
s_infoBannerTexture = ImGuiExt::Texture(wolv::util::toUTF8String(infoBannerPath).c_str());
break;
} else {
TaskManager::createBackgroundTask("Load banner", [](auto&) {
HttpRequest request("GET", ImHexApiURL + std::string("/info_banner"));
auto response = request.downloadFile().get();
if (response.isSuccess()) {
const auto &data = response.getData();
TaskManager::doLater([data] {
s_infoBannerTexture = ImGuiExt::Texture(data.data(), data.size());
});
}
});
if (s_infoBannerTexture.isValid())
break;
}
}
if (!s_infoBannerTexture.isValid()) {
TaskManager::createBackgroundTask("Load banner", [](auto&) {
HttpRequest request("GET", ImHexApiURL + std::string("/info_banner"));
auto response = request.downloadFile().get();
if (response.isSuccess()) {
const auto &data = response.getData();
TaskManager::doLater([data] {
s_infoBannerTexture = ImGuiExt::Texture(data.data(), data.size());
});
}
});
}
});
}