| 84 | } |
| 85 | |
| 86 | bool LevelSearchLayer::init() |
| 87 | { |
| 88 | if (!Layer::init()) return false; |
| 89 | |
| 90 | auto winSize = Director::getInstance()->getWinSize(); |
| 91 | |
| 92 | GameToolbox::createBG(this); |
| 93 | GameToolbox::createCorners(this, false, false, true, true); |
| 94 | |
| 95 | auto backBtnMenu = Menu::create(); |
| 96 | auto backBtn = MenuItemSpriteExtra::create("GJ_arrow_01_001.png", [](Node*) { |
| 97 | // Director::getInstance()->replaceScene(TransitionFade::create(.5, CreatorLayer::scene())); |
| 98 | GameToolbox::popSceneWithTransition(0.5f); |
| 99 | }); |
| 100 | |
| 101 | backBtnMenu->addChild(backBtn); |
| 102 | backBtnMenu->setPosition({ 24.0, winSize.height - 23.0f }); |
| 103 | this->addChild(backBtnMenu); |
| 104 | |
| 105 | |
| 106 | // Search bar, search button |
| 107 | Vec2 searchPos{ winSize.width / 2, winSize.height / 2 + 130.0f }; |
| 108 | |
| 109 | auto searchBg = ui::Scale9Sprite::create(GameToolbox::getTextureString("square02b_001.png")); |
| 110 | searchBg->setOpacity(255); |
| 111 | searchBg->setContentSize({ 365.0, 40.0 }); |
| 112 | searchBg->setPosition(searchPos); |
| 113 | searchBg->setScale(1.0f); |
| 114 | searchBg->setColor({ 0, 56, 141 }); |
| 115 | this->addChild(searchBg); |
| 116 | |
| 117 | searchBg = ui::Scale9Sprite::create(GameToolbox::getTextureString("square02b_small.png")); |
| 118 | searchBg->setOpacity(255); |
| 119 | searchBg->setContentSize({ 210.0f, 30.0f }); |
| 120 | searchBg->setPosition({ searchPos.x - 73.0f, searchPos.y }); |
| 121 | searchBg->setScale(1.0f); |
| 122 | searchBg->setColor({ 0, 39, 98 }); |
| 123 | this->addChild(searchBg); |
| 124 | |
| 125 | _searchObject = GJSearchObject::create(); |
| 126 | addChild(_searchObject); |
| 127 | |
| 128 | auto menuSearch = Menu::create(); |
| 129 | auto searchBtn = MenuItemSpriteExtra::create(searchButton("GJ_longBtn02_001.png", "Search", 0.6, ""), AX_CALLBACK_1(LevelSearchLayer::onSearch, this)); |
| 130 | |
| 131 | searchBtn->setPosition(menuSearch->convertToNodeSpace({ searchPos.x + 84.0f, searchPos.y })); |
| 132 | menuSearch->addChild(searchBtn); |
| 133 | |
| 134 | auto searchProfileBtn = MenuItemSpriteExtra::create("GJ_longBtn05_001.png", AX_CALLBACK_1(LevelSearchLayer::onSearchProfile, this)); |
| 135 | searchProfileBtn->setPosition(menuSearch->convertToNodeSpace({ searchPos.x + 156.0f, searchPos.y })); |
| 136 | menuSearch->addChild(searchProfileBtn); |
| 137 | this->addChild(menuSearch); |
| 138 | |
| 139 | _searchField = TextInputNode::create(194.0f, 50.0f, GameToolbox::getTextureString("bigFont.fnt").c_str(), "Enter a level, user or id", 0x18); |
| 140 | _searchField->setPosition({ searchPos.x - 174.0f, searchPos.y }); |
| 141 | _searchField->setAnchorPoint({ 0.0, 0.5 }); |
| 142 | |
| 143 | auto sfTextField = _searchField->getTextField(); |
nothing calls this directly
no test coverage detected