From d5ef3688b862d5cbc29895add4971a7f4791a667 Mon Sep 17 00:00:00 2001 From: Erymanthus | RayDeeUx <51521765+RayDeeUx@users.noreply.github.com> Date: Wed, 1 May 2024 15:09:31 -0400 Subject: [PATCH 1/3] v1.1.6 --- .github/workflows/multi-platform.yml | 57 ++++++++++++++++++++++++++++ mod.json | 14 +++++-- src/main.cpp | 29 +++++++++++--- 3 files changed, 91 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/multi-platform.yml diff --git a/.github/workflows/multi-platform.yml b/.github/workflows/multi-platform.yml new file mode 100644 index 0000000..0533242 --- /dev/null +++ b/.github/workflows/multi-platform.yml @@ -0,0 +1,57 @@ +name: Build Geode Mod + +on: + workflow_dispatch: + push: + branches: + - "**" + +jobs: + build: + strategy: + fail-fast: false + matrix: + config: + - name: Windows + os: windows-latest + + # - name: macOS + # os: macos-latest + + # - name: Android32 + # os: ubuntu-latest + # target: Android32 + + # - name: Android64 + # os: ubuntu-latest + # target: Android64 + + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build the mod + uses: geode-sdk/build-geode-mod@main + with: + bindings: geode-sdk/bindings + bindings-ref: main + combine: true + target: ${{ matrix.config.target }} + + package: + name: Package builds + runs-on: ubuntu-latest + needs: ['build'] + + steps: + - uses: geode-sdk/build-geode-mod/combine@main + id: build + + - uses: actions/upload-artifact@v4 + with: + name: Build Output + path: ${{ steps.build.outputs.build-output }} \ No newline at end of file diff --git a/mod.json b/mod.json index 9fbdfee..f322932 100644 --- a/mod.json +++ b/mod.json @@ -1,10 +1,18 @@ { - "geode": "2.0.0", - "version": "v1.1.5", + "geode": "2.0.0-beta.25", + "version": "v1.1.6", "gd": "2.204", "id": "adyagd.ingamelistmod", "name": "IngameListMod", "developer": "AdyaGD", "description": "Shows the position of a demon/challenge in the list", - "repository": "https://github.com/AdyaGMD/IngameListMod" + "repository": "https://github.com/AdyaGMD/IngameListMod", + "settings": { + "silentFail": { + "name": "Suppress Errors", + "description": "When IngameListMod fails to get the ranking of a demon level, you'll get an alert. Enabling this setting disables the alert.\n\nFetching level rankings will still fail even if you enable this.", + "type": "bool", + "default": false + } + } } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index a9a64be..b5b7756 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,8 +15,9 @@ int listtype; class DemonClass { public: - void infobox(CCObject*); - void openLink(cocos2d::CCObject* ret); + void infobox(CCObject* sender); + void internetFail(CCObject* sender); + void openLink(CCObject* ret); }; static size_t my_write(void* buffer, size_t size, size_t nmemb, void* param) @@ -61,10 +62,11 @@ void DemonClass::openLink(CCObject* ret) { } } -void infoButton(CCLayer* layer, CCLabelBMFont* thelabel) { +void infoButton(CCLayer* layer, CCLabelBMFont* thelabel, bool internetFail = false) { CCPoint position = { thelabel->getPositionX() - 122, thelabel->getPositionY() - 81 }; CCSprite* buttonbg = CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png"); auto button = CCMenuItemSpriteExtra::create(buttonbg, layer, menu_selector(DemonClass::infobox)); + if (internetFail) button = CCMenuItemSpriteExtra::create(buttonbg, layer, menu_selector(DemonClass::internetFail)); auto menu = CCMenu::create(); menu->setScale(0.5f); menu->addChild(button); @@ -72,10 +74,14 @@ void infoButton(CCLayer* layer, CCLabelBMFont* thelabel) { layer->addChild(menu); } -void DemonClass::infobox(CCObject*) { +void DemonClass::infobox(CCObject* sender) { FLAlertLayer::create("N/A Position Help", "The Demon or Challenge has either never been List Worthy or hasn't been placed yet on the List.", "OK")->show(); } +void DemonClass::internetFail(CCObject* sender) { + FLAlertLayer::create("??? Position Help", "IngameListMod could not fetch this level's ranking right now.\n\nTry again later.", "OK")->show(); +} + void getRequest(CCLayer* self, GJGameLevel* level, CCLabelBMFont* thelabel, bool pointercrate, bool platformer) { static nlohmann::json childJson; @@ -104,7 +110,7 @@ void getRequest(CCLayer* self, GJGameLevel* level, CCLabelBMFont* thelabel, bool .fetch(url) .text() .then([self, thelabel, pointercrate, level, platformer](std::string const& resultat) mutable { - std::cout << resultat << "\n\n"; + log::info("{}\n\n", resultat); std::string result; try { @@ -113,7 +119,7 @@ void getRequest(CCLayer* self, GJGameLevel* level, CCLabelBMFont* thelabel, bool self->autorelease(); - if (childJson[0].contains("position")) { + if (childJson.size() > 0 && childJson[0].contains("position")) { int position = childJson[0]["position"]; std::string label = std::string(std::to_string(position)); thelabel->setString(label.c_str()); @@ -129,6 +135,17 @@ void getRequest(CCLayer* self, GJGameLevel* level, CCLabelBMFont* thelabel, bool infoButton(self, thelabel); cachedPositions.insert({ level->m_levelID, -1 }); } + } catch (nlohmann::json::exception &e) { // refer to: https://github.com/nlohmann/json/discussions/2467#discussioncomment-127872 + log::info("e.what(): {}", e.what()); // log for users to end to adya + thelabel->setString("???"); // distinguish from "N/A" rankings + infoButton(self, thelabel, true); // distinguish from "N/A" rankings + if (!Mod::get()->getSettingValue("silentFail")) { + FLAlertLayer::create( + "Oof!", + "IngameListMod is unable to find the ranking of this level right now.\n\nThis is usually not your fault, but double-check your Internet connection just to be safe.\n\nPing me in the Geode SDK Discord server (@adyagd) if you continue seeing this error.", + "Close" + )->show(); + } } catch (int a) {} }) .expect([](std::string const& error) { From d7f7a82490198fe9059af46d14b1e3bfc6859e13 Mon Sep 17 00:00:00 2001 From: Erymanthus | RayDeeUx <51521765+RayDeeUx@users.noreply.github.com> Date: Wed, 1 May 2024 15:11:40 -0400 Subject: [PATCH 2/3] cdc suggested a revision --- mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod.json b/mod.json index f322932..4c10c3a 100644 --- a/mod.json +++ b/mod.json @@ -10,7 +10,7 @@ "settings": { "silentFail": { "name": "Suppress Errors", - "description": "When IngameListMod fails to get the ranking of a demon level, you'll get an alert. Enabling this setting disables the alert.\n\nFetching level rankings will still fail even if you enable this.", + "description": "When the mod fails to get the ranking of a demon level, you'll get an alert. Enabling this setting disables the alert.\n\nFetching level rankings will still fail even if you enable this.", "type": "bool", "default": false } From fd02aff03cf3773f68144c38dc2d0ab761d90636 Mon Sep 17 00:00:00 2001 From: Erymanthus | RayDeeUx <51521765+RayDeeUx@users.noreply.github.com> Date: Wed, 1 May 2024 15:52:50 -0400 Subject: [PATCH 3/3] revise alert setup --- mod.json | 12 ++---------- src/main.cpp | 9 +-------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/mod.json b/mod.json index 4c10c3a..d17bee0 100644 --- a/mod.json +++ b/mod.json @@ -5,14 +5,6 @@ "id": "adyagd.ingamelistmod", "name": "IngameListMod", "developer": "AdyaGD", - "description": "Shows the position of a demon/challenge in the list", - "repository": "https://github.com/AdyaGMD/IngameListMod", - "settings": { - "silentFail": { - "name": "Suppress Errors", - "description": "When the mod fails to get the ranking of a demon level, you'll get an alert. Enabling this setting disables the alert.\n\nFetching level rankings will still fail even if you enable this.", - "type": "bool", - "default": false - } - } + "description": "Shows the position of a demon/challenge level in the list.", + "repository": "https://github.com/AdyaGMD/IngameListMod" } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index b5b7756..3eb458f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -79,7 +79,7 @@ void DemonClass::infobox(CCObject* sender) { } void DemonClass::internetFail(CCObject* sender) { - FLAlertLayer::create("??? Position Help", "IngameListMod could not fetch this level's ranking right now.\n\nTry again later.", "OK")->show(); + FLAlertLayer::create("??? Position Help", "IngameListMod is unable to find the ranking of this level right now.\n\nThis is usually not your fault, but double-check your Internet connection just to be safe.\n\nPing me in the Geode SDK Discord server (@adyagd) if you continue seeing this error.", "OK")->show(); } void getRequest(CCLayer* self, GJGameLevel* level, CCLabelBMFont* thelabel, bool pointercrate, bool platformer) @@ -139,13 +139,6 @@ void getRequest(CCLayer* self, GJGameLevel* level, CCLabelBMFont* thelabel, bool log::info("e.what(): {}", e.what()); // log for users to end to adya thelabel->setString("???"); // distinguish from "N/A" rankings infoButton(self, thelabel, true); // distinguish from "N/A" rankings - if (!Mod::get()->getSettingValue("silentFail")) { - FLAlertLayer::create( - "Oof!", - "IngameListMod is unable to find the ranking of this level right now.\n\nThis is usually not your fault, but double-check your Internet connection just to be safe.\n\nPing me in the Geode SDK Discord server (@adyagd) if you continue seeing this error.", - "Close" - )->show(); - } } catch (int a) {} }) .expect([](std::string const& error) {