Skip to content

Commit

Permalink
beta 35
Browse files Browse the repository at this point in the history
  • Loading branch information
Minemaker0430 committed Jul 31, 2024
1 parent 1e1d384 commit 540c5f6
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 18 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ An official mod for the **G**eometry **D**ash **D**emon **P**rogression list tha
* **Minemaker0430** - Made the mod
* oatmealine - API Framework for "Rate All Demons"
* wint0r - Created the "Rate All Demons" Option & its Sprite Framework
* hiimjustin000 - Made the code that I borrowed for a Custom List framework
* ElohmroW - GDDP Co-Owner & Website Programmer
* Trusta - For making GDDP in the first place
* GDDP Website - Source of the custom Demon Icons
* Firee - For helping me start modding back in the old 2.1 DLL days :)
* Colon - For helping me with Server Response stuff for lists
* The Geode Discord Server - For helping me figure out a few things
* Patrick61804 - For helping me get higher quality textures
* Patrick61804 - For helping me get higher quality textures
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# v1.0.0-beta.35
* Fixed Rate All Demons
* Spreadsheet Parsing Code borrowed from hiimjustin
* Still investigating mobile crashes

# v1.0.0-beta.34

* Fixed Various Visual Bugs
Expand Down
8 changes: 4 additions & 4 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"geode": "3.2.0",
"geode": "3.4.0",
"gd": {
"win": "2.206",
"android": "2.206"
},
"version": "v1.0.0-beta.34",
"version": "v1.0.0-beta.35",
"id": "minemaker0430.gddp_integration",
"name": "GDDP Integration",
"developer": "Minemaker0430",
Expand Down Expand Up @@ -133,8 +133,8 @@
"default": true
},
"all-demons-rated": {
"name": "[BROKEN] Rate All Demons",
"description": "Shows custom difficulty faces on all rated demons. <cr>Requires \"Show Faces Outside Menus\".</c> \n\n(Option created by wint0r)",
"name": "Rate All Demons",
"description": "Shows custom difficulty faces on all rated demons. Please note that demons without GDDL Ratings will not be given ratings. <cr>Requires \"Show Faces Outside Menus\".</c> \n\n(Option created by wint0r)",
"type": "bool",
"default": false
},
Expand Down
2 changes: 1 addition & 1 deletion src/DPLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,4 +965,4 @@ void DPLayer::onTab(CCObject* pSender) {

DPLayer::~DPLayer() {
this->removeAllChildrenWithCleanup(true);
}
}
45 changes: 34 additions & 11 deletions src/ListManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

using namespace geode::prelude;

const std::string GDDL_API_URL = "https://gdladder.com/api/theList";
const std::string GDDL_API_URL = "https://docs.google.com/spreadsheets/d/1qKlWKpDkOpU1ZF6V6xGfutDY2NvcA8MNPnsv6GBkKPQ/gviz/tq?tqx=out:csv&sheet=GDDL"; //"https://gdladder.com/api/theList";

bool ListManager::fetchedGDDLRatings;
std::vector<ListRating> ListManager::ratings;
Expand All @@ -30,13 +30,38 @@ void ListManager::init() {
return;
}

void ListManager::parseResponse(matjson::Value val) {
if (!val.is_array()) {
// todo: show error to user
return;
void ListManager::parseResponse(std::string val) {

//Thank you hiimjustin :pray:

// MAKE SURE WE ARE NOT SPLITTING THE COMMAS IN THE QUOTATION MARKS
auto lines = string::split(val, "\n");
auto keys = string::split(lines[0].substr(1, lines[0].size() - 2), "\",\"");
static auto demons = matjson::Array();
for (size_t i = 1; i < lines.size(); i++) {
auto values = string::split(lines[i].substr(1, lines[i].size() - 2), "\",\"");
ListRating demon;
for (size_t j = 0; j < keys.size(); j++) {
auto key = keys[j];
auto value = values[j];
if (key == "ID")
{
demon.id = std::stoi(value);
}
else if (key == "Name") {
demon.name = value;
}
else if (key == "Tier")
{
demon.tier = value != "" ? round(std::stod(value) * 100) / 100 : 0;
}
}
ListManager::ratings.push_back(demon);
}

auto levels = val.as_array();
return;

/*auto levels = val.as_array();
for (auto level : levels) {
ListRating rating;
Expand All @@ -47,9 +72,7 @@ void ListManager::parseResponse(matjson::Value val) {
rating.tier = level["Rating"].is_number() ? level["Rating"].as_int() : 0;
ListManager::ratings.push_back(rating);
}

return;
}*/
}

int levenshteinDistance(std::string a, std::string b) {
Expand Down Expand Up @@ -161,8 +184,8 @@ bool GDDLListener::init() {
if (!ListManager::fetchedGDDLRatings) {
this->bind([this](web::WebTask::Event* e) {
if (auto res = e->getValue()) {
if (res->ok() && res->json().isOk()) {
auto response = res->json().unwrap();
if (res->ok() && res->string().isOk()) {
auto response = res->string().value();

log::info("Successfully obtained GDDL Data.");

Expand Down
2 changes: 1 addition & 1 deletion src/ListManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct ListManager {
static bool fetchedGDDLRatings;

static void init();
static void parseResponse(matjson::Value val);
static void parseResponse(std::string val);
//static void throwError(std::string message);
static std::optional<ListRating> getRating(int levelID);
static std::string getSpriteName(GJGameLevel* level);
Expand Down

0 comments on commit 540c5f6

Please sign in to comment.