Skip to content

Commit

Permalink
make items in user info in own profile page clickable
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Dec 3, 2024
1 parent ca767f9 commit 4fd419f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
54 changes: 49 additions & 5 deletions src/hooks/ProfilePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,63 @@ class BI_DLL $modify(BIProfilePage, ProfilePage) {
auto score = this->m_score;
auto GM = GameManager::sharedState();

CCMenuItemSpriteExtra* userButton = nullptr;
CCMenuItemSpriteExtra* accountButton = nullptr;
CCMenuItemSpriteExtra* bootupsButton = nullptr;

std::ostringstream contentStream;
if(score->m_userID == GM->m_playerUserID) contentStream << "<cy>User ID:</c> " << score->m_userID
<< "\n<cr>Account ID:</c> " << score->m_accountID
<< "\n\n";//Leaderboard Icon: " << StaticStringHelper::getIconType(score->getIconType()) (is not sent)
if(score->m_userID == GM->m_playerUserID) {
contentStream << "\n\n\n";

userButton = CCMenuItemExt::createSpriteExtra(
TextArea::create(fmt::format("<cy>User ID:</c> {}", score->m_userID), "chatFont.fnt", 1, 200, {0.5,0.5}, 20, false),
[id = score->m_userID](CCObject* sender){
BetterInfo::copyToClipboard(std::to_string(id).c_str(), CCScene::get());
}
);
userButton->setPosition({-2, 175});
userButton->setContentSize({200, 20});
userButton->getNormalImage()->setPosition(userButton->getContentSize() / 2);
userButton->setID("user-id-button"_spr);

accountButton = CCMenuItemExt::createSpriteExtra(
TextArea::create(fmt::format("<cr>Account ID:</c> {}", score->m_accountID), "chatFont.fnt", 1, 200, {0.5,0.5}, 20, false),
[id = score->m_accountID](CCObject* sender){
BetterInfo::copyToClipboard(std::to_string(id).c_str(), CCScene::get());
}
);
accountButton->setPosition({-2, 155});
accountButton->setContentSize({200, 20});
accountButton->getNormalImage()->setPosition(accountButton->getContentSize() / 2);
accountButton->setID("account-id-button"_spr);
}

contentStream << "<cg>Friend Requests:</c> " << StaticStringHelper::getFriendRequestType(score->m_friendStatus)
<< "\n<cl>Private Messages:</c> " << StaticStringHelper::getMessageType(score->m_messageState)
<< "\n<cp>Comment History:</c> " << StaticStringHelper::getMessageType(score->m_commentHistoryStatus)
<< "\n";
if(score->m_userID == GM->m_playerUserID) contentStream << "\n<co>Bootups:</c> " << GM->m_bootups;
if(score->m_userID == GM->m_playerUserID) {
contentStream << "\n\n";

bootupsButton = CCMenuItemExt::createSpriteExtra(
TextArea::create(fmt::format("<co>Bootups:</c> {}", GM->m_bootups), "chatFont.fnt", 1, 200, {0.5,0.5}, 20, false),
[id = GM->m_bootups](CCObject* sender){
BetterInfo::copyToClipboard(std::to_string(id).c_str(), CCScene::get());
}
);
bootupsButton->setPosition({0, 35});
bootupsButton->setContentSize({200, 20});
bootupsButton->getNormalImage()->setPosition(bootupsButton->getContentSize() / 2);
bootupsButton->setID("bootups-button"_spr);
}

//if(score->m_userID == cvoltonID) contentStream << "\n\nThis user is epic!";

FLAlertLayer::create("User Info", contentStream.str(), "OK")->show();
auto alert = FLAlertLayer::create("User Info", contentStream.str(), "OK");
if(userButton) alert->m_buttonMenu->addChild(userButton);
if(accountButton) alert->m_buttonMenu->addChild(accountButton);
if(bootupsButton) alert->m_buttonMenu->addChild(bootupsButton);
alert->show();
}

void onProfilePageLeaderboard(CCObject* sender){
Expand Down
2 changes: 1 addition & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void BetterInfo::copyToClipboard(const char* text){
clipboard::write(text);
}

void BetterInfo::copyToClipboard(const char* text, CCLayer* parent){
void BetterInfo::copyToClipboard(const char* text, CCNode* parent){
copyToClipboard(text);

Notification::create("Copied to clipboard", NotificationIcon::None)->show();
Expand Down
2 changes: 1 addition & 1 deletion src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace BetterInfo {
BI_DLL std::string fixNullByteCrash(std::string input);

BI_DLL void copyToClipboard(const char* text);
BI_DLL void copyToClipboard(const char* text, CCLayer* parent);
BI_DLL void copyToClipboard(const char* text, CCNode* parent);

BI_DLL std::string getSongUrl(int audioID);
BI_DLL bool isNewGrounds(int audioID);
Expand Down

0 comments on commit 4fd419f

Please sign in to comment.