| 58 | } |
| 59 | |
| 60 | bool ProfilePage::init(int accountID, bool mainMenuProfile) |
| 61 | { |
| 62 | GameToolbox::log("{}", accountID); |
| 63 | if (!PopupLayer::init()) return false; |
| 64 | const auto& winSize = Director::getInstance()->getWinSize(); |
| 65 | _accountID = accountID; |
| 66 | |
| 67 | auto bg = ui::Scale9Sprite::create(GameToolbox::getTextureString("GJ_square01.png")); |
| 68 | bg->setContentSize({ 440.0, 290.0 }); |
| 69 | bg->setPosition(winSize / 2); |
| 70 | |
| 71 | _mainLayer->addChild(bg); |
| 72 | |
| 73 | auto playerName = Label::createWithBMFont(GameToolbox::getTextureString("bigFont.fnt"), "Hello World"); |
| 74 | ax::Vec2 playerNamePos { winSize.width / 2, ((winSize.height / 2) + 145.0f) - 20.0f}; |
| 75 | playerName->setPosition(playerNamePos); |
| 76 | GameToolbox::limitLabelWidth(playerName, 185.0f, 0.9f, 0.0f); |
| 77 | |
| 78 | _mainLayer->addChild(playerName); |
| 79 | |
| 80 | auto floorLine = Sprite::createWithSpriteFrameName("floorLine_001.png"); |
| 81 | floorLine->setOpacity(100); |
| 82 | floorLine->setScaleX(0.8f); |
| 83 | playerNamePos.y -= 21.0f; |
| 84 | floorLine->setPosition(playerNamePos); |
| 85 | |
| 86 | _mainLayer->addChild(floorLine); |
| 87 | |
| 88 | // TODO: GJCommentListLayer position: -170.0f,-22.5f; |
| 89 | |
| 90 | auto closeBtnSprite = Sprite::createWithSpriteFrameName("GJ_closeBtn_001.png"); |
| 91 | auto closeBtn = MenuItemSpriteExtra::create(closeBtnSprite, [&](Node*) { this->close(); }); |
| 92 | |
| 93 | auto menu = Menu::create(); |
| 94 | menu->setPosition((winSize.width / 2 - 220.0f) + 10.0f, ((winSize.y / 2) + 145.0f) - 10.0f ); |
| 95 | menu->addChild(closeBtn); |
| 96 | |
| 97 | _errorMsg = Label::createWithBMFont(GameToolbox::getTextureString("goldFont.fnt"), "Something went wrong..."); |
| 98 | _errorMsg->setScale(0.6f); |
| 99 | _errorMsg->setPosition({ winSize.width / 2, winSize.height / 2 - 53.0f}); |
| 100 | _errorMsg->setVisible(false); |
| 101 | |
| 102 | _mainLayer->addChild(_errorMsg); |
| 103 | |
| 104 | auto gm = GameManager::getInstance(); |
| 105 | if (!mainMenuProfile) |
| 106 | { |
| 107 | bool isFollowingUser = gm->isFollowingUser(accountID); |
| 108 | const char* heartSprite = isFollowingUser ? "gj_heartOn_001.png" : "gj_heartOff_001.png"; |
| 109 | auto heartObject = MenuItemSpriteExtra::create(heartSprite, [this](Node* btn) |
| 110 | { |
| 111 | bool isFollowingUser = static_cast<bool>(btn->getTag()); |
| 112 | //if(isFollowingUser) { |
| 113 | // GameManager::getInstance()->followUser(this->_accountID); |
| 114 | //} |
| 115 | //else { |
| 116 | // GameManager::getInstance()->unfollowUser(this->_accountID); |
| 117 | //} |
no test coverage detected