Skip to content

Commit

Permalink
add daily and gauntlet to starsinfopopup
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Jan 14, 2024
1 parent 81dd17c commit cb96778
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
28 changes: 28 additions & 0 deletions src/layers/StarsInfoPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ bool StarsInfoPopup::init(){
m_closeBtn->setVisible(false);

auto winSize = CCDirector::sharedDirector()->getWinSize();
auto GLM = GameLevelManager::sharedState();

auto diffMenu = CCMenu::create();
diffMenu->setLayout(
Expand All @@ -75,6 +76,18 @@ bool StarsInfoPopup::init(){
thirdRowMenu->setPosition({winSize.width / 2, winSize.height / 2 - 35});
m_mainLayer->addChild(thirdRowMenu);

auto cornerMenu = CCMenu::create();
cornerMenu->setLayout(ColumnLayout::create()
->setGap(14.f)
->setAxisAlignment(AxisAlignment::Start)
->setCrossAxisLineAlignment(AxisAlignment::End)
->setAxisReverse(true)
);
cornerMenu->setContentSize({100, 182});
cornerMenu->setPosition({winSize.width / 2 + 178, winSize.height / 2});
cornerMenu->setAnchorPoint({1, .5f});
m_mainLayer->addChild(cornerMenu);

for(int i = -1; i < 6; i++) {
//if(i == 0) continue;

Expand Down Expand Up @@ -128,6 +141,21 @@ bool StarsInfoPopup::init(){
buttonButton->setPosition({0, -80});
m_buttonMenu->addChild(buttonButton);

auto cornerFont1 = CCLabelBMFont::create(fmt::format("Daily: {}", BetterInfo::completedLevelsInStarRange(0, 10, false, GLM->m_dailyLevels).size() + BetterInfo::completedLevelsInStarRange(0, 10, true, GLM->m_dailyLevels).size()).c_str(), "goldFont.fnt");
cornerFont1->setLayoutOptions(AxisLayoutOptions::create()
->setMinScale(.0f)
->setMaxScale(.4f)
);
cornerFont1->setAnchorPoint({1, 0});
cornerMenu->addChild(cornerFont1);

auto cornerFont2 = CCLabelBMFont::create(fmt::format("Gauntlet: {}", BetterInfo::completedLevelsInStarRange(0, 10, false, GLM->m_gauntletLevels).size() + BetterInfo::completedLevelsInStarRange(0, 10, true, GLM->m_gauntletLevels).size()).c_str(), "goldFont.fnt");
cornerFont2->setLayoutOptions(cornerFont1->getLayoutOptions());
cornerFont2->setAnchorPoint(cornerFont1->getAnchorPoint());
cornerMenu->addChild(cornerFont2);

cornerMenu->updateLayout();

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ bool BetterInfo::levelProgressMatchesObject(GJGameLevel* level, const BISearchOb
return true;
}

std::vector<GJGameLevel*> BetterInfo::completedLevelsInStarRange(int min, int max, bool platformer) {
std::vector<GJGameLevel*> BetterInfo::completedLevelsInStarRange(int min, int max, bool platformer, CCDictionary* dict) {
std::vector<GJGameLevel*> levels;

for(auto [key, level] : CCDictionaryExt<gd::string, GJGameLevel*>(GameLevelManager::sharedState()->m_onlineLevels)) {
for(auto [key, level] : CCDictionaryExt<gd::string, GJGameLevel*>(dict)) {
if(level->m_normalPercent < 100) continue;
if(level->m_stars < min || level->m_stars > max) continue;
if((platformer && !level->isPlatformer()) || (!platformer && level->isPlatformer())) continue;
Expand Down
2 changes: 1 addition & 1 deletion src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace BetterInfo {
bool validateRangeItem(const BISearchObject::RangeItem& rangeItem, int value);
bool levelMatchesObject(GJGameLevel* level, const BISearchObject& searchObj);
bool levelProgressMatchesObject(GJGameLevel* level, const BISearchObject& searchObj);
std::vector<GJGameLevel*> completedLevelsInStarRange(int min, int max, bool platformer);
std::vector<GJGameLevel*> completedLevelsInStarRange(int min, int max, bool platformer, CCDictionary* dict = GameLevelManager::sharedState()->m_onlineLevels);

void reloadUsernames(LevelBrowserLayer* levelBrowserLayer);

Expand Down

0 comments on commit cb96778

Please sign in to comment.