Skip to content

Commit

Permalink
Upgraded CommentCell for level comments (#104)
Browse files Browse the repository at this point in the history
* Upgraded CommentCell for level comments

* Remove useless winSize

* Fixed for a profile comments

* Tweaked position Y

* Fixed issue with green users for big comments

* Nevermind, concerning all big comments
  • Loading branch information
Jouca authored Aug 21, 2024
1 parent 3e25de3 commit 01c6665
Showing 1 changed file with 69 additions and 4 deletions.
73 changes: 69 additions & 4 deletions src/CommentCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ using namespace geode::node_ids;
if(!smallCommentsMode) getChildOfType<CCScale9Sprite>(m_mainLayer, 0)->setID("background");

int bmfontOffset = 0;
/*if(m_comment->m_modBadge > 0) {
if(m_comment->m_modBadge > 0) {
getChildOfType<CCSprite>(m_mainLayer, 0)->setID("mod-badge");
}*/
}
if(m_comment->m_percentage > 0) {
getChildOfType<CCLabelBMFont>(m_mainLayer, 0 + bmfontOffset)->setID("percentage-label");
bmfontOffset += 1;
Expand All @@ -35,11 +35,16 @@ using namespace geode::node_ids;

if(!m_comment->m_isSpam) {
getChildOfType<CCLabelBMFont>(m_mainLayer, 0 + bmfontOffset)->setID("likes-label");
if(!(m_comment->m_uploadDate).empty()) getChildOfType<CCLabelBMFont>(m_mainLayer, 1 + bmfontOffset)->setID("date-label");
bmfontOffset += 1;
if(!(m_comment->m_uploadDate).empty()) getChildOfType<CCLabelBMFont>(m_mainLayer, 0 + bmfontOffset)->setID("date-label");
bmfontOffset += 1;
}

if (!m_accountComment && usernameNotInMenu) {
getChildOfType<SimplePlayer>(m_mainLayer, 0)->setID("player-icon");
}

if(!smallCommentsMode) getChildOfType<TextArea>(m_mainLayer, 0)->setID("comment-text-area");
//getChildOfType<SimplePlayer>(m_mainLayer, 0)->setID("player-icon");

if (auto mainMenu = getChildOfType<CCMenu>(m_mainLayer, 0)) {
mainMenu->setID("main-menu");
Expand All @@ -60,6 +65,66 @@ using namespace geode::node_ids;
setIDSafe(mainMenu, 0 + menuOffset, "like-button");
setIDSafe(mainMenu, 1 + menuOffset, "delete-button");
}

if (!m_accountComment) {
CCNode* usernameLabel = nullptr;
auto userMenu = CCMenu::create();

if (!usernameNotInMenu) {
usernameLabel = mainMenu->getChildByID("username-button");
usernameLabel->setContentHeight(usernameLabel->getContentHeight() - 5.f);
userMenu->setPositionY(usernameLabel->getPositionY() - 2.f);
} else {
usernameLabel = m_mainLayer->getChildByID("username-label");
usernameLabel->setContentHeight(usernameLabel->getContentHeight() - 5.f);
userMenu->setPositionY(-135.f);
}

if (!smallCommentsMode) userMenu->setPositionY(-100.f);

auto playerIcon = getChildOfType<SimplePlayer>(m_mainLayer, 0);
auto iconSpr = getChildOfType<CCSprite>(playerIcon, 0);
playerIcon->setContentSize({40, 40}); // to make it work with layouts
iconSpr->setPosition(ccp(playerIcon->getContentWidth() / 2.f, playerIcon->getContentHeight() / 2.f));
if (auto robotSpr = getChildOfType<GJRobotSprite>(playerIcon, 0)) robotSpr->setPosition(ccp(20.f, 20.f));
playerIcon->removeFromParent();
playerIcon->setZOrder(-1);
playerIcon->setLayoutOptions(AxisLayoutOptions::create()->setAutoScale(false));

userMenu->setID("user-menu");
userMenu->setLayout(RowLayout::create()->setAxisAlignment(AxisAlignment::Center)->setGap(5.f)->setAutoScale(false)->setCrossAxisOverflow(false));
userMenu->setPositionX(-114.f);
userMenu->setContentSize({320, 30});
userMenu->addChild(playerIcon);
setIDSafe(userMenu, 0, "player-icon");

mainMenu->addChild(userMenu);

auto usernameMenu = CCMenu::create();
usernameMenu->setID("username-menu");
usernameMenu->setLayout(RowLayout::create()->setAxisAlignment(AxisAlignment::Start)->setGap(2.f)->setAutoScale(false)->setCrossAxisOverflow(false));
usernameMenu->setPositionY(usernameLabel->getPositionY() - 2.f);
usernameMenu->setPositionX(-114.f);
usernameMenu->setContentSize({320, 30});

switchToMenu(usernameLabel, usernameMenu);
setIDSafe(usernameMenu, 0, "username-button");

if (m_comment->m_modBadge > 0) {
switchToMenu(getChildOfType<CCSprite>(m_mainLayer, 0), usernameMenu);
setIDSafe(usernameMenu, 1, "mod-badge");
}

if (m_comment->m_percentage > 0) {
switchToMenu(getChildOfType<CCLabelBMFont>(m_mainLayer, 0), usernameMenu);
setIDSafe(usernameMenu, 2, "percentage-label");
}

userMenu->addChild(usernameMenu);

usernameMenu->updateLayout();
userMenu->updateLayout();
}
}
}

Expand Down

0 comments on commit 01c6665

Please sign in to comment.