Jouca / GDUtils-Geode

A Geometry Dash mod adding more tools on the game (Online notifications, level URL, epic UI redesigns, auto-song mute, games fixes & more)
GNU General Public License v3.0
15 stars 7 forks source link

Add option to use AREDL instead of Pointercrate #20

Closed nytelytee closed 1 month ago

nytelytee commented 6 months ago

Would be great to have the option to use the All Rated Extreme Demons List instead of the Pointercrate one, in my case mainly because the Grandpa Demon mod uses AREDL to change the difficulty faces, so I would want to be more in line with the difficulty faces it shows me.

This is all I had to do to get it to request to AREDL instead of Pointercrate (obviously the code would be different if an actual option were added, but this is just to demonstrate how the request would look):

diff --git a/mod.json b/mod.json
index 65522d5..f55e386 100644
--- a/mod.json
+++ b/mod.json
@@ -181,7 +181,7 @@
         },
         "demonListPlacement": {
             "name": "Demon Placements",
-            "description": "Whether or not to show placements for <cr>Extreme Demons</c> from <cy>Pointercrate</c>.",
+            "description": "Whether or not to show placements for <cr>Extreme Demons</c> from <cy>AREDL</c>.",
             "type": "bool",
             "default": true
         },
diff --git a/src/Utils/DemonList.cpp b/src/Utils/DemonList.cpp
index 6a069cd..23d758a 100644
--- a/src/Utils/DemonList.cpp
+++ b/src/Utils/DemonList.cpp
@@ -98,9 +98,9 @@ class $modify(LevelInfoLayer) {
             }
             loading_circle->setParentLayer(this);
             loading_circle->show();
-            log::info("Sending a request to pointercrate...");
+            log::info("Sending a request to AREDL...");
             web::AsyncWebRequest()
-                .fetch(fmt::format("https://pointercrate.com/api/v2/demons/listed/?name={}", url_encode(level->m_levelName).c_str()))
+                .fetch(fmt::format("https://api.aredl.net/api/aredl/level?level_id={}", levelID))
                 .json()
                 .then([this, level, levelID, loading_circle, positionLabel, demonSpr, winSize](matjson::Value const& json) {
                     if (loading_circle != nullptr) {
@@ -109,18 +109,18 @@ class $modify(LevelInfoLayer) {
                     auto scene = CCDirector::sharedDirector()->getRunningScene();
                     //auto layer = misc::findNode("LevelInfoLayer");
                     //if (layer == nullptr) return;
-                    if (json.dump() == "[]") { //idk how to check size, doing .count crashes
-                        log::info("Level not found in pointercrate.");
+                    if (json.contains("code")) {
+                        log::info("Level not found in AREDL.");
                         this->release();
                     } else {
-                        auto info = json.get<matjson::Value>(0);
-                        auto position = info.get<int>("position");
+                        //auto info = json.get<matjson::Value>(0);
+                        auto position = json.get<int>("position");
                         positionLabel->setString(fmt::format("#{}", position).c_str());
                         positionLabel->setScale(getScaleBasedPos(position));
                         positionLabel->setVisible(true);
                         demonSpr->setVisible(true);
                         set(levelID, position);
-                        log::info("Level found in Pointercrate! {} at #{}", level->m_levelName.c_str(), position);
+                        log::info("Level found in AREDL! {} at #{}", level->m_levelName.c_str(), position);
                         this->release();
                     }
                 })
@@ -128,10 +128,10 @@ class $modify(LevelInfoLayer) {
                     if (loading_circle != nullptr) {
                         loading_circle->fadeAndRemove();
                     }
-                    log::error("Error while sending a request to Pointercrate: {}", error);
+                    log::error("Error while sending a request to AREDL: {}", error);
                     FLAlertLayer::create(nullptr,
                         "Error",
-                        "Failed to make a request to <cy>Pointercrate</c>. Please either <cg>try again later</c>, look at the error logs to see what might have happened, or report this to the developers.",
+                        "Failed to make a request to <cy>AREDL</c>. Please either <cg>try again later</c>, look at the error logs to see what might have happened, or report this to the developers.",
                         "OK",
                         nullptr,
                         350.0F
nytelytee commented 6 months ago

Side note: whoops this part doesn't actually do what I wanted it to do lol, I just sent the api requests in a browser and looked at the output.

-                    if (json.dump() == "[]") { //idk how to check size, doing .count crashes
-                        log::info("Level not found in pointercrate.");
+                    if (json.contains("code")) {
+                        log::info("Level not found in AREDL.");

I did not notice that it didn't work because the list contains all extreme demons. I had to go and add 1 to the level ID to test it, and I did that after I had opened this issue already.

FireMario211 commented 6 months ago

We could add an option to switch to using AREDL, but we aren't going to change this mod to just only use AREDL as there are some inaccuracies

Aktimoose commented 6 months ago

We could add an option to switch to using AREDL, but we aren't going to change this mod to just only use AREDL as there are some inaccuracies

If accuracy is a concern, then legacy levels should be omitted from the mod, as their "placements" on the demon list are severely outdated and don't count harder levels above them that were released after they fell off the list. It also doesn't make sense to consider a list less accurate than the other when it's entirely subjective.

FireMario211 commented 6 months ago

We could add an option to switch to using AREDL, but we aren't going to change this mod to just only use AREDL as there are some inaccuracies

If accuracy is a concern, then legacy levels should be omitted from the mod, as their "placements" on the demon list are severely outdated and don't count harder levels above them that were released after they fell off the list. It also doesn't make sense to consider a list less accurate than the other when it's entirely subjective.

I agree. I wasn't saying that AREDL should not be added. I was more so saying it shouldn't be replaced as some people have opinions on them.

nytelytee commented 6 months ago

BTW, if you do end up adding an option, AREDL has an option to fetch the entire list at once, it seems, I looked at the Grandpa Demon source code. Not sure if Pointercrate has a similar option or not, but in the case of AREDL at least, maybe it would make more sense to make a single request when the game is first started and then cache the results?