From 348fe27a3c3f7a67ab884f8e795f2fe7d1ea0113 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 5 Jun 2024 22:23:43 +0200 Subject: [PATCH] impr: Added small moon icon to the welcome screen of nightly builds --- lib/libimhex/source/api/imhex_api.cpp | 2 +- .../builtin/romfs/assets/common/nightly.svg | 21 +++++++++++++++++++ .../builtin/source/content/welcome_screen.cpp | 20 ++++++++++++++---- 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 plugins/builtin/romfs/assets/common/nightly.svg diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index ce4636e29..c012229bb 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -805,7 +805,7 @@ namespace hex { #endif } - bool isNightly() { + bool isNightlyBuild() { return getImHexVersion(false).ends_with("WIP"); } diff --git a/plugins/builtin/romfs/assets/common/nightly.svg b/plugins/builtin/romfs/assets/common/nightly.svg new file mode 100644 index 000000000..cab5c3d41 --- /dev/null +++ b/plugins/builtin/romfs/assets/common/nightly.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index d1828f910..919cfc8ee 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -37,7 +37,7 @@ namespace hex::plugin::builtin { namespace { - ImGuiExt::Texture s_bannerTexture, s_backdropTexture, s_infoBannerTexture; + ImGuiExt::Texture s_bannerTexture, s_nightlyTexture, s_backdropTexture, s_infoBannerTexture; std::string s_tipOfTheDay; @@ -183,6 +183,17 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); ImGui::Image(s_bannerTexture, s_bannerTexture.getSize()); + if (ImHexApi::System::isNightlyBuild()) { + auto cursor = ImGui::GetCursorPos(); + + ImGui::SameLine(0); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 15_scaled); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5_scaled); + ImGui::Image(s_nightlyTexture, s_nightlyTexture.getSize()); + + ImGui::SetCursorPos(cursor); + } + ImGui::NewLine(); ImGui::PushStyleColor(ImGuiCol_ChildBg, ImGui::GetStyleColorVec4(ImGuiCol_PopupBg)); @@ -504,12 +515,13 @@ namespace hex::plugin::builtin { return ImGuiExt::Texture::fromImage(romfs::get(path).span(), ImGuiExt::Texture::Filter::Nearest); }; - auto changeTextureSvg = [&](const std::string &path) { - return ImGuiExt::Texture::fromSVG(romfs::get(path).span(), 300_scaled, 0, ImGuiExt::Texture::Filter::Linear); + auto changeTextureSvg = [&](const std::string &path, float width) { + return ImGuiExt::Texture::fromSVG(romfs::get(path).span(), width, 0, ImGuiExt::Texture::Filter::Linear); }; ThemeManager::changeTheme(theme); - s_bannerTexture = changeTextureSvg(hex::format("assets/{}/banner.svg", ThemeManager::getImageTheme())); + s_bannerTexture = changeTextureSvg(hex::format("assets/{}/banner.svg", ThemeManager::getImageTheme()), 300_scaled); + s_nightlyTexture = changeTextureSvg(hex::format("assets/{}/nightly.svg", "common"), 35_scaled); s_backdropTexture = changeTexture(hex::format("assets/{}/backdrop.png", ThemeManager::getImageTheme())); if (!s_bannerTexture.isValid()) {