Skip to content

Commit

Permalink
Things people kept pestering me about
Browse files Browse the repository at this point in the history
hiimjustin000 committed Aug 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent eebc855 commit fb56f27
Showing 10 changed files with 170 additions and 32 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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.6)
project(FakeRate VERSION 1.4.7)

add_library(${PROJECT_NAME} SHARED
src/FakeRate.cpp
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Fake Rate Changelog
## v1.4.7 (2024-08-29)
- Added Demons In Between legendary and mythic difficulties
- Added Animated Fire support to the fake rate popup
- Fixed a bug where removing a fake rate would not apply the background color correctly

## v1.4.6 (2024-08-19)
- Fixed a bug where the hard demon face would not display before the other demon faces in the difficulty selection popup

2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
"win": "2.206",
"mac": "2.206"
},
"version": "v1.4.6",
"version": "v1.4.7",
"id": "hiimjustin000.fake_rate",
"name": "Fake Rate",
"developer": "hiimjustin000",
64 changes: 57 additions & 7 deletions src/FREditPopup.cpp
Original file line number Diff line number Diff line change
@@ -226,6 +226,29 @@ 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")) switch (m_feature) {
case 2: {
auto fire = FireSprite::create(GJFeatureState::Epic);
fire->setPosition(m_difficultySprite->getContentSize() / 2 + CCPoint { 0.0f, 16.875f });
if (auto oldFire = getChildBySpriteFrameName(m_difficultySprite, "GJ_epicCoin_001.png")) oldFire->setVisible(false);
m_difficultySprite->addChild(fire, -1);
break;
}
case 3: {
auto fire = FireSprite::create(GJFeatureState::Legendary);
fire->setPosition(m_difficultySprite->getContentSize() / 2 + CCPoint { 0.0f, 15.875f });
if (auto oldFire = getChildBySpriteFrameName(m_difficultySprite, "GJ_epicCoin2_001.png")) oldFire->setVisible(false);
m_difficultySprite->addChild(fire, -1);
break;
}
case 4: {
auto fire = FireSprite::create(GJFeatureState::Mythic);
fire->setPosition(m_difficultySprite->getContentSize() / 2 + CCPoint { 0.0f, 15.875f });
if (auto oldFire = getChildBySpriteFrameName(m_difficultySprite, "GJ_epicCoin3_001.png")) oldFire->setVisible(false);
m_difficultySprite->addChild(fire, -1);
break;
}
}
if (Loader::get()->isModLoaded("uproxide.more_difficulties")) {
if (m_moreDifficultiesOverride == 4 || m_moreDifficultiesOverride == 7 || m_moreDifficultiesOverride == 9) {
m_mdSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(
@@ -252,8 +275,12 @@ void FREditPopup::updateLabels() {
}
if (Loader::get()->isModLoaded("hiimjustin000.demons_in_between")) {
if (m_demonsInBetweenOverride > 0 && m_demonsInBetweenOverride < 21) {
auto demonsInBetween = Loader::get()->getLoadedMod("hiimjustin000.demons_in_between");
auto dibFeature = "";
if (m_feature == 3 && demonsInBetween->getSettingValue<bool>("enable-legendary")) dibFeature = "_4";
else if (m_feature == 4 && demonsInBetween->getSettingValue<bool>("enable-mythic")) dibFeature = "_5";
m_dibSprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(
fmt::format("hiimjustin000.demons_in_between/DIB_{:02d}_btn2_001.png", m_demonsInBetweenOverride).c_str()));
fmt::format("hiimjustin000.demons_in_between/DIB_{:02d}{}_btn2_001.png", m_demonsInBetweenOverride, dibFeature).c_str()));
m_dibSprite->setPosition(m_difficultySprite->getPosition() + FakeRate::getDIBOffset(m_demonsInBetweenOverride, GJDifficultyName::Long));
m_dibSprite->setVisible(true);
if (m_mdSprite) m_mdSprite->setVisible(false);
@@ -299,7 +326,6 @@ bool FRSetDifficultyPopup::setup(FakeRateSaveData data, bool legacy, SetDifficul
m_legacy = legacy;

auto table = TableNode::create(Loader::get()->isModLoaded("uproxide.more_difficulties") ? 5 : 4, 3);
table->setAnchorPoint({ 0.5f, 0.5f });
table->setColumnLayout(ColumnLayout::create()->setAxisReverse(true));
table->setRowLayout(RowLayout::create()->setAxisAlignment(AxisAlignment::Even));
table->setRowHeight(63.0f);
@@ -485,6 +511,29 @@ 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")) switch (i) {
case 2: {
auto fire = FireSprite::create(GJFeatureState::Epic);
fire->setPosition(difficultySprite->getContentSize() / 2 + CCPoint { 0.0f, 16.875f });
if (auto oldFire = getChildBySpriteFrameName(difficultySprite, "GJ_epicCoin_001.png")) oldFire->setVisible(false);
difficultySprite->addChild(fire, -1);
break;
}
case 3: {
auto fire = FireSprite::create(GJFeatureState::Legendary);
fire->setPosition(difficultySprite->getContentSize() / 2 + CCPoint { 0.0f, 15.875f });
if (auto oldFire = getChildBySpriteFrameName(difficultySprite, "GJ_epicCoin2_001.png")) oldFire->setVisible(false);
difficultySprite->addChild(fire, -1);
break;
}
case 4: {
auto fire = FireSprite::create(GJFeatureState::Mythic);
fire->setPosition(difficultySprite->getContentSize() / 2 + CCPoint { 0.0f, 15.875f });
if (auto oldFire = getChildBySpriteFrameName(difficultySprite, "GJ_epicCoin3_001.png")) oldFire->setVisible(false);
difficultySprite->addChild(fire, -1);
break;
}
}
if (Loader::get()->isModLoaded("uproxide.more_difficulties") && m_moreDifficultiesOverride > 0
&& m_grandpaDemonOverride == 0 && m_demonsInBetweenOverride == 0) {
auto mdSprite = CCSprite::createWithSpriteFrameName((m_legacy ?
@@ -501,8 +550,12 @@ bool FRSetFeaturePopup::setup(FakeRateSaveData data, bool legacy, SetIntCallback
difficultySprite->addChild(grdSprite);
}
if (Loader::get()->isModLoaded("hiimjustin000.demons_in_between") && m_demonsInBetweenOverride > 0) {
auto dibSprite = CCSprite::createWithSpriteFrameName(fmt::format("hiimjustin000.demons_in_between/DIB_{:02d}_btn2_001.png",
m_demonsInBetweenOverride).c_str());
auto demonsInBetween = Loader::get()->getLoadedMod("hiimjustin000.demons_in_between");
auto dibFeature = "";
if (i == 3 && demonsInBetween->getSettingValue<bool>("enable-legendary")) dibFeature = "_4";
else if (i == 4 && demonsInBetween->getSettingValue<bool>("enable-mythic")) dibFeature = "_5";
auto dibSprite = CCSprite::createWithSpriteFrameName(fmt::format("hiimjustin000.demons_in_between/DIB_{:02d}{}_btn2_001.png",
m_demonsInBetweenOverride, dibFeature).c_str());
dibSprite->setPosition(difficultySprite->getContentSize() / 2 + FakeRate::getDIBOffset(m_demonsInBetweenOverride, GJDifficultyName::Long));
difficultySprite->setOpacity(0);
difficultySprite->addChild(dibSprite);
@@ -557,7 +610,6 @@ bool FRGRDPopup::setup(int grandpaDemonOverride, SetIntCallback callback) {
m_grandpaDemonOverride = grandpaDemonOverride;

auto table = TableNode::create(3, 2);
table->setAnchorPoint({ 0.5f, 0.5f });
table->setColumnLayout(ColumnLayout::create()->setAxisReverse(true));
table->setRowLayout(RowLayout::create()->setAxisAlignment(AxisAlignment::Even));
table->setRowHeight(65.0f);
@@ -606,7 +658,6 @@ bool FRDIBPopup::setup(int demonsInBetweenOverride, SetIntCallback callback) {
m_demonsInBetweenOverride = demonsInBetweenOverride;

auto table = TableNode::create(5, 4);
table->setAnchorPoint({ 0.5f, 0.5f });
table->setColumnLayout(ColumnLayout::create()->setAxisReverse(true));
table->setRowLayout(RowLayout::create()->setAxisAlignment(AxisAlignment::Even));
table->setRowHeight(60.0f);
@@ -655,7 +706,6 @@ bool FRGDDPPopup::setup(int gddpIntegrationOverride, SetIntCallback callback) {
m_gddpIntegrationOverride = gddpIntegrationOverride;

auto table = TableNode::create(5, 3);
table->setAnchorPoint({ 0.5f, 0.5f });
table->setColumnLayout(ColumnLayout::create()->setAxisReverse(true));
table->setRowLayout(RowLayout::create()->setAxisAlignment(AxisAlignment::Even));
table->setRowHeight(60.0f);
48 changes: 48 additions & 0 deletions src/FREffects.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
#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);
11 changes: 11 additions & 0 deletions src/FREffects.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#include "TableNode.hpp"

class FireSprite : public CCSprite {
protected:
int m_currentFrame = 1;
GJFeatureState m_featureState;

bool init(GJFeatureState);
void fireAnimation(float);
public:
static FireSprite* create(GJFeatureState);
};

class FREffects {
public:
static CCSprite* grdInfinity();
28 changes: 8 additions & 20 deletions src/FakeRate.cpp
Original file line number Diff line number Diff line change
@@ -99,25 +99,26 @@ CCPoint FakeRate::getDIBOffset(int difficulty, GJDifficultyName name) {

int FakeRate::getGRDOverride(CCSprite* sprite) {
auto sprName = getSpriteName(sprite);
if (sprName.substr(sprName.size() - 9) == "_text.png") sprName = sprName.substr(0, sprName.size() - 9);

auto pos = sprName.find("GrD_demon");
if (pos != std::string::npos) {
auto num = sprName.substr(pos + 9);
return std::stoi(num) + 1;
auto str = numFromString<int>(num);
if (str.has_value()) return str.value() + 1;
else return 0;
}
else return 0;
}

int FakeRate::getDIBOverride(CCSprite* sprite) {
auto sprName = getSpriteName(sprite);
if (sprName.substr(sprName.size() - 12) == "_btn_001.png") sprName = sprName.substr(0, sprName.size() - 12);
else if (sprName.substr(sprName.size() - 13) == "_btn2_001.png") sprName = sprName.substr(0, sprName.size() - 13);

auto pos = sprName.find("DIB_");
if (pos != std::string::npos) {
auto num = sprName.substr(pos + 4);
return std::stoi(num);
auto str = numFromString<int>(num);
if (str.has_value()) return str.value();
else return 0;
}
else return 0;
}
@@ -131,21 +132,8 @@ int FakeRate::getGDDPOverride(CCSprite* sprite) {
auto pos = sprName.find("DP_");
if (pos != std::string::npos) {
auto num = sprName.substr(pos + 3);
if (num == "Beginner") return 1;
else if (num == "Bronze") return 2;
else if (num == "Silver") return 3;
else if (num == "Gold") return 4;
else if (num == "Amber") return 5;
else if (num == "Platinum") return 6;
else if (num == "Sapphire") return 7;
else if (num == "Jade") return 8;
else if (num == "Emerald") return 9;
else if (num == "Ruby") return 10;
else if (num == "Diamond") return 11;
else if (num == "Onyx") return 12;
else if (num == "Amethyst") return 13;
else if (num == "Azurite") return 14;
else if (num == "Obsidian") return 15;
auto str = GDDP_INDICES.find(num);
if (str != GDDP_INDICES.end()) return str->second;
else return 0;
}
else return 0;
18 changes: 18 additions & 0 deletions src/FakeRate.hpp
Original file line number Diff line number Diff line change
@@ -15,6 +15,24 @@ struct FakeRateSaveData {
};

class FakeRate {
private:
inline static std::unordered_map<std::string, int> GDDP_INDICES = {
{ "Beginner", 1 },
{ "Bronze", 2 },
{ "Silver", 3 },
{ "Gold", 4 },
{ "Amber", 5 },
{ "Platinum", 6 },
{ "Sapphire", 7 },
{ "Jade", 8 },
{ "Emerald", 9 },
{ "Ruby", 10 },
{ "Diamond", 11 },
{ "Onyx", 12 },
{ "Amethyst", 13 },
{ "Azurite", 14 },
{ "Obsidian", 15 }
};
public:
static int getBaseCurrency(int);
static int getDifficultyFromLevel(GJGameLevel*);
1 change: 1 addition & 0 deletions src/TableNode.cpp
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ TableNode* TableNode::create(int columns, int rows) {
bool TableNode::init(int columns, int rows) {
if (!CCNode::init()) return false;

setAnchorPoint({ 0.5f, 0.5f });
m_menus = CCArray::create();
m_menus->retain();
m_columns = columns;
23 changes: 20 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ class $modify(FRLevelInfoLayer, LevelInfoLayer) {
CCParticleSystemQuad* m_grandpaParticles1;
CCParticleSystemQuad* m_grandpaParticles2;
ccColor3B m_backgroundColor;
bool m_fakeRateApplied;
};

static void onModify(auto& self) {
@@ -73,7 +74,7 @@ class $modify(FRLevelInfoLayer, LevelInfoLayer) {
stars == 0 && (starsRequested == 4 || starsRequested == 7 || starsRequested == 9) ? starsRequested : 0 : 0,
.grandpaDemonOverride = grandpaDemon && (!gddpOverride || !gddpDifficulty) ? FakeRate::getGRDOverride(grandpaDemon) : 0,
.demonsInBetweenOverride = demonInBetween ? FakeRate::getDIBOverride(demonInBetween) : 0,
.gddpIntegrationOverride = gddpDifficulty && (!grandpaDemon || gddpOverride) ? FakeRate::getGDDPOverride(gddpDifficulty) : 0,
.gddpIntegrationOverride = gddpDifficulty && (!grandpaDemon || gddpOverride) && !demonInBetween ? FakeRate::getGDDPOverride(gddpDifficulty) : 0,
.coins = m_level->m_coinsVerified > 0
};
}
@@ -100,6 +101,14 @@ class $modify(FRLevelInfoLayer, LevelInfoLayer) {
.coins = coins
};

if (!fields->m_fakeRateApplied) {
fields->m_fakeRateApplied = true;
fields->m_backgroundColor = static_cast<CCSprite*>(getChildByID("background"))->getColor();
auto gdutils = Loader::get()->getLoadedMod("gdutilsdevs.gdutils");
if (gdutils && gdutils->getSettingValue<bool>("activate-background"))
fields->m_backgroundColor = gdutils->getSettingValue<ccColor3B>("background");
}

fields->m_grandpaBackground1 = static_cast<CCSprite*>(getChildByID("grandpa-background-1"_spr));
fields->m_grandpaBackground2 = static_cast<CCSprite*>(getChildByID("grandpa-background-2"_spr));
fields->m_grandpaParticles1 = static_cast<CCParticleSystemQuad*>(getChildByID("grandpa-particles-1"_spr));
@@ -326,7 +335,11 @@ class $modify(FRLevelInfoLayer, LevelInfoLayer) {
if (Loader::get()->isModLoaded("hiimjustin000.demons_in_between") && dbo > 0 && dbo < 21) {
if (auto fakeBetweenDemon = static_cast<CCSprite*>(getChildByID("between-difficulty-sprite"_spr))) fakeBetweenDemon->removeFromParent();

auto dibSprite = CCSprite::createWithSpriteFrameName(fmt::format("hiimjustin000.demons_in_between/DIB_{:02d}_btn2_001.png", dbo).c_str());
auto demonsInBetween = Loader::get()->getLoadedMod("hiimjustin000.demons_in_between");
auto dibFeature = "";
if (feature == 3 && demonsInBetween->getSettingValue<bool>("enable-legendary")) dibFeature = "_4";
else if (feature == 4 && demonsInBetween->getSettingValue<bool>("enable-mythic")) dibFeature = "_5";
auto dibSprite = CCSprite::createWithSpriteFrameName(fmt::format("hiimjustin000.demons_in_between/DIB_{:02d}{}_btn2_001.png", dbo, dibFeature).c_str());
dibSprite->setID("between-difficulty-sprite"_spr);
dibSprite->setPosition(position + FakeRate::getDIBOffset(dbo, GJDifficultyName::Long));
addChild(dibSprite, 3);
@@ -539,7 +552,11 @@ class $modify(FRLevelCell, LevelCell) {
}

if (Loader::get()->isModLoaded("hiimjustin000.demons_in_between") && dbo > 0 && dbo < 21) {
auto dibSprite = CCSprite::createWithSpriteFrameName(fmt::format("hiimjustin000.demons_in_between/DIB_{:02d}_btn_001.png", dbo).c_str());
auto demonsInBetween = Loader::get()->getLoadedMod("hiimjustin000.demons_in_between");
auto dibFeature = "";
if (fakeRateData.feature == 3 && demonsInBetween->getSettingValue<bool>("enable-legendary")) dibFeature = "_4";
else if (fakeRateData.feature == 4 && demonsInBetween->getSettingValue<bool>("enable-mythic")) dibFeature = "_5";
auto dibSprite = CCSprite::createWithSpriteFrameName(fmt::format("hiimjustin000.demons_in_between/DIB_{:02d}{}_btn_001.png", dbo, dibFeature).c_str());
dibSprite->setID("between-difficulty-sprite"_spr);
dibSprite->setPosition(position + FakeRate::getDIBOffset(dbo, GJDifficultyName::Short));
difficultyContainer->addChild(dibSprite, 3);

0 comments on commit fb56f27

Please sign in to comment.