Skip to content

Commit

Permalink
v1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimjasmine00 committed Jun 23, 2024
1 parent 1e4a23c commit b3e6b99
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 268 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
with:
name: Build Output
path: ${{ steps.build.outputs.build-output }}

draft:
name: Draft Release
runs-on: ubuntu-latest
Expand Down Expand Up @@ -102,5 +103,3 @@ jobs:
tag_name: ${{ github.event.head_commit.message }}
name: ${{ github.event.head_commit.message }}
draft: true
body: |
Replace with release notes
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)

project(FakeRate VERSION 1.2.0)
project(FakeRate VERSION 1.2.1)

add_library(${PROJECT_NAME} SHARED
src/FakeRate.cpp
src/FREditPopup.cpp
src/FRLevelInfoLayer.cpp
src/main.cpp
)

Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Fake Rate Changelog
## v1.2.1 (2024-06-23)
- Fixed gaps in the various fake rate popup elements

## v1.2.0 (2024-06-22)
- Revamped the fake rate popup
- Allowed independent customization of difficulty, stars, and featured status
Expand Down
6 changes: 3 additions & 3 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"geode": "3.0.0-beta.5",
"geode": "3.0.0",
"gd": {
"android": "2.206",
"win": "2.206",
"mac": "2.206"
},
"version": "v1.2.0",
"version": "v1.2.1",
"id": "hiimjustin000.fake_rate",
"name": "Fake Rate",
"developer": "hiimjustin000",
Expand Down Expand Up @@ -36,4 +36,4 @@
"interface",
"online"
]
}
}
49 changes: 24 additions & 25 deletions src/FREditPopup.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#include "FREditPopup.hpp"

