2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2022-02-24 18:45:25 +08:00
|
|
|
https://adxeproject.github.io/
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-05-10 15:07:05 +08:00
|
|
|
#include "DataVisitorTest.h"
|
|
|
|
#include "../testResource.h"
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
DataVisitorTests::DataVisitorTests()
|
|
|
|
{
|
|
|
|
ADD_TEST_CASE(PrettyPrinterDemo);
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string PrettyPrinterDemo::title() const
|
2013-05-10 15:07:05 +08:00
|
|
|
{
|
|
|
|
return "PrettyPrinter Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string PrettyPrinterDemo::subtitle() const
|
2013-05-10 15:07:05 +08:00
|
|
|
{
|
|
|
|
return "Please see log!";
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrettyPrinterDemo::addSprite()
|
|
|
|
{
|
|
|
|
// create sprites
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s1 = Sprite::create("Images/grossini.png");
|
|
|
|
auto s2 = Sprite::create("Images/grossini_dance_01.png");
|
|
|
|
auto s3 = Sprite::create("Images/grossini_dance_02.png");
|
|
|
|
auto s4 = Sprite::create("Images/grossini_dance_03.png");
|
|
|
|
auto s5 = Sprite::create("Images/grossini_dance_04.png");
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-08-28 11:41:18 +08:00
|
|
|
s1->setPosition(50, 50);
|
|
|
|
s2->setPosition(60, 50);
|
|
|
|
s3->setPosition(70, 50);
|
|
|
|
s4->setPosition(80, 50);
|
|
|
|
s5->setPosition(90, 50);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-05-10 15:07:05 +08:00
|
|
|
this->addChild(s1);
|
|
|
|
this->addChild(s2);
|
|
|
|
this->addChild(s3);
|
|
|
|
this->addChild(s4);
|
|
|
|
this->addChild(s5);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrettyPrinterDemo::onEnter()
|
|
|
|
{
|
2015-04-03 14:31:03 +08:00
|
|
|
TestCase::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-04-09 23:31:05 +08:00
|
|
|
auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 28);
|
2021-12-28 16:06:23 +08:00
|
|
|
label->setPosition(s.width / 2, s.height * 4 / 5);
|
2013-05-10 15:07:05 +08:00
|
|
|
this->addChild(label, 1);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-05-10 15:07:05 +08:00
|
|
|
std::string strSubtitle = subtitle();
|
2021-12-28 16:06:23 +08:00
|
|
|
if (strSubtitle.empty() == false)
|
2013-05-10 15:07:05 +08:00
|
|
|
{
|
2014-04-09 23:31:05 +08:00
|
|
|
auto subLabel = Label::createWithTTF(strSubtitle.c_str(), "fonts/Thonburi.ttf", 16);
|
2021-12-28 16:06:23 +08:00
|
|
|
subLabel->setPosition(s.width / 2, s.height * 3 / 5);
|
2013-05-10 15:07:05 +08:00
|
|
|
this->addChild(subLabel, 1);
|
|
|
|
}
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-05-10 15:07:05 +08:00
|
|
|
// Test code
|
2021-12-28 16:06:23 +08:00
|
|
|
// TODO: minggo
|
|
|
|
// PrettyPrinter visitor;
|
|
|
|
//
|
|
|
|
// // print dictionary
|
|
|
|
// auto dict = __Dictionary::createWithContentsOfFile("animations/animations.plist");
|
|
|
|
// dict->acceptVisitor(visitor);
|
|
|
|
// log("%s", visitor.getResult().c_str());
|
|
|
|
// log("-------------------------------");
|
|
|
|
//
|
|
|
|
// __Set myset;
|
|
|
|
// for (int i = 0; i < 30; ++i) {
|
|
|
|
// myset.addObject(__String::createWithFormat("str: %d", i));
|
|
|
|
// }
|
|
|
|
// visitor.clear();
|
|
|
|
// myset.acceptVisitor(visitor);
|
|
|
|
// log("%s", visitor.getResult().c_str());
|
|
|
|
// log("-------------------------------");
|
|
|
|
//
|
|
|
|
// visitor.clear();
|
2013-05-10 15:07:05 +08:00
|
|
|
addSprite();
|
2021-12-28 16:06:23 +08:00
|
|
|
// dict = Director::getInstance()->getTextureCache()->snapshotTextures();
|
|
|
|
// dict->acceptVisitor(visitor);
|
|
|
|
// log("%s", visitor.getResult().c_str());
|
2013-05-10 15:07:05 +08:00
|
|
|
}
|