Skip to content

Commit

Permalink
fix erymantheus
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Dec 11, 2024
1 parent af360a8 commit 10e936b
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
## <cg>v4.3.1</c> (2024-12-11)
* <cg>Fixed</c> <cl>compatibility</c> with <co>AlertLayerTweaks</c>

## <cg>v4.3.0</c> (2024-12-09)
* <cg>Added</c> <cl>Featured Lite</c> (Weekly Levels) to <co>BI menu</c>
* <cg>Added</c> <cl>integration</c> with <co>Eclipse Menu</c> and <co>QOLmod</c>
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "4.0.1",
"version": "v4.3.0",
"version": "v4.3.1",
"gd": {
"win": "2.2074",
"android": "2.2074",
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/ProfilePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -72,7 +73,7 @@ class BI_DLL $modify(BIProfilePage, ProfilePage) {
<< "\n<cl>Private Messages:</c> " << StaticStringHelper::getMessageType(score->m_messageState)
<< "\n<cp>Comment History:</c> " << 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));
Expand Down
1 change: 1 addition & 0 deletions src/layers/PaginatedFLAlert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ bool PaginatedFLAlert::init(const std::string& title, const std::vector<std::str
if(m_content.size() == 0) m_content.push_back("PaginatedFLAlert content is empty, this is very likely a coding mistake and should be reported as a bug to the mod author(s).");

FLAlertLayer::init(nullptr, title.c_str(), content[page % m_content.size()], "OK", nullptr, 400, false, 300, 1);
BetterInfo::fixOversizedPopup(this);

/*
next/prev page btn
Expand Down
42 changes: 40 additions & 2 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ FLAlertLayer* BetterInfo::createUpdateDialog() {
//if(versionResult.isOk() && versionResult->getMinor() == 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",
"<cg>BetterInfo has updated!</c>\n"
"\n"
Expand All @@ -819,7 +819,7 @@ FLAlertLayer* BetterInfo::createUpdateDialog() {
"\n",
"More Info",
"Ok",
420,
450,
[](FLAlertLayer* me, bool btn2) {
Mod::get()->setSavedValue<std::string>("last_dialog_version", Mod::get()->getVersion().toVString());

Expand All @@ -829,6 +829,8 @@ FLAlertLayer* BetterInfo::createUpdateDialog() {
},
false
);
fixOversizedPopup(popup);
return popup;
}

//from coloride on geode sdk discord
Expand Down Expand Up @@ -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<CCScale9Sprite>(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);
}
}
2 changes: 2 additions & 0 deletions src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 10e936b

Please sign in to comment.