From 71c31181ed4f5d659d8fa325923ea0de8c7cfba6 Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Thu, 14 Nov 2024 14:41:13 +0300 Subject: [PATCH] port to geode 4.0, bump to v1.4.0-beta.4 --- CMakeLists.txt | 2 +- mod.json | 12 ++++++------ src/ListManager.cpp | 5 +++-- src/NLWRating.cpp | 22 +++++++++++----------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b69bb2a..ff69caa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,4 +21,4 @@ endif() add_subdirectory($ENV{GEODE_SDK} ${CMAKE_CURRENT_BINARY_DIR}/geode) -setup_geode_mod(${PROJECT_NAME} EXTERNALS geode.node-ids:1.12.0) +setup_geode_mod(${PROJECT_NAME} EXTERNALS geode.node-ids:1.17.0-alpha.1) diff --git a/mod.json b/mod.json index 08c5ab7..a301cd1 100644 --- a/mod.json +++ b/mod.json @@ -1,17 +1,17 @@ { - "geode": "3.0.0-beta.3", + "geode": "4.0.0-alpha.1", "gd": { - "win": "2.206", - "mac": "2.206", - "android": "2.206" + "win": "2.2074", + "mac": "2.2074", + "android": "2.2074" }, - "version": "v1.4.0-beta.3", + "version": "v1.4.0-beta.4", "id": "oatmealine.nlw_integration", "name": "NLW Integration", "dependencies": [ { "id": "geode.node-ids", - "version": ">=v1.12.0", + "version": ">=v1.17.0-alpha.1", "importance": "required" } ], diff --git a/src/ListManager.cpp b/src/ListManager.cpp index 4831a77..299c902 100644 --- a/src/ListManager.cpp +++ b/src/ListManager.cpp @@ -20,12 +20,13 @@ std::vector ListManager::ratings; EventListener ListManager::fetchListListener; void ListManager::parseResponse(matjson::Value data) { - if (!data.is_array()) { + if (!data.isArray()) { log::error("got unexpected data: {}", data.dump()); ListManager::throwError("expected root element to be an array! check logs"); + return; } - auto arr = data.as_array(); + auto arr = data.asArray().unwrap(); for (auto& level : arr) { auto rating = NLWRating(level); diff --git a/src/NLWRating.cpp b/src/NLWRating.cpp index 00f6d7c..bee0940 100644 --- a/src/NLWRating.cpp +++ b/src/NLWRating.cpp @@ -4,8 +4,8 @@ using namespace geode::prelude; NLWRating::NLWRating(matjson::Value levelData) { - this->sheetIndex = levelData["sheetIndex"].as_int(); - auto type = levelData["type"].as_string(); + this->sheetIndex = levelData["sheetIndex"].asInt().unwrapOrDefault(); + auto type = levelData["type"].asString().unwrapOrDefault(); if (type == "platformer") { this->type = NLWRatingType::Platformer; } else if (type == "pending") { @@ -13,15 +13,15 @@ NLWRating::NLWRating(matjson::Value levelData) { } else { this->type = NLWRatingType::Regular; } - this->tier = levelData["tier"].as_string(); - this->id = levelData["id"].is_number() ? levelData["id"].as_int() : -1; - this->name = levelData["name"].is_string() ? levelData["name"].as_string() : "?"; - this->creator = levelData["creator"].is_string() ? levelData["creator"].as_string() : "?"; - this->skillset = levelData["skillset"].is_string() ? levelData["skillset"].as_string() : ""; - this->enjoyment = levelData["enjoyment"].is_number() ? static_cast(levelData["enjoyment"].as_double()) : -1.f; // unsure if the cast is necessary but better safe than sorry - this->description = levelData["description"].is_string() ? levelData["description"].as_string() : ""; - if (levelData["broken"].is_string()) { - this->broken = levelData["broken"].as_string(); + this->tier = levelData["tier"].asString().unwrapOrDefault(); + this->id = levelData["id"].asInt().unwrapOr(-1); + this->name = levelData["name"].asString().unwrapOr("?"); + this->creator = levelData["creator"].asString().unwrapOr("?"); + this->skillset = levelData["skillset"].asString().unwrapOrDefault(); + this->enjoyment = levelData["enjoyment"].asDouble().unwrapOr(-1.f); + this->description = levelData["description"].asString().unwrapOrDefault(); + if (levelData["broken"].isString()) { + this->broken = levelData["broken"].asString().unwrap(); } }