| 175 | |
| 176 | |
| 177 | void ProfilePage::loadPageFromUserInfo(GJUserScore* score) // replace with 'GJUserScore* score' |
| 178 | { |
| 179 | const auto& winSize = Director::getInstance()->getWinSize(); |
| 180 | |
| 181 | //GameToolbox::limitLabelWidth(playerName, 185.0f, 0.9f, 0.0f); |
| 182 | |
| 183 | auto playerStatsNode = Node::create(); |
| 184 | std::string_view statSpriteName; |
| 185 | |
| 186 | bool hasCP = score->_creatorpoints > 0; |
| 187 | int statValue; |
| 188 | ax::Vec2 initialPos = ax::Vec2::ZERO; |
| 189 | |
| 190 | float v16 = 0.0f; |
| 191 | |
| 192 | for (int i = 0; i < (hasCP ? 6 : 5); i++) |
| 193 | { |
| 194 | switch (i) |
| 195 | { |
| 196 | case 1: |
| 197 | statSpriteName = "GJ_diamondsIcon_001.png"; |
| 198 | statValue = score->_diamonds; |
| 199 | break; |
| 200 | case 2: |
| 201 | statSpriteName = "GJ_coinsIcon_001.png"; |
| 202 | statValue = score->_secretCoins; |
| 203 | break; |
| 204 | case 3: |
| 205 | statSpriteName = "GJ_coinsIcon2_001.png"; |
| 206 | statValue = score->_usercoins; |
| 207 | break; |
| 208 | case 4: |
| 209 | statSpriteName = "GJ_demonIcon_001.png"; |
| 210 | statValue = score->_demons; |
| 211 | break; |
| 212 | case 5: |
| 213 | statSpriteName = "GJ_hammerIcon_001.png"; |
| 214 | statValue = score->_creatorpoints; |
| 215 | break; |
| 216 | default: |
| 217 | statSpriteName = "GJ_starsIcon_001.png"; |
| 218 | statValue = score->_stars; |
| 219 | break; |
| 220 | } |
| 221 | int widthLimit = hasCP ? 50 : 60; |
| 222 | std::string bigFontStr = GameToolbox::getTextureString("bigFont.fnt"); |
| 223 | auto statLabel = Label::createWithBMFont(bigFontStr, std::to_string(statValue)); |
| 224 | GameToolbox::limitLabelWidth(statLabel, widthLimit, 0.6, 0.0); |
| 225 | statLabel->setAnchorPoint({0.0f, 0.5f}); |
| 226 | statLabel->setScale(0.6f); |
| 227 | statLabel->setPosition(initialPos); |
| 228 | playerStatsNode->addChild(statLabel); |
| 229 | |
| 230 | auto statSprite = Sprite::createWithSpriteFrameName(statSpriteName); |
| 231 | playerStatsNode->addChild(statSprite); |
| 232 | |
| 233 | auto labelPos = statLabel->getPosition(); |
| 234 | auto scaledContentSize = statLabel->getContentSize(); |
nothing calls this directly
no test coverage detected