PuzzleSDK
LabelLocalizationTest类 参考

#include <LabelTestNew.h>

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

Public 成员函数

 CREATE_FUNC (LabelLocalizationTest)
 
 LabelLocalizationTest ()
 
void onChangedRadioButtonSelect (cocos2d::ui::RadioButton *radioButton, cocos2d::ui::RadioButton::EventType type)
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
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
 
virtual void onEnter () override
 

Public 属性

cocos2d::Label * _label1
 
cocos2d::Label * _label2
 
cocostudio::ILocalizationManager * _localizationJson
 
cocostudio::ILocalizationManager * _localizationBin
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 LabelTestNew.h898 行定义.

构造及析构函数说明

◆ LabelLocalizationTest()

LabelLocalizationTest::LabelLocalizationTest ( )

在文件 LabelTestNew.cpp3270 行定义.

3271{
3272 _localizationJson = cocostudio::JsonLocalizationManager::getInstance();
3273 _localizationJson->initLanguageData("configs/en-US.lang.json");
3274
3275 _localizationBin = cocostudio::BinLocalizationManager::getInstance();
3276 _localizationBin->initLanguageData("configs/ENGLISH.lang.csb");
3277
3278 const float BUTTON_WIDTH = 100;
3279 float startPosX = 0;
3280 Size winSize = Director::getInstance()->getVisibleSize();
3281
3282 // Create a radio button group
3283 auto radioButtonGroup = RadioButtonGroup::create();
3284 this->addChild(radioButtonGroup);
3285
3286 // Create the radio buttons
3287 const int NUMBER_OF_BUTTONS = 3;
3288 startPosX = winSize.width / 2.0f - (NUMBER_OF_BUTTONS - 1) * 0.5 * BUTTON_WIDTH - 30;
3289 std::vector<std::string> labelTypes = { "English", "Chinese", "Japanese" };
3290
3291 for (int i = 0; i < NUMBER_OF_BUTTONS; ++i)
3292 {
3293 RadioButton* radioButton = RadioButton::create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png");
3294 float posX = startPosX + BUTTON_WIDTH * i;
3295 radioButton->setPosition(Vec2(posX, winSize.height / 2.0f + 70));
3296 radioButton->setScale(1.2f);
3297 radioButton->addEventListener(CC_CALLBACK_2(LabelLocalizationTest::onChangedRadioButtonSelect, this));
3298 radioButton->setTag(i);
3299 radioButtonGroup->addRadioButton(radioButton);
3300 this->addChild(radioButton);
3301
3302 auto label = Label::createWithSystemFont(labelTypes.at(i), "Arial", 20);
3303 label->setPosition(radioButton->getPosition() + Vec2(50.0f, 0.0f));
3304 this->addChild(label);
3305 }
3306
3307 _label1 = Label::createWithSystemFont(_localizationJson->getLocalizationString("Text Label"), "Arial", 24);
3308 addChild(_label1, 0);
3309 _label1->setPosition(Vec2(winSize.width / 2, winSize.height * 1 / 3));
3310
3311 Label * label = Label::createWithSystemFont("From json data :", "Arial", 24);
3312 label->setAnchorPoint(Vec2(0.0f, 0.5f));
3313 addChild(label, 0);
3314 label->setPosition(Vec2(20.0f, winSize.height * 1 / 3 + 24));
3315
3316 _label2 = Label::createWithSystemFont(_localizationBin->getLocalizationString("Text Label"), "Arial", 24);
3317 addChild(_label2, 0);
3318 _label2->setPosition(Vec2(winSize.width / 2, winSize.height * 1 / 2));
3319
3320 label = Label::createWithSystemFont("From binary data :", "Arial", 24);
3321 label->setAnchorPoint(Vec2(0.0f, 0.5f));
3322 addChild(label, 0);
3323 label->setPosition(Vec2(20.0f, winSize.height * 1 / 2 + 24));
3324}
static float startPosX
static const float BUTTON_WIDTH
cocostudio::ILocalizationManager * _localizationBin
Definition: LabelTestNew.h:912
void onChangedRadioButtonSelect(cocos2d::ui::RadioButton *radioButton, cocos2d::ui::RadioButton::EventType type)
cocos2d::Label * _label1
Definition: LabelTestNew.h:909
cocostudio::ILocalizationManager * _localizationJson
Definition: LabelTestNew.h:911
cocos2d::Label * _label2
Definition: LabelTestNew.h:910

