feat: Draw info banner on welcome screen if one exists
This commit is contained in:
parent
1f05deddc8
commit
36a352b096
@ -72,8 +72,8 @@ namespace hex::plugin::builtin::recent {
|
||||
void draw();
|
||||
|
||||
/**
|
||||
* @brief Draw the "open recent" item in the "File" menu
|
||||
* @brief Adds the "open recent" item in the "File" menu
|
||||
*/
|
||||
void drawFileMenuItem();
|
||||
void addMenuItems();
|
||||
|
||||
}
|
@ -223,7 +223,7 @@ namespace hex::plugin::builtin::recent {
|
||||
ImGuiExt::EndSubWindow();
|
||||
}
|
||||
|
||||
void drawFileMenuItem() {
|
||||
void addMenuItems() {
|
||||
ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.file" }, 1200, [] {
|
||||
if (ImGui::BeginMenu("hex.builtin.menu.file.open_recent"_lang, !recent::s_recentEntriesUpdating && !s_recentEntries.empty())) {
|
||||
// Copy to avoid changing list while iteration
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
static ImGuiExt::Texture s_bannerTexture, s_backdropTexture;
|
||||
static ImGuiExt::Texture s_bannerTexture, s_backdropTexture, s_infoBannerTexture;
|
||||
|
||||
static std::string s_tipOfTheDay;
|
||||
|
||||
@ -330,6 +330,18 @@ namespace hex::plugin::builtin {
|
||||
ImGuiExt::EndSubWindow();
|
||||
}
|
||||
|
||||
if (s_infoBannerTexture.isValid()) {
|
||||
auto width = ImGui::GetContentRegionAvail().x - windowPadding;
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
ImGuiExt::BeginSubWindow("hex.builtin.welcome.header.info"_lang, ImVec2(), ImGuiChildFlags_AutoResizeX);
|
||||
{
|
||||
ImGui::Image(s_infoBannerTexture, ImVec2(width, width / s_infoBannerTexture.getAspectRatio()));
|
||||
}
|
||||
ImGuiExt::EndSubWindow();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
@ -495,7 +507,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
|
||||
recent::drawFileMenuItem();
|
||||
recent::addMenuItems();
|
||||
|
||||
// Check for crash backup
|
||||
constexpr static auto CrashFileName = "crash.json";
|
||||
@ -575,6 +587,29 @@ namespace hex::plugin::builtin {
|
||||
AchievementManager::unlockAchievement("hex.builtin.achievement.starting_out", "hex.builtin.achievement.starting_out.crash.name");
|
||||
});
|
||||
}
|
||||
|
||||
// Load info banner texture either locally or from the server
|
||||
TaskManager::doLater([] {
|
||||
for (const auto &defaultPath : fs::getDefaultPaths(fs::ImHexPath::Resources)) {
|
||||
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());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user