Skip to content

Commit

Permalink
Fixed ProfilePage crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Jouca committed Jun 4, 2024
1 parent 06f2af6 commit 0265f58
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Utils/NewProfilePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,16 @@ You found a <co>GDUtils developer</c>! :O
class $modify(ProfilePage) {
void loadPageFromUserInfo(GJUserScore* a2) {
auto layer = m_mainLayer;
CCMenu* username_menu = typeinfo_cast<CCMenu*>(layer->getChildByIDRecursive("username-menu"));
CCLabelBMFont* label = typeinfo_cast<CCLabelBMFont*>(layer->getChildByIDRecursive("username-label"));
CCMenuItemSpriteExtra* badgeBtn = nullptr;
CCMenuItemSpriteExtra* badgeGDUtilBtn = nullptr;

bool modbadge_bool = false;

ProfilePage::loadPageFromUserInfo(a2);

CCMenu* username_menu = typeinfo_cast<CCMenu*>(layer->getChildByIDRecursive("username-menu"));
CCLabelBMFont* label = typeinfo_cast<CCLabelBMFont*>(layer->getChildByIDRecursive("username-label"));

// Keep 7976112 for contributors soon

if (layer) {
Expand All @@ -173,10 +175,10 @@ class $modify(ProfilePage) {

std::vector<int> gdutils_accountID_devs = { 7026949, 6253758, 5509312 };
if (std::find(gdutils_accountID_devs.begin(), gdutils_accountID_devs.end(), a2->m_accountID) != gdutils_accountID_devs.end()) {
if (label != nullptr && username_menu != nullptr && !this->getChildByIDRecursive("gdutils-badge"_spr)) {
if (label != nullptr) {
auto badgeGDUtil = CCSprite::create(Mod::get()->expandSpriteName("gdutils_badge.png"));
badgeGDUtil->setScale(.3f);
auto badgeGDUtilBtn = CCMenuItemSpriteExtra::create(
badgeGDUtilBtn = CCMenuItemSpriteExtra::create(
badgeGDUtil,
this,
menu_selector(NewProfilePage::onGDUtilsBadgePressed)
Expand All @@ -191,10 +193,8 @@ class $modify(ProfilePage) {
username_menu->addChild(badgeGDUtilBtn);
}
}
}

username_menu->updateLayout();

NodeIDs::provideFor(this);
if (username_menu != nullptr) username_menu->updateLayout();
}
}
};

0 comments on commit 0265f58

Please sign in to comment.