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

Method init

Source/InfoLayer.cpp:49–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49bool InfoLayer::init(GJGameLevel* level)
50{
51 if (!PopupLayer::init()) return false;
52 const auto& winSize = Director::getInstance()->getWinSize();
53
54 auto bg = ui::Scale9Sprite::create(GameToolbox::getTextureString("GJ_square01.png"));
55 bg->setContentSize({ 420.0, 260.0 });
56
57 bg->setPosition(winSize / 2);
58
59 this->_mainLayer->addChild(bg);
60
61 auto closeBtnMenu = Menu::create();
62 auto closeBtn = MenuItemSpriteExtra::create(Sprite::createWithSpriteFrameName("GJ_closeBtn_001.png"), [&](Node*) {this->close();});
63 closeBtnMenu->addChild(closeBtn);
64 closeBtnMenu->setPosition({ 0, 0 });
65
66 closeBtn->setPosition({ (winSize.width / 2) - 200.0f, (winSize.height / 2.0f) + 120.f});
67
68 this->_mainLayer->addChild(closeBtnMenu);
69
70
71 auto levelName = Label::createWithBMFont(GameToolbox::getTextureString("bigFont.fnt"), level->_levelName);
72 levelName->setPosition({ winSize.width / 2, (winSize.height / 2) + 105.f });
73
74 if (levelName->getContentSize().width > 300.0f)
75 {
76 levelName->setScale(300.0f / levelName->getContentSize().width);
77 }
78
79 this->_mainLayer->addChild(levelName);
80
81 auto levelCreator = Label::createWithBMFont(GameToolbox::getTextureString("goldFont.fnt"), fmt::format("By {}", level->_levelCreator));
82 levelCreator->setPosition({ winSize.width / 2, levelName->getPositionY() - 30.f });
83
84 if (levelCreator->getContentSize().width > 300.0f)
85 {
86 levelCreator->setScale(300.0f / levelCreator->getContentSize().width);
87 }
88 if (levelCreator->getScale() > 0.8)
89 {
90 levelCreator->setScale(0.8);
91 }
92
93 this->_mainLayer->addChild(levelCreator);
94
95
96 auto desc = level->_description.empty() ? "(No description provided)" : base64_decode(level->_description);
97
98 auto descField = ax::ui::UICCTextField::createWithBMFont(GameToolbox::getTextureString("chatFont.fnt"), desc, TextHAlignment::CENTER, 380.f);
99 descField->setPosition({ winSize.width / 2, (winSize.height / 2) + 10.f /*+ 20.f */});
100 this->_mainLayer->addChild(descField, 4);
101
102 auto moreBtnMenu = Menu::create();
103
104 auto moreBtn = MenuItemSpriteExtra::create(ButtonSprite::create("More by this user", 0xDC, 0, 0.6, false, GameToolbox::getTextureString("bigFont.fnt"), GameToolbox::getTextureString("GJ_button_01.png"), 30), [](Node*) {});
105 moreBtnMenu->addChild(moreBtn);
106 moreBtnMenu->setPosition({ winSize.width / 2, (winSize.height / 2) - 70.f });

Callers 1

createMethod · 0.45

Calls 6

createFunction · 0.85
base64_decodeFunction · 0.85
setPositionMethod · 0.80
setScaleMethod · 0.80
emptyMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected