mirror of https://github.com/axmolengine/axmol.git
Merge pull request #14632 from liamcindy/UITest
update for ui resource test
This commit is contained in:
commit
2881ce7c40
|
@ -75,7 +75,15 @@ bool UIButtonTest::init()
|
|||
|
||||
_uiLayer->addChild(imageView);
|
||||
|
||||
_button = button;
|
||||
|
||||
TTFConfig ttfConfig("fonts/arial.ttf", 15);
|
||||
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
|
||||
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIButtonTest::printWidgetResources, this));
|
||||
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
|
||||
auto pMenu1 = Menu::create(item1, nullptr);
|
||||
pMenu1->setPosition(Vec2(0, 0));
|
||||
this->addChild(pMenu1, 10);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -117,6 +125,16 @@ void UIButtonTest::touchEvent(Ref *pSender, Widget::TouchEventType type)
|
|||
}
|
||||
}
|
||||
|
||||
void UIButtonTest::printWidgetResources(cocos2d::Ref* sender)
|
||||
{
|
||||
cocos2d::ResourceData normalFileName = _button->getNormalFile();
|
||||
CCLOG("normalFileName Name : %s, Type: %d", normalFileName.file.c_str(), normalFileName.type);
|
||||
cocos2d::ResourceData clickedFileName = _button->getPressedFile();
|
||||
CCLOG("clickedFileName Name : %s, Type: %d", clickedFileName.file.c_str(), clickedFileName.type);
|
||||
cocos2d::ResourceData disabledFileName = _button->getDisabledFile();
|
||||
CCLOG("disabledFileName Name : %s, Type: %d", disabledFileName.file.c_str(), disabledFileName.type);
|
||||
}
|
||||
|
||||
|
||||
// UIButtonTest_Scale9
|
||||
UIButtonTest_Scale9::UIButtonTest_Scale9()
|
||||
|
|
|
@ -40,8 +40,10 @@ public:
|
|||
virtual bool init() override;
|
||||
void touchEvent(cocos2d::Ref* sender, cocos2d::ui::Widget::TouchEventType type);
|
||||
|
||||
void printWidgetResources(cocos2d::Ref* sender);
|
||||
protected:
|
||||
cocos2d::ui::Text* _displayValueLabel;
|
||||
cocos2d::ui::Button* _button;
|
||||
};
|
||||
|
||||
class UIButtonTest_Scale9 : public UIScene
|
||||
|
|
|
@ -40,15 +40,23 @@ bool UICheckBoxTest::init()
|
|||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the checkbox
|
||||
CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png",
|
||||
_checkBox = CheckBox::create("cocosui/check_box_normal.png",
|
||||
"cocosui/check_box_normal_press.png",
|
||||
"cocosui/check_box_active.png",
|
||||
"cocosui/check_box_normal_disable.png",
|
||||
"cocosui/check_box_active_disable.png");
|
||||
checkBox->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||
_checkBox->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||
|
||||
checkBox->addEventListener(CC_CALLBACK_2(UICheckBoxTest::selectedEvent, this));
|
||||
_uiLayer->addChild(checkBox);
|
||||
_checkBox->addEventListener(CC_CALLBACK_2(UICheckBoxTest::selectedEvent, this));
|
||||
_uiLayer->addChild(_checkBox);
|
||||
|
||||
TTFConfig ttfConfig("fonts/arial.ttf", 15);
|
||||
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
|
||||
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UICheckBoxTest::printWidgetResources, this));
|
||||
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
|
||||
auto pMenu1 = Menu::create(item1, nullptr);
|
||||
pMenu1->setPosition(Vec2(0, 0));
|
||||
this->addChild(pMenu1, 10);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -73,6 +81,20 @@ void UICheckBoxTest::selectedEvent(Ref* pSender,CheckBox::EventType type)
|
|||
|
||||
}
|
||||
|
||||
void UICheckBoxTest::printWidgetResources(cocos2d::Ref* sender)
|
||||
{
|
||||
cocos2d::ResourceData backGroundFileName = _checkBox->getBackNormalFile();
|
||||
CCLOG("backGroundFile Name : %s, Type: %d", backGroundFileName.file.c_str(),backGroundFileName.type);
|
||||
cocos2d::ResourceData backGroundSelectedFileName = _checkBox->getBackPressedFile();
|
||||
CCLOG("backGroundSelectedFile Name : %s, Type: %d", backGroundSelectedFileName.file.c_str(), backGroundSelectedFileName.type);
|
||||
cocos2d::ResourceData backGroundDisabledFileName = _checkBox->getBackDisabledFile();
|
||||
CCLOG("backGroundDisabledFile Name : %s, Type: %d", backGroundDisabledFileName.file.c_str(), backGroundDisabledFileName.type);
|
||||
cocos2d::ResourceData frontCrossFileName = _checkBox->getCrossNormalFile();
|
||||
CCLOG("frontCrossFile Name : %s, Type: %d", frontCrossFileName.file.c_str(), frontCrossFileName.type);
|
||||
cocos2d::ResourceData frontCrossDisabledFileName = _checkBox->getCrossDisabledFile();
|
||||
CCLOG("frontCrossDisabledFile Name : %s, Type: %d", frontCrossDisabledFileName.file.c_str(), frontCrossDisabledFileName.type);
|
||||
}
|
||||
|
||||
|
||||
// UICheckBoxDefaultBehaviorTest
|
||||
UICheckBoxDefaultBehaviorTest::UICheckBoxDefaultBehaviorTest()
|
||||
|
|
|
@ -40,8 +40,10 @@ public:
|
|||
virtual bool init() override;
|
||||
void selectedEvent(cocos2d::Ref* sender,cocos2d::ui::CheckBox::EventType type);
|
||||
|
||||
void printWidgetResources(cocos2d::Ref* sender);
|
||||
protected:
|
||||
cocos2d::ui::Text* _displayValueLabel;
|
||||
cocos2d::ui::CheckBox* _checkBox;
|
||||
};
|
||||
|
||||
class UICheckBoxDefaultBehaviorTest : public UIScene
|
||||
|
|
|
@ -35,13 +35,26 @@ bool UIImageViewTest::init()
|
|||
|
||||
_uiLayer->addChild(imageView);
|
||||
|
||||
|
||||
_image = imageView;
|
||||
|
||||
TTFConfig ttfConfig("fonts/arial.ttf", 15);
|
||||
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
|
||||
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIImageViewTest::printWidgetResources, this));
|
||||
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
|
||||
auto pMenu1 = Menu::create(item1, nullptr);
|
||||
pMenu1->setPosition(Vec2(0, 0));
|
||||
this->addChild(pMenu1, 10);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UIImageViewTest::printWidgetResources(cocos2d::Ref* sender)
|
||||
{
|
||||
cocos2d::ResourceData textureFile = _image->getRenderFile();
|
||||
CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
|
||||
}
|
||||
|
||||
// UIImageViewTest_Scale9
|
||||
|
||||
|
|
|
@ -35,6 +35,10 @@ public:
|
|||
CREATE_FUNC(UIImageViewTest);
|
||||
|
||||
virtual bool init() override;
|
||||
|
||||
void printWidgetResources(cocos2d::Ref* sender);
|
||||
protected:
|
||||
cocos2d::ui::ImageView* _image;
|
||||
};
|
||||
|
||||
class UIImageViewTest_Scale9 : public UIScene
|
||||
|
|
|
@ -264,12 +264,28 @@ bool UILayoutTest_BackGroundImage::init()
|
|||
button_scale9->getContentSize().height / 2.0f));
|
||||
|
||||
layout->addChild(button_scale9);
|
||||
|
||||
_layout = layout;
|
||||
|
||||
TTFConfig ttfConfig("fonts/arial.ttf", 15);
|
||||
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
|
||||
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILayoutTest_BackGroundImage::printWidgetResources, this));
|
||||
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
|
||||
auto pMenu1 = Menu::create(item1, nullptr);
|
||||
pMenu1->setPosition(Vec2(0, 0));
|
||||
this->addChild(pMenu1, 10);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UILayoutTest_BackGroundImage::printWidgetResources(cocos2d::Ref* sender)
|
||||
{
|
||||
cocos2d::ResourceData textureFile = _layout->getRenderFile();
|
||||
CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
|
||||
}
|
||||
|
||||
// UILayoutTest_BackGroundImage_Scale9
|
||||
|
||||
UILayoutTest_BackGroundImage_Scale9::UILayoutTest_BackGroundImage_Scale9()
|
||||
|
|
|
@ -67,6 +67,10 @@ public:
|
|||
virtual bool init() override;
|
||||
|
||||
CREATE_FUNC(UILayoutTest_BackGroundImage);
|
||||
|
||||
void printWidgetResources(cocos2d::Ref* sender);
|
||||
protected:
|
||||
cocos2d::ui::Layout* _layout;
|
||||
};
|
||||
|
||||
class UILayoutTest_BackGroundImage_Scale9 : public UIScene
|
||||
|
|
|
@ -79,6 +79,16 @@ bool UILoadingBarTest_Left::init()
|
|||
_uiLayer->addChild(loadingBar,1);
|
||||
_uiLayer->addChild(loadingBarCopy,2);
|
||||
_uiLayer->addChild(button);
|
||||
|
||||
_loadingBar = loadingBar;
|
||||
|
||||
TTFConfig ttfConfig("fonts/arial.ttf", 15);
|
||||
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
|
||||
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILoadingBarTest_Left::printWidgetResources, this));
|
||||
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
|
||||
auto pMenu1 = Menu::create(item1, nullptr);
|
||||
pMenu1->setPosition(Vec2(0, 0));
|
||||
this->addChild(pMenu1, 10);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -98,6 +108,12 @@ void UILoadingBarTest_Left::update(float delta)
|
|||
loadingBarCopy->setPercent(_count);
|
||||
}
|
||||
|
||||
void UILoadingBarTest_Left::printWidgetResources(cocos2d::Ref* sender)
|
||||
{
|
||||
cocos2d::ResourceData textureFile = _loadingBar->getRenderFile();
|
||||
CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
|
||||
}
|
||||
|
||||
// UILoadingBarTest_Right
|
||||
|
||||
UILoadingBarTest_Right::UILoadingBarTest_Right()
|
||||
|
@ -493,4 +509,4 @@ void UILoadingBarIssue12249::update(float delta)
|
|||
LoadingBar* loadingBarCopy = static_cast<LoadingBar*>(_uiLayer->getChildByTag(1));
|
||||
loadingBar->setPercent(_count);
|
||||
loadingBarCopy->setPercent(_count);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,9 +38,11 @@ public:
|
|||
~UILoadingBarTest_Left();
|
||||
virtual bool init() override;
|
||||
void update(float delta)override;
|
||||
void printWidgetResources(cocos2d::Ref* sender);
|
||||
|
||||
protected:
|
||||
int _count;
|
||||
cocos2d::ui::LoadingBar* _loadingBar;
|
||||
};
|
||||
|
||||
class UILoadingBarTest_Right : public UIScene
|
||||
|
|
|
@ -54,6 +54,15 @@ bool UISliderTest::init()
|
|||
slider->addEventListener(CC_CALLBACK_2(UISliderTest::sliderEvent, this));
|
||||
_uiLayer->addChild(slider);
|
||||
|
||||
_slider = slider;
|
||||
|
||||
TTFConfig ttfConfig("fonts/arial.ttf", 15);
|
||||
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
|
||||
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UISliderTest::printWidgetResources, this));
|
||||
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
|
||||
auto pMenu1 = Menu::create(item1, nullptr);
|
||||
pMenu1->setPosition(Vec2(0, 0));
|
||||
this->addChild(pMenu1, 10);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -70,6 +79,19 @@ void UISliderTest::sliderEvent(Ref *pSender, Slider::EventType type)
|
|||
_displayValueLabel->setString(StringUtils::format("Percent %f", 10000.0 * percent / maxPercent));
|
||||
}
|
||||
}
|
||||
void UISliderTest::printWidgetResources(cocos2d::Ref* sender)
|
||||
{
|
||||
cocos2d::ResourceData textureFile = _slider->getBackFile();
|
||||
CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
|
||||
cocos2d::ResourceData progressBarTextureFile = _slider->getProgressBarFile();
|
||||
CCLOG("progressBarTextureFile Name : %s, Type: %d", progressBarTextureFile.file.c_str(), progressBarTextureFile.type);
|
||||
cocos2d::ResourceData slidBallNormalTextureFile = _slider->getBallNormalFile();
|
||||
CCLOG("slidBallNormalTextureFile Name : %s, Type: %d", slidBallNormalTextureFile.file.c_str(), slidBallNormalTextureFile.type);
|
||||
cocos2d::ResourceData slidBallPressedTextureFile = _slider->getBallPressedFile();
|
||||
CCLOG("slidBallPressedTextureFile Name : %s, Type: %d", slidBallPressedTextureFile.file.c_str(), slidBallPressedTextureFile.type);
|
||||
cocos2d::ResourceData slidBallDisabledTextureFile = _slider->getBallDisabledFile();
|
||||
CCLOG("slidBallDisabledTextureFile Name : %s, Type: %d", slidBallDisabledTextureFile.file.c_str(), slidBallDisabledTextureFile.type);
|
||||
}
|
||||
|
||||
// UISliderTest_Scale9
|
||||
|
||||
|
|
|
@ -38,9 +38,11 @@ public:
|
|||
~UISliderTest();
|
||||
virtual bool init() override;
|
||||
void sliderEvent(cocos2d::Ref* sender, cocos2d::ui::Slider::EventType type);
|
||||
void printWidgetResources(cocos2d::Ref* sender);
|
||||
|
||||
protected:
|
||||
cocos2d::ui::TextBMFont* _displayValueLabel;
|
||||
cocos2d::ui::Slider* _slider;
|
||||
};
|
||||
|
||||
class UISliderTest_Scale9 : public UIScene
|
||||
|
|
|
@ -34,7 +34,21 @@ bool UITextAtlasTest::init()
|
|||
textAtlas->setPosition(Vec2((widgetSize.width) / 2, widgetSize.height / 2.0f));
|
||||
_uiLayer->addChild(textAtlas);
|
||||
|
||||
_textAtlas = textAtlas;
|
||||
|
||||
TTFConfig ttfConfig("fonts/arial.ttf", 15);
|
||||
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
|
||||
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextAtlasTest::printWidgetResources, this));
|
||||
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
|
||||
auto pMenu1 = Menu::create(item1, nullptr);
|
||||
pMenu1->setPosition(Vec2(0, 0));
|
||||
this->addChild(pMenu1, 10);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void UITextAtlasTest::printWidgetResources(cocos2d::Ref* sender)
|
||||
{
|
||||
cocos2d::ResourceData textureFile = _textAtlas->getRenderFile();
|
||||
CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@ public:
|
|||
CREATE_FUNC(UITextAtlasTest);
|
||||
|
||||
virtual bool init() override;
|
||||
void printWidgetResources(cocos2d::Ref* sender);
|
||||
protected:
|
||||
cocos2d::ui::TextAtlas* _textAtlas;
|
||||
};
|
||||
|
||||
#endif /* defined(__TestCpp__UITextAtlasTest__) */
|
||||
|
|
|
@ -25,7 +25,22 @@ bool UITextBMFontTest::init()
|
|||
textBMFont->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + textBMFont->getContentSize().height / 8.0f));
|
||||
_uiLayer->addChild(textBMFont);
|
||||
|
||||
_textBMFont = textBMFont;
|
||||
|
||||
TTFConfig ttfConfig("fonts/arial.ttf", 15);
|
||||
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
|
||||
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextBMFontTest::printWidgetResources, this));
|
||||
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
|
||||
auto pMenu1 = Menu::create(item1, nullptr);
|
||||
pMenu1->setPosition(Vec2(0, 0));
|
||||
this->addChild(pMenu1, 10);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void UITextBMFontTest::printWidgetResources(cocos2d::Ref* sender)
|
||||
{
|
||||
cocos2d::ResourceData textureFile = _textBMFont->getRenderFile();
|
||||
CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@ public:
|
|||
CREATE_FUNC(UITextBMFontTest)
|
||||
|
||||
virtual bool init() override;
|
||||
void printWidgetResources(cocos2d::Ref* sender);
|
||||
protected:
|
||||
cocos2d::ui::TextBMFont* _textBMFont;
|
||||
};
|
||||
|
||||
#endif /* defined(__TestCpp__UITextBMFontTest__) */
|
||||
|
|
Loading…
Reference in New Issue