Skip to content

Commit

Permalink
v1.3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimjasmine00 committed Aug 13, 2024
1 parent 26f6797 commit ec21ae6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 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.3.8)
project(FakeRate VERSION 1.3.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.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

Expand Down
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.206",
"mac": "2.206"
},
"version": "v1.3.8",
"version": "v1.3.9",
"id": "hiimjustin000.fake_rate",
"name": "Fake Rate",
"developer": "hiimjustin000",
Expand Down
40 changes: 31 additions & 9 deletions src/FREditPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -354,17 +354,17 @@ 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;
}
delete ret;
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;
Expand All @@ -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<int64_t>(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);
Expand Down
8 changes: 5 additions & 3 deletions src/FREditPopup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ class FRSetDifficultyPopup : public Popup<int, int, int, int, bool, SetDifficult
static FRSetDifficultyPopup* create(int, int, int, int, bool, SetDifficultyCallback);
};

class FRSetStarsPopup : public Popup<int, SetStarsCallback> {
class FRSetStarsPopup : public Popup<int, bool, SetStarsCallback> {
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<int, int, int, int, int, bool, SetFeatureCallback> {
Expand Down

0 comments on commit ec21ae6

Please sign in to comment.