Skip to content

Commit

Permalink
Merge #64 v1.1.13
Browse files Browse the repository at this point in the history
1.1.13
  • Loading branch information
B1rtek authored Oct 26, 2024
2 parents 14932af + 51425b9 commit db6a993
Show file tree
Hide file tree
Showing 44 changed files with 1,284 additions and 956 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ project(GDDLIntegration VERSION 1.0.0)
# to recursively add all source files
# under src/
file(GLOB SOURCES
src/*.cpp src/*.h src/*/*.cpp src/*/*.h
src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/*/*/*.cpp src/*/*/*.h
)

include_directories(src)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ If you encounter an <cy>issue</c> with the mod, [open an issue in the mod's GitH
## Special thanks

<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), [peteratomic](https://github.com/B1rtek/Geode-GDDLIntegration/issues/34), [ninXout](https://github.com/B1rtek/Geode-GDDLIntegration/pull/61)</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), [peteratomic](https://github.com/B1rtek/Geode-GDDLIntegration/issues/34), [ninXout](https://github.com/B1rtek/Geode-GDDLIntegration/pull/61), [itzgabrix](https://github.com/B1rtek/Geode-GDDLIntegration/issues/45)</c>
<cy>*Problem solving:*</c> <cy>hiimjustin000</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), Cvolton, [pointedbowl](https://github.com/B1rtek/Geode-GDDLIntegration/issues/33), [Neonyx27, ItzGabrix](https://github.com/B1rtek/Geode-GDDLIntegration/issues/40), [Aktimoose](https://github.com/B1rtek/Geode-GDDLIntegration/issues/46), [MasterGamerY, Denyscrasav4ik, rynethegrynd](https://github.com/B1rtek/Geode-GDDLIntegration/issues/49), [ZorTik](https://github.com/B1rtek/Geode-GDDLIntegration/issues/50), [ZorTik, zHackro, powerz](https://github.com/B1rtek/Geode-GDDLIntegration/issues/58), </c>
2 changes: 1 addition & 1 deletion about.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ If you encounter an <cy>issue</c> with the mod, [open an issue in the mod's GitH
## Special thanks

<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), [peteratomic](https://github.com/B1rtek/Geode-GDDLIntegration/issues/34), [ninXout](https://github.com/B1rtek/Geode-GDDLIntegration/pull/61)</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), [peteratomic](https://github.com/B1rtek/Geode-GDDLIntegration/issues/34), [ninXout](https://github.com/B1rtek/Geode-GDDLIntegration/pull/61), [itzgabrix](https://github.com/B1rtek/Geode-GDDLIntegration/issues/45)</c>
<cy>*Problem solving:*</c> <cy>hiimjustin000</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), Cvolton, [pointedbowl](https://github.com/B1rtek/Geode-GDDLIntegration/issues/33), [Neonyx27, ItzGabrix](https://github.com/B1rtek/Geode-GDDLIntegration/issues/40), [Aktimoose](https://github.com/B1rtek/Geode-GDDLIntegration/issues/46), [MasterGamerY, Denyscrasav4ik, rynethegrynd](https://github.com/B1rtek/Geode-GDDLIntegration/issues/49), [ZorTik](https://github.com/B1rtek/Geode-GDDLIntegration/issues/50), [ZorTik, zHackro, powerz](https://github.com/B1rtek/Geode-GDDLIntegration/issues/58), </c>
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v1.1.13
- Added difficulty tiers to RobTop's demons
- Ported settings to SettingsV3, making GDDL Integration one of the first mods to use the new standard (yaaaaay!)

# v1.1.12
- Added a GDDL cache reset button in the settings, in case the GDDL Split shows only zeroes you should use it, removing the json file will no longer be needed
- If you're disconnected from the internet the mod should no longer show you an alert about that every time you're in the main menu
Expand Down
24 changes: 12 additions & 12 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "3.7.1",
"version": "v1.1.12",
"geode": "3.8.1",
"version": "v1.1.13",
"gd": {
"android": "2.206",
"win": "2.206",
Expand Down Expand Up @@ -42,23 +42,23 @@
"settings": {
"button-position": {
"name": "Button position",
"description": "Sets the GDDL Button position on the level info page",
"type": "custom"
"description": "Defines the <cr>GDDL Button</c> position on the <cb>level info</c> page. <cy>By default</c> it's positioned <cp>to the left</c> of the <cr>demon difficulty face</c>. This setting <cy>is overriden</c> by the setting \"<cb>Use old tier label</c>\"",
"type": "custom:button-position-v3"
},
"use-old-tier-label" : {
"name": "Use old tier label",
"description": "Changes the tier button into a label, allows for shifting it up and down",
"type": "custom"
"description": "<cy>Changes</c> the <cr>tier button</c> on the <cb>level info page</c> into a <cg>clickable label</c>, just like it used to be in the <co>early versions of this mod</c>. Allows you to <cy>specify an offset</c> to move the label <cg>up</c> <cb>or</c> <cr>down</c> by the given number of rows. <cr>This settings overrides \"Button position\"!</c>",
"type": "custom:use-old-tier-label-v3"
},
"exclude-range": {
"exclude-range" : {
"name": "Include/Exclude range",
"description": "The GDDL Button will be hidden/shown on the level pages within the exclusion/inclusion range",
"type": "custom"
"description": "<cr>Removes</c> the GDDL button from level pages of levels <cy>within</c> the specified range. If the <cb>include</c> toggle is toggled <cg>on</c>, the ratings will <cy>only</c> be displayed in the specified range. If both range ends are set to <cb>0</c>, this setting does <cy>nothing</c>, an empty value means 1 (range beginning) and 35 (range end) by default. Range is <cg>inclusive</c> on <cb>both</c> ends.",
"type": "custom:exclude-range-v3"
},
"cache-reset": {
"cache-reset-v3": {
"name": "Reset GDDL cache",
"description": "Resets the GDDL cache, useful if the GDDL split isn't working",
"type": "custom"
"description": "Use if the <cr>GDDL Split layer</c> shows <cy>zero</c> for every tier or if the ratings on the level info page are <co>inaccurate</c>.",
"type": "custom:cache-reset-v3"
}
}
}
12 changes: 12 additions & 0 deletions src/GDDLBoomScrollLayer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "GDDLBoomScrollLayer.h"

void GDDLBoomScrollLayer::ccTouchEnded(cocos2d::CCTouch* p0, cocos2d::CCEvent* p1) {
BoomScrollLayer::ccTouchEnded(p0, p1);
int actualPage = m_page;
while (actualPage < 0) {
actualPage += GDDLRobtopLevelsLayer::Fields::pageCount;
}
if (GDDLRobtopLevelsLayer::Fields::beingBrowsed && Fields::robtopLevelsLayer != nullptr) {
Fields::robtopLevelsLayer->swiped(actualPage % GDDLRobtopLevelsLayer::Fields::pageCount);
}
}
19 changes: 19 additions & 0 deletions src/GDDLBoomScrollLayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef GDDLBOOMSCROLLLAYER_H
#define GDDLBOOMSCROLLLAYER_H

#include <Geode/Bindings.hpp>
#include <Geode/modify/BoomScrollLayer.hpp>

#include "GDDLRobtopLevelsLayer.h"

using namespace geode::prelude;

struct GDDLBoomScrollLayer : public geode::Modify<GDDLBoomScrollLayer, BoomScrollLayer> {
struct Fields {
static inline GDDLRobtopLevelsLayer* robtopLevelsLayer = nullptr;
};

void ccTouchEnded(cocos2d::CCTouch* p0, cocos2d::CCEvent* p1) override;
};

#endif //GDDLBOOMSCROLLLAYER_H
222 changes: 222 additions & 0 deletions src/GDDLRobtopLevelsLayer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
#include "GDDLRobtopLevelsLayer.h"

#include <GDDLBoomScrollLayer.h>

bool GDDLRobtopLevelsLayer::init(int page) {
if (!LevelSelectLayer::init(page)) {
return false;
}
m_fields->beingBrowsed = true;
GDDLBoomScrollLayer::Fields::robtopLevelsLayer = this;
// setup potential web req
m_fields->robtopLevelsLayerGetRatingListener.bind([this](web::WebTask::Event* e) {
if (web::WebResponse* res = e->getValue()) {
const std::string response = res->string().unwrapOrDefault();
if (response.empty()) {
updateButton(-1);
}
else {
const int levelID = convertPageToLevel(m_fields->currentPage);
int tierAfterFetch = -1;
if (RatingsManager::addRatingFromResponse(levelID, response)) {
tierAfterFetch = RatingsManager::getDemonTier(levelID);
}
updateButton(tierAfterFetch);
}
}
else if (e->isCancelled()) {
updateButton(-1);
}
});

m_fields->currentPage = page;
pageChanged(-1);
return true;
}

void GDDLRobtopLevelsLayer::onNext(CCObject* sender) {
int previousPage = m_fields->currentPage++;
if (m_fields->currentPage >= m_fields->pageCount) {
m_fields->currentPage = 0;
}
pageChanged(previousPage);
LevelSelectLayer::onNext(sender);
}

void GDDLRobtopLevelsLayer::onPrev(CCObject* sender) {
int previousPage = m_fields->currentPage--;
if (m_fields->currentPage < 0) {
m_fields->currentPage = m_fields->pageCount - 1;
}
pageChanged(previousPage);
LevelSelectLayer::onPrev(sender);
}

void GDDLRobtopLevelsLayer::swiped(const int newPage) {
if (newPage == m_fields->currentPage) return;
m_fields->changedBySwiping = true;
const int previousPage = m_fields->currentPage;
m_fields->currentPage = newPage;
pageChanged(previousPage);
}

void GDDLRobtopLevelsLayer::onBack(CCObject* sender) {
LevelSelectLayer::onBack(sender);
backActions();
}

void GDDLRobtopLevelsLayer::keyBackClicked() {
LevelSelectLayer::keyBackClicked();
backActions();
}

void GDDLRobtopLevelsLayer::backActions() {
m_fields->beingBrowsed = false;
GDDLBoomScrollLayer::Fields::robtopLevelsLayer = nullptr;
}

void GDDLRobtopLevelsLayer::pageChanged(int previousPage) {
// first, remove any buttons that should be removed
if (m_fields->currentPage == Level::TOE && previousPage == Level::ELECTROMAN_ADVENTURES &&
m_fields->buttonsAdded[0]) {
// navigated away from clubstep to the left, button should be removed
removeFrom(2);
m_fields->buttonsAdded[0] = false;
}
else if (m_fields->currentPage == Level::HEXAGON_FORCE && previousPage == Level::ELECTRODYNAMIX &&
m_fields->buttonsAdded[0]) {
// navigated away from clubstep to the right, button should be removed
removeFrom(2);
m_fields->buttonsAdded[0] = false;
}
else if (m_fields->currentPage == Level::HEXAGON_FORCE && previousPage == Level::BLAST_PROCESSING &&
m_fields->buttonsAdded[1]) {
// navigated away from toe2 to the left, button should be removed
removeFrom(3);
m_fields->buttonsAdded[1] = false;
}
else if (m_fields->currentPage == Level::DEADLOCKED && previousPage == Level::GEOMETRICAL_DOMINATOR &&
m_fields->buttonsAdded[1]) {
// navigated away from toe2 to the right, button should be removed
removeFrom(3);
m_fields->buttonsAdded[1] = false;
}
else if (m_fields->currentPage == Level::TOE2 && previousPage == Level::GEOMETRICAL_DOMINATOR &&
m_fields->buttonsAdded[2]) {
// navigated away from deadlocked to the left, button should be removed
removeFrom(2);
m_fields->buttonsAdded[2] = false;
}
else if (m_fields->currentPage == Level::DASH && previousPage == Level::FINGERDASH &&
m_fields->buttonsAdded[2]) {
// navigated away from deadlocked to the right, button should be removed
removeFrom(2);
m_fields->buttonsAdded[2] = false;
}
// then add them if that's required
if (m_fields->currentPage == Level::CLUBSTEP && !m_fields->buttonsAdded[0]) {
// just navigated to clubstep
addTo(2, 1);
m_fields->buttonsAdded[0] = true;
}
else if (m_fields->currentPage == Level::TOE2 && !m_fields->buttonsAdded[1]) {
// just navigated to toe2
addTo(3, 2);
m_fields->buttonsAdded[1] = true;
}
else if (m_fields->currentPage == Level::DEADLOCKED && !m_fields->buttonsAdded[2]) {
// just navigated to deadlocked
addTo(2, 3);
m_fields->buttonsAdded[2] = true;
}
}

void GDDLRobtopLevelsLayer::removeFrom(int scrollLayerPage) {
if (m_fields->changedBySwiping) {
// for some reason the usual way of doing that bugs out in that case
// find the button menu on all layers and remove them
auto buttonMenu = getChildByIDRecursive("gddl-button-menu"_spr);
while (buttonMenu != nullptr) {
auto buttonMenuParent = buttonMenu->getParent();
buttonMenuParent->removeChildByID("gddl-button-menu"_spr);
buttonMenu = getChildByIDRecursive("gddl-button-menu"_spr);
}
// same for the button because sometimes it decides to reattach itself to the nearest random menu????
auto button = getChildByIDRecursive("gddl-button"_spr);
while (button != nullptr) {
auto buttonParent = button->getParent();
buttonParent->removeChildByID("gddl-button"_spr);
button = getChildByIDRecursive("gddl-button"_spr);
}
m_fields->changedBySwiping = false;
} else {
const std::string pageID = "level-page-" + std::to_string(scrollLayerPage);
auto levelButton = getLevelButton(scrollLayerPage);
levelButton->removeChildByID("gddl-button-menu"_spr);
}
}

void GDDLRobtopLevelsLayer::addTo(int scrollLayerPage, int levelID) {
// create the buttonMenu and the button
if (!Utils::notExcluded(levelID)) {
return;
}
const auto buttonMenu = CCMenu::create();
buttonMenu->setID("gddl-button-menu"_spr);
buttonMenu->setContentSize({25, 25});
const auto sprite = Utils::getSpriteFromTier(RatingsManager::getCachedTier(levelID));
sprite->setScale(sprite->getScale() / 2);
const auto button = CCMenuItemSpriteExtra::create(sprite, this, menu_selector(GDDLRobtopLevelsLayer::onGDDLInfo));
button->setID("gddl-button"_spr);
// add it
auto levelButton = getLevelButton(scrollLayerPage);
if (!levelButton) return;
buttonMenu->addChild(button);
button->setPosition(12.5, 12.5);
levelButton->addChild(buttonMenu);
buttonMenu->setPosition(5, 69);
// after placing the button fetch the full level info
const int tier = RatingsManager::getDemonTier(levelID);
if (tier == -1) {
auto req = web::WebRequest();
m_fields->robtopLevelsLayerGetRatingListener.setFilter(req.get(RatingsManager::getRequestUrl(levelID)));
}
}

int GDDLRobtopLevelsLayer::convertPageToLevel(int page) {
int levelID = 1;
if (page == Level::TOE2) {
levelID = 2;
} else if (page == Level::DEADLOCKED) {
levelID = 3;
}
return levelID;
}

CCNode* GDDLRobtopLevelsLayer::getLevelButton(int pageID) {
const std::string pageIDStr = "level-page-" + std::to_string(pageID);
return getChildByID("levels-list")->getChildByID("level-pages")->getChildByID(pageIDStr)->getChildByID(
"level-menu")->getChildByID("level-button")->getChildByID("white-sprite")->getChildByID(
"scale-9-sprite");
}

void GDDLRobtopLevelsLayer::onGDDLInfo(CCObject *sender) {
const int levelID = convertPageToLevel(m_fields->currentPage);
GDDLLevelInfoPopup::create(levelID)->show();
}

void GDDLRobtopLevelsLayer::updateButton(const int tier) {
// get the menu
auto gddlButtonMenu = getLevelButton(m_fields->currentPage % 3 + 1)->getChildByID("gddl-button-menu"_spr);
if (gddlButtonMenu == nullptr) return; // the user most likely scrolled past quicker than it loaded
// remove the old button
gddlButtonMenu->removeAllChildren();
// add the new one
const int levelID = convertPageToLevel(m_fields->currentPage);
const auto sprite = Utils::getSpriteFromTier(RatingsManager::getCachedTier(levelID));
sprite->setScale(sprite->getScale() / 2);
const auto button = CCMenuItemSpriteExtra::create(sprite, this,menu_selector(GDDLRobtopLevelsLayer::onGDDLInfo));
button->setID("gddl-button"_spr);
gddlButtonMenu->addChild(button);
button->setPosition(12.5, 12.5);
}
Loading

0 comments on commit db6a993

Please sign in to comment.