Skip to content

Commit

Permalink
fix comment cell usernames on node ids 1.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Sep 16, 2024
1 parent 22b6669 commit dc1324d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ endif()
add_subdirectory($ENV{GEODE_SDK} $ENV{GEODE_SDK}/build)

# Set up dependencies, resources, link Geode
setup_geode_mod(${PROJECT_NAME} EXTERNALS geode.node-ids:1.13.1 cvolton.misc_bugfixes:1.1.3)
setup_geode_mod(${PROJECT_NAME} EXTERNALS geode.node-ids:1.14.0 cvolton.misc_bugfixes:1.1.3)
4 changes: 2 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"geode": "3.4.0",
"geode": "3.7.1",
"version": "v4.2.8",
"gd": {
"win": "2.206",
Expand All @@ -21,7 +21,7 @@
"dependencies": [
{
"id": "geode.node-ids",
"version": "v1.13.1",
"version": "v1.14.0",
"importance": "required"
},
{
Expand Down
44 changes: 21 additions & 23 deletions src/hooks/CommentCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,29 @@ class BI_DLL $modify(BICommentCell, CommentCell) {
/**
* Add username button
*/
if(b->m_accountID == 0) if(auto usernameLabel = static_cast<CCLabelBMFont*>(m_mainLayer->getChildByID("username-label"))) {
auto content = std::string_view(usernameLabel->getString());
if(content == "" || content == "-") {
usernameLabel->setString(fmt::format("- (ID: {})", b->m_userID).c_str());
if(auto usernameMenu = menu->getChildByIDRecursive("username-menu")) {
if(b->m_accountID == 0) if(auto usernameLabel = typeinfo_cast<CCLabelBMFont*>(usernameMenu->getChildByID("username-button"))) {
auto content = std::string_view(usernameLabel->getString());
if(content == "" || content == "-") {
usernameLabel->setString(fmt::format("- (ID: {})", b->m_userID).c_str());
}

usernameLabel->removeFromParent();

auto buttonButton = CCMenuItemSpriteExtra::create(
usernameLabel,
this,
menu_selector(BICommentCell::onProfilePage)
);
buttonButton->setSizeMult(1.2f);
//buttonButton->setPosition(position + CCPoint(usernameLabel->getScaledContentSize().width / 2, 0));
buttonButton->setEnabled(true);
buttonButton->setID("username-button"); //using vanilla style node ID because this is a replacement for a vanilla feature

usernameMenu->addChild(buttonButton);
usernameMenu->updateLayout();
}

CCPoint position = menu->convertToNodeSpace(m_mainLayer->convertToWorldSpace(usernameLabel->getPosition()));
usernameLabel->removeFromParent();


auto buttonButton = CCMenuItemSpriteExtra::create(
usernameLabel,
this,
menu_selector(BICommentCell::onProfilePage)
);
buttonButton->setSizeMult(1.2f);
buttonButton->setPosition(position + CCPoint(usernameLabel->getScaledContentSize().width / 2, 0));
buttonButton->setEnabled(true);
buttonButton->setID("username-button"); //using vanilla style node ID because this is a replacement for a vanilla feature

menu->addChild(buttonButton);
}


}

}
};

0 comments on commit dc1324d

Please sign in to comment.