From 10e936b834b77c523e132f76b38581a232190598 Mon Sep 17 00:00:00 2001 From: Cvolton Date: Wed, 11 Dec 2024 13:47:28 +0100 Subject: [PATCH] fix erymantheus --- changelog.md | 3 +++ mod.json | 2 +- src/hooks/ProfilePage.cpp | 5 ++-- src/layers/PaginatedFLAlert.cpp | 1 + src/utils.cpp | 42 +++++++++++++++++++++++++++++++-- src/utils.hpp | 2 ++ 6 files changed, 50 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 20b520a..92e1161 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,7 @@ # Changelog +## v4.3.1 (2024-12-11) +* Fixed compatibility with AlertLayerTweaks + ## v4.3.0 (2024-12-09) * Added Featured Lite (Weekly Levels) to BI menu * Added integration with Eclipse Menu and QOLmod diff --git a/mod.json b/mod.json index fe7f76c..b355ae2 100644 --- a/mod.json +++ b/mod.json @@ -1,6 +1,6 @@ { "geode": "4.0.1", - "version": "v4.3.0", + "version": "v4.3.1", "gd": { "win": "2.2074", "android": "2.2074", diff --git a/src/hooks/ProfilePage.cpp b/src/hooks/ProfilePage.cpp index f4bb85a..2433ba9 100644 --- a/src/hooks/ProfilePage.cpp +++ b/src/hooks/ProfilePage.cpp @@ -56,7 +56,8 @@ class BI_DLL $modify(BIProfilePage, ProfilePage) { CCMenuItemSpriteExtra* bootupsButton = nullptr; std::ostringstream contentStream; - if(score->m_userID == GM->m_playerUserID) { + //AlertLayerTweaks users don't deserve rights + if(score->m_userID == GM->m_playerUserID && !Loader::get()->isModLoaded("raydeeux.alertlayertweaks")) { contentStream << "\n\n\n"; userButton = CopyableLabel::create("cy", "User ID", std::to_string(score->m_userID)); @@ -72,7 +73,7 @@ class BI_DLL $modify(BIProfilePage, ProfilePage) { << "\nPrivate Messages: " << StaticStringHelper::getMessageType(score->m_messageState) << "\nComment History: " << StaticStringHelper::getMessageType(score->m_commentHistoryStatus) << "\n"; - if(score->m_userID == GM->m_playerUserID) { + if(score->m_userID == GM->m_playerUserID && !Loader::get()->isModLoaded("raydeeux.alertlayertweaks")) { contentStream << "\n\n"; bootupsButton = CopyableLabel::create("co", "Bootups", std::to_string(GM->m_bootups)); diff --git a/src/layers/PaginatedFLAlert.cpp b/src/layers/PaginatedFLAlert.cpp index 8187fb4..1c9dedd 100644 --- a/src/layers/PaginatedFLAlert.cpp +++ b/src/layers/PaginatedFLAlert.cpp @@ -24,6 +24,7 @@ bool PaginatedFLAlert::init(const std::string& title, const std::vectorgetMinor() == Mod::get()->getVersion().getMinor()) return nullptr; if(versionResult.isOk() && ComparableVersionInfo::parse(">=4.3.0").unwrap().compare(versionResult.unwrap())) return nullptr; - return createQuickPopup( + auto popup = createQuickPopup( "BetterInfo", "BetterInfo has updated!\n" "\n" @@ -819,7 +819,7 @@ FLAlertLayer* BetterInfo::createUpdateDialog() { "\n", "More Info", "Ok", - 420, + 450, [](FLAlertLayer* me, bool btn2) { Mod::get()->setSavedValue("last_dialog_version", Mod::get()->getVersion().toVString()); @@ -829,6 +829,8 @@ FLAlertLayer* BetterInfo::createUpdateDialog() { }, false ); + fixOversizedPopup(popup); + return popup; } //from coloride on geode sdk discord @@ -1032,4 +1034,40 @@ void BetterInfo::cancelUnimportantNotifications() { notification->cancel(); } s_notifications.clear(); +} + +/** + * This function fixes compatibility with AlertLayerTweaks by Erymantheus + * + * @param node the popup that is likely broken by AlertLayerTweaks by Erymantheus + */ +void BetterInfo::fixOversizedPopup(FLAlertLayer* node) { + auto winSize = CCDirector::sharedDirector()->getWinSize(); + auto backgroundSprite = node->m_mainLayer->getChildByType(0); + + if(!backgroundSprite) return; + auto size = backgroundSprite->getContentSize(); + + bool fixApplied = false; + + if(size.width > winSize.width) { + node->setScale(winSize.width / size.width); + fixApplied = true; + } + if(size.height > winSize.height) { + node->setScale(winSize.height / size.height); + fixApplied = true; + } + + if(fixApplied) { + node->setOpacity(0.f); + + auto newLayerColor = CCLayerColor::create({0, 0, 0, 150}); + newLayerColor->setContentSize(winSize / node->getScale()); + newLayerColor->ignoreAnchorPointForPosition(false); + newLayerColor->setPosition(winSize / 2); + newLayerColor->setID("background-fix"_spr); + + node->addChild(newLayerColor, -1); + } } \ No newline at end of file diff --git a/src/utils.hpp b/src/utils.hpp index 86de4cf..480a95d 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -98,4 +98,6 @@ namespace BetterInfo { BI_DLL void showUnimportantNotification(const std::string& content, NotificationIcon icon, float time = 5.f); BI_DLL void cancelUnimportantNotifications(); + + BI_DLL void fixOversizedPopup(FLAlertLayer* node); } \ No newline at end of file