Skip to content

Commit

Permalink
Merge pull request #1 from hiimjasmine00/patch-1
Browse files Browse the repository at this point in the history
Do some integrity checks
  • Loading branch information
Ziegenhainy authored Feb 7, 2025
2 parents 3171999 + 4379d40 commit 04e0781
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using namespace geode::prelude;

void shuffle(CCNode* menu) {
if (!menu) return;
int childrenCount = menu->getChildrenCount();
if (childrenCount <= 1) return;
log::debug("shuffling menu: {}", menu->getID());
Expand All @@ -31,11 +32,13 @@ void shuffle(CCNode* menu) {
auto child = static_cast<CCNode*>(menu->getChildren()->objectAtIndex(rand()%childrenCount));
// log::debug("Children: {}",childrenCount);
shuffledChildrenBuffer[i] = child;
child->retain();
menu->removeChild(child);
}

for(auto child : shuffledChildrenBuffer) {
menu->addChild(child,0);
child->release();
}

menu->updateLayout();
Expand Down Expand Up @@ -80,13 +83,15 @@ class $modify(HookedMenuLayer, MenuLayer) {

CCNode* socialMediaMenu = this->getChildByID("social-media-menu");
CCNode* safeChild = socialMediaMenu->getChildByID("robtop-logo-button");
safeChild->retain();
socialMediaMenu->removeChildByID("robtop-logo-button");

for(auto menu : menus) {
shuffle(menu);
}
shuffleRaw(socialMediaMenu);
socialMediaMenu->addChild(safeChild);
safeChild->release();

return true;
}
Expand Down Expand Up @@ -248,6 +253,7 @@ class $modify(HookedLevelSearchLayer, LevelSearchLayer) {
this->getChildByID("search-button-menu")
};
auto protectedChild = menusRaw[2]->getChildByID("demon-type-filter-button");
protectedChild->retain();
menusRaw[2]->removeChildByID("demon-type-filter-button");

CCNode* menus[] = {
Expand All @@ -259,6 +265,7 @@ class $modify(HookedLevelSearchLayer, LevelSearchLayer) {
for(auto menu : menus) shuffle(menu);

menusRaw[2]->addChild(protectedChild);
protectedChild->release();

return true;
}
Expand Down

0 comments on commit 04e0781

Please sign in to comment.