From b2eaa112c97f422f324f5dbad1707d5a14976bae Mon Sep 17 00:00:00 2001 From: Cvolton Date: Sat, 6 Jul 2024 12:29:47 +0200 Subject: [PATCH] add "folder" button to levelcategorysearchalert --- .../LevelCategorySearchAlert.cpp | 28 +++++++++++++++++-- .../LevelFiltering/LevelCategorySearchAlert.h | 4 ++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/layers/LevelFiltering/LevelCategorySearchAlert.cpp b/src/layers/LevelFiltering/LevelCategorySearchAlert.cpp index a6f7dc4..71887f7 100644 --- a/src/layers/LevelFiltering/LevelCategorySearchAlert.cpp +++ b/src/layers/LevelFiltering/LevelCategorySearchAlert.cpp @@ -36,6 +36,13 @@ void LevelCategorySearchAlert::onFavorites(cocos2d::CCObject* sender) { CCDirector::sharedDirector()->pushScene(transitionFade); } +void LevelCategorySearchAlert::onFolder(cocos2d::CCObject* sender) { + auto popup = SetFolderPopup::create(0, false, "Go to Folder"); + popup->m_delegate = this; + popup->m_scene = this; + popup->show(); +} + void LevelCategorySearchAlert::onCompleted(cocos2d::CCObject* sender) { BISearchObject searchObj; searchObj.completed = true; @@ -82,6 +89,15 @@ void LevelCategorySearchAlert::onNoCoins(cocos2d::CCObject* sender) { CCDirector::sharedDirector()->pushScene(transitionFade); } +void LevelCategorySearchAlert::setIDPopupClosed(SetIDPopup* popup, int value) { + BISearchObject searchObj; + searchObj.folder = value; + + auto browserLayer = LevelSearchViewLayer::scene(LevelUtils::completedDeque(), searchObj); + auto transitionFade = CCTransitionFade::create(0.5, browserLayer); + CCDirector::sharedDirector()->pushScene(transitionFade); +} + bool LevelCategorySearchAlert::init(){ bool init = cocos2d::CCLayerColor::initWithColor({0x00, 0x00, 0x00, 0x4B}); if(!init) return false; @@ -132,16 +148,24 @@ bool LevelCategorySearchAlert::init(){ //auto playedButton = createButton(m_buttonMenu, "Played", menu_selector(LevelCategorySearchAlert::onPlayed), -57, 18, (int)(120*0.6), 44*0.6f, 0.6f); auto playedButton = BetterInfo::createSearchButton(this, "Played", "BI_playIcon_001.png"_spr, menu_selector(LevelCategorySearchAlert::onPlayed), .5f, .35f); - playedButton->setPosition({-58.5, 18}); + playedButton->setPosition({-117, 18}); playedButton->setID("played-button"_spr); m_buttonMenu->addChild(playedButton); //auto favoriteButton = createButton(m_buttonMenu, "Favorites", menu_selector(LevelCategorySearchAlert::onFavorites), 57, 18, (int)(120*0.6), 44*0.6f, 0.6f); auto favoriteButton = BetterInfo::createSearchButton(this, "Favorites", "gj_heartOn_001.png", menu_selector(LevelCategorySearchAlert::onFavorites), .45f, .6f); - favoriteButton->setPosition({58.5, 18}); + favoriteButton->setPosition({0, 18}); favoriteButton->setID("favorite-button"_spr); m_buttonMenu->addChild(favoriteButton); + auto folderButton = BetterInfo::createSearchButton(this, "Folder", "folderIcon_001.png", menu_selector(LevelCategorySearchAlert::onFolder), .45f, .525f); + folderButton->setPosition({117, 18}); + folderButton->setID("folder-button"_spr); + auto folderSearchBtn = static_cast(folderButton->getNormalImage()); + folderSearchBtn->m_icon->setPositionX(folderSearchBtn->m_icon->getPositionX() + 1); + folderSearchBtn->m_icon->setPositionY(folderSearchBtn->m_icon->getPositionY() + 1); + m_buttonMenu->addChild(folderButton); + //auto completedButton = createButton(m_buttonMenu, "Completed", menu_selector(LevelCategorySearchAlert::onCompleted), -114, -22, (int)(120*0.6), 44*0.6f, 0.6f); auto completedButton = BetterInfo::createSearchButton(this, "Completed", "GJ_completesIcon_001.png", menu_selector(LevelCategorySearchAlert::onCompleted), .45f, .5f); completedButton->setPosition({-117, -22}); diff --git a/src/layers/LevelFiltering/LevelCategorySearchAlert.h b/src/layers/LevelFiltering/LevelCategorySearchAlert.h index f070506..a96a933 100644 --- a/src/layers/LevelFiltering/LevelCategorySearchAlert.h +++ b/src/layers/LevelFiltering/LevelCategorySearchAlert.h @@ -5,17 +5,19 @@ using namespace geode::prelude; //TODO: use CvoltonAlertLayerStub -class BI_DLL LevelCategorySearchAlert : public FLAlertLayer { +class BI_DLL LevelCategorySearchAlert : public FLAlertLayer, public SetIDPopupDelegate { public: static LevelCategorySearchAlert* create(); void onClose(cocos2d::CCObject* sender); void onPlayed(cocos2d::CCObject* sender); void onFavorites(cocos2d::CCObject* sender); + void onFolder(cocos2d::CCObject* sender); void onCompleted(cocos2d::CCObject* sender); void onOrbs(cocos2d::CCObject* sender); void onLeaderboard(cocos2d::CCObject* sender); void onCoins(cocos2d::CCObject* sender); void onNoCoins(cocos2d::CCObject* sender); + void setIDPopupClosed(SetIDPopup*, int); bool init(); CCMenuItemSpriteExtra* createButton(cocos2d::CCNode* menu, const char* text, cocos2d::SEL_MenuHandler handler, float x, float y, int width, float height, float scale); }; \ No newline at end of file