Skip to content

Commit ff798b7

Browse files
committed
fix(main): Fixed RobTop & other badges rendering even when custom badge option is desactivated
1 parent d90afb0 commit ff798b7

File tree

2 files changed

+140
-145
lines changed

2 files changed

+140
-145
lines changed

src/Styles/NewGJCommentList.cpp

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,20 @@ class $modify(CommentCell) {
1414
};
1515

1616
void badgeHandle(std::string result, CCLayer* layer, int commentID) {
17-
CCArray* badges_to_put = CCArray::create();
18-
19-
if (result.empty()) return;
2017
if (this->m_accountComment) return;
2118

22-
std::string data = result;
23-
std::vector<std::string> data_user = MoreLeaderboards::getWords(data, "|");
2419
CommentCell* cell = this;
25-
2620
int accountID = cell->m_comment->m_accountID;
27-
std::string username = cell->m_comment->m_userName;
2821

29-
CCMenuItemSpriteExtra* badgeBtn = nullptr;
30-
CCSprite* modbadge = typeinfo_cast<CCSprite*>(cell->getChildByIDRecursive("mod-badge"));
31-
CCMenu* username_menu = typeinfo_cast<CCMenu*>(cell->getChildByIDRecursive("username-menu"));
32-
if (modbadge != nullptr) {
33-
modbadge->removeFromParentAndCleanup(true);
22+
// Part for handling GDUtils badges
23+
if (!Mod::get()->template getSettingValue<bool>("customBadges")) return;
3424

35-
if (username == "RobTop") {
36-
auto robtopSpr = CCSprite::createWithSpriteFrameName("robtop_badge.png"_spr);
37-
robtopSpr->setScale(0.75f);
38-
badgeBtn = CCMenuItemSpriteExtra::create(
39-
robtopSpr,
40-
this,
41-
menu_selector(NewProfilePage::onRobTopBadgePressed)
42-
);
43-
} else {
44-
badgeBtn = CCMenuItemSpriteExtra::create(
45-
modbadge,
46-
this,
47-
menu_selector(NewProfilePage::onBadgePressed)
48-
);
49-
}
25+
if (result.empty()) return;
5026

51-
badgeBtn->setID("mod-badge");
52-
GJUserScore* us = GJUserScore::create();
53-
us->m_modBadge = cell->m_comment->m_modBadge;
54-
badgeBtn->setUserObject(us);
55-
if (cell->getChildByIDRecursive("percentage-label")) {
56-
username_menu->insertBefore(badgeBtn, cell->getChildByIDRecursive("percentage-label"));
57-
} else {
58-
username_menu->addChild(badgeBtn);
59-
}
60-
}
27+
std::string data = result;
28+
std::vector<std::string> data_user = MoreLeaderboards::getWords(data, "|");
6129

62-
if (username_menu != nullptr) username_menu->updateLayout();
30+
CCMenu* username_menu = typeinfo_cast<CCMenu*>(cell->getChildByIDRecursive("username-menu"));
6331

6432
while (data_user.size() > 0) {
6533
std::vector<std::string> data = MoreLeaderboards::getWords(data_user[0], "?");
@@ -281,16 +249,47 @@ class $modify(CommentCell) {
281249
}
282250
}
283251

284-
void requestGDUtilsBadges(CCLayer* layer, int commentID) {
285-
badgeHandle(result_global, layer, commentID);
286-
}
287-
288252
void loadFromComment(GJComment* comment) {
289253
CommentCell::loadFromComment(comment);
290-
auto layer = m_mainLayer;
291254

292255
if (comment->m_commentDeleted) return;
293256

257+
CCMenuItemSpriteExtra* badgeBtn = nullptr;
258+
CommentCell* cell = this;
259+
CCSprite* modbadge = typeinfo_cast<CCSprite*>(cell->getChildByIDRecursive("mod-badge"));
260+
std::string username = cell->m_comment->m_userName;
261+
CCMenu* username_menu = typeinfo_cast<CCMenu*>(cell->getChildByIDRecursive("username-menu"));
262+
263+
if (modbadge != nullptr) {
264+
modbadge->removeFromParentAndCleanup(true);
265+
266+
if (username == "RobTop" && Mod::get()->template getSettingValue<bool>("customBadges")) {
267+
auto robtopSpr = CCSprite::createWithSpriteFrameName("robtop_badge.png"_spr);
268+
robtopSpr->setScale(0.75f);
269+
badgeBtn = CCMenuItemSpriteExtra::create(
270+
robtopSpr,
271+
this,
272+
menu_selector(NewProfilePage::onRobTopBadgePressed)
273+
);
274+
} else {
275+
badgeBtn = CCMenuItemSpriteExtra::create(
276+
modbadge,
277+
this,
278+
menu_selector(NewProfilePage::onBadgePressed)
279+
);
280+
}
281+
282+
badgeBtn->setID("mod-badge");
283+
badgeBtn->setUserObject(CCInteger::create(comment->m_modBadge));
284+
if (cell->getChildByIDRecursive("percentage-label")) {
285+
username_menu->insertBefore(badgeBtn, cell->getChildByIDRecursive("percentage-label"));
286+
} else {
287+
username_menu->addChild(badgeBtn);
288+
}
289+
}
290+
291+
if (username_menu != nullptr) username_menu->updateLayout();
292+
294293
if (result_global.empty()) {
295294
m_fields->m_listener.bind([] (web::WebTask::Event* e) {
296295
if (web::WebResponse* res = e->getValue()) {
@@ -304,8 +303,6 @@ class $modify(CommentCell) {
304303
m_fields->m_listener.setFilter(req.get("https://clarifygdps.com/gdutils/gdutils_roles.php"));
305304
}
306305

307-
if (layer && Mod::get()->template getSettingValue<bool>("customBadges")) {
308-
requestGDUtilsBadges(layer, comment->m_commentID);
309-
}
306+
badgeHandle(result_global, cell, cell->m_comment->m_commentID);
310307
}
311308
};

src/Styles/NewProfilePage.cpp

Lines changed: 97 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -4,102 +4,104 @@
44
#include <Geode/utils/web.hpp>
55

66
void NewProfilePage::onBadgePressed(CCObject* pSender) {
7-
GJUserScore* score = static_cast<GJUserScore*>(static_cast<CCNode*>(pSender)->getUserObject());
8-
switch (score->m_modBadge) {
7+
geode::log::info("Object: {}", static_cast<CCNode*>(pSender)->getUserObject());
8+
CCInteger* score = static_cast<CCInteger*>(static_cast<CCNode*>(pSender)->getUserObject());
9+
geode::log::info("Badge pressed: {}", score->getValue());
10+
switch (score->getValue()) {
911
case 1:
10-
#ifndef GEODE_IS_ANDROID
11-
FLAlertLayer::create(
12-
nullptr,
13-
"Geometry Dash Moderator",
14-
R"text(
15-
A <cl>Geometry Dash Moderator</c> is a user that has been chosen by <cj>RobTop</c> and other <cy>Moderators</c> on the team by suggestions.
16-
17-
Their first task is to suggest levels to be rated to <cj>RobTop</c>, the current developer of the game and the maintainer of the <co>level rating system</c>, he is the only one that can rate levels.
18-
19-
<cr>How to become a Geometry Dash Moderator?</c>
20-
21-
Many community members want to become a <cl>Moderator</c> to be able to suggest levels for a rating. Similar to rating, Moderator promotions are solely done by <cj>RobTop</c> himself on a case-by-case basis, so there are no clear steps to getting it. Here are some general criteria:
22-
<cg>- Be nice.</c>
23-
<cg>- Be active in the community.</c>
24-
<cg>- Be trustworthy.</c>
25-
<cg>- Be able to judge levels well.</c>
26-
27-
If you display these qualities over time, there is a chance that <cy>other Moderators</c> may suggest you to <cj>RobTop</c>. Of course, showing that you are qualified may be difficult if you do not share circles with pre-existing Moderators. If you are interested, you can apply to join the team using our application form. Make sure you read the information in it clearly before submitting. Here is the link:
28-
29-
<cl>https://forms.gle/XyRGtFzD3hshDUQV7</c>
30-
)text",
31-
"OK",
32-
nullptr,
33-
400.0f,
34-
true,
35-
100.0f,
36-
1.0f
37-
)->show();
38-
#else
39-
FLAlertLayer::create(
40-
nullptr,
41-
"Geometry Dash Moderator",
42-
R"text(
43-
A <cl>Geometry Dash Moderator</c> is a user that has been chosen by <cj>RobTop</c> and other <cy>Moderators</c> on the team by suggestions.
44-
45-
Their first task is to suggest levels to be rated to <cj>RobTop</c>, the current developer of the game and the maintainer of the <co>level rating system</c>, he is the only one that can rate levels.
46-
)text",
47-
"OK",
48-
nullptr,
49-
400.0f,
50-
true,
51-
100.0f,
52-
1.0f
53-
)->show();
54-
55-
#endif
12+
#ifndef GEODE_IS_ANDROID
13+
FLAlertLayer::create(
14+
nullptr,
15+
"Geometry Dash Moderator",
16+
R"text(
17+
A <cl>Geometry Dash Moderator</c> is a user that has been chosen by <cj>RobTop</c> and other <cy>Moderators</c> on the team by suggestions.
18+
19+
Their first task is to suggest levels to be rated to <cj>RobTop</c>, the current developer of the game and the maintainer of the <co>level rating system</c>, he is the only one that can rate levels.
20+
21+
<cr>How to become a Geometry Dash Moderator?</c>
22+
23+
Many community members want to become a <cl>Moderator</c> to be able to suggest levels for a rating. Similar to rating, Moderator promotions are solely done by <cj>RobTop</c> himself on a case-by-case basis, so there are no clear steps to getting it. Here are some general criteria:
24+
<cg>- Be nice.</c>
25+
<cg>- Be active in the community.</c>
26+
<cg>- Be trustworthy.</c>
27+
<cg>- Be able to judge levels well.</c>
28+
29+
If you display these qualities over time, there is a chance that <cy>other Moderators</c> may suggest you to <cj>RobTop</c>. Of course, showing that you are qualified may be difficult if you do not share circles with pre-existing Moderators. If you are interested, you can apply to join the team using our application form. Make sure you read the information in it clearly before submitting. Here is the link:
30+
31+
<cl>https://forms.gle/XyRGtFzD3hshDUQV7</c>
32+
)text",
33+
"OK",
34+
nullptr,
35+
400.0f,
36+
true,
37+
100.0f,
38+
1.0f
39+
)->show();
40+
#else
41+
FLAlertLayer::create(
42+
nullptr,
43+
"Geometry Dash Moderator",
44+
R"text(
45+
A <cl>Geometry Dash Moderator</c> is a user that has been chosen by <cj>RobTop</c> and other <cy>Moderators</c> on the team by suggestions.
46+
47+
Their first task is to suggest levels to be rated to <cj>RobTop</c>, the current developer of the game and the maintainer of the <co>level rating system</c>, he is the only one that can rate levels.
48+
)text",
49+
"OK",
50+
nullptr,
51+
400.0f,
52+
true,
53+
100.0f,
54+
1.0f
55+
)->show();
56+
57+
#endif
5658
break;
5759
case 2:
58-
#ifndef GEODE_IS_ANDROID // android height broken
59-
FLAlertLayer::create(
60-
nullptr,
61-
"Geometry Dash Elder Moderator",
62-
R"text(
63-
A <cg>Geometry Dash Elder Moderator</c> is a user that has been chosen by <cj>RobTop</c> and other <cy>Moderators</c> on the team by suggestions and was already a <cy>Geometry Dash Moderator</c> before his promotion. They are the <cp>pillars</c> of the moderation team.
64-
65-
Their first task is to suggest levels to be rated to <cj>RobTop</c>, the current developer of the game and the maintainer of the <co>level rating system</c>, which he is the only one that can rate levels. But they also have the power to <cg>moderate comments</c>, <cg>whitelists Newgrounds artists</c> and <cg>unlocks updates for old rated levels</c>.
66-
67-
<cr>How to become a Geometry Dash Moderator?</c>
68-
69-
Many community members want to become a <cl>Moderator</c> to be able to suggest levels for a rating. Similar to rating, Moderator promotions are solely done by <cj>RobTop</c> himself on a case-by-case basis, so there are no clear steps to getting it. Here are some general criteria:
70-
<cg>- Be nice.</c>
71-
<cg>- Be active in the community.</c>
72-
<cg>- Be trustworthy.</c>
73-
<cg>- Be able to judge levels well.</c>
74-
75-
If you display these qualities over time, there is a chance that <cy>other Moderators</c> may suggest you to <cj>RobTop</c>. Of course, showing that you are qualified may be difficult if you do not share circles with pre-existing Moderators. If you are interested, you can apply to join the team using our application form. Make sure you read the information in it clearly before submitting. Here is the link:
76-
77-
<cl>https://forms.gle/XyRGtFzD3hshDUQV7</c>
78-
)text",
79-
"OK",
80-
nullptr,
81-
400.0f,
82-
true,
83-
100.0f,
84-
1.0f
85-
)->show();
86-
#else
87-
FLAlertLayer::create(
88-
nullptr,
89-
"Geometry Dash Elder Moderator",
90-
R"text(
91-
A <cg>Geometry Dash Elder Moderator</c> is a user that has been chosen by <cj>RobTop</c> and other <cy>Moderators</c> on the team by suggestions and was already a <cy>Geometry Dash Moderator</c> before his promotion. They are the <cp>pillars</c> of the moderation team.
92-
93-
Their first task is to suggest levels to be rated to <cj>RobTop</c>, the current developer of the game and the maintainer of the <co>level rating system</c>, which he is the only one that can rate levels. But they also have the power to <cg>moderate comments</c>, <cg>whitelists Newgrounds artists</c> and <cg>unlocks updates for old rated levels</c>.
94-
)text",
95-
"OK",
96-
nullptr,
97-
400.0f,
98-
true,
99-
100.0f,
100-
1.0f
101-
)->show();
102-
#endif
60+
#ifndef GEODE_IS_ANDROID // android height broken
61+
FLAlertLayer::create(
62+
nullptr,
63+
"Geometry Dash Elder Moderator",
64+
R"text(
65+
A <cg>Geometry Dash Elder Moderator</c> is a user that has been chosen by <cj>RobTop</c> and other <cy>Moderators</c> on the team by suggestions and was already a <cy>Geometry Dash Moderator</c> before his promotion. They are the <cp>pillars</c> of the moderation team.
66+
67+
Their first task is to suggest levels to be rated to <cj>RobTop</c>, the current developer of the game and the maintainer of the <co>level rating system</c>, which he is the only one that can rate levels. But they also have the power to <cg>moderate comments</c>, <cg>whitelists Newgrounds artists</c> and <cg>unlocks updates for old rated levels</c>.
68+
69+
<cr>How to become a Geometry Dash Moderator?</c>
70+
71+
Many community members want to become a <cl>Moderator</c> to be able to suggest levels for a rating. Similar to rating, Moderator promotions are solely done by <cj>RobTop</c> himself on a case-by-case basis, so there are no clear steps to getting it. Here are some general criteria:
72+
<cg>- Be nice.</c>
73+
<cg>- Be active in the community.</c>
74+
<cg>- Be trustworthy.</c>
75+
<cg>- Be able to judge levels well.</c>
76+
77+
If you display these qualities over time, there is a chance that <cy>other Moderators</c> may suggest you to <cj>RobTop</c>. Of course, showing that you are qualified may be difficult if you do not share circles with pre-existing Moderators. If you are interested, you can apply to join the team using our application form. Make sure you read the information in it clearly before submitting. Here is the link:
78+
79+
<cl>https://forms.gle/XyRGtFzD3hshDUQV7</c>
80+
)text",
81+
"OK",
82+
nullptr,
83+
400.0f,
84+
true,
85+
100.0f,
86+
1.0f
87+
)->show();
88+
#else
89+
FLAlertLayer::create(
90+
nullptr,
91+
"Geometry Dash Elder Moderator",
92+
R"text(
93+
A <cg>Geometry Dash Elder Moderator</c> is a user that has been chosen by <cj>RobTop</c> and other <cy>Moderators</c> on the team by suggestions and was already a <cy>Geometry Dash Moderator</c> before his promotion. They are the <cp>pillars</c> of the moderation team.
94+
95+
Their first task is to suggest levels to be rated to <cj>RobTop</c>, the current developer of the game and the maintainer of the <co>level rating system</c>, which he is the only one that can rate levels. But they also have the power to <cg>moderate comments</c>, <cg>whitelists Newgrounds artists</c> and <cg>unlocks updates for old rated levels</c>.
96+
)text",
97+
"OK",
98+
nullptr,
99+
400.0f,
100+
true,
101+
100.0f,
102+
1.0f
103+
)->show();
104+
#endif
103105
break;
104106
case 3:
105107
FLAlertLayer::create(
@@ -475,8 +477,6 @@ class $modify(ProfilePage) {
475477
auto layer = m_mainLayer;
476478
CCMenuItemSpriteExtra* badgeBtn = nullptr;
477479

478-
bool modbadge_bool = false;
479-
480480
CCMenu* username_menu = typeinfo_cast<CCMenu*>(layer->getChildByIDRecursive("username-menu"));
481481
CCLabelBMFont* label = typeinfo_cast<CCLabelBMFont*>(layer->getChildByIDRecursive("username-label"));
482482

@@ -485,7 +485,7 @@ class $modify(ProfilePage) {
485485
if (modbadge != nullptr) {
486486
modbadge->removeFromParentAndCleanup(true);
487487

488-
if (a2->m_userName == "RobTop") {
488+
if (a2->m_userName == "RobTop" && Mod::get()->template getSettingValue<bool>("customBadges")) {
489489
auto robtopSpr = CCSprite::createWithSpriteFrameName("robtop_badge.png"_spr);
490490
badgeBtn = CCMenuItemSpriteExtra::create(
491491
robtopSpr,
@@ -501,10 +501,8 @@ class $modify(ProfilePage) {
501501
}
502502

503503
badgeBtn->setID("mod-badge");
504-
badgeBtn->setUserObject(a2);
504+
badgeBtn->setUserObject(CCInteger::create(a2->m_modBadge));
505505
username_menu->addChild(badgeBtn);
506-
507-
modbadge_bool = true;
508506
}
509507

510508
if (username_menu != nullptr) username_menu->updateLayout();

0 commit comments

Comments
 (0)