Skip to content

Commit 40d4084

Browse files
committed
fix(ProfilePage): better positioning for stats
1 parent 34aff35 commit 40d4084

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/ProfilePage.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ using namespace geode::node_ids;
7474
auto statsMenu = CCMenu::create();
7575
statsMenu->setLayout(
7676
RowLayout::create()
77-
->setGap(3.f)
77+
->setGap(2.5f)
7878
->setAxisAlignment(AxisAlignment::Center)
7979
);
8080
statsMenu->setID("stats-menu");
@@ -172,6 +172,8 @@ struct ProfilePageIDs : Modify<ProfilePageIDs, ProfilePage> {
172172
std::array<const char*, 7> labels = {"stars", "moons", "diamonds", "coins", "user-coins", "demons", m_score->m_creatorPoints > 0 ? "creator-points" : nullptr};
173173
#endif
174174

175+
auto statsMenu = m_mainLayer->getChildByID("stats-menu");
176+
175177
for(auto label : labels) {
176178
if(!label) continue;
177179

@@ -202,21 +204,31 @@ struct ProfilePageIDs : Modify<ProfilePageIDs, ProfilePage> {
202204
AxisLayoutOptions::create()
203205
->setRelativeScale(.9f)
204206
->setScaleLimits(.0f, 1.f)
205-
->setNextGap(10.f)
207+
->setNextGap(7.0f)
206208
);
207209
if(typeinfo_cast<CCMenuItemSpriteExtra*>(icon)) {
208-
static_cast<CCNode*>(icon->getChildren()->objectAtIndex(0))->setScale(1.f);
210+
auto child = static_cast<CCNode*>(icon->getChildren()->objectAtIndex(0));
211+
child->setScale(1.f);
212+
213+
// Make the button's content size match the inner icon
214+
icon->setContentSize(child->getContentSize());
215+
child->setPosition(
216+
icon->getContentWidth() / 2,
217+
icon->getContentHeight() / 2
218+
);
209219
}
210220

211-
if(auto statsMenu = m_mainLayer->getChildByID("stats-menu")) {
221+
if(statsMenu) {
212222
statsMenu->addChild(bmFontContainer);
213223
statsMenu->addChild(icon);
214-
215-
statsMenu->updateLayout();
216224
m_buttons->addObject(bmFontContainer);
217225
}
218226
}
219227

228+
if (statsMenu) {
229+
statsMenu->updateLayout();
230+
}
231+
220232
static_cast<CCNode*>(m_buttons->objectAtIndex(idx++))->setID("player-icon");
221233
static_cast<CCNode*>(m_buttons->objectAtIndex(idx++))->setID("player-ship");
222234
static_cast<CCNode*>(m_buttons->objectAtIndex(idx++))->setID("player-ball");

0 commit comments

Comments
 (0)