@@ -39,29 +39,24 @@ std::vector<std::string> MoreLeaderboards::getWords(std::string s, std::string d
3939 return res;
4040}
4141
42- class SearchUserLBLayer : public BrownAlertDelegate {
43- protected:
44- MoreLeaderboards* m_layer;
45- TextInput* input_username = TextInput::create(200 .0F , " Username" , " bigFont.fnt" );
4642
47- virtual void setup () {
48- auto winSize = cocos2d::CCDirector::sharedDirector ()->getWinSize ();
43+ class SearchUserLBLayer : public Popup <MoreLeaderboards*> {
44+ protected:
45+ bool setup (MoreLeaderboards* layer) {
46+ m_layer = layer;
4947 input_username->setMaxCharCount (20 );
5048 input_username->setPlaceholder (" " );
5149 input_username->setPositionY (10 );
52- this ->m_buttonMenu ->addChild (input_username);
50+
51+ m_buttonMenu->addChildAtPosition (input_username, Anchor::Center);
52+ auto winSize = cocos2d::CCDirector::sharedDirector ()->getWinSize ();
5353 auto validate_spr = ButtonSprite::create (" Search" , 60 , true , " bigFont.fnt" , " GJ_button_01.png" , 30 , .5F );
5454 auto validate_btn = CCMenuItemSpriteExtra::create (
5555 validate_spr,
5656 this ,
5757 menu_selector (SearchUserLBLayer::onValidate)
5858 );
59-
60- validate_btn->setPosition ({
61- 0 ,
62- -35
63- });
64- this ->m_buttonMenu ->addChild (validate_btn, 1 );
59+ m_buttonMenu->addChildAtPosition (validate_btn, Anchor::Center, {0 , -35 });
6560
6661 if (MoreLeaderboards::username != " " ) {
6762 input_username->setString (MoreLeaderboards::username);
@@ -73,35 +68,22 @@ class SearchUserLBLayer : public BrownAlertDelegate {
7368 this ,
7469 menu_selector (SearchUserLBLayer::onRemoveUsername)
7570 );
76- delete_btn->setPosition ({
77- 113 ,
78- 11
79- });
80- this ->m_buttonMenu ->addChild (delete_btn, 1 );
71+ m_buttonMenu->addChildAtPosition (delete_btn, Anchor::Right, {-17 , 0 });
8172 }
82-
83- this ->m_mainLayer ->addChild (this ->m_buttonMenu );
84- this ->setTouchEnabled (true );
85- }
86- cocos2d::CCSize m_sScrLayerSize;
87- void onClose (cocos2d::CCObject* pSender) {
88- BrownAlertDelegate::onClose (pSender);
73+ return true ;
8974 }
9075 void onValidate (cocos2d::CCObject*);
9176 void onRemoveUsername (cocos2d::CCObject*);
92- float m_fWidth = s_defWidth;
93- float m_fHeight = s_defHeight;
9477 public:
95- static constexpr const float s_defWidth = 260 . 0f ;
96- static constexpr const float s_defHeight = 120 . 0f ;
78+ MoreLeaderboards* m_layer ;
79+ TextInput* input_username = TextInput::create( 200 . 0F , " Username " , " bigFont.fnt " ) ;
9780 static SearchUserLBLayer* create (MoreLeaderboards* layer) {
98- auto pRet = new SearchUserLBLayer ();
99- if (pRet && pRet->init (SearchUserLBLayer::s_defWidth, SearchUserLBLayer::s_defHeight, " GJ_square01.png" )) {
100- pRet->autorelease ();
101- pRet->m_layer = layer;
102- return pRet;
81+ auto ret = new SearchUserLBLayer ();
82+ if (ret->initAnchored (260 .f , 120 .f , layer)) {
83+ ret->autorelease ();
84+ return ret;
10385 }
104- CC_SAFE_DELETE (pRet) ;
86+ delete ret ;
10587 return nullptr ;
10688 }
10789};
@@ -115,7 +97,7 @@ void SearchUserLBLayer::onValidate(CCObject* pSender) {
11597
11698 this ->m_layer ->onTab (nullptr );
11799
118- BrownAlertDelegate ::onClose (pSender);
100+ Popup ::onClose (pSender);
119101}
120102
121103void SearchUserLBLayer::onRemoveUsername (CCObject* pSender) {
@@ -126,7 +108,7 @@ void SearchUserLBLayer::onRemoveUsername(CCObject* pSender) {
126108 this ->m_layer ->changeTabPage ();
127109 this ->m_layer ->onTab (nullptr );
128110
129- BrownAlertDelegate ::onClose (pSender);
111+ Popup ::onClose (pSender);
130112}
131113
132114CCDictionary* MoreLeaderboards::responseToDict (const std::string& response){
0 commit comments