Skip to content

Commit

Permalink
v1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimjasmine00 committed May 25, 2024
1 parent 6336997 commit 1634d6e
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 26 deletions.
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.1.4 (2024-05-24)
- Fixed incompatibility with the mod "Underrated Non-Demons" by acaruso
- Tweaked appearance of the fake rate button

## v1.1.3 (2024-05-20)
- Fixed a mistake in the manifest that caused More Difficulties 1.1.0 to not be marked as incompatible

Expand Down
Binary file modified logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"win": "2.204",
"mac": "2.200"
},
"version": "v1.1.3",
"version": "v1.1.4",
"id": "hiimjustin000.fake_rate",
"name": "Fake Rate",
"developer": "hiimjustin000",
Expand Down
Binary file modified resources/FR_fakeRateBtn_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 39 additions & 20 deletions src/FREditPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ bool FRLevelInfoLayer::init(GJGameLevel* level, bool challenge) {
if (!LevelInfoLayer::init(level, challenge)) return false;

auto leftSideMenu = getChildByID("left-side-menu");
auto fakeRateButton = CCMenuItemSpriteExtra::create(
CCSprite::create("FR_fakeRateBtn_001.png"_spr),
this,
menu_selector(FRLevelInfoLayer::onFakeRate)
);
auto buttonSprite = CircleButtonSprite::createWithSprite("FR_fakeRateBtn_001.png"_spr, 1.0f, CircleBaseColor::Green, CircleBaseSize::Medium);
buttonSprite->getTopNode()->setScale(1.0f);
auto fakeRateButton = CCMenuItemSpriteExtra::create(buttonSprite, this, menu_selector(FRLevelInfoLayer::onFakeRate));
fakeRateButton->setID("fake-rate-button"_spr);
leftSideMenu->addChild(fakeRateButton);
leftSideMenu->updateLayout();

Expand Down Expand Up @@ -66,18 +65,35 @@ void FRLevelInfoLayer::updateFakeRate(int stars, int feature, int difficulty, bo
auto winSize = CCDirector::sharedDirector()->getWinSize();
auto gsm = GameStatsManager::sharedState();
auto showStars = stars > 0 || m_level->m_dailyID > 0 || m_level->m_gauntletLevel;
m_difficultySprite->updateDifficultyFrame(difficulty, (GJDifficultyName)1);
m_difficultySprite->updateDifficultyFrame(difficulty, GJDifficultyName::Long);
m_difficultySprite->updateFeatureState((GJFeatureState)feature);
m_difficultySprite->setPositionY(winSize.height / 2 + 56.0f + (difficulty > 5 ? 5.0f : 0.0f) + (showStars ? 10.0f : 0.0f));
m_starsIcon->setPosition({ m_difficultySprite->getPositionX() + 8.0f, m_difficultySprite->getPositionY() - 30.0f - (difficulty > 5 ? 9.0f : 0.0f) });
CCNode* nodeToSetPosition = m_difficultySprite;
CCNode* difficultySpriteParent = m_difficultySprite->getParent();
if (Loader::get()->isModLoaded("acaruso.horn")) {
auto children = getChildren();
for (int i = 0; i < children->count(); i++) {
if (auto child = typeinfo_cast<CCMenu*>(children->objectAtIndex(i))) {
if (auto button = typeinfo_cast<CCMenuItemSpriteExtra*>(child->getChildren()->objectAtIndex(0))) {
if (button->getNormalImage() == m_difficultySprite) {
nodeToSetPosition = child;
difficultySpriteParent = button;
break;
}
}
}
}
}
nodeToSetPosition->setPositionY(winSize.height / 2 + 56.0f + (difficulty > 5 ? 5.0f : 0.0f) + (showStars ? 10.0f : 0.0f));
auto& position = nodeToSetPosition->getPosition();
m_starsIcon->setPosition({ position.x + 8.0f, position.y - 30.0f - (difficulty > 5 ? 9.0f : 0.0f) });
m_starsIcon->setVisible(showStars);
m_starsLabel->setPosition(m_starsIcon->getPositionX() - 8.0f, m_starsIcon->getPositionY());
m_starsLabel->setString(std::to_string(stars).c_str());
m_starsLabel->setVisible(showStars);
m_starsLabel->setColor({ 255, 255, (unsigned char)(gsm->hasCompletedLevel(m_level) ? 50 : 255) });
for (int i = 0; i < m_coins->count(); i++) {
auto coin = static_cast<CCSprite*>(m_coins->objectAtIndex(i));
coin->setPositionY(m_difficultySprite->getPositionY() - 31.5f - (showStars ? 14.0f : 0.0f)
coin->setPositionY(position.y - 31.5f - (showStars ? 14.0f : 0.0f)
- (m_level->m_gauntletLevel || m_level->m_dailyID > 0 ? 14.5f : 0.0f) - (difficulty > 5 ? 9.0f : 0.0f));
auto coinStr = fmt::format("{}_{}", m_level->m_levelID.value(), i + 1);
if (m_level->m_dailyID > 0) coinStr += "_" + std::to_string(m_level->m_dailyID);
Expand All @@ -97,8 +113,8 @@ void FRLevelInfoLayer::updateFakeRate(int stars, int feature, int difficulty, bo
auto diamonds = stars > 1 ? stars + 2 : 0;
diamondLabel->setString(fmt::format("{}/{}", (int)floorf(diamonds * m_level->m_normalPercent / 100.0f), diamonds).c_str());
diamondIcon->setPosition({
m_difficultySprite->getPositionX() + diamondLabel->getScaledContentSize().width * 0.5f + 2.0f,
m_difficultySprite->getPositionY() - (difficulty > 5 ? 9.0f : 0.0f) - 44.5f
position.x + diamondLabel->getScaledContentSize().width * 0.5f + 2.0f,
position.y - (difficulty > 5 ? 9.0f : 0.0f) - 44.5f
});
diamondLabel->setPosition({ diamondIcon->getPositionX() - 8.0f, diamondIcon->getPositionY() });
}
Expand Down Expand Up @@ -127,7 +143,7 @@ void FRLevelInfoLayer::updateFakeRate(int stars, int feature, int difficulty, bo
m_lengthLabel->setPositionY(m_lengthLabel->getPositionY() + 6.0f);
}

if (Loader::get()->isModLoaded("uproxide.more_difficulties")) fixMoreDifficultiesIncompatibility();
if (Loader::get()->isModLoaded("uproxide.more_difficulties")) fixMoreDifficultiesIncompatibility(difficultySpriteParent);
}

void FRLevelInfoLayer::onFakeRate(CCObject*) {
Expand All @@ -141,7 +157,7 @@ void FRLevelInfoLayer::onFakeRate(CCObject*) {
popup->show();
}

void FRLevelInfoLayer::fixMoreDifficultiesIncompatibility() {
void FRLevelInfoLayer::fixMoreDifficultiesIncompatibility(CCNode* difficultySpriteParent) {
auto spriteName = std::string();
auto moreDifficultiesSprite = static_cast<CCSprite*>(getChildByID("uproxide.more_difficulties/more-difficulties-spr"));
if (moreDifficultiesSprite) {
Expand All @@ -150,8 +166,11 @@ void FRLevelInfoLayer::fixMoreDifficultiesIncompatibility() {
}
m_difficultySprite->setOpacity(255);

auto legacy = Loader::get()->getInstalledMod("uproxide.more_difficulties")->getSettingValue<bool>("legacy-difficulties");
auto pos = CCPoint { m_difficultySprite->getPositionX() + (legacy ? 0.0f : 0.25f), m_difficultySprite->getPositionY() - (legacy ? 0.0f : 0.1f) };
auto legacy = Loader::get()->getLoadedMod("uproxide.more_difficulties")->getSettingValue<bool>("legacy-difficulties");
auto pos = difficultySpriteParent->convertToWorldSpace({
m_difficultySprite->getPositionX() + (legacy ? 0.0f : 0.25f),
m_difficultySprite->getPositionY() - (legacy ? 0.0f : 0.1f)
});
if (spriteName.compare("uproxide.more_difficulties/MD_DifficultyCP.png") == 0) {
moreDifficultiesSprite->setVisible(true);
m_difficultySprite->setOpacity(0);
Expand Down Expand Up @@ -219,12 +238,12 @@ bool FREditPopup::setup(GJGameLevel* level, int stars, int feature, int difficul
m_feature = feature;
m_difficulty = difficulty;

m_difficultySprite = GJDifficultySprite::create(difficulty, (GJDifficultyName)1);
m_difficultySprite = GJDifficultySprite::create(difficulty, GJDifficultyName::Long);
m_difficultySprite->setPositionX(100.0f);
m_mainLayer->addChild(m_difficultySprite);

if (Loader::get()->isModInstalled("uproxide.more_difficulties")) {
auto legacy = Loader::get()->getInstalledMod("uproxide.more_difficulties")->getSettingValue<bool>("legacy-difficulties");
if (Loader::get()->isModLoaded("uproxide.more_difficulties")) {
auto legacy = Loader::get()->getLoadedMod("uproxide.more_difficulties")->getSettingValue<bool>("legacy-difficulties");
auto pos = CCPoint { legacy ? 100.0f : 100.25f, legacy ? 85.0f : 84.9f };

m_casualSprite = CCSprite::createWithSpriteFrameName(fmt::format("uproxide.more_difficulties/MD_Difficulty04{}.png", legacy ? "_Legacy" : "").c_str());
Expand Down Expand Up @@ -351,7 +370,7 @@ void FREditPopup::onFeatureRight(CCObject*) {

void FREditPopup::updateLabels() {
m_difficulty = m_stars >= 10 ? m_difficulty > 5 ? m_difficulty : 7 : FakeRate::getDifficultyForStars(m_stars);
m_difficultySprite->updateDifficultyFrame(m_difficulty, (GJDifficultyName)1);
m_difficultySprite->updateDifficultyFrame(m_difficulty, GJDifficultyName::Long);
m_difficultySprite->updateFeatureState((GJFeatureState)m_feature);
m_difficultySprite->setPositionY(85.0f + (m_difficulty > 5 ? 5.0f : 0.0f));
m_starSprite->setPosition({ m_difficultySprite->getPositionX() + 8.0f, m_difficultySprite->getPositionY() - 30.0f - (m_difficulty > 5 ? 9.0f : 0.0f) });
Expand All @@ -365,7 +384,7 @@ void FREditPopup::updateLabels() {
m_difficultyRightArrow->setEnabled(m_difficulty > 5);
m_featureLeftArrow->setPositionY(m_difficultySprite->getPositionY() + 5.0f);
m_featureRightArrow->setPositionY(m_difficultySprite->getPositionY() + 5.0f);
if (Loader::get()->isModInstalled("uproxide.more_difficulties")) {
if (Loader::get()->isModLoaded("uproxide.more_difficulties")) {
m_casualSprite->setVisible(m_stars == 4);
m_toughSprite->setVisible(m_stars == 7);
m_cruelSprite->setVisible(m_stars == 9);
Expand Down
2 changes: 1 addition & 1 deletion src/FREditPopup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FRLevelInfoLayerDummy; struct FRLevelInfoLayer : Modify<FRLevelInfoLayer,
void checkFakeRate();
void updateFakeRate(int, int, int, bool, bool);
void onFakeRate(CCObject*);
void fixMoreDifficultiesIncompatibility();
void fixMoreDifficultiesIncompatibility(CCNode*);
};

class FREditPopup : public Popup<GJGameLevel*, int, int, int> {
Expand Down
7 changes: 3 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class $modify(FRLevelCell, LevelCell) {
featureGlow->setPosition(difficultySprite->getContentWidth() * 0.5f, difficultySprite->getContentHeight() * 0.5f);
}

auto fakeRateData = *it;
difficultySprite->updateDifficultyFrame(fakeRateData.difficulty, (GJDifficultyName)0);
auto& fakeRateData = *it;
difficultySprite->updateDifficultyFrame(fakeRateData.difficulty, GJDifficultyName::Short);
difficultySprite->updateFeatureState((GJFeatureState)fakeRateData.feature);
auto addCoins = level->m_coins > 0 && !m_compactView;
auto showStars = fakeRateData.stars > 0 || level->m_dailyID > 0;
Expand Down Expand Up @@ -110,7 +110,6 @@ class $modify(FRLevelCell, LevelCell) {
}
auto orbs = FakeRate::getBaseCurrency(fakeRateData.stars);
auto totalOrbs = (int)floorf(orbs * 1.25f);
log::info("{}", level->m_normalPercent.value());
orbsLabel->setString((level->m_normalPercent == 100 ?
fmt::format("{}", totalOrbs) :
fmt::format("{}/{}", (int)floorf(orbs * level->m_normalPercent / 100.0f), totalOrbs)).c_str());
Expand Down Expand Up @@ -139,7 +138,7 @@ class $modify(FRLevelCell, LevelCell) {
auto difficultySprite = static_cast<GJDifficultySprite*>(difficultyContainer->getChildByID("difficulty-sprite"));
difficultySprite->setOpacity(255);

auto legacy = Loader::get()->getInstalledMod("uproxide.more_difficulties")->getSettingValue<bool>("legacy-difficulties");
auto legacy = Loader::get()->getLoadedMod("uproxide.more_difficulties")->getSettingValue<bool>("legacy-difficulties");
auto pos = CCPoint { difficultySprite->getPositionX() + (legacy ? 0.0f : 0.25f), difficultySprite->getPositionY() - (legacy ? 0.0f : 0.1f) };
if (spriteName.compare("uproxide.more_difficulties/MD_DifficultyCP.png") == 0) {
moreDifficultiesSprite->setVisible(true);
Expand Down

0 comments on commit 1634d6e

Please sign in to comment.