diff --git a/CMakeLists.txt b/CMakeLists.txt index 668362f..91864bc 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.3.8) +project(FakeRate VERSION 1.3.9) add_library(${PROJECT_NAME} SHARED src/FakeRate.cpp diff --git a/changelog.md b/changelog.md index ff4a97d..b542c86 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,8 @@ # Fake Rate Changelog +## v1.3.9 (2024-08-13) +- Added a star display to the set stars popup +- Fixed bugs relating to star input in the set stars popup + ## v1.3.8 (2024-08-11) - Fixed a bug where selecting a difficulty face in the fake rate popup would not work with an override set diff --git a/mod.json b/mod.json index 831b769..29e15de 100644 --- a/mod.json +++ b/mod.json @@ -5,7 +5,7 @@ "win": "2.206", "mac": "2.206" }, - "version": "v1.3.8", + "version": "v1.3.9", "id": "hiimjustin000.fake_rate", "name": "Fake Rate", "developer": "hiimjustin000", diff --git a/src/FREditPopup.cpp b/src/FREditPopup.cpp index 35aa621..fc21f0f 100644 --- a/src/FREditPopup.cpp +++ b/src/FREditPopup.cpp @@ -84,7 +84,7 @@ bool FREditPopup::setup(GJGameLevel* level, FakeRateSaveData data, UpdateFakeRat m_buttonMenu->addChild(difficultyButton); auto starsButton = CCMenuItemExt::createSpriteExtra(ButtonSprite::create("Stars", "goldFont.fnt", "GJ_button_02.png", 0.8f), [this, data](auto) { - FRSetStarsPopup::create(m_stars, [this](int stars) { + FRSetStarsPopup::create(m_stars, m_level->m_levelLength == 5, [this](int stars) { m_stars = stars; updateLabels(); })->show(); @@ -354,9 +354,9 @@ void FRSetDifficultyPopup::createDifficultyToggle(CCMenu* menu, int difficulty, menu->addChild(toggle); } -FRSetStarsPopup* FRSetStarsPopup::create(int stars, SetStarsCallback callback) { +FRSetStarsPopup* FRSetStarsPopup::create(int stars, bool platformer, SetStarsCallback callback) { auto ret = new FRSetStarsPopup(); - if (ret->initAnchored(250.0f, 150.0f, stars, callback)) { + if (ret->initAnchored(250.0f, 150.0f, stars, platformer, callback)) { ret->autorelease(); return ret; } @@ -364,7 +364,7 @@ FRSetStarsPopup* FRSetStarsPopup::create(int stars, SetStarsCallback callback) { return nullptr; } -bool FRSetStarsPopup::setup(int stars, SetStarsCallback callback) { +bool FRSetStarsPopup::setup(int stars, bool platformer, SetStarsCallback callback) { setTitle("Set Stars"); m_noElasticity = true; m_stars = stars; @@ -374,26 +374,48 @@ bool FRSetStarsPopup::setup(int stars, SetStarsCallback callback) { m_input->setPosition(125.0f, 80.0f); m_input->getInputNode()->setLabelPlaceholderColor({ 120, 170, 240 }); m_input->setString(std::to_string(m_stars)); + m_input->setMaxCharCount(11); m_input->setCallback([this](std::string const& text) { - auto stars = (text.empty() || text == "-" || (text.find('-') != std::string::npos && !string::startsWith(text, "-"))) ? 0 : std::stoll(text); + auto stars = numFromString(text).unwrapOr(0); if (stars < INT_MIN) stars = INT_MIN; if (stars > INT_MAX) stars = INT_MAX; m_stars = stars; - auto starsStr = std::to_string(m_stars); - if (starsStr != text) m_input->setString(starsStr); + m_label->setString(std::to_string(m_stars).c_str()); + m_starLayout->updateLayout(); }); m_mainLayer->addChild(m_input); + m_starLayout = CCNode::create(); + m_starLayout->setPosition(125.0f, 52.5f); + m_starLayout->setContentSize({ 250.0f, 15.0f }); + m_starLayout->setAnchorPoint({ 0.5f, 0.5f }); + m_starLayout->setLayout(RowLayout::create()->setGap(1.75f)->setAutoScale(false)); + m_mainLayer->addChild(m_starLayout); + + m_label = CCLabelBMFont::create(std::to_string(m_stars).c_str(), "bigFont.fnt"); + m_label->setScale(0.4f); + m_starLayout->addChild(m_label); + + m_starLayout->addChild(CCSprite::createWithSpriteFrameName(platformer ? "moon_small01_001.png" : "star_small01_001.png")); + + m_starLayout->updateLayout(); + auto leftButton = CCMenuItemExt::createSpriteExtraWithFrameName("edit_leftBtn_001.png", 1.1f, [this](auto) { if (m_stars != INT_MIN) m_stars -= 1; - m_input->setString(std::to_string(m_stars)); + auto stars = std::to_string(m_stars); + m_input->setString(stars); + m_label->setString(stars.c_str()); + m_starLayout->updateLayout(); }); leftButton->setPosition(30.0f, 80.0f); m_buttonMenu->addChild(leftButton); auto rightButton = CCMenuItemExt::createSpriteExtraWithFrameName("edit_rightBtn_001.png", 1.1f, [this](auto) { if (m_stars != INT_MAX) m_stars += 1; - m_input->setString(std::to_string(m_stars)); + auto stars = std::to_string(m_stars); + m_input->setString(stars); + m_label->setString(stars.c_str()); + m_starLayout->updateLayout(); }); rightButton->setPosition(220.0f, 80.0f); m_buttonMenu->addChild(rightButton); diff --git a/src/FREditPopup.hpp b/src/FREditPopup.hpp index 698995e..4c4c5d6 100644 --- a/src/FREditPopup.hpp +++ b/src/FREditPopup.hpp @@ -50,14 +50,16 @@ class FRSetDifficultyPopup : public Popup { +class FRSetStarsPopup : public Popup { protected: int m_stars; TextInput* m_input; + CCLabelBMFont* m_label; + CCNode* m_starLayout; - bool setup(int, SetStarsCallback) override; + bool setup(int, bool, SetStarsCallback) override; public: - static FRSetStarsPopup* create(int, SetStarsCallback); + static FRSetStarsPopup* create(int, bool, SetStarsCallback); }; class FRSetFeaturePopup : public Popup {