| 36 | UIScene::~UIScene() {} |
| 37 | |
| 38 | bool UIScene::init() |
| 39 | { |
| 40 | if (TestCase::init()) |
| 41 | { |
| 42 | _uiLayer = Layer::create(); |
| 43 | addChild(_uiLayer); |
| 44 | |
| 45 | _widget = dynamic_cast<Layout*>( |
| 46 | cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UITest/UITest.json")); |
| 47 | _uiLayer->addChild(_widget); |
| 48 | |
| 49 | Size screenSize = Director::getInstance()->getWinSize(); |
| 50 | Size rootSize = _widget->getContentSize(); |
| 51 | _uiLayer->setPosition(Vec2((screenSize.width - rootSize.width) / 2, (screenSize.height - rootSize.height) / 2)); |
| 52 | |
| 53 | // disable these widgets because they are conflict with menu items created in `TestCase` |
| 54 | |
| 55 | auto restartButton = Helper::seekWidgetByName(_widget, "middle_Button"); |
| 56 | restartButton->setVisible(false); |
| 57 | restartButton->setEnabled(false); |
| 58 | |
| 59 | auto leftButton = Helper::seekWidgetByName(_widget, "left_Button"); |
| 60 | leftButton->setVisible(false); |
| 61 | leftButton->setEnabled(false); |
| 62 | |
| 63 | auto rightButton = Helper::seekWidgetByName(_widget, "right_Button"); |
| 64 | rightButton->setVisible(false); |
| 65 | rightButton->setEnabled(false); |
| 66 | |
| 67 | Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)); |
| 68 | |
| 69 | _sceneTitle = dynamic_cast<Text*>(root->getChildByName("UItest")); |
| 70 | return true; |
| 71 | } |
| 72 | return false; |
| 73 | } |
| 74 | |
| 75 | void UIScene::onEnter() |
| 76 | { |
nothing calls this directly
no test coverage detected