PuzzleSDK
FontNoReplacementTest类 参考

#include <FontTest.h>

+ 类 FontNoReplacementTest 继承关系图:
+ FontNoReplacementTest 的协作图:

Public 成员函数

 ~FontNoReplacementTest ()
 
virtual void onEnter () override
 
virtual std::string title () const override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string subtitle () const
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 

静态 Public 成员函数

static FontNoReplacementTestcreate ()
 

Protected 成员函数

 FontNoReplacementTest ()
 

Protected 属性

bool _replace
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 

详细描述

在文件 FontTest.h58 行定义.

构造及析构函数说明

◆ ~FontNoReplacementTest()

FontNoReplacementTest::~FontNoReplacementTest ( )

在文件 FontTest.cpp166 行定义.

167{
168 // need to clear the caches since we change the lookup dictionary after the application init.
169 FontAtlasCache::unloadFontAtlasTTF("fonts/A Damn Mess.ttf");
170 FontFreeType::releaseFont("fonts/A Damn Mess.ttf");
171 FontAtlasCache::unloadFontAtlasTTF("fonts/Abberancy.ttf");
172 FontFreeType::releaseFont("fonts/Abberancy.ttf");
173 FontAtlasCache::unloadFontAtlasTTF("fonts/Abduction.ttf");
174 FontFreeType::releaseFont("fonts/Abduction.ttf");
175 FontAtlasCache::unloadFontAtlasTTF("fonts/Schwarzwald.ttf");
176 FontFreeType::releaseFont("fonts/Schwarzwald.ttf");
177 FileUtils::getInstance()->setFilenameLookupDictionary(ValueMap());
178}

◆ FontNoReplacementTest()

FontNoReplacementTest::FontNoReplacementTest ( )
protected

在文件 FontTest.cpp161 行定义.

162{
163 _replace = false;
164}

引用了 _replace.

成员函数说明

◆ create()

FontNoReplacementTest * FontNoReplacementTest::create ( )
static

在文件 FontTest.cpp145 行定义.

146{
147 auto ret = new (std::nothrow) FontNoReplacementTest;
148 if (ret && ret->init())
149 {
150 ret->autorelease();
151 }
152 else
153 {
154 delete ret;
155 ret = nullptr;
156 }
157
158 return ret;
159}

◆ onEnter()

void FontNoReplacementTest::onEnter ( )
overridevirtual

重载 TestCase .

在文件 FontTest.cpp180 行定义.

181{
183
184 std::string suffix;
185 if (_replace)
186 {
187 ValueMap dict{
188 { "fonts/A Damn Mess.ttf", Value("fonts/arial.ttf") },
189 { "fonts/Abberancy.ttf", Value("fonts/arial.ttf") },
190 { "fonts/Abduction.ttf", Value("fonts/arial.ttf") },
191 { "fonts/Schwarzwald.ttf", Value("fonts/arial.ttf") }
192 };
193
194 FileUtils::getInstance()->setFilenameLookupDictionary(dict);
195 suffix = " replaced by arial.ttf";
196 }
197
198 auto s = Director::getInstance()->getWinSize();
199
200 auto blockSize = Size(s.width / 3, 200);
201 float fontSize = 26;
202
203 removeChildByTag(kTagLabel1, true);
204 removeChildByTag(kTagLabel2, true);
205 removeChildByTag(kTagLabel3, true);
206 removeChildByTag(kTagLabel4, true);
207 removeChildByTag(kTagColor1, true);
208 removeChildByTag(kTagColor2, true);
209 removeChildByTag(kTagColor3, true);
210
211 auto top = Label::createWithTTF("fonts/A Damn Mess.ttf" + suffix, "fonts/A Damn Mess.ttf", 24);
212 auto left = Label::createWithTTF("fonts/Abberancy.ttf" + suffix, "fonts/Abberancy.ttf", fontSize,
213 blockSize, TextHAlignment::LEFT, verticalAlignment[0]);
214 auto center = Label::createWithTTF("fonts/Abduction.ttf" + suffix, "fonts/Abduction.ttf", fontSize,
215 blockSize, TextHAlignment::CENTER, verticalAlignment[0]);
216 auto right = Label::createWithTTF("fonts/Schwarzwald.ttf" + suffix, "fonts/Schwarzwald.ttf", fontSize,
217 blockSize, TextHAlignment::RIGHT, verticalAlignment[0]);
218
219 auto leftColor = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height);
220 auto centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height);
221 auto rightColor = LayerColor::create(Color4B(100, 100, 200, 255), blockSize.width, blockSize.height);
222
223 leftColor->setIgnoreAnchorPointForPosition(false);
224 centerColor->setIgnoreAnchorPointForPosition(false);
225 rightColor->setIgnoreAnchorPointForPosition(false);
226
227 top->setAnchorPoint(Vec2(0.5, 1));
228 left->setAnchorPoint(Vec2(0, 0.5));
229 leftColor->setAnchorPoint(Vec2(0, 0.5));
230 center->setAnchorPoint(Vec2(0, 0.5));
231 centerColor->setAnchorPoint(Vec2(0, 0.5));
232 right->setAnchorPoint(Vec2(0, 0.5));
233 rightColor->setAnchorPoint(Vec2(0, 0.5));
234
235 top->setPosition(s.width / 2, s.height - 20);
236 left->setPosition(0, s.height / 2);
237 leftColor->setPosition(left->getPosition());
238 center->setPosition(blockSize.width, s.height / 2);
239 centerColor->setPosition(center->getPosition());
240 right->setPosition(blockSize.width * 2, s.height / 2);
241 rightColor->setPosition(right->getPosition());
242
243 this->addChild(leftColor, -1, kTagColor1);
244 this->addChild(left, 0, kTagLabel1);
245 this->addChild(rightColor, -1, kTagColor2);
246 this->addChild(right, 0, kTagLabel2);
247 this->addChild(centerColor, -1, kTagColor3);
248 this->addChild(center, 0, kTagLabel3);
249 this->addChild(top, 0, kTagLabel4);
250}
static TextVAlignment verticalAlignment[]
Definition: FontTest.cpp:55
@ kTagColor1
Definition: FontTest.cpp:38
@ kTagLabel4
Definition: FontTest.cpp:36
@ kTagColor2
Definition: FontTest.cpp:39
@ kTagLabel1
Definition: FontTest.cpp:33
@ kTagLabel3
Definition: FontTest.cpp:35
@ kTagLabel2
Definition: FontTest.cpp:34
@ kTagColor3
Definition: FontTest.cpp:40
virtual void onEnter() override
Definition: BaseTest.cpp:430

引用了 _replace, kTagColor1, kTagColor2, kTagColor3, kTagLabel1, kTagLabel2, kTagLabel3, kTagLabel4, TestCase::onEnter() , 以及 verticalAlignment.

+ 函数调用图:

◆ title()

std::string FontNoReplacementTest::title ( ) const
overridevirtual

重载 TestCase .

FontReplacementTest 重载.

在文件 FontTest.cpp252 行定义.

253{
254 return "Font no replacement test";
255}

类成员变量说明

◆ _replace

bool FontNoReplacementTest::_replace
protected

在文件 FontTest.h68 行定义.

被这些函数引用 FontNoReplacementTest(), FontReplacementTest::FontReplacementTest() , 以及 onEnter().


该类的文档由以下文件生成: