Skip to content

Commit

Permalink
Utilize node ID layouts more properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Jan 2, 2024
1 parent df845cf commit 3e27d8e
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 198 deletions.
5 changes: 2 additions & 3 deletions src/hooks/CommentCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ class $modify(BICommentCell, CommentCell) {
bool liked = GameLevelManager::sharedState()->hasLikedItemFullCheck(type, this->m_comment->m_commentID, special);
if(liked) return;

//TODO: missing game manager members
/*auto GM = GameManager::sharedState();
if (this->m_comment->m_userID == GM->m_playerUserID) return;*/
auto GM = GameManager::sharedState();
if (this->m_comment->m_userID == GM->m_playerUserID) return;

auto AM = GJAccountManager::sharedState();
if (this->m_comment->m_accountID && this->m_comment->m_accountID == AM->m_accountID) return;
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/DailyLevelNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class $modify(BIDailyLevelNode, DailyLevelNode) {
bool init(GJGameLevel* level, DailyLevelPage* page, bool weekly) {
if(!DailyLevelNode::init(level, page, weekly)) return false;

for(auto node : CCArrayExt<CCNode>(this->getChildren())) {
if(node->getPosition() == CCPoint(182, 53)) node->setPositionX(130);
if(auto newNode = getChildByID("new-label")) {
if(newNode->getPositionX() == 182) newNode->setPositionX(130);
}

return true;
Expand Down
69 changes: 35 additions & 34 deletions src/hooks/InfoLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,38 +77,42 @@ class $modify(BIInfoLayer, InfoLayer) {
cache->storeDatesForLevel(this->m_level);
}

//geode doesn't have ids defined for this so i have to resort to objectAtIndex
auto layer = static_cast<CCLayer*>(this->getChildren()->objectAtIndex(0));
CCMenu* menu = static_cast<CCMenu*>(layer->getChildren()->objectAtIndex(1));

CCMenuItemSpriteExtra* playerName = static_cast<CCMenuItemSpriteExtra*>(menu->getChildren()->objectAtIndex(0));
playerName->setEnabled(true);
if(auto playerName = static_cast<CCMenuItemSpriteExtra*>(m_buttonMenu->getChildByID("creator-button"))) {
playerName->setEnabled(true);
}

auto buttonSprite = ButtonSprite::create("1", 12, true, "bigFont.fnt", "GJ_button_02.png", 25, 0.4f);
auto buttonButton = CCMenuItemSpriteExtra::create(
buttonSprite,
this,
menu_selector(BIInfoLayer::onJumpToPageLayer)
);
buttonButton->setSizeMult(1.2f);
buttonButton->setPosition({195,34});
buttonButton->setID("comment-page-btn"_spr);
//buttonButton->setTag(commentPageBtnTag);
menu->addChild(buttonButton);
if(auto menu = m_mainLayer->getChildByID("refresh-menu")) {
auto buttonSprite = ButtonSprite::create("1", 12, true, "bigFont.fnt", "GJ_button_02.png", 25, 0.4f);
auto buttonButton = CCMenuItemSpriteExtra::create(
buttonSprite,
this,
menu_selector(BIInfoLayer::onJumpToPageLayer)
);
buttonButton->setSizeMult(1.2f);
buttonButton->setPosition({195,34});
buttonButton->setID("comment-page-btn"_spr);
//buttonButton->setTag(commentPageBtnTag);
menu->addChild(buttonButton);
menu->updateLayout();
}

if(level == nullptr) return true;

auto searchSprite = CCSprite::createWithSpriteFrameName("gj_findBtn_001.png");
searchSprite->setScale(0.8f);
auto searchButton = CCMenuItemSpriteExtra::create(
searchSprite,
this,
menu_selector(BIInfoLayer::onCustomSearch)
);
menu->addChild(searchButton);
searchButton->setPosition({195, 68});
searchButton->setSizeMult(1.2f);
searchButton->setID("search-btn"_spr);
//end of level stuff

if(auto menu = m_mainLayer->getChildByID("refresh-menu")) {
auto searchSprite = CCSprite::createWithSpriteFrameName("gj_findBtn_001.png");
searchSprite->setScale(0.8f);
auto searchButton = CCMenuItemSpriteExtra::create(
searchSprite,
this,
menu_selector(BIInfoLayer::onCustomSearch)
);
menu->addChild(searchButton);
searchButton->setSizeMult(1.2f);
searchButton->setID("search-btn"_spr);

menu->updateLayout();
}

auto scheduleOffSprite = CCSprite::createWithSpriteFrameName("GJ_playEditorBtn_001.png");
scheduleOffSprite->setScale(.625f);
Expand All @@ -122,13 +126,10 @@ class $modify(BIInfoLayer, InfoLayer) {
);
scheduleBtn->setUserData(reinterpret_cast<void*>(false));
scheduleBtn->setPosition({202.5, 100});
menu->addChild(scheduleBtn);
m_buttonMenu->addChild(scheduleBtn);
scheduleBtn->setID("schedule-btn"_spr);

if(level->m_originalLevel != 0) {
auto originalBtn = typeinfo_cast<CCNode*>(menu->getChildren()->objectAtIndex(1));
if(!originalBtn || originalBtn->getPositionY() != 99) return true;

if(auto originalBtn = m_buttonMenu->getChildByID("original-level-button")) {
if(originalBtn->getPositionX() > 155.4f) originalBtn->setPosition({155.4f, originalBtn->getPositionY()});
}

Expand Down
29 changes: 12 additions & 17 deletions src/hooks/LeaderboardsLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,18 @@ class $modify(BILeaderboardsLayer, LeaderboardsLayer) {
bool init(LeaderboardState state){
if(!LeaderboardsLayer::init(state)) return false;

auto winSize = CCDirector::sharedDirector()->getWinSize();
auto layer = static_cast<CCLayer*>(this->getChildren()->objectAtIndex(0));

auto refreshBtn = CCMenuItemSpriteExtra::create(
CCSprite::createWithSpriteFrameName("GJ_updateBtn_001.png"),
this,
menu_selector(BILeaderboardsLayer::onLeaderboardRefresh)
);
refreshBtn->setID("refresh-button"_spr);

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

this->addChild(menuRefresh);
if(auto menu = getChildByID("bottom-right-menu")) {
auto refreshBtn = CCMenuItemSpriteExtra::create(
CCSprite::createWithSpriteFrameName("GJ_updateBtn_001.png"),
this,
menu_selector(BILeaderboardsLayer::onLeaderboardRefresh)
);
refreshBtn->setID("refresh-button"_spr);
refreshBtn->setZOrder(-2); //this should ensure we stay at the bottom

menu->addChild(refreshBtn);
menu->updateLayout();
}

return true;
}
Expand Down
Loading

0 comments on commit 3e27d8e

Please sign in to comment.