diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp index f112b125a1..cf3fc88605 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp @@ -181,7 +181,11 @@ ActionTimeline* ActionTimeline::clone() const newAction->addTimeline(newTimeline); } } - + + for( auto info : _animationInfos) + { + newAction->addAnimationInfo(info.second); + } return newAction; } diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp index fc2227f5d1..a68d3af35b 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp @@ -481,6 +481,9 @@ InnerActionFrame::InnerActionFrame() void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex) { auto innerActiontimeline = static_cast(_node->getActionByTag(_node->getTag())); + if( nullptr == innerActiontimeline) + return; + if (InnerActionType::SingleFrame == _innerActionType) { innerActiontimeline->gotoFrameAndPause(_singleFrameIndex); diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp index 7fceedb098..5d14a35363 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp @@ -833,20 +833,24 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree) auto projectNodeOptions = (ProjectNodeOptions*)options->data(); std::string filePath = projectNodeOptions->fileName()->c_str(); CCLOG("filePath = %s", filePath.c_str()); + + cocostudio::timeline::ActionTimeline* action = nullptr; if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath)) { - node = createNodeWithFlatBuffersFile(filePath); - reader->setPropsWithFlatBuffers(node, options->data()); - - cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath); - if (action) - { - node->runAction(action); - action->gotoFrameAndPause(0); - } + action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath); } + else + { + node = Node::create(); + } + reader->setPropsWithFlatBuffers(node, options->data()); + if (action) + { + node->runAction(action); + action->gotoFrameAndPause(0); + } } else if (classname == "SimpleAudio") { @@ -1164,17 +1168,22 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod std::string filePath = projectNodeOptions->fileName()->c_str(); CCLOG("filePath = %s", filePath.c_str()); + cocostudio::timeline::ActionTimeline* action = nullptr; if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath)) { - node = createNodeWithFlatBuffersForSimulator(filePath); - reader->setPropsWithFlatBuffers(node, options->data()); + node = createNodeWithFlatBuffersFile(filePath); + action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath); - cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator(filePath); - if (action) - { - node->runAction(action); - action->gotoFrameAndPause(0); - } + } + else + { + node = Node::create(); + } + reader->setPropsWithFlatBuffers(node, options->data()); + if (action) + { + node->runAction(action); + action->gotoFrameAndPause(0); } } else if (classname == "SimpleAudio") diff --git a/cocos/scripting/lua-bindings/auto/api/EditBox.lua b/cocos/scripting/lua-bindings/auto/api/EditBox.lua index ca9abc6723..82e27b5b40 100644 --- a/cocos/scripting/lua-bindings/auto/api/EditBox.lua +++ b/cocos/scripting/lua-bindings/auto/api/EditBox.lua @@ -254,6 +254,12 @@ -- @param #vec2_table anchorPoint -- @return EditBox#EditBox self (return value: ccui.EditBox) +-------------------------------- +-- Returns the "class name" of widget. +-- @function [parent=#EditBox] getDescription +-- @param self +-- @return string#string ret (return value: string) + -------------------------------- -- -- @function [parent=#EditBox] setPosition diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 7847428e18..45ef0531a4 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -449,15 +449,9 @@ void Button::onPressStateChangedToPressed() _buttonNormalRenderer->setScale(_pressedTextureScaleXInSize + _zoomScale, _pressedTextureScaleYInSize + _zoomScale); _titleRenderer->stopAllActions(); + Action *zoomTitleAction = ScaleTo::create(ZOOM_ACTION_TIME_STEP, 1.0f + _zoomScale, 1.0f + _zoomScale); - if (_unifySize) - { - _titleRenderer->runAction(zoomTitleAction); - } - else - { - _titleRenderer->runAction(zoomTitleAction->clone()); - } + _titleRenderer->runAction(zoomTitleAction); } } else diff --git a/cocos/ui/UIEditBox/UIEditBox.cpp b/cocos/ui/UIEditBox/UIEditBox.cpp index 73a504930d..6d71191916 100644 --- a/cocos/ui/UIEditBox/UIEditBox.cpp +++ b/cocos/ui/UIEditBox/UIEditBox.cpp @@ -385,6 +385,11 @@ void EditBox::setAnchorPoint(const Vec2& anchorPoint) } } +std::string EditBox::getDescription() const +{ + return "EditBox"; +} + void EditBox::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { Widget::visit(renderer, parentTransform, parentFlags); diff --git a/cocos/ui/UIEditBox/UIEditBox.h b/cocos/ui/UIEditBox/UIEditBox.h index 72af4a2627..d35e27d60e 100644 --- a/cocos/ui/UIEditBox/UIEditBox.h +++ b/cocos/ui/UIEditBox/UIEditBox.h @@ -394,6 +394,12 @@ namespace ui { virtual void setVisible(bool visible) override; virtual void setContentSize(const Size& size) override; virtual void setAnchorPoint(const Vec2& anchorPoint) override; + + /** + * Returns the "class name" of widget. + */ + virtual std::string getDescription() const override; + /** * @js NA * @lua NA diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index 917a07e3ed..7910dc6899 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -193,6 +193,8 @@ void LoadingBar::loadTexture(const std::string& texture,TextureResType texType) barRendererScaleChangedWithSize(); updateContentSizeWithTextureSize(_barRendererTextureSize); + + this->updateProgressBar(); _barRendererAdaptDirty = true; } @@ -216,7 +218,7 @@ void LoadingBar::setScale9Enabled(bool enabled) ignoreContentAdaptWithSize(_prevIgnoreSize); } setCapInsets(_capInsets); - setPercent(_percent); + this->updateProgressBar(); _barRendererAdaptDirty = true; } @@ -255,18 +257,24 @@ void LoadingBar::setPercent(float percent) return; } _percent = percent; + if (_totalLength <= 0) { return; } - float res = _percent / 100.0f; + this->updateProgressBar(); +} + +void LoadingBar::updateProgressBar() +{ if (_scale9Enabled) { setScale9Scale(); } else { + float res = _percent / 100.0f; Sprite* spriteRenderer = _barRenderer->getSprite(); Rect rect = spriteRenderer->getTextureRect(); rect.size.width = _barRendererTextureSize.width * res; @@ -334,7 +342,7 @@ void LoadingBar::barRendererScaleChangedWithSize() _totalLength = _contentSize.width; if (_scale9Enabled) { - setScale9Scale(); + this->setScale9Scale(); _barRenderer->setScale(1.0f); } else diff --git a/cocos/ui/UILoadingBar.h b/cocos/ui/UILoadingBar.h index 058ce793ac..3a961c0f29 100644 --- a/cocos/ui/UILoadingBar.h +++ b/cocos/ui/UILoadingBar.h @@ -148,6 +148,7 @@ protected: virtual void onSizeChanged() override; void setScale9Scale(); + void updateProgressBar(); void barRendererScaleChangedWithSize(); virtual void adaptRenderers() override; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp index 0a63ebbf5f..b5489b4451 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp @@ -139,7 +139,7 @@ g_guisTests[] = UISceneManager* sceneManager = UISceneManager::sharedUISceneManager(); sceneManager->setCurrentUISceneId(kUILoadingBarTest_Left); sceneManager->setMinUISceneId(kUILoadingBarTest_Left); - sceneManager->setMaxUISceneId(kUILoadingBarTest_Right_Scale9); + sceneManager->setMaxUISceneId(kUILoadingBarReloadTexture); Scene* scene = sceneManager->currentUIScene(); Director::getInstance()->replaceScene(scene); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index 94e1062365..fcf8ed7580 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -396,4 +396,90 @@ bool UILoadingBarTest_Scale9_State_Change::init() return true; } return false; +} + + +// UILoadingBarReloadTexture + +UILoadingBarReloadTexture::UILoadingBarReloadTexture() +: _count(0) +{ + +} + +UILoadingBarReloadTexture::~UILoadingBarReloadTexture() +{ + +} + +bool UILoadingBarReloadTexture::init() +{ + if (UIScene::init()) + { + Size widgetSize = _widget->getContentSize(); + + // Add the alert + Text *alert = Text::create("Click button to Toggle Scale9 and switch Texture.", "fonts/Marker Felt.ttf", 20); + alert->setColor(Color3B(159, 168, 176)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, + widgetSize.height / 2.0f - alert->getContentSize().height * 2.7f)); + _uiLayer->addChild(alert); + + LoadingBar* loadingBar = LoadingBar::create("cocosui/slider_bar_active_9patch.png"); + loadingBar->setTag(0); + loadingBar->ignoreContentAdaptWithSize(false); +// loadingBar->setScale9Enabled(true); + loadingBar->setCapInsets(Rect(0, 0, 0, 0)); + loadingBar->setContentSize(Size(300, 13)); + loadingBar->setName("texture0"); + loadingBar->setDirection(LoadingBar::Direction::RIGHT); + loadingBar->setPercent(70); + loadingBar->setPosition(Vec2(widgetSize.width / 2.0f, + widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f)); + + _uiLayer->addChild(loadingBar); + + auto buttonScale9 = Button::create("cocosui/animationbuttonnormal.png", + "cocosui/animationbuttonpressed.png"); + buttonScale9->setTitleText("ToggleScale9"); + buttonScale9->addClickEventListener([=](Ref*){ + loadingBar->setScale9Enabled(!loadingBar->isScale9Enabled()); + }); + buttonScale9->setPosition(loadingBar->getPosition() + Vec2(-50,50)); + _uiLayer->addChild(buttonScale9); + + auto buttonChangeTexture = Button::create("cocosui/animationbuttonnormal.png", + "cocosui/animationbuttonpressed.png"); + buttonChangeTexture->setTitleText("ChangeTexture"); + buttonChangeTexture->addClickEventListener([=](Ref*){ + auto name = loadingBar->getName(); + if (name == "texture0") + { + loadingBar->loadTexture("cocosui/slider_bar_active_9patch2.png"); + loadingBar->setName("texture1"); + } + else + { + loadingBar->loadTexture("cocosui/slider_bar_active_9patch.png"); + loadingBar->setName("texture0"); + } + }); + buttonChangeTexture->setPosition(loadingBar->getPosition() + Vec2(50,50)); + _uiLayer->addChild(buttonChangeTexture); + + this->scheduleUpdate(); + return true; + } + return false; +} + +void UILoadingBarReloadTexture::update(float delta) +{ + _count++; + if (_count > 100) + { + _count = 0; + } + LoadingBar* loadingBar = static_cast(_uiLayer->getChildByTag(0)); + loadingBar->setPercent(_count); } \ No newline at end of file diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h index c6c8a4d56a..79428689b4 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h @@ -104,7 +104,21 @@ public: protected: UI_SCENE_CREATE_FUNC(UILoadingBarTest_Scale9_State_Change) - int _count; + int _count; +}; + +class UILoadingBarReloadTexture : public UIScene +{ +public: + UILoadingBarReloadTexture(); + ~UILoadingBarReloadTexture(); + void update(float dt); + bool init(); + +protected: + UI_SCENE_CREATE_FUNC(UILoadingBarReloadTexture); + int _count; + }; #endif /* defined(__TestCpp__UILoadingBarTest__) */ diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp index 5de0885b90..90439e937a 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp @@ -71,6 +71,7 @@ static const char* s_testArray[] = "UILoadingBarTest_Scale9_State_Change", "UILoadingBarTest_Left_Scale9", "UILoadingBarTest_Right_Scale9", + "UILoadingBarReloadTexture", "UITextAtlasTest", "UITextTest", @@ -284,6 +285,8 @@ Scene *UISceneManager::currentUIScene() case kUILoadingBarTest_Right_Scale9: return UILoadingBarTest_Right_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]); + case kUILoadingBarReloadTexture: + return UILoadingBarReloadTexture::sceneWithTitle(s_testArray[_currentUISceneId]); case kUITextAtlasTest: return UITextAtlasTest::sceneWithTitle(s_testArray[_currentUISceneId]); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h index f0613a2680..52df15c65d 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h @@ -66,6 +66,7 @@ enum kUILoadingBarTest_Scale9_State_Change, kUILoadingBarTest_Left_Scale9, kUILoadingBarTest_Right_Scale9, + kUILoadingBarReloadTexture, kUITextAtlasTest, kUITextTest, kUITextTest_LineWrap, diff --git a/tests/cpp-tests/Resources/ccs-res b/tests/cpp-tests/Resources/ccs-res index 615f52a6c5..ce5606d4e5 160000 --- a/tests/cpp-tests/Resources/ccs-res +++ b/tests/cpp-tests/Resources/ccs-res @@ -1 +1 @@ -Subproject commit 615f52a6c5fc1f60c6f01832d110c78a65be3a11 +Subproject commit ce5606d4e520d2671a678b0ba3d5a0b84fdb5ab9