diff --git a/src/hooks/CreatorLayer.cpp b/src/hooks/CreatorLayer.cpp index efb0b8a..70d9fe0 100644 --- a/src/hooks/CreatorLayer.cpp +++ b/src/hooks/CreatorLayer.cpp @@ -78,6 +78,7 @@ class $modify(BICreatorLayer, CreatorLayer) { this->addChild(menu); showQuestExclamationMark(); + BetterInfo::loadImportantNotices(this); /*auto alert = CM->updateCompleteDialog(); if(alert) { diff --git a/src/utils.cpp b/src/utils.cpp index 2efa81a..084c5bd 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -7,6 +7,7 @@ #include #include +#include CCSprite* BetterInfo::createWithBISpriteFrameName(const char* name){ return createBISprite(name); @@ -579,4 +580,26 @@ bool BetterInfo::controllerConnected() { #else return CCApplication::sharedApplication()->getControllerConnected(); #endif +} + +void BetterInfo::loadImportantNotices(CCLayer* layer) { + static bool hasBeenCalled = false; + if(hasBeenCalled) return; + hasBeenCalled = true; + + layer->retain(); + + web::AsyncWebRequest().fetch(fmt::format("https://geometrydash.eu/mods/betterinfo/_api/importantNotices/?platform={}&version={}", GEODE_PLATFORM_NAME, Mod::get()->getVersion().toString(false))).json().then([layer](const json::Value& info){ + auto notice = info.try_get("notice"); + if(notice == std::nullopt) return; + + if(info["notice"].is_string()) { + auto alert = FLAlertLayer::create("BetterInfo", info["notice"].as_string(), "OK"); + alert->m_scene = layer; + alert->show(); + layer->release(); + } + }).expect([](const std::string& error){ + log::warn("Fetching important notices failed: {}", error); + }); } \ No newline at end of file diff --git a/src/utils.hpp b/src/utils.hpp index aedf7a8..a6a38b6 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -57,4 +57,6 @@ namespace BetterInfo { float timeForLevelString(const std::string& levelString); bool controllerConnected(); + + void loadImportantNotices(CCLayer* layer); } \ No newline at end of file