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..d17bee0 100644 --- a/mod.json +++ b/mod.json @@ -1,10 +1,10 @@ { - "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", + "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 a9a64be..3eb458f 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 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) { 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,10 @@ 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 } catch (int a) {} }) .expect([](std::string const& error) {