Skip to content

Commit

Permalink
add refresh button to view leaderboard as
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Dec 6, 2023
1 parent 8a6f403 commit e878e6b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/layers/LeaderboardViewLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ bool LeaderboardViewLayer::init(int accountID) {
m_circle->setParentLayer(this);
m_circle->show();

//refresh btn
auto refreshBtn = CCMenuItemSpriteExtra::create(
CCSprite::createWithSpriteFrameName("GJ_updateBtn_001.png"),
this,
menu_selector(LeaderboardViewLayer::onRefresh)
);

auto menuRefresh = CCMenu::create();
menuRefresh->addChild(refreshBtn);
menuRefresh->setPosition({winSize.width - 26.75f, 26.75f});
menuRefresh->setZOrder(2);
menuRefresh->setID("bi-refresh-menu");

this->addChild(menuRefresh);

loadPage();
BetterInfoOnline::sharedState()->loadScores(m_accountID, false, this);

Expand Down Expand Up @@ -109,11 +124,24 @@ void LeaderboardViewLayer::keyBackClicked() {
CCDirector::sharedDirector()->popSceneWithTransition(0.5f, PopTransition::kPopTransitionFade);
}


void LeaderboardViewLayer::onBack(CCObject* object) {
keyBackClicked();
}

void LeaderboardViewLayer::onRefresh(CCObject* object) {
BetterInfoOnline::sharedState()->loadScores(m_accountID, true, this);

if(m_circle) {
m_circle->fadeAndRemove();
m_circle->release();
}

m_circle = LoadingCircle::create();
m_circle->retain();
m_circle->setParentLayer(this);
m_circle->show();
}

CCScene* LeaderboardViewLayer::scene(int accountID) {
auto layer = LeaderboardViewLayer::create(accountID);
auto scene = CCScene::create();
Expand Down
1 change: 1 addition & 0 deletions src/layers/LeaderboardViewLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class LeaderboardViewLayer : public cocos2d::CCLayer, public BILeaderboardDelega
virtual bool init(int accountID);
virtual void keyBackClicked();
void onBack(cocos2d::CCObject*);
void onRefresh(cocos2d::CCObject*);
public:
void loadPage();
static LeaderboardViewLayer* create(int accountID);
Expand Down

0 comments on commit e878e6b

Please sign in to comment.