Skip to content

Commit 1807de3

Browse files
committed
update(main): Update country ID to be STR for leaderboards
1 parent 20ebe1e commit 1807de3

File tree

6 files changed

+18
-17
lines changed

6 files changed

+18
-17
lines changed

src/MoreLeaderboards/MoreLeaderboards.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void MoreLeaderboards::onModsList(CCObject* pSender) {
178178
}
179179

180180
void MoreLeaderboards::onRegion(CCObject* pSender) {
181-
SelectRegion::scene([this](int id) {
181+
SelectRegion::scene([this](std::string id) {
182182
country_id = id;
183183

184184
if (loading) return;
@@ -253,7 +253,7 @@ You can submit your <cy>user stats</c> to the <cj>Updated Leaderboards</c> team
253253

254254
MoreLeaderboards* MoreLeaderboards::create(std::string type) {
255255
auto pRet = new MoreLeaderboards();
256-
SelectRegionCell::country_id = 0;
256+
SelectRegionCell::country_id = "NAN";
257257
if (pRet && pRet->init(type)) {
258258
pRet->autorelease();
259259
return pRet;
@@ -632,6 +632,7 @@ void MoreLeaderboards::startLoadingMore() {
632632
.param("username", username)
633633
.param("mod", (modFilter ? "1" : "0"))
634634
.param("modFilter", modFilterType)
635+
.param("version", "1.0")
635636
.get("https://clarifygdps.com/gdutils/moreleaderboards.php")
636637
);
637638
};

src/MoreLeaderboards/MoreLeaderboards.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class MoreLeaderboards : public CCLayer {
4848
CCString* datas = nullptr;
4949
std::string data_region = "";
5050

51-
int country_id = 0;
51+
std::string country_id = "NAN";
5252

5353
CCMenu* m_menu;
5454
CCMenuItemToggler* m_tab1;

src/MoreLeaderboards/SelectRegion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ std::vector<std::string> SelectRegion::getWords(std::string s, std::string delim
2525
return res;
2626
}
2727

28-
void SelectRegion::scene(const std::function<void(int)>& callback) {
28+
void SelectRegion::scene(const std::function<void(std::string)>& callback) {
2929
auto popup = new SelectRegion(callback);
3030

3131
if (popup && popup->initAnchored(250.0f, 210.0f)) {
@@ -52,7 +52,7 @@ void SelectRegion::loadPage() {
5252
CCArray* data = CCArray::create();
5353

5454
for (std::string const& mod : SelectRegion::displayedData) {
55-
auto cell = SelectRegionCell::create(mod, [this](int id) {
55+
auto cell = SelectRegionCell::create(mod, [this](std::string id) {
5656
selectedRegion(id);
5757
removeFromParent();
5858
});

src/MoreLeaderboards/SelectRegion.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class SelectRegion : public Popup<> {
88
LoadingCircle* loading_circle;
9-
std::function<void(int)> selectedRegion;
9+
std::function<void(std::string)> selectedRegion;
1010

1111
protected:
1212
bool setup() override;
@@ -16,9 +16,9 @@ class SelectRegion : public Popup<> {
1616
public:
1717
static std::vector<std::string> displayedData;
1818

19-
SelectRegion(const std::function<void(int)>& callback) : selectedRegion(callback) {}
19+
SelectRegion(const std::function<void(std::string)>& callback) : selectedRegion(callback) {}
2020

21-
static void scene(const std::function<void(int)>& callback);
21+
static void scene(const std::function<void(std::string)>& callback);
2222

2323
static std::vector<std::string> getWords(std::string s, std::string delim);
2424
};

src/MoreLeaderboards/SelectRegionCell.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "SelectRegionCell.h"
22

3-
int SelectRegionCell::country_id = 0;
3+
std::string SelectRegionCell::country_id = "NAN";
44

55
bool SelectRegionCell::init(std::string mod) {
66
std::vector<std::string> data = SelectRegion::getWords(mod, ":");
@@ -33,14 +33,14 @@ bool SelectRegionCell::init(std::string mod) {
3333
earthSpr->setPosition({ 20, 14 });
3434
addChild(earthSpr);
3535
}
36+
37+
id_ctr = name;
3638
} else if (id == "5") {
3739
auto nbPlayers = cocos2d::CCLabelBMFont::create((name + " players").c_str(), "goldFont.fnt");
3840
nbPlayers->setPosition({ 38, 8 });
3941
nbPlayers->setAnchorPoint({ 0, 0.5 });
4042
nbPlayers->setScale(.375f);
4143
addChild(nbPlayers);
42-
} else if (id == "4") {
43-
id_ctr = numFromString<int>(name).unwrapOrDefault();
4444
}
4545

4646
data.erase(data.begin());
@@ -81,7 +81,7 @@ void SelectRegionCell::onClick(cocos2d::CCObject* pSender) {
8181
selectedRegion(country_id = id_ctr);
8282
}
8383

84-
SelectRegionCell* SelectRegionCell::create(std::string mod, const std::function<void(int)>& callback) {
84+
SelectRegionCell* SelectRegionCell::create(std::string mod, const std::function<void(std::string)>& callback) {
8585
auto ret = new SelectRegionCell(callback);
8686
if (ret && ret->init(mod)) {
8787
ret->retain();

src/MoreLeaderboards/SelectRegionCell.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
#include <Geode/Bindings.hpp>
44

55
class SelectRegionCell : public cocos2d::CCLayer {
6-
std::function<void(int)> selectedRegion;
7-
int id_ctr;
6+
std::function<void(std::string)> selectedRegion;
7+
std::string id_ctr;
88

99
void onClick(cocos2d::CCObject* pSender);
1010
public:
11-
SelectRegionCell(const std::function<void(int)>& callback) : selectedRegion(callback) {}
11+
SelectRegionCell(const std::function<void(std::string)>& callback) : selectedRegion(callback) {}
1212

13-
static int country_id;
13+
static std::string country_id;
1414
bool init(std::string mod);
15-
static SelectRegionCell* create(std::string mod, const std::function<void(int)>& callback);
15+
static SelectRegionCell* create(std::string mod, const std::function<void(std::string)>& callback);
1616
};

0 commit comments

Comments
 (0)