引用了 _label1, _label2, _localizationBin, _localizationJson, BUTTON_WIDTH, onChangedRadioButtonSelect() , 以及 startPosX.

+ 函数调用图:

成员函数说明

◆ CREATE_FUNC()

LabelLocalizationTest::CREATE_FUNC ( LabelLocalizationTest  )

◆ onChangedRadioButtonSelect()

void LabelLocalizationTest::onChangedRadioButtonSelect ( cocos2d::ui::RadioButton *  radioButton,
cocos2d::ui::RadioButton::EventType  type 
)

在文件 LabelTestNew.cpp3337 行定义.

3338{
3339 if (radioButton == nullptr)
3340 {
3341 return;
3342 }
3343
3344 switch (type)
3345 {
3346 case RadioButton::EventType::SELECTED:
3347 {
3348 switch (radioButton->getTag()) {
3349 case 0:
3350 _localizationJson->initLanguageData("configs/en-US.lang.json");
3351 _label1->setString(_localizationJson->getLocalizationString("Text Label"));
3352 _localizationBin->initLanguageData("configs/ENGLISH.lang.csb");
3353 _label2->setString(_localizationBin->getLocalizationString("Text Label"));
3354 break;
3355 case 1:
3356 _localizationJson->initLanguageData("configs/zh-CN.lang.json");
3357 _label1->setString(_localizationJson->getLocalizationString("Text Label"));
3358 _localizationBin->initLanguageData("configs/CHINESE.lang.csb");
3359 _label2->setString(_localizationBin->getLocalizationString("Text Label"));
3360 break;
3361 case 2:
3362 _localizationJson->initLanguageData("configs/ja-JP.lang.json");
3363 _label1->setString(_localizationJson->getLocalizationString("Text Label"));
3364 _localizationBin->initLanguageData("configs/JAPANESE.lang.csb");
3365 _label2->setString(_localizationBin->getLocalizationString("Text Label"));
3366 break;
3367 default:
3368 break;
3369 }
3370 break;
3371 }
3372 default:
3373 break;
3374 }
3375}

引用了 _label1, _label2, _localizationBin , 以及 _localizationJson.

被这些函数引用 LabelLocalizationTest().

+ 这是这个函数的调用关系图:

◆ subtitle()

std::string LabelLocalizationTest::subtitle ( ) const
overridevirtual

重载 TestCase .

在文件 LabelTestNew.cpp3331 行定义.

3332{
3333 return "Change language selected and see label change";
3334}

◆ title()

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

重载 TestCase .

在文件 LabelTestNew.cpp3326 行定义.

3327{
3328 return "Localization Test";
3329}

类成员变量说明

◆ _label1

cocos2d::Label* LabelLocalizationTest::_label1

在文件 LabelTestNew.h909 行定义.

被这些函数引用 LabelLocalizationTest() , 以及 onChangedRadioButtonSelect().

◆ _label2

cocos2d::Label* LabelLocalizationTest::_label2

在文件 LabelTestNew.h910 行定义.

被这些函数引用 LabelLocalizationTest() , 以及 onChangedRadioButtonSelect().

◆ _localizationBin

cocostudio::ILocalizationManager* LabelLocalizationTest::_localizationBin

在文件 LabelTestNew.h912 行定义.

被这些函数引用 LabelLocalizationTest() , 以及 onChangedRadioButtonSelect().

◆ _localizationJson

cocostudio::ILocalizationManager* LabelLocalizationTest::_localizationJson

在文件 LabelTestNew.h911 行定义.

被这些函数引用 LabelLocalizationTest() , 以及 onChangedRadioButtonSelect().


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