Skip to content

Commit

Permalink
I'm doing this tonight
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimjustin000 committed Oct 30, 2024
1 parent b3f9b4f commit 538b5bc
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 93 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 2 additions & 3 deletions mod.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
35 changes: 8 additions & 27 deletions src/FREditPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>("legacy-difficulties");
m_mdSprite = CCSprite::createWithSpriteFrameName(m_legacy ?
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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(
Expand Down Expand Up @@ -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;
});
Expand Down Expand Up @@ -502,13 +488,6 @@ bool FRSetFeaturePopup::setup(FakeRateSaveData data, bool legacy, SetIntCallback
auto feature = static_cast<GJFeatureState>(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 ?
Expand Down Expand Up @@ -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<CCParticleSystemQuad>(m_selected->getNormalImage(), 0)) particleSystem->setVisible(false);
if (m_selected) {
FakeRate::toggle(m_selected->getNormalImage(), false);
if (auto particleSystem = m_selected->getNormalImage()->getChildByType<CCParticleSystemQuad>(0)) particleSystem->setVisible(false);
}
FakeRate::toggle(sender->getNormalImage(), true);
if (auto particleSystem = getChildOfType<CCParticleSystemQuad>(sender->getNormalImage(), 0)) particleSystem->setVisible(true);
if (auto particleSystem = sender->getNormalImage()->getChildByType<CCParticleSystemQuad>(0)) particleSystem->setVisible(true);
m_selected = sender;
});
FakeRate::toggle(difficultySprite, feature == m_feature);
if (auto particleSystem = getChildOfType<CCParticleSystemQuad>(difficultySprite, 0)) particleSystem->setVisible(feature == m_feature);
if (auto particleSystem = difficultySprite->getChildByType<CCParticleSystemQuad>(0)) particleSystem->setVisible(feature == m_feature);
m_selected = feature == m_feature ? toggle : m_selected;
menuRow->addChild(toggle);
}
Expand Down
7 changes: 3 additions & 4 deletions src/FREditPopup.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "FREffects.hpp"

typedef MiniFunction<void(FakeRateSaveData, bool)> UpdateFakeRateCallback;
typedef MiniFunction<void(int, int, int, int, int)> SetDifficultyCallback;
typedef MiniFunction<void(int)> SetIntCallback;
typedef std::function<void(FakeRateSaveData, bool)> const& UpdateFakeRateCallback;
typedef std::function<void(int, int, int, int, int)> const& SetDifficultyCallback;
typedef std::function<void(int)> const& SetIntCallback;

class FREditPopup : public Popup<GJGameLevel*, FakeRateSaveData, UpdateFakeRateCallback> {
protected:
Expand All @@ -23,7 +23,6 @@ class FREditPopup : public Popup<GJGameLevel*, FakeRateSaveData, UpdateFakeRateC
CCSprite* m_dibSprite;
CCSprite* m_gddpSprite;
CCSprite* m_starSprite;
FireSprite* m_fireSprite;
CCLabelBMFont* m_starsLabel;
CCArray* m_coinSprites;

Expand Down
48 changes: 0 additions & 48 deletions src/FREffects.cpp
Original file line number Diff line number Diff line change
@@ -1,53 +1,5 @@
#include <random>
#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);
Expand Down
10 changes: 0 additions & 10 deletions src/FREffects.hpp
Original file line number Diff line number Diff line change
@@ -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();
Expand Down

0 comments on commit 538b5bc

Please sign in to comment.