MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / setupPage

Method setupPage

Source/GarageLayer.cpp:320–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318}
319
320void GarageLayer::setupPage(IconType type, int page)
321{
322 if (_selectSprite != nullptr)
323 GameToolbox::log("posx: {}, posy {}", _selectSprite->getPositionX(), _selectSprite->getPositionY());
324 GameToolbox::log("page: {}", page);
325 _selectedMode = type;
326 // aqui robtop hace cosas con funciones del gamemanager, ni idea
327 auto size = Director::getInstance()->getWinSize();
328
329 if (_menuIcons)
330 this->removeChild(_menuIcons);
331
332 _menuIcons = Menu::create();
333 _menuIcons->setPosition(0, 0);
334
335 float paddingX = 0, paddingY = 0;
336
337 //loop vars
338 int i = page * 36;
339 i++;
340 int max = std::clamp((page + 1) * 36, i, GameToolbox::getValueForGamemode(_selectedMode));
341 int selectedForGameMode = GameManager::getInstance()->getSelectedIcon(_selectedMode);
342 GameToolbox::log("selectedForGameMode: {}", selectedForGameMode);
343
344 if (_selectSprite != nullptr)
345 _selectSprite->setVisible(false);
346 GameToolbox::log("i: {}, max: {}", i, max);
347 for (;i <= max; i++)
348 {
349 if (i > GameToolbox::getValueForGamemode(type))
350 break;
351 GameToolbox::log("i: {}", i);
352 auto browserItem = Sprite::createWithSpriteFrameName("playerSquare_001.png");
353 browserItem->setOpacity(0);
354
355 if (type == IconType::kIconTypeSpecial)
356 {
357 auto icono = Sprite::createWithSpriteFrameName(StringUtils::format("player_special_%02d_001.png", i));
358 icono->setPosition(browserItem->getContentSize() / 2);
359 icono->setScale(27.0f / icono->getContentSize().width);
360 browserItem->addChild(icono);
361 }
362 else if (type == IconType::kIconTypeDeathEffect)
363 {
364 auto icono = Sprite::createWithSpriteFrameName(StringUtils::format("explosionIcon_%02d_001.png", i));
365 icono->setPosition(browserItem->getContentSize() / 2);
366 icono->setScale(0.9f);
367 browserItem->addChild(icono);
368 }
369 else
370 {
371 auto icono = SimplePlayer::create(0);
372 icono->updateGamemode(i, type);
373 icono->setMainColor({175, 175, 175});
374 icono->setPosition(browserItem->getContentSize() / 2);
375 if (type == IconType::kIconTypeUfo)
376 {
377 icono->setPositionY(icono->getPositionY() + 5);

Callers 1

setupIconSelectMethod · 0.95

Calls 9

logFunction · 0.85
createFunction · 0.85
setPositionMethod · 0.80
getSelectedIconMethod · 0.80
setOpacityMethod · 0.80
setScaleMethod · 0.80
updateGamemodeMethod · 0.80
setSelectedIconMethod · 0.80
setMainColorMethod · 0.45

Tested by

no test coverage detected