Skip to content

Commit

Permalink
Merge pull request #10 from RayDeeUx/master
Browse files Browse the repository at this point in the history
v1.1.6
  • Loading branch information
AdyaGMD authored May 1, 2024
2 parents 3c980cc + fd02aff commit fe5107d
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 9 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/multi-platform.yml
Original file line number Diff line number Diff line change
@@ -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 }}
6 changes: 3 additions & 3 deletions mod.json
Original file line number Diff line number Diff line change
@@ -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"
}
22 changes: 16 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -61,21 +62,26 @@ 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);
menu->setPosition(position);
layer->addChild(menu);
}

void DemonClass::infobox(CCObject*) {
void DemonClass::infobox(CCObject* sender) {
FLAlertLayer::create("N/A Position Help", "The <cr>Demon</c> or <cr>Challenge</c> has either never been <cl>List Worthy</c> or hasn't been placed yet on the <cy>List</c>.", "OK")->show();
}

void DemonClass::internetFail(CCObject* sender) {
FLAlertLayer::create("??? Position Help", "IngameListMod is unable to find the ranking of this level right now.\n\n<cy>This is usually not your fault, but double-check your Internet connection just to be safe.</c>\n\nPing me in the Geode SDK Discord server (<cb>@adyagd</c>) if you continue seeing this error.", "OK")->show();
}

void getRequest(CCLayer* self, GJGameLevel* level, CCLabelBMFont* thelabel, bool pointercrate, bool platformer)
{
static nlohmann::json childJson;
Expand Down Expand Up @@ -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 {
Expand All @@ -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());
Expand All @@ -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) {
Expand Down

0 comments on commit fe5107d

Please sign in to comment.