Skip to content

Commit

Permalink
Badge-friendly username menu in ProfilePage
Browse files Browse the repository at this point in the history
  • Loading branch information
ninXout committed May 28, 2024
1 parent 73dd32b commit b47da29
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"geode": "2.0.0-beta.26",
"geode": "2.0.0-beta.27",
"gd": {
"win": "2.204",
"android": "2.205",
Expand Down
32 changes: 32 additions & 0 deletions src/ProfilePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ using namespace geode::node_ids;
socialsMenu->setZOrder(10);
m_mainLayer->addChild(socialsMenu);

auto usernameMenu = CCMenu::create();
usernameMenu->setLayout(
RowLayout::create()
->setGap(3.f)
->setAxisAlignment(AxisAlignment::Center)
->setCrossAxisOverflow(false)
->setAutoScale(false)
);
usernameMenu->setID("username-menu");
usernameMenu->setPosition({(winSize.width / 2), (winSize.height / 2) + 125.f});
usernameMenu->setContentSize({286, 40});
usernameMenu->setZOrder(20);
usernameMenu->updateLayout();
m_mainLayer->addChild(usernameMenu);

}

void wrapSimplePlayer(CCNode* player, CCArray* buttons, CCSize size = {42.6f, 42.6f}) {
Expand Down Expand Up @@ -358,5 +373,22 @@ struct ProfilePageIDs : Modify<ProfilePageIDs, ProfilePage> {
socialsMenu->updateLayout();
}

if(auto usernameMenu = m_mainLayer->getChildByID("username-menu")) {
if(auto usernameLabel = m_mainLayer->getChildByID("username-label")) {
usernameLabel->removeFromParent();
CCLabelBMFont* usrLabel = dynamic_cast<CCLabelBMFont*>(usernameLabel);
score->m_modBadge > 0
? usrLabel->limitLabelWidth(140.f, 0.9f, 0.0f)
: usrLabel->limitLabelWidth(160.0f, 0.8f, 0.0f);
usernameMenu->addChild(usernameLabel);
}
if(auto modBadge = m_mainLayer->getChildByID("mod-badge")) {
modBadge->removeFromParent();
usernameMenu->addChild(modBadge);
usernameMenu->setPositionX(usernameMenu->getPositionX() - 13.f);
}
usernameMenu->updateLayout();
}

}
};

0 comments on commit b47da29

Please sign in to comment.