diff --git a/CMakeLists.txt b/CMakeLists.txt index 462495d..ec629fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64") set(CMAKE_CXX_VISIBILITY_PRESET hidden) -project(FakeRate VERSION 1.4.8) +project(FakeRate VERSION 1.4.9) add_library(${PROJECT_NAME} SHARED src/FakeRate.cpp diff --git a/changelog.md b/changelog.md index 51e5f47..7ca7d48 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,8 @@ # Fake Rate Changelog +## v1.4.9 (2024-10-30) +- Fixed a bug where the game would crash when re-rating a level with a More Difficulties difficulty when More Difficulties is disabled +- Removed Animated Fire support from the fake rate popup (Waiting for Uproxide to fix the bug) + ## v1.4.8 (2024-08-31) - Fixed a bug where the animated fire in the fake rate popup would sometimes appear twice diff --git a/mod.json b/mod.json index 395fad9..7863488 100644 --- a/mod.json +++ b/mod.json @@ -1,16 +1,15 @@ { - "geode": "3.4.0", + "geode": "3.9.0", "gd": { "android": "2.206", "win": "2.206", "mac": "2.206" }, - "version": "v1.4.8", + "version": "v1.4.9", "id": "hiimjustin000.fake_rate", "name": "Fake Rate", "developer": "hiimjustin000", "description": "A mod that allows you to assign a fake rating to online levels.", - "repository": "https://github.com/hiimjustin000/FakeRate", "dependencies": [ { "id": "geode.node-ids", diff --git a/src/FREditPopup.cpp b/src/FREditPopup.cpp index 149f583..591fbb6 100644 --- a/src/FREditPopup.cpp +++ b/src/FREditPopup.cpp @@ -27,11 +27,6 @@ bool FREditPopup::setup(GJGameLevel* level, FakeRateSaveData data, UpdateFakeRat m_difficultySprite->setPositionX(60.0f); m_mainLayer->addChild(m_difficultySprite); - if (Loader::get()->isModLoaded("uproxide.animated_fire")) { - m_fireSprite = FireSprite::create(GJFeatureState::Epic); - m_fireSprite->setPosition(m_difficultySprite->getContentSize() / 2 + CCPoint { 0.0f, 16.875f }); - m_difficultySprite->addChild(m_fireSprite, -1); - } if (Loader::get()->isModLoaded("uproxide.more_difficulties")) { m_legacy = Loader::get()->getLoadedMod("uproxide.more_difficulties")->getSettingValue("legacy-difficulties"); m_mdSprite = CCSprite::createWithSpriteFrameName(m_legacy ? @@ -200,7 +195,7 @@ bool FREditPopup::setup(GJGameLevel* level, FakeRateSaveData data, UpdateFakeRat .stars = stars, .feature = m_level->m_featured > 1 ? m_level->m_isEpic + 1 : 0, .difficulty = FakeRate::getDifficultyFromLevel(m_level), - .moreDifficultiesOverride = stars == 4 || stars == 7 || stars == 9 ? stars : 0, + .moreDifficultiesOverride = Loader::get()->isModLoaded("uproxide.more_difficulties") && (stars == 4 || stars == 7 || stars == 9) ? stars : 0, .grandpaDemonOverride = 0, .demonsInBetweenOverride = 0, .gddpIntegrationOverride = 0, @@ -217,7 +212,6 @@ bool FREditPopup::setup(GJGameLevel* level, FakeRateSaveData data, UpdateFakeRat } void FREditPopup::updateLabels() { - if (m_fireSprite && m_difficultySprite->m_featureState != (GJFeatureState)m_feature) m_fireSprite->retain(); m_difficultySprite->updateFeatureState((GJFeatureState)m_feature); m_difficultySprite->updateDifficultyFrame(m_difficulty, GJDifficultyName::Long); auto isDemon = m_difficulty > 5 || m_grandpaDemonOverride > 0 || m_demonsInBetweenOverride > 0 || m_gddpIntegrationOverride > 0; @@ -232,14 +226,6 @@ void FREditPopup::updateLabels() { coin->setColor(m_coins ? ccColor3B { 255, 255, 255 } : ccColor3B { 255, 175, 75 }); } m_difficultySprite->setOpacity(255); - if (Loader::get()->isModLoaded("uproxide.animated_fire") && m_feature > 1) { - m_fireSprite->init((GJFeatureState)m_feature); - m_fireSprite->setPosition(m_difficultySprite->getContentSize() / 2 + CCPoint { 0.0f, m_feature == 2 ? 16.875f : 15.875f }); - if (auto oldFire = getChildBySpriteFrameName(m_difficultySprite, (m_feature == 2 ? "GJ_epicCoin_001.png" : - fmt::format("GJ_epicCoin{}_001.png", m_feature - 1)).c_str())) oldFire->setVisible(false); - m_difficultySprite->addChild(m_fireSprite, -1); - m_fireSprite->release(); - } if (Loader::get()->isModLoaded("uproxide.more_difficulties")) { if (m_moreDifficultiesOverride == 4 || m_moreDifficultiesOverride == 7 || m_moreDifficultiesOverride == 9) { m_mdSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName( @@ -337,7 +323,7 @@ bool FRSetDifficultyPopup::setup(FakeRateSaveData data, bool legacy, SetDifficul m_grandpaDemonOverride = 0; m_demonsInBetweenOverride = 0; m_gddpIntegrationOverride = 0; - FakeRate::toggle(m_selected->getNormalImage(), false); + if (m_selected) FakeRate::toggle(m_selected->getNormalImage(), false); FakeRate::toggle(sender->getNormalImage(), true); m_selected = sender; }); @@ -502,13 +488,6 @@ bool FRSetFeaturePopup::setup(FakeRateSaveData data, bool legacy, SetIntCallback auto feature = static_cast(i); auto difficultySprite = GJDifficultySprite::create(m_difficulty, GJDifficultyName::Long); difficultySprite->updateFeatureState(feature); - if (Loader::get()->isModLoaded("uproxide.animated_fire") && i > 1) { - auto fire = FireSprite::create((GJFeatureState)i); - fire->setPosition(difficultySprite->getContentSize() / 2 + CCPoint { 0.0f, i == 2 ? 16.875f : 15.875f }); - if (auto oldFire = getChildBySpriteFrameName(difficultySprite, (i == 2 ? "GJ_epicCoin_001.png" : - fmt::format("GJ_epicCoin{}_001.png", i - 1)).c_str())) oldFire->setVisible(false); - difficultySprite->addChild(fire, -1); - } if (Loader::get()->isModLoaded("uproxide.more_difficulties") && m_moreDifficultiesOverride > 0 && m_grandpaDemonOverride == 0 && m_demonsInBetweenOverride == 0) { auto mdSprite = CCSprite::createWithSpriteFrameName((m_legacy ? @@ -545,14 +524,16 @@ bool FRSetFeaturePopup::setup(FakeRateSaveData data, bool legacy, SetIntCallback auto toggle = CCMenuItemExt::createSpriteExtra(difficultySprite, [this, feature](CCMenuItemSpriteExtra* sender) { if (sender == m_selected) return; m_feature = feature; - FakeRate::toggle(m_selected->getNormalImage(), false); - if (auto particleSystem = getChildOfType(m_selected->getNormalImage(), 0)) particleSystem->setVisible(false); + if (m_selected) { + FakeRate::toggle(m_selected->getNormalImage(), false); + if (auto particleSystem = m_selected->getNormalImage()->getChildByType(0)) particleSystem->setVisible(false); + } FakeRate::toggle(sender->getNormalImage(), true); - if (auto particleSystem = getChildOfType(sender->getNormalImage(), 0)) particleSystem->setVisible(true); + if (auto particleSystem = sender->getNormalImage()->getChildByType(0)) particleSystem->setVisible(true); m_selected = sender; }); FakeRate::toggle(difficultySprite, feature == m_feature); - if (auto particleSystem = getChildOfType(difficultySprite, 0)) particleSystem->setVisible(feature == m_feature); + if (auto particleSystem = difficultySprite->getChildByType(0)) particleSystem->setVisible(feature == m_feature); m_selected = feature == m_feature ? toggle : m_selected; menuRow->addChild(toggle); } diff --git a/src/FREditPopup.hpp b/src/FREditPopup.hpp index 32932b0..1d519a6 100644 --- a/src/FREditPopup.hpp +++ b/src/FREditPopup.hpp @@ -1,8 +1,8 @@ #include "FREffects.hpp" -typedef MiniFunction UpdateFakeRateCallback; -typedef MiniFunction SetDifficultyCallback; -typedef MiniFunction SetIntCallback; +typedef std::function const& UpdateFakeRateCallback; +typedef std::function const& SetDifficultyCallback; +typedef std::function const& SetIntCallback; class FREditPopup : public Popup { protected: @@ -23,7 +23,6 @@ class FREditPopup : public Popup #include "FREffects.hpp" -FireSprite* FireSprite::create(GJFeatureState featureState) { - auto ret = new FireSprite(); - if (ret->init(featureState)) { - ret->autorelease(); - return ret; - } - delete ret; - return nullptr; -} - -bool FireSprite::init(GJFeatureState featureState) { - auto frameName = ""; - switch (featureState) { - case GJFeatureState::Epic: frameName = "uproxide.animated_fire/EpicFrame_01.png"; break; - case GJFeatureState::Legendary: frameName = "uproxide.animated_fire/LegendaryFrame_01.png"; break; - case GJFeatureState::Mythic: frameName = "uproxide.animated_fire/MythicFrame_01.png"; break; - default: break; - } - if (!CCSprite::initWithSpriteFrameName(frameName)) return false; - - m_featureState = featureState; - - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_int_distribution<> dis(1, 7); - m_currentFrame = dis(gen); - - schedule(schedule_selector(FireSprite::fireAnimation), 1.0f / 12.0f); - - return true; -} - -void FireSprite::fireAnimation(float) { - auto type = ""; - switch (m_featureState) { - case GJFeatureState::Epic: type = "Epic"; break; - case GJFeatureState::Legendary: type = "Legendary"; break; - case GJFeatureState::Mythic: type = "Mythic"; break; - default: break; - } - - m_currentFrame++; - if (m_currentFrame > 8) m_currentFrame = 1; - setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName( - fmt::format("uproxide.animated_fire/{}Frame_{:02d}.png", type, m_currentFrame).c_str())); -} - CCSprite* FREffects::grdInfinity() { CCSprite* infinity = CCSprite::createWithSpriteFrameName("itzkiba.grandpa_demon/GrD_demon4_infinity.png"); infinity->setZOrder(30); diff --git a/src/FREffects.hpp b/src/FREffects.hpp index af9a806..02401f9 100644 --- a/src/FREffects.hpp +++ b/src/FREffects.hpp @@ -1,15 +1,5 @@ #include "TableNode.hpp" -class FireSprite : public CCSprite { -protected: - int m_currentFrame = 1; - GJFeatureState m_featureState; -public: - static FireSprite* create(GJFeatureState); - bool init(GJFeatureState); - void fireAnimation(float); -}; - class FREffects { public: static CCSprite* grdInfinity();