Skip to content

Commit

Permalink
show icon unlock dialog in GJScoreCell
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Jan 10, 2024
1 parent f633259 commit 703d00d
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 1 deletion.
47 changes: 47 additions & 0 deletions src/hooks/GJScoreCell.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <Geode/Bindings.hpp>
#include <Geode/modify/GJScoreCell.hpp>

#include "../utils.hpp"

using namespace geode::prelude;

class $modify(BIGJScoreCell, GJScoreCell) {

/*
* Callbacks
*/
void onSimplePlayer(CCObject* sender){
ItemInfoPopup::create(m_score->m_iconID, BetterInfo::iconTypeToUnlockType(m_score->m_iconType))->show();
}

/*
* Hooks
*/

void loadFromScore(GJUserScore* b) {
GJScoreCell::loadFromScore(b);

if(auto player = m_mainLayer->getChildByID("player-icon")) {
auto playerMenu = CCMenu::create();
playerMenu->setPosition(player->getPosition());

m_mainLayer->removeChild(player);
m_mainLayer->addChild(playerMenu);

auto container = CCNode::create();
container->setContentSize({50,50});
container->addChild(player);

player->setPosition(container->getContentSize() / 2);

auto playerBtn = CCMenuItemSpriteExtra::create(
container,
this,
menu_selector(BIGJScoreCell::onSimplePlayer)
);

playerMenu->addChild(playerBtn);
}

}
};
55 changes: 54 additions & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,4 +591,57 @@ bool BetterInfo::isSprite(CCSprite* sprite, const char* name) {
if(!cache) return false;

return cache->getTexture() == sprite->getTexture() && cache->getRect() == sprite->getTextureRect();
}
}

UnlockType BetterInfo::iconTypeToUnlockType(IconType type)
{
//the actual func doesnt work for an unknown reason
int result = 0;

switch ((int) type)
{
case 0:
result = 1;
break;
case 1:
result = 4;
break;
case 2:
result = 5;
break;
case 3:
result = 6;
break;
case 4:
result = 7;
break;
case 5:
result = 8;
break;
case 6:
result = 9;
break;
case 7:
result = 13;
break;
case 8:
result = 14;
break;
case 9:
result = 11;
break;
case 0xA:
result = 10;
break;
case 0xB:
result = 12;
break;
case 0xC:
result = 15;
break;
default:
result = 0;
break;
}
return (UnlockType) result;
}
2 changes: 2 additions & 0 deletions src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ namespace BetterInfo {
bool isHoveringNode(CCNode* target);

bool isSprite(CCSprite* sprite, const char* name);

UnlockType iconTypeToUnlockType(IconType type);
}

0 comments on commit 703d00d

Please sign in to comment.