Skip to content

Commit

Permalink
fix profilepage button positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Jun 23, 2024
1 parent 8582366 commit fe93f31
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"geode": "3.0.0-beta.3",
"geode": "3.0.0",
"gd": {
"win": "2.206",
"android": "2.206",
Expand Down
31 changes: 21 additions & 10 deletions src/ProfilePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ using namespace geode::node_ids;
usernameMenu->setPosition({(winSize.width / 2), (winSize.height / 2) + 125.f});
usernameMenu->setContentSize({286, 40});
usernameMenu->setZOrder(20);
usernameMenu->updateLayout();
m_mainLayer->addChild(usernameMenu);

switchToMenu(m_usernameLabel, usernameMenu);
m_usernameLabel->setZOrder(20);
usernameMenu->updateLayout();

}

void wrapSimplePlayer(CCNode* player, CCArray* buttons, CCSize size = {42.6f, 42.6f}) {
Expand Down Expand Up @@ -377,20 +380,28 @@ struct ProfilePageIDs : Modify<ProfilePageIDs, ProfilePage> {
}

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->retain();
modBadge->removeFromParent();
usernameMenu->addChild(modBadge);
usernameMenu->setPositionX(usernameMenu->getPositionX() - 13.f);
if(usernameMenu->getPositionX() == (winSize.width / 2)) usernameMenu->setPositionX((winSize.width / 2) - 13.f);
modBadge->release();
} else {
if(usernameMenu->getPositionX() == (winSize.width / 2) - 13.f) usernameMenu->setPositionX(winSize.width / 2);
}
usernameMenu->updateLayout();

if(auto infoButton = m_buttonMenu->getChildByID("info-button")) {
infoButton->setPosition(
(usernameMenu->getPosition() - m_buttonMenu->getPosition()) + (m_usernameLabel->getScaledContentSize() / 2) + CCPoint(8.f, -5.f) - ( (usernameMenu->getContentSize() / 2) - m_usernameLabel->getPosition() )
);
}

if(auto copyButton = m_buttonMenu->getChildByID("copy-username-button")) {
copyButton->setPosition(
(usernameMenu->getPosition() - m_buttonMenu->getPosition()) - ( (usernameMenu->getContentSize() / 2) - m_usernameLabel->getPosition() )
);
}
}

}
Expand Down

0 comments on commit fe93f31

Please sign in to comment.