FREditPopup* FREditPopup::create(FRLevelInfoLayer* delegate, GJGameLevel* level, int stars, int feature, int difficulty, int mdo) {
FREditPopup* FREditPopup::create(GJGameLevel* level, int stars, int feature, int difficulty, int mdo, UpdateFakeRateCallback callback) {
auto ret = new FREditPopup();
if (ret && ret->initAnchored(300.0f, 200.0f, delegate, level, stars, feature, difficulty, mdo)) {
if (ret->initAnchored(300.0f, 200.0f, level, stars, feature, difficulty, mdo, callback)) {
ret->autorelease();
return ret;
}
CC_SAFE_DELETE(ret);
delete ret;
return nullptr;
}

bool FREditPopup::setup(FRLevelInfoLayer* delegate, GJGameLevel* level, int stars, int feature, int difficulty, int mdo) {
bool FREditPopup::setup(GJGameLevel* level, int stars, int feature, int difficulty, int mdo, UpdateFakeRateCallback callback) {
setTitle("Fake Rate");
m_delegate = delegate;
m_level = level;
m_stars = stars;
m_feature = feature;
Expand Down Expand Up @@ -74,7 +73,7 @@ bool FREditPopup::setup(FRLevelInfoLayer* delegate, GJGameLevel* level, int star
m_buttonMenu->addChild(difficultyButton);

auto starsButton = CCMenuItemExt::createSpriteExtra(ButtonSprite::create("Stars", "goldFont.fnt", "GJ_button_02.png", 0.8f), [this, stars](auto) {
auto popup = SetIDPopup::create(m_stars, 0, 127, "Set Stars", "Set", true, stars, 60.0f, false, false);
auto popup = SetIDPopup::create(m_stars, 0, 127, "Set Stars", "Set", true, stars, 0.0f, false, false);
popup->m_delegate = this;
popup->show();
});
Expand All @@ -90,7 +89,7 @@ bool FREditPopup::setup(FRLevelInfoLayer* delegate, GJGameLevel* level, int star
featureButton->setPosition(200.0f, 70.0f);
m_buttonMenu->addChild(featureButton);

auto addButton = CCMenuItemExt::createSpriteExtra(ButtonSprite::create("Add", "goldFont.fnt", "GJ_button_01.png", 0.8f), [this](auto) {
auto addButton = CCMenuItemExt::createSpriteExtra(ButtonSprite::create("Add", "goldFont.fnt", "GJ_button_01.png", 0.8f), [this, callback](auto) {
auto vec = Mod::get()->getSavedValue<std::vector<FakeRateSaveData>>("fake-rate", {});
auto it = std::find_if(vec.begin(), vec.end(), [this](auto const& item) {
return item.id == m_level->m_levelID;
Expand All @@ -111,21 +110,21 @@ bool FREditPopup::setup(FRLevelInfoLayer* delegate, GJGameLevel* level, int star
});
}
Mod::get()->setSavedValue("fake-rate", vec);
m_delegate->updateFakeRate(m_stars, m_feature, m_difficulty, m_moreDifficultiesOverride, true, true);
callback(m_stars, m_feature, m_difficulty, m_moreDifficultiesOverride, true, true);
onClose(nullptr);
});
addButton->setPosition(150.0f, 30.0f);
m_buttonMenu->addChild(addButton);

auto removeButton = CCMenuItemExt::createSpriteExtra(ButtonSprite::create("Remove", "goldFont.fnt", "GJ_button_06.png", 0.8f), [this](auto) {
auto removeButton = CCMenuItemExt::createSpriteExtra(ButtonSprite::create("Remove", "goldFont.fnt", "GJ_button_06.png", 0.8f), [this, callback](auto) {
auto vec = Mod::get()->getSavedValue<std::vector<FakeRateSaveData>>("fake-rate", {});
if (vec.empty()) return;
vec.erase(std::remove_if(vec.begin(), vec.end(), [this](auto const& item) {
return item.id == m_level->m_levelID;
}), vec.end());
Mod::get()->setSavedValue("fake-rate", vec);
auto stars = m_level->m_stars;
m_delegate->updateFakeRate(m_level->m_stars, m_level->m_featured > 1 ? m_level->m_isEpic + 1 : 0, FakeRate::getDifficultyFromLevel(m_level),
callback(m_level->m_stars, m_level->m_featured > 1 ? m_level->m_isEpic + 1 : 0, FakeRate::getDifficultyFromLevel(m_level),
stars == 4 || stars == 7 || stars == 9 ? stars : 0, true, false);
onClose(nullptr);
});
Expand Down Expand Up @@ -171,36 +170,36 @@ FREditPopup::~FREditPopup() {
m_coins->release();
}

FRSetDifficultyPopup* FRSetDifficultyPopup::create(int difficulty, int moreDifficultiesOverride, bool legacy, MiniFunction<void(int, int)> callback) {
FRSetDifficultyPopup* FRSetDifficultyPopup::create(int difficulty, int moreDifficultiesOverride, bool legacy, SetDifficultyCallback callback) {
auto ret = new FRSetDifficultyPopup();
if (ret && ret->initAnchored(300.0f, 250.0f, difficulty, moreDifficultiesOverride, legacy, callback)) {
if (ret->initAnchored(300.0f, 250.0f, difficulty, moreDifficultiesOverride, legacy, callback)) {
ret->autorelease();
return ret;
}
CC_SAFE_DELETE(ret);
delete ret;
return nullptr;
}

bool FRSetDifficultyPopup::setup(int difficulty, int moreDifficultiesOverride, bool legacy, MiniFunction<void(int, int)> callback) {
setTitle("Set Difficulty");
bool FRSetDifficultyPopup::setup(int difficulty, int moreDifficultiesOverride, bool legacy, SetDifficultyCallback callback) {
setTitle("Select Difficulty");
m_difficulty = difficulty;
m_moreDifficultiesOverride = moreDifficultiesOverride;
m_legacy = legacy;

auto menuRow1 = CCMenu::create();
menuRow1->setLayout(RowLayout::create()->setGap(20.0f));
menuRow1->setLayout(RowLayout::create()->setAxisAlignment(AxisAlignment::Even));
menuRow1->setPosition(150.0f, 185.0f);
menuRow1->setContentSize({ 300.0f, 45.0f });
m_mainLayer->addChild(menuRow1);

auto menuRow2 = CCMenu::create();
menuRow2->setLayout(RowLayout::create()->setGap(20.0f));
menuRow2->setLayout(RowLayout::create()->setAxisAlignment(AxisAlignment::Even));
menuRow2->setPosition(150.0f, 135.0f);
menuRow2->setContentSize({ 300.0f, 45.0f });
m_mainLayer->addChild(menuRow2);

auto menuRow3 = CCMenu::create();
menuRow3->setLayout(RowLayout::create()->setGap(20.0f));
menuRow3->setLayout(RowLayout::create()->setAxisAlignment(AxisAlignment::Even));
menuRow3->setPosition(150.0f, 80.0f);
menuRow3->setContentSize({ 300.0f, 65.0f });
m_mainLayer->addChild(menuRow3);
Expand Down Expand Up @@ -255,26 +254,26 @@ void FRSetDifficultyPopup::createDifficultyToggle(CCMenu* menu, int difficulty,
menu->addChild(toggle);
}

FRSetFeaturePopup* FRSetFeaturePopup::create(int feature, int difficulty, int moreDifficultiesOverride, bool legacy, MiniFunction<void(int)> callback) {
FRSetFeaturePopup* FRSetFeaturePopup::create(int feature, int difficulty, int moreDifficultiesOverride, bool legacy, SetFeatureCallback callback) {
auto ret = new FRSetFeaturePopup();
if (ret && ret->initAnchored(300.0f, 150.0f, feature, difficulty, moreDifficultiesOverride, legacy, callback)) {
if (ret->initAnchored(300.0f, 150.0f, feature, difficulty, moreDifficultiesOverride, legacy, callback)) {
ret->autorelease();
return ret;
}
CC_SAFE_DELETE(ret);
delete ret;
return nullptr;
}

bool FRSetFeaturePopup::setup(int feature, int difficulty, int moreDifficultiesOverride, bool legacy, MiniFunction<void(int)> callback) {
setTitle("Set Feature");
bool FRSetFeaturePopup::setup(int feature, int difficulty, int moreDifficultiesOverride, bool legacy, SetFeatureCallback callback) {
setTitle("Select Feature");
m_feature = static_cast<GJFeatureState>(feature);
m_difficulty = difficulty;
m_moreDifficultiesOverride = moreDifficultiesOverride;
m_legacy = legacy;

auto menuRow = CCMenu::create();
menuRow->setLayout(RowLayout::create()->setGap(25.0f));
menuRow->setPosition(150.0f, 75.0f);
menuRow->setLayout(RowLayout::create()->setAxisAlignment(AxisAlignment::Even));
menuRow->setPosition(150.0f, 80.0f + (difficulty > 5 ? 5.0f : 0.0f));
menuRow->setContentSize({ 300.0f, 50.0f });
m_mainLayer->addChild(menuRow);

Expand Down
25 changes: 14 additions & 11 deletions src/FREditPopup.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "FRLevelInfoLayer.hpp"
#include "FakeRate.hpp"

class FREditPopup : public Popup<FRLevelInfoLayer*, GJGameLevel*, int, int, int, int>, SetIDPopupDelegate {
typedef MiniFunction<void(int, int, int, int, bool, bool)> UpdateFakeRateCallback;
typedef MiniFunction<void(int, int)> SetDifficultyCallback;
typedef MiniFunction<void(int)> SetFeatureCallback;

class FREditPopup : public Popup<GJGameLevel*, int, int, int, int, UpdateFakeRateCallback>, SetIDPopupDelegate {
protected:
FRLevelInfoLayer* m_delegate;
GJGameLevel* m_level;
int m_stars;
int m_feature;
Expand All @@ -17,39 +20,39 @@ class FREditPopup : public Popup<FRLevelInfoLayer*, GJGameLevel*, int, int, int,
CCLabelBMFont* m_starsLabel;
CCArray* m_coins;

bool setup(FRLevelInfoLayer*, GJGameLevel*, int, int, int, int) override;
bool setup(GJGameLevel*, int, int, int, int, UpdateFakeRateCallback) override;
void updateLabels();
public:
static FREditPopup* create(FRLevelInfoLayer*, GJGameLevel*, int, int, int, int);
static FREditPopup* create(GJGameLevel*, int, int, int, int, UpdateFakeRateCallback);

void setIDPopupClosed(SetIDPopup*, int) override;

~FREditPopup() override;
};

class FRSetDifficultyPopup : public Popup<int, int, bool, MiniFunction<void(int, int)>> {
class FRSetDifficultyPopup : public Popup<int, int, bool, SetDifficultyCallback> {
protected:
int m_difficulty;
int m_moreDifficultiesOverride;
bool m_legacy;
CCMenuItemSpriteExtra* m_selected;

bool setup(int, int, bool, MiniFunction<void(int, int)>) override;
bool setup(int, int, bool, SetDifficultyCallback) override;
void createDifficultyToggle(CCMenu*, int, int);
public:
static FRSetDifficultyPopup* create(int, int, bool, MiniFunction<void(int, int)>);
static FRSetDifficultyPopup* create(int, int, bool, SetDifficultyCallback);
};

class FRSetFeaturePopup : public Popup<int, int, int, bool, MiniFunction<void(int)>> {
class FRSetFeaturePopup : public Popup<int, int, int, bool, SetFeatureCallback> {
protected:
GJFeatureState m_feature;
int m_difficulty;
int m_moreDifficultiesOverride;
bool m_legacy;
CCMenuItemSpriteExtra* m_selected;

bool setup(int, int, int, bool, MiniFunction<void(int)>) override;
bool setup(int, int, int, bool, SetFeatureCallback) override;
void createFeatureToggle(CCMenu*, GJFeatureState);
public:
static FRSetFeaturePopup* create(int, int, int, bool, MiniFunction<void(int)>);
static FRSetFeaturePopup* create(int, int, int, bool, SetFeatureCallback);
};
Loading

0 comments on commit b3e6b99

Please sign in to comment.