Skip to content

Commit

Permalink
Merge #31 v1.1.4
Browse files Browse the repository at this point in the history
# v1.1.4
- Fixed [the bug that prevented players from using the simple search UI](#29)
- The local ratings cache updates downloaded from the API are now saved, so the GDDL Split should be even more accurate now
- Added a button showing completed unrated levels in the GDDL Demon Split screen
- Fixed searching for unrated levels
- Fixed crashes related to putting invalid numbers as tier/enjoyment rating in the full search UI on Android
- Fixed a bug that would cause the search to be called more times than necessary if the search button was clicked twice or more (or to stop working until you reopen it)
  • Loading branch information
B1rtek authored Mar 9, 2024
2 parents 5b2587e + 5ef2302 commit 945aa20
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ If you encounter an <cy>issue</c> with the mod, [open an issue in the mod's GitH

<cb>*Code contributions:*</c> <cy>**[Diversion](https://github.com/B1rtek/Geode-GDDLIntegration/pull/3)**</c>
<cg>*Feature suggestions:*</c> <cy>[MasterGamerY](https://github.com/B1rtek/Geode-GDDLIntegration/issues/1), [Weebifying](https://github.com/B1rtek/Geode-GDDLIntegration/pull/2), [averiee_](https://github.com/B1rtek/Geode-GDDLIntegration/milestone/4), [TheSuperJepphyKiller](https://github.com/B1rtek/Geode-GDDLIntegration/issues/6), [hoshinekosanti](https://github.com/B1rtek/Geode-GDDLIntegration/issues/11), [epicmushroom.](https://github.com/B1rtek/Geode-GDDLIntegration/issues/15), [Koble](https://github.com/B1rtek/Geode-GDDLIntegration/issues/21), [Diversion](https://github.com/B1rtek/Geode-GDDLIntegration/issues/25)</c>
<cr>*Bug reporters:*</c> <cy>croozington, bllue, [Fleeym](https://github.com/geode-sdk/indexer/issues/557#issuecomment-1913780380), [matcool](https://github.com/geode-sdk/indexer/issues/557#issuecomment-1913780699), [Lexicon](https://github.com/B1rtek/Geode-GDDLIntegration/issues/7), [patrick61804](https://github.com/B1rtek/Geode-GDDLIntegration/issues/16), [epicmushroom.](https://github.com/B1rtek/Geode-GDDLIntegration/issues/20), [GlassesCatandsteve](https://github.com/B1rtek/Geode-GDDLIntegration/issues/27)</c>
<cr>*Bug reporters:*</c> <cy>croozington, bllue, [Fleeym](https://github.com/geode-sdk/indexer/issues/557#issuecomment-1913780380), [matcool](https://github.com/geode-sdk/indexer/issues/557#issuecomment-1913780699), [Lexicon](https://github.com/B1rtek/Geode-GDDLIntegration/issues/7), [patrick61804](https://github.com/B1rtek/Geode-GDDLIntegration/issues/16), [epicmushroom.](https://github.com/B1rtek/Geode-GDDLIntegration/issues/20), [GlassesCatandsteve](https://github.com/B1rtek/Geode-GDDLIntegration/issues/27), [HotKentang, wangko5383, dshifter, Ev212](https://github.com/B1rtek/Geode-GDDLIntegration/issues/29)</c>
2 changes: 1 addition & 1 deletion about.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ If you encounter an <cy>issue</c> with the mod, [open an issue in the mod's GitH

<cb>*Code contributions:*</c> <cy>**[Diversion](https://github.com/B1rtek/Geode-GDDLIntegration/pull/3)**</c>
<cg>*Feature suggestions:*</c> <cy>[MasterGamerY](https://github.com/B1rtek/Geode-GDDLIntegration/issues/1), [Weebifying](https://github.com/B1rtek/Geode-GDDLIntegration/pull/2), [averiee_](https://github.com/B1rtek/Geode-GDDLIntegration/milestone/4), [TheSuperJepphyKiller](https://github.com/B1rtek/Geode-GDDLIntegration/issues/6), [hoshinekosanti](https://github.com/B1rtek/Geode-GDDLIntegration/issues/11), [epicmushroom.](https://github.com/B1rtek/Geode-GDDLIntegration/issues/15), [Koble](https://github.com/B1rtek/Geode-GDDLIntegration/issues/21), [Diversion](https://github.com/B1rtek/Geode-GDDLIntegration/issues/25)</c>
<cr>*Bug reporters:*</c> <cy>croozington, bllue, [Fleeym](https://github.com/geode-sdk/indexer/issues/557#issuecomment-1913780380), [matcool](https://github.com/geode-sdk/indexer/issues/557#issuecomment-1913780699), [Lexicon](https://github.com/B1rtek/Geode-GDDLIntegration/issues/7), [patrick61804](https://github.com/B1rtek/Geode-GDDLIntegration/issues/16), [epicmushroom.](https://github.com/B1rtek/Geode-GDDLIntegration/issues/20), [GlassesCatandsteve](https://github.com/B1rtek/Geode-GDDLIntegration/issues/27)</c>
<cr>*Bug reporters:*</c> <cy>croozington, bllue, [Fleeym](https://github.com/geode-sdk/indexer/issues/557#issuecomment-1913780380), [matcool](https://github.com/geode-sdk/indexer/issues/557#issuecomment-1913780699), [Lexicon](https://github.com/B1rtek/Geode-GDDLIntegration/issues/7), [patrick61804](https://github.com/B1rtek/Geode-GDDLIntegration/issues/16), [epicmushroom.](https://github.com/B1rtek/Geode-GDDLIntegration/issues/20), [GlassesCatandsteve](https://github.com/B1rtek/Geode-GDDLIntegration/issues/27), [HotKentang, wangko5383, dshifter, Ev212](https://github.com/B1rtek/Geode-GDDLIntegration/issues/29)</c>
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v1.1.4
- Fixed [the bug that prevented players from using the simple search UI](https://github.com/B1rtek/Geode-GDDLIntegration/issues/29)
- The local ratings cache updates downloaded from the API are now saved, so the GDDL Split should be even more accurate now
- Added a button showing completed unrated levels in the GDDL Demon Split screen
- Fixed searching for unrated levels
- Fixed crashes related to putting invalid numbers as tier/enjoyment rating in the full search UI on Android
- Fixed a bug that would cause the search to be called more times than necessary if the search button was clicked twice or more (or to stop working until you reopen it)

# v1.1.3
- Replaced the search interface switching button with a better one
- Added links to GDDL in the mod description and in level details
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "2.0.0",
"version": "v1.1.3",
"version": "v1.1.4",
"gd": {
"android": "2.205",
"win": "2.204"
Expand Down
Binary file modified resources/old_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/split.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions src/GDDLDemonSplitLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
bool GDDLDemonSplitLayer::init() {
if(!FLAlertLayer::init(75)) return false; // that magic number is actualy bg opacity btw

const CCPoint popupSize = {360.0f, 200.0f};
const CCPoint popupSize = {360.0f, 225.0f};
const auto winSize = CCDirector::sharedDirector()->getWinSize();
// background
const auto bg = CCScale9Sprite::create("GJ_square02.png", {0.0f, 0.0f, 80.0f, 80.0f});
Expand Down Expand Up @@ -52,6 +52,10 @@ bool GDDLDemonSplitLayer::init() {
m_buttonMenu->addChild(rowNode);
m_buttonMenu->reorderChild(rowNode, row+1);
}
// unrated tier
const auto unratedTierNode = createTierNode(-1);
m_buttonMenu->addChild(unratedTierNode, 7);

// ok button
const auto spr = ButtonSprite::create("OK");
const auto okButton = CCMenuItemSpriteExtra::create(spr, this, menu_selector(GDDLDemonSplitLayer::onClose));
Expand Down Expand Up @@ -92,21 +96,25 @@ void GDDLDemonSplitLayer::onTierSearch(cocos2d::CCObject *sender) { // NOLINT(*-
auto *senderNode = dynamic_cast<CCNode *>(sender);
const std::string tierStr = senderNode->getID();
const int tierNumber = std::stoi(tierStr.substr(12, tierStr.size()-10));
log::debug("Requesting tier {}", std::to_string(tierNumber));
GDDLSearchLayer::requestSearchFromDemonSplit(tierNumber);
// the list should display itself hopefully
}

void GDDLDemonSplitLayer::onEnter() {
FLAlertLayer::onEnter();
cocos::handleTouchPriority(this);
GDDLSearchLayer::restoreValuesAfterSplit();
GDDLSearchLayer::stopSearch();
}

CCNode *GDDLDemonSplitLayer::createTierNode(const int tier) {
const auto tierNode = CCMenu::create();
tierNode->setLayout(RowLayout::create()->setGap(3.0f)->setAutoScale(true));
tierNode->setContentSize({50.0f, 20.0f});
// tier sprite
const std::string tierSpriteName = "tier_" + std::to_string(tier) + ".png";
std::string tierStrName = tier != -1 ? std::to_string(tier) : "unrated";
const std::string tierSpriteName = "tier_" + tierStrName + ".png";
const auto textureName = Mod::get()->expandSpriteName(tierSpriteName.c_str());
const auto tierSprite = CCSprite::create(textureName);
tierSprite->setScale(0.05f);
Expand Down
73 changes: 44 additions & 29 deletions src/GDDLSearchLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ void GDDLSearchLayer::showPage() {
m_mainLayer->reorderChild(simplifiedMenu, 0);
m_mainLayer->reorderChild(normalMenu, 1);
} else { // the other way lmao
clickOffTextfields(); // typing into invisible textfields crash prevention
normalMenu->setVisible(false);
if(!simplifiedLoaded) {
loadPageSimple();
Expand Down Expand Up @@ -481,6 +482,7 @@ std::string GDDLSearchLayer::formSearchRequest() {
request += addValueToRequest("enjHigh", enjHigh, highestEnjoyment);
request += addStringToRequest("sort", sort[sortOptionIndex]);
request += addStringToRequest("sortDirection", sortDirection[sortDirectionIndex]);
log::debug("Search request: {}", request);
return request;
}

Expand Down Expand Up @@ -947,6 +949,7 @@ void GDDLSearchLayer::onSortDirectionRight(CCObject *sender) {
}

void GDDLSearchLayer::onSearchClicked(CCObject *sender) {
if (searching) return; // super good multithreaded code
saveValues();
totalOnlineResults = 0;
cachedResults.clear();
Expand All @@ -965,6 +968,7 @@ void GDDLSearchLayer::onSwapLayout(CCObject *sender) {
}

void GDDLSearchLayer::onTierSearch(CCObject *sender) {
if (searching) return; // super good multithreaded code
// save values before replacing them
saveValues();
cacheValues();
Expand All @@ -977,6 +981,8 @@ void GDDLSearchLayer::onTierSearch(CCObject *sender) {
highTier = tierNumber;
} else {
removeRated = true;
lowTier = 0;
highTier = 0;
}
completed = completedTogglerSimple->isToggled();
uncompleted = uncompletedTogglerSimple->isToggled();
Expand Down Expand Up @@ -1023,13 +1029,11 @@ void GDDLSearchLayer::setSortDirectionLabel() {
int GDDLSearchLayer::getNumberTextfieldValue(CCTextInputNode *&textfield) {
if (textfield->getString().empty())
return 0;
int returnValue;
try {
returnValue = std::stoi(textfield->getString());
} catch (std::invalid_argument &e) {
returnValue = 0;
} catch (std::out_of_range &e) {
returnValue = 0;
// instead of try/catch because of android
int returnValue = 0;
auto returnValueResult = numFromString<int>(textfield->getString());
if (returnValueResult.isOk()) {
returnValue = returnValueResult.value();
}
return returnValue;
}
Expand All @@ -1038,20 +1042,17 @@ float GDDLSearchLayer::getFloatTextfieldValue(CCTextInputNode *&textfield, float
if (textfield->getString().empty())
return 0;
float returnValue = defaultValue;
try {
returnValue = std::stof(textfield->getString());
} catch (std::invalid_argument &e) {
returnValue = defaultValue;
} catch (std::out_of_range &e) {
returnValue = defaultValue;
auto returnValueResult = numFromString<float>(textfield->getString());
if (returnValueResult.isOk()) {
returnValue = returnValueResult.value();
}
return returnValue;
}

void GDDLSearchLayer::onEnter()
{
void GDDLSearchLayer::onEnter() {
FLAlertLayer::onEnter();
cocos::handleTouchPriority(this);
stopSearch();
restoreValuesAfterSplit(); // scene switching won't come back to the init() reset in creatorlayer
}

Expand Down Expand Up @@ -1178,11 +1179,18 @@ void GDDLSearchLayer::requestSearchPage(int requestedPage, GDDLBrowserLayer *cal
}

void GDDLSearchLayer::requestSearchFromDemonSplit(const int tier) {
if (searching) return; // super good multithreaded code
// save values before replacing them
cacheValues();
// and then
lowTier = tier;
highTier = tier;
if (tier == -1) {
removeRated = true;
lowTier = 0;
highTier = 0;
} else {
lowTier = tier;
highTier = tier;
}
completed = true;
uncompleted = false;
totalOnlineResults = 0;
Expand Down Expand Up @@ -1212,22 +1220,29 @@ void GDDLSearchLayer::stopSearch() { searching = false; }

void GDDLSearchLayer::restoreValuesAfterSplit() {
if (savedLowTier == -1) return; // there's nothing to restore
log::debug("{}", "Values restored");
restoreValues();
savedLowTier = -1;
}

void GDDLSearchLayer::onExit() {
FLAlertLayer::onExit();
// https://github.com/B1rtek/Geode-GDDLIntegration/issues/27 fix??
nameTextfield->onClickTrackNode(false);
creatorTextfield->onClickTrackNode(false);
songTextfield->onClickTrackNode(false);
tierLowTextfield->onClickTrackNode(false);
tierHighTextfield->onClickTrackNode(false);
enjoymentLowTextfield->onClickTrackNode(false);
enjoymentHighTextfield->onClickTrackNode(false);
submissionsCountHighTextfield->onClickTrackNode(false);
submissionsCountLowTextfield->onClickTrackNode(false);
enjSubmissionsCountHighTextfield->onClickTrackNode(false);
enjSubmissionsCountLowTextfield->onClickTrackNode(false);
// https://github.com/B1rtek/Geode-GDDLIntegration/issues/27
clickOffTextfields();
}

void GDDLSearchLayer::clickOffTextfields() {
if(!simplified) { // if you do that in the simplified menu it'll crash if the full menu wasn't loaded
nameTextfield->onClickTrackNode(false);
creatorTextfield->onClickTrackNode(false);
songTextfield->onClickTrackNode(false);
tierLowTextfield->onClickTrackNode(false);
tierHighTextfield->onClickTrackNode(false);
enjoymentLowTextfield->onClickTrackNode(false);
enjoymentHighTextfield->onClickTrackNode(false);
submissionsCountHighTextfield->onClickTrackNode(false);
submissionsCountLowTextfield->onClickTrackNode(false);
enjSubmissionsCountHighTextfield->onClickTrackNode(false);
enjSubmissionsCountLowTextfield->onClickTrackNode(false);
}
}
2 changes: 2 additions & 0 deletions src/GDDLSearchLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ class GDDLSearchLayer final : public FLAlertLayer {
// getters for the same thing
static int getNumberTextfieldValue(CCTextInputNode *&textfield);
static float getFloatTextfieldValue(CCTextInputNode *&textfield, float defaultValue);
// bug fixes
void onEnter() override;
void clickOffTextfields();

public:
void onExit() override;
Expand Down
4 changes: 2 additions & 2 deletions src/RatingsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class RatingsManager {

static void populateFromSave();

static void cacheList();

public:
static int getDemonTier(int id);

Expand All @@ -43,6 +41,8 @@ class RatingsManager {
static void updateCacheFromSearch(int levelID, const float rating);

static int getCachedTier(int levelID);

static void cacheList();
};


Expand Down
5 changes: 5 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ class $modify(MenuLayer) {
}
return true;
}

void onQuit(cocos2d::CCObject* sender) {
MenuLayer::onQuit(sender);
RatingsManager::cacheList(); // cache modified list on every exit
}
};

0 comments on commit 945aa20

Please sign in to comment.