Skip to content

Commit 824f8b2

Browse files
committed
fix(main): Fixed color priority
1 parent 1c686cd commit 824f8b2

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

src/Styles/NewGJCommentList.cpp

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "NewGJCommentList.h"
2+
#include "Geode/loader/Log.hpp"
23
#include "NewProfilePage.h"
34
#include "../MoreLeaderboards/MoreLeaderboards.h"
45
#include "ccTypes.h"
@@ -30,6 +31,8 @@ class $modify(CommentCell) {
3031

3132
CCMenu* username_menu = typeinfo_cast<CCMenu*>(cell->getChildByIDRecursive("username-menu"));
3233

34+
bool colorSet = false;
35+
3336
while (data_user.size() > 0) {
3437
std::vector<std::string> data = MoreLeaderboards::getWords(data_user[0], "?");
3538

@@ -90,16 +93,22 @@ class $modify(CommentCell) {
9093
);
9194

9295
if (auto commentText = cell->getChildByIDRecursive("comment-text-label")) {
93-
as<CCLabelBMFont*>(commentText)->setColor(color);
94-
cell->m_comment->m_color = color;
96+
if (color.r != 255 && color.g != 255 && color.b != 255 && !colorSet) {
97+
as<CCLabelBMFont*>(commentText)->setColor(color);
98+
cell->m_comment->m_color = color;
99+
colorSet = true;
100+
}
95101
}
96102
if (auto commentText = cell->getChildByIDRecursive("comment-text-area")) {
97103
TextArea* textArea = as<TextArea*>(commentText);
98104
MultilineBitmapFont* bmFont = as<MultilineBitmapFont*>(textArea->getChildren()->objectAtIndex(0));
99105
CCArray* children = bmFont->getChildren();
100106
for (int i = 0; i < children->count(); i++) {
101107
auto child = as<CCLabelBMFont*>(children->objectAtIndex(i));
102-
child->setColor(color);
108+
if (color.r != 255 && color.g != 255 && color.b != 255 && !colorSet) {
109+
child->setColor(color);
110+
colorSet = true;
111+
}
103112
}
104113
}
105114

@@ -176,19 +185,20 @@ class $modify(CommentCell) {
176185

177186
if (username_menu != nullptr) username_menu->updateLayout();
178187

179-
if (result_global.empty()) {
180-
m_fields->m_listener.bind([] (web::WebTask::Event* e) {
181-
if (web::WebResponse* res = e->getValue()) {
182-
if (res->ok()) {
183-
result_global = res->string().unwrapOrDefault();
184-
}
185-
}
186-
});
188+
const std::function<void(std::string const&)> then = [this, cell](std::string const& result) {
189+
badgeHandle(result, cell, cell->m_comment->m_commentID);
190+
};
187191

188-
auto req = web::WebRequest();
189-
m_fields->m_listener.setFilter(req.get("https://clarifygdps.com/gdutils/gdutils_roles.php"));
190-
}
192+
m_fields->m_listener.bind([then = std::move(then)] (web::WebTask::Event* e) {
193+
if (web::WebResponse* res = e->getValue()) {
194+
if (res->ok()) {
195+
result_global = res->string().unwrapOrDefault();
196+
then(result_global);
197+
}
198+
}
199+
});
191200

192-
badgeHandle(result_global, cell, cell->m_comment->m_commentID);
201+
auto req = web::WebRequest();
202+
m_fields->m_listener.setFilter(req.get("https://clarifygdps.com/gdutils/gdutils_roles.php"));
193203
}
194204
};

0 commit comments

Comments
 (0)