Skip to content

Commit

Permalink
enable level leaderboards
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Jan 2, 2024
1 parent 6b847cf commit bcca637
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
12 changes: 5 additions & 7 deletions src/hooks/LevelCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,12 @@ class $modify(BILevelCell, LevelCell) {
LevelCell::onViewProfile(sender);
}

void loadFromLevel(GJGameLevel* level) {
if(std::string(level->m_creatorName).empty() && m_level->m_levelType != GJLevelType::Editor) {
level->m_creatorName = BetterInfoCache::sharedState()->getUserName(level->m_userID, false);
void loadCustomLevelCell() {
if(std::string(m_level->m_creatorName).empty()) {
m_level->m_creatorName = BetterInfoCache::sharedState()->getUserName(m_level->m_userID, false);
}

LevelCell::loadFromLevel(level);

if(m_level->m_levelType == GJLevelType::Editor) return;
LevelCell::loadCustomLevelCell();

//this->getScheduler()->scheduleSelector(schedule_selector(BILevelCell::checkHover), this, 0.1f, false);

Expand Down Expand Up @@ -161,7 +159,7 @@ class $modify(BILevelCell, LevelCell) {
if(!BetterInfo::isNewGrounds(m_level->m_songID)) static_cast<CCLabelBMFont*>(songLabel)->setColor({249,170,190});
}

if(auto playerName = m_mainLayer->getChildByID("player-name")) {
if(auto playerName = m_mainMenu->getChildByID("creator-name")) {
static_cast<CCMenuItemSpriteExtra*>(playerName)->setEnabled(true);
}
}
Expand Down
17 changes: 9 additions & 8 deletions src/hooks/LevelLeaderboard.cpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
//TODO: reverse LevelLeaderboard

/*#include <Geode/Bindings.hpp>
#include <Geode/Bindings.hpp>
#include <Geode/modify/LevelLeaderboard.hpp>

using namespace geode::prelude;

class $modify(BILevelLeaderboard, LevelLeaderboard) {*/
class $modify(BILevelLeaderboard, LevelLeaderboard) {

/*
* Callbacks
*/

/*void onLeaderboardDaily(CCObject* sender){
void onLeaderboardDaily(CCObject* sender){
auto level = GJGameLevel::create();
level->m_levelID = this->m_level->m_levelID;
level->m_levelName = this->m_level->m_levelName;
level->m_dailyID = !this->m_level->m_dailyID;
level->m_levelLength = this->m_level->m_levelLength;
GameLevelManager::sharedState()->m_timerDict->removeAllObjects(); //this is equivalent to GLM::resetAllTimers() which I suspect is inlined on windows but i didn't bother checking
auto newLeaderboard = LevelLeaderboard::create(level, this->m_type);
auto newLeaderboard = LevelLeaderboard::create(level, this->m_type, this->m_mode);
newLeaderboard->onUpdate(sender);
CCDirector::sharedDirector()->getRunningScene()->addChild(newLeaderboard);
this->onClose(sender);
}*/
}

/*
* Hooks
*/

/*bool init(GJGameLevel* level, LevelLeaderboardType type) { //type is usually an enum but i dont have that rn
if(!LevelLeaderboard::init(level, type)) return false;
bool init(GJGameLevel* level, LevelLeaderboardType type, LevelLeaderboardMode mode) {
if(!LevelLeaderboard::init(level, type, mode)) return false;

auto buttonSprite = ButtonSprite::create((level->m_dailyID ? "Daily" : "Normal"), 20, true, "bigFont.fnt", "GJ_button_01.png", 30, 0.5);
auto buttonButton = CCMenuItemSpriteExtra::create(
Expand All @@ -43,4 +44,4 @@ class $modify(BILevelLeaderboard, LevelLeaderboard) {*/

return true;
}
};*/
};
9 changes: 3 additions & 6 deletions src/layers/DailyHistory/DailyCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,9 @@ void DailyCell::onView(CCObject* sender){
}

void DailyCell::onLeaderboards(CCObject* sender){
//TODO: reverse LevelLeaderboard
//TODO: find the replacement for getIntGameVariableDefault

/*auto GM = GameManager::sharedState();
auto newLeaderboard = LevelLeaderboard::create(m_level, (LevelLeaderboardType) GM->getIntGameVariableDefault("0098", 1));
newLeaderboard->show();*/
auto GM = GameManager::sharedState();
auto newLeaderboard = LevelLeaderboard::create(m_level, (LevelLeaderboardType) GM->getIntGameVariableDefault("0098", 1), (LevelLeaderboardMode) GM->getIntGameVariableDefault("0164", 0));
newLeaderboard->show();
}

void DailyCell::onInfo(CCObject* sender){
Expand Down

0 comments on commit bcca637

Please sign in to comment.