Skip to content

Commit

Permalink
stop calling old update endpoints in update check dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Jun 11, 2023
1 parent 3b38ce2 commit fc28668
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
7 changes: 6 additions & 1 deletion src/layers/CvoltonUpdateLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ CvoltonUpdateLayer* CvoltonUpdateLayer::create(){

void CvoltonUpdateLayer::onClose(cocos2d::CCObject* sender)
{
auto CM = CvoltonManager::sharedState();
CM->updateLayer = nullptr;
setKeypadEnabled(false);
removeFromParentAndCleanup(true);
}
Expand Down Expand Up @@ -115,6 +117,9 @@ bool CvoltonUpdateLayer::init(){
historyBtn->setPosition({-210,-135});
m_pButtonMenu->addChild(historyBtn);

auto CM = CvoltonManager::sharedState();
CM->updateLayer = this;

downloadChangelog();
showVersion();

Expand All @@ -124,7 +129,7 @@ bool CvoltonUpdateLayer::init(){
void CvoltonUpdateLayer::downloadChangelog(){
auto CM = CvoltonManager::sharedState();

if(CM->changelog == "" || CM->latestVer == "") CM->downloadChangelog(this);
if(CM->changelog == "" || CM->latestVer == "") CM->downloadChangelog();
else onLoadFinished();
}

Expand Down
29 changes: 20 additions & 9 deletions src/managers/CvoltonManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,26 @@ bool CvoltonManager::init(){

void CvoltonManager::doUpdateHttpRequest(){
CCHttpRequest* request = new CCHttpRequest;
request->setUrl("https://cvolton.eu/gdmods/api/betterinfo/version/");
request->setUrl("https://geometrydash.eu/mods/betterinfo/v2/stable/version.txt");
request->setRequestType(CCHttpRequest::HttpRequestType::kHttpPost);
request->setResponseCallback(this, httpresponse_selector(CvoltonManager::onUpdateHttpResponse));
CCHttpClient::getInstance()->send(request);
request->release();
}

void CvoltonManager::onUpdateHttpResponse(CCHttpClient* client, CCHttpResponse* response){
if(!(response->isSucceed())) return;
if(!(response->isSucceed())) {
if(updateLayer) updateLayer->onLoadFailed();
return;
}

std::vector<char>* responseData = response->getResponseData();
std::string responseString(responseData->begin(), responseData->end());
latestVer = responseString;

if(isUpToDate()) return;
if(updateLayer) updateLayer->onLoadFinished();

//if(isUpToDate()) return;

/*std::ostringstream stream;
stream << modNameColored << " " << responseString;*/
Expand All @@ -72,7 +77,7 @@ void CvoltonManager::onUpdateHttpResponse(CCHttpClient* client, CCHttpResponse*

}

void CvoltonManager::onChangelogHttpResponse(CCHttpClient* client, CCHttpResponse* response){
/*void CvoltonManager::onChangelogHttpResponse(CCHttpClient* client, CCHttpResponse* response){
CvoltonUpdateLayer* updateLayer = static_cast<CvoltonUpdateLayer*>(response->getHttpRequest()->getUserData());
if(!(response->isSucceed())){
Expand All @@ -87,7 +92,7 @@ void CvoltonManager::onChangelogHttpResponse(CCHttpClient* client, CCHttpRespons
updateLayer->onLoadFinished();
updateLayer->release();
//FLAlertLayer::create(nullptr, "User Info", "OK", nullptr, 300, stream.str().c_str())->show();
}
}*/

//CvoltonManager* CvoltonManager::sharedState()

Expand All @@ -112,16 +117,16 @@ const char* CvoltonManager::getUserName(int id){
return obj->getCString();
}

void CvoltonManager::downloadChangelog(CvoltonUpdateLayer* updateLayer){
updateLayer->retain();
void CvoltonManager::downloadChangelog(){
changelog = "Click the button in the lower left corner to see changelogs";
forceUpdateCheck();

CCHttpRequest* request = new CCHttpRequest;
/*CCHttpRequest* request = new CCHttpRequest;
request->setUrl("https://cvolton.eu/gdmods/api/betterinfo/changelog/latest/");
request->setRequestType(CCHttpRequest::HttpRequestType::kHttpPost);
request->setUserData(updateLayer);
request->setResponseCallback(this, httpresponse_selector(CvoltonManager::onChangelogHttpResponse));
CCHttpClient::getInstance()->send(request);
CCHttpClient::getInstance()->send(request);*/
//request->release();

}
Expand Down Expand Up @@ -294,6 +299,12 @@ FLAlertLayer* CvoltonManager::updateCompleteDialog(bool forced) {
versions.push_back(
"<cg>BetterInfo has updated!</c>\n"
"\n"
"<cy>Changelog:</c> <cg>(v2.4.6 - 2023-06-11)</c>\n"
"- Added \"no coins\" filter\n"
"- Bugfixes & improvements\n"
);

versions.push_back(
"<cy>Changelog:</c> <cg>(v2.4.5 - 2023-02-03)</c>\n"
"- Songs not served from NG highlighted in orange/red/brown/pink/whatever that color is now (idk its a weird shade, i copied it from gdbrowser)\n"
"- Fixed a crash when exiting user leaderboards\n"
Expand Down
5 changes: 3 additions & 2 deletions src/managers/CvoltonManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ class CvoltonManager : public gd::GManager {


public:
inline static const char* version = "v2.4.5\n";
inline static const char* version = "v2.4.6\n";
inline static const char* modName = "BetterInfo";
inline static const char* modNameColored = "Better<cg>Info</c>";
std::string latestVer;
std::string changelog;
std::string saveVer;
cocos2d::CCDictionary* nameDict;
cocos2d::CCDictionary* settingsDict;
CvoltonUpdateLayer* updateLayer = nullptr;
const char* cellTitle = nullptr;
bool hasDoneUpdateCheck = false;
bool plistLoaded = false;
Expand All @@ -50,7 +51,7 @@ class CvoltonManager : public gd::GManager {
void doUpdateHttpRequest();
void doUpdateCheck();
void forceUpdateCheck();
void downloadChangelog(CvoltonUpdateLayer* updateLayer);
void downloadChangelog();
bool isUpToDate();
bool getOption(std::string option);
bool toggleOption(std::string option);
Expand Down

0 comments on commit fc28668

Please sign in to comment.