diff --git a/src/layers/LeaderboardListView.cpp b/src/layers/LeaderboardListView.cpp deleted file mode 100644 index 16553b2..0000000 --- a/src/layers/LeaderboardListView.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "LeaderboardListView.h" - -LeaderboardListView* LeaderboardListView::create(cocos2d::CCArray* scores, float width, float height) { - auto ret = new LeaderboardListView(); - if (ret && ret->init(scores, 0x420, width, height)) { - ret->autorelease(); - } else { - delete ret; - ret = nullptr; - } - return ret; -} - -void LeaderboardListView::setupList() { - this->m_itemSeparation = 60.0f; - - this->m_tableView->retain(); - this->m_tableView->reloadData(); - - auto coverage = calculateNodeCoverage(m_tableView->m_contentLayer->getChildren()); - if (this->m_entries->count() > 4) - m_tableView->m_contentLayer->setContentSize({-coverage.origin.x + coverage.size.width, -coverage.origin.y + coverage.size.height}); - - this->m_tableView->moveToTop(); - - if (this->m_entries->count() == 1) - this->m_tableView->moveToTopWithOffset(this->m_itemSeparation); -} - -void LeaderboardListView::loadCell(TableViewCell* cell, int index) { - static_cast(cell)->loadFromScore( - static_cast(this->m_entries->objectAtIndex(index)) - ); - static_cast(cell)->updateBGColor(index); -} - -TableViewCell* LeaderboardListView::getListCell(const char* key) { - return new GJScoreCell(key, this->m_width, this->m_itemSeparation); -} \ No newline at end of file diff --git a/src/layers/LeaderboardListView.h b/src/layers/LeaderboardListView.h deleted file mode 100644 index 0a37214..0000000 --- a/src/layers/LeaderboardListView.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "CvoltonListView.h" -#include - -using namespace geode::prelude; - -class LeaderboardListView : public CvoltonListView { -protected: - virtual void setupList() override; - TableViewCell* getListCell(const char* key) override; - virtual void loadCell(TableViewCell* cell, int index) override; - -public: - static LeaderboardListView* create(cocos2d::CCArray* scores, float width, float height); -}; \ No newline at end of file diff --git a/src/layers/LeaderboardViewLayer.cpp b/src/layers/LeaderboardViewLayer.cpp index df60156..1ffb570 100644 --- a/src/layers/LeaderboardViewLayer.cpp +++ b/src/layers/LeaderboardViewLayer.cpp @@ -89,8 +89,8 @@ void LeaderboardViewLayer::loadPage(){ if(m_listLayer != nullptr) m_listLayer->removeFromParentAndCleanup(true); if(m_leaderboardView) m_leaderboardView->release(); - m_leaderboardView = LeaderboardListView::create(m_scores, 356.f, 220.f); - m_listLayer = GJListLayer::create(m_leaderboardView, "Scores", {191, 114, 62, 255}, 356.f, 220.f); + m_leaderboardView = CustomListView::create(m_scores, BoomListType::Score, 220.f, 356.f); + m_listLayer = GJListLayer::create(m_leaderboardView, "Global Leaderboards", {191, 114, 62, 255}, 356.f, 220.f); m_listLayer->setPosition(winSize / 2 - m_listLayer->getScaledContentSize() / 2 - CCPoint(0,5)); addChild(m_listLayer); } diff --git a/src/layers/LeaderboardViewLayer.h b/src/layers/LeaderboardViewLayer.h index 034c889..773022c 100644 --- a/src/layers/LeaderboardViewLayer.h +++ b/src/layers/LeaderboardViewLayer.h @@ -1,10 +1,9 @@ #pragma once -#include "LeaderboardListView.h" #include "../delegates/BILeaderboardDelegate.h" class LeaderboardViewLayer : public cocos2d::CCLayer, public BILeaderboardDelegate { - LeaderboardListView* m_leaderboardView = nullptr; + CustomListView* m_leaderboardView = nullptr; GJListLayer* m_listLayer = nullptr; cocos2d::CCArray* m_scores = nullptr; LoadingCircle* m_circle = nullptr; diff --git a/src/managers/BetterInfoOnline.cpp b/src/managers/BetterInfoOnline.cpp index d9dacd4..73d9ec7 100644 --- a/src/managers/BetterInfoOnline.cpp +++ b/src/managers/BetterInfoOnline.cpp @@ -39,6 +39,7 @@ void BetterInfoOnline::loadScores(int accountID, bool force){ } void BetterInfoOnline::generateScores(const std::string& response, int accountID){ + auto GM = GameManager::sharedState(); if(m_scoreDict.contains(accountID)) { m_scoreDict[accountID]->release(); @@ -55,16 +56,14 @@ void BetterInfoOnline::generateScores(const std::string& response, int accountID std::string current; while(getline(responseStream, current, '|')){ - - //auto CM = CvoltonManager::sharedState(); - auto GLM = GameLevelManager::sharedState(); auto score = GJUserScore::create( - //CM->responseToDict(current) - //GLM->responseToDict(current, false) BetterInfo::responseToDict(current) ); + // workaround for leaderboard highlighting + if(std::string(score->m_userUDID) != "") score->m_userUDID = GM->m_playerUDID; + scores->addObject(score); } }