Skip to content

Commit

Permalink
Fixed Better Progression crash (#38) and added Pointercrate leaderboard
Browse files Browse the repository at this point in the history
Made better progression leaderboard as optionnal if you don't have the mod.

If you don't have the mod, it's replaced with the new leaderboard type : Pointercrate
  • Loading branch information
Jouca committed Oct 20, 2024
1 parent 7ca06fc commit 8a4062d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 9 deletions.
25 changes: 25 additions & 0 deletions src/MoreLeaderboards/CustomScoreCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ class $modify(CustomScoreCell, GJScoreCell) {
platformer_sprite->setPositionX(30);
platformer_sprite->setScale(1.2f);

auto pointercrate = CCSprite::createWithSpriteFrameName("diffIcon_06_btn_001.png");
auto pointercrate_text = CCLabelBMFont::create("PC", "goldFont.fnt");
pointercrate_text->setPosition(28, 0);
pointercrate_text->setScale(0.5f);
pointercrate->addChild(pointercrate_text);

auto easydemon_sprite_classic = CCSprite::createWithSpriteFrameName("diffIcon_07_btn_001.png");
easydemon_sprite_classic->addChild(classic_sprite);
auto mediumdemon_sprite_classic = CCSprite::createWithSpriteFrameName("diffIcon_08_btn_001.png");
Expand Down Expand Up @@ -389,6 +395,25 @@ class $modify(CustomScoreCell, GJScoreCell) {
demon_icon->setZOrder(demon_icon_z);
statsMenu->addChild(extreme_sprite_classic);

demon_label->removeFromParent();
demon_label = CCLabelBMFont::create(count_diff.c_str(), "bigFont.fnt");
demon_label->setPosition(demon_label_pos);
demon_label->setScale(demon_label_scale);
demon_label->setZOrder(demon_label_z);
demon_label->setTag(demon_label_tag);
demon_label->setLayoutOptions(demon_label_layout);
statsMenu->addChild(demon_label);
break;
case StatsListType::Pointercrate:
demon_icon->removeFromParent();
demon_icon = pointercrate;
demon_icon->setPosition(demon_icon_pos);
demon_icon->setScale(demon_icon_scale);
demon_icon->setLayoutOptions(demon_icon_layout);
demon_icon->setTag(demon_icon_tag);
demon_icon->setZOrder(demon_icon_z);
statsMenu->addChild(pointercrate);

demon_label->removeFromParent();
demon_label = CCLabelBMFont::create(count_diff.c_str(), "bigFont.fnt");
demon_label->setPosition(demon_label_pos);
Expand Down
45 changes: 37 additions & 8 deletions src/MoreLeaderboards/MoreLeaderboards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Newtab.h"
#include <Geode/modify/LeaderboardsLayer.hpp>
#include <Geode/ui/GeodeUI.hpp>
#include <Geode/loader/Loader.hpp>

StatsListType MoreLeaderboards::g_tab = StatsListType::Stars;
bool MoreLeaderboards::modFilter = false;
Expand Down Expand Up @@ -546,6 +547,9 @@ void MoreLeaderboards::startLoadingMore() {
case StatsListType::BetterProgression:
type = "betterProgression";
break;
case StatsListType::Pointercrate:
type = "pointercratePoints";
break;
}

const geode::utils::MiniFunction<void(std::string const&)> expect = [this](std::string const& error) {
Expand Down Expand Up @@ -975,6 +979,11 @@ void MoreLeaderboards::changeTabPage() {
platformer_sprite->setScale(1.2f);

auto better_progression = CCSprite::create("better_progression.png"_spr);
auto pointercrate = CCSprite::createWithSpriteFrameName("diffIcon_06_btn_001.png");
auto pointercrate_text = CCLabelBMFont::create("PC", "goldFont.fnt");
pointercrate_text->setPosition(28, 0);
pointercrate_text->setScale(0.5f);
pointercrate->addChild(pointercrate_text);

auto easydemon_sprite_classic = CCSprite::createWithSpriteFrameName("diffIcon_07_btn_001.png");
easydemon_sprite_classic->addChild(classic_sprite);
Expand Down Expand Up @@ -1046,14 +1055,25 @@ void MoreLeaderboards::changeTabPage() {

break;
case 1:
MoreLeaderboards::g_tab = StatsListType::BetterProgression;

m_tab1 = NewTabButton::create(TabBaseColor::Unselected, TabBaseColor::Selected, better_progression, this, menu_selector(MoreLeaderboards::onTab));
m_tab1->setPosition(-140.f, 132);
m_tab1->setTag(static_cast<int>(StatsListType::BetterProgression));
m_tab1->setZOrder(30);
m_tab1->setScale(0.8f);
m_menu->addChild(m_tab1);
if (geode::Loader::get()->isModLoaded("itzkiba.better_progression")) {
MoreLeaderboards::g_tab = StatsListType::BetterProgression;

m_tab1 = NewTabButton::create(TabBaseColor::Unselected, TabBaseColor::Selected, better_progression, this, menu_selector(MoreLeaderboards::onTab));
m_tab1->setPosition(-140.f, 132);
m_tab1->setTag(static_cast<int>(StatsListType::BetterProgression));
m_tab1->setZOrder(30);
m_tab1->setScale(0.8f);
m_menu->addChild(m_tab1);
} else {
MoreLeaderboards::g_tab = StatsListType::Pointercrate;

m_tab1 = NewTabButton::create(TabBaseColor::Unselected, TabBaseColor::Selected, pointercrate, this, menu_selector(MoreLeaderboards::onTab));
m_tab1->setPosition(-140.f, 132);
m_tab1->setTag(static_cast<int>(StatsListType::Pointercrate));
m_tab1->setZOrder(30);
m_tab1->setScale(0.8f);
m_menu->addChild(m_tab1);
}

m_tab2 = NewTabButton::create(TabBaseColor::Unselected, TabBaseColor::Selected, easydemon_sprite_classic, this, menu_selector(MoreLeaderboards::onTab));
m_tab2->setPosition(-86.f, 132);
Expand Down Expand Up @@ -1129,6 +1149,15 @@ void MoreLeaderboards::changeTabPage() {
m_tab5->setScale(0.8f);
m_menu->addChild(m_tab5);

if (geode::Loader::get()->isModLoaded("itzkiba.better_progression")) {
m_tab6 = NewTabButton::create(TabBaseColor::Unselected, TabBaseColor::Selected, pointercrate, this, menu_selector(MoreLeaderboards::onTab));
m_tab6->setPosition(138.f, 132);
m_tab6->setTag(static_cast<int>(StatsListType::Pointercrate));
m_tab6->setZOrder(30);
m_tab6->setScale(0.8f);
m_menu->addChild(m_tab6);
}

break;
}

Expand Down
3 changes: 2 additions & 1 deletion src/MoreLeaderboards/MoreLeaderboards.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ enum class StatsListType {
platformerDemonsHard,
platformerDemonsInsane,
platformerDemonsExtreme,
BetterProgression
BetterProgression,
Pointercrate
};

class MoreLeaderboards : public CCLayer {
Expand Down

0 comments on commit 8a4062d

Please sign in to comment.