mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 21:05:56 -05:00
feat: Added nag banners for donations
This commit is contained in:
@@ -37,6 +37,8 @@
|
||||
|
||||
#include <string>
|
||||
#include <random>
|
||||
#include <banners/banner_button.hpp>
|
||||
#include <banners/banner_icon.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
@@ -765,6 +767,21 @@ namespace hex::plugin::builtin {
|
||||
TaskManager::doLater([]{
|
||||
AchievementManager::unlockAchievement("hex.builtin.achievement.starting_out", "hex.builtin.achievement.starting_out.crash.name");
|
||||
});
|
||||
} else {
|
||||
std::random_device rd;
|
||||
if (!ImHexApi::System::isCorporateEnvironment()) {
|
||||
if (rd() % 25 == 0) {
|
||||
ui::BannerButton::open(ICON_VS_HEART, "Using ImHex for professional work? Ask your boss to sponsor us!", ImColor(0x68, 0xA7, 0x70), "Donate Now!", [] {
|
||||
hex::openWebpage("https://imhex.werwolv.net/donate_work");
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (rd() % 75 == 0) {
|
||||
ui::BannerButton::open(ICON_VS_HEART, "ImHex needs your help to stay alive! Donate now to fund infrastructure and further development", ImColor(0x68, 0xA7, 0x70), "Donate Now!", [] {
|
||||
hex::openWebpage("https://github.com/sponsors/WerWolv");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load info banner texture either locally or from the server
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace hex::ui {
|
||||
: Banner(color), m_icon(icon), m_message(std::move(message)), m_buttonText(std::move(buttonText)), m_buttonCallback(std::move(buttonCallback)) { }
|
||||
|
||||
void drawContent() override {
|
||||
const std::string buttonText = Lang(m_buttonText);
|
||||
const std::string buttonText = hex::format(" {} ", Lang(m_buttonText).get());
|
||||
const auto buttonSize = ImGui::CalcTextSize(buttonText.c_str());
|
||||
const auto iconSize = ImGui::CalcTextSize(m_icon);
|
||||
const auto textHeight = std::max(ImGui::CalcTextSize(Lang(m_message)).y, iconSize.y);
|
||||
@@ -37,11 +37,14 @@ namespace hex::ui {
|
||||
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - buttonSize.x - 20_scaled);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 2_scaled);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1_scaled);
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_Tab));
|
||||
if (ImGui::SmallButton(buttonText.c_str())) {
|
||||
m_buttonCallback();
|
||||
this->close();
|
||||
}
|
||||
ImGui::PopStyleVar(1);
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user