Skip to content

Commit 7a39f67

Browse files
authored
Add files via upload
1 parent f2ccb91 commit 7a39f67

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ You can enable/disable the auto rating feature, and override the difficulty the
1313
## Credits
1414
Inspiration: [Auto Like](mod:hbg1010.auto-like)
1515

16-
Testers: [ArcticWoof](https://www.youtube.com/@ArcticWoofxD)
16+
Testers: [ArcticWoof](https://www.youtube.com/@ArcticWoofxD), [nobrainrgamr](https://www.youtube.com/@nobrainrgamr)
1717

1818
Made with love from Sweep <3

src/main.cpp

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ using namespace geode::prelude;
55
#include <Geode/modify/LevelInfoLayer.hpp>
66

77
class $modify(AutoLevelRate, LevelInfoLayer) {
8-
bool init(GJGameLevel* level, bool challenge) {
9-
if (!LevelInfoLayer::init(level, challenge)) return false;
10-
8+
void levelDownloadFinished(GJGameLevel* p0) {
9+
LevelInfoLayer::levelDownloadFinished(p0); // Run the original levelDownloadFinished code before running our custom code.
10+
1111
// Make sure we haven't rated the level yet.
12-
if (!m_starRateBtn) return false;
13-
if (!m_starRateBtn->isEnabled()) return false;
12+
if (!m_starRateBtn) return;
13+
if (!m_starRateBtn->isEnabled()) return;
1414

1515
// Make sure the user has the feature enabled.
16-
if (!Mod::get()->getSettingValue<bool>("enable-auto-rater")) return false;
16+
if (!Mod::get()->getSettingValue<bool>("enable-auto-rater")) return;
1717

1818
// Open the rate menu.
1919
m_starRateBtn->activate();
@@ -34,15 +34,15 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
3434

3535
if (!rateLayer) {
3636
log::warn("RateStarsLayer could not be found!");
37-
return false;
37+
return;
3838
}
3939

4040
// We can just use the first object because it is the only object.
4141
auto mainLayer = static_cast<CCNode*>(rateLayer->getChildren()->objectAtIndex(0));
4242

4343
if (!mainLayer) {
4444
log::warn("Main Layer not found inside RateStarsLayer!");
45-
return false;
45+
return;
4646
}
4747

4848
CCMenu* menuLayer = nullptr;
@@ -61,7 +61,7 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
6161

6262
if (!menuLayer) {
6363
log::warn("Main CCMenu Layer could not be found!");
64-
return false;
64+
return;
6565
}
6666

6767
CCMenuItemSpriteExtra* button;
@@ -70,12 +70,12 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
7070

7171
// Only rate the requested difficulty if the user doesn't have a difficulty override.
7272
if (!Mod::get()->getSettingValue<bool>("toggle-override-difficulty-rate")){
73-
if (level->m_starsRequested == 0) { // If they never requested any stars (N/A)
73+
if (p0->m_starsRequested == 0) { // If they never requested any stars (N/A)
7474
button = static_cast<CCMenuItemSpriteExtra*>(menuLayer->getChildren()->objectAtIndex(4));
7575
starsRated = 5;
7676
} else {
77-
button = static_cast<CCMenuItemSpriteExtra*>(menuLayer->getChildren()->objectAtIndex(level->m_starsRequested));
78-
starsRated = level->m_starsRequested;
77+
button = static_cast<CCMenuItemSpriteExtra*>(menuLayer->getChildren()->objectAtIndex(p0->m_starsRequested));
78+
starsRated = p0->m_starsRequested;
7979
}
8080
} else { // This is if the user specified a difficulty override.
8181
button = static_cast<CCMenuItemSpriteExtra*>(menuLayer->getChildren()->objectAtIndex(Mod::get()->getSettingValue<int>("override-difficulty-rate") - 1));
@@ -84,15 +84,15 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
8484

8585
// Only rate the requested difficulty if the user chose it.
8686
if (Mod::get()->getSettingValue<std::string>("rate-mode-selection") == "Requested Difficulty"){
87-
if (level->m_starsRequested == 0) { // If they never requested any stars (N/A)
87+
if (p0->m_starsRequested == 0) { // If they never requested any stars (N/A)
8888
button = static_cast<CCMenuItemSpriteExtra*>(menuLayer->getChildren()->objectAtIndex(4));
8989
starsRated = 5;
9090
} else {
91-
button = static_cast<CCMenuItemSpriteExtra*>(menuLayer->getChildren()->objectAtIndex(level->m_starsRequested));
92-
starsRated = level->m_starsRequested;
91+
button = static_cast<CCMenuItemSpriteExtra*>(menuLayer->getChildren()->objectAtIndex(p0->m_starsRequested));
92+
starsRated = p0->m_starsRequested;
9393
}
9494
} else if(Mod::get()->getSettingValue<std::string>("rate-mode-selection") == "Current Difficulty") { // Only rate the current difficulty if the user chose it.
95-
starsRated = level->getAverageDifficulty();
95+
starsRated = p0->getAverageDifficulty();
9696

9797
switch (starsRated) {
9898
case 0:
@@ -130,7 +130,7 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
130130
// Check if the difficulty selection button exists
131131
if (!button) {
132132
log::warn("Difficulty selection button not found!");
133-
return false;
133+
return;
134134
}
135135

136136
button->activate();
@@ -140,7 +140,7 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
140140
// Check if the submit rating button exists
141141
if (!button) {
142142
log::warn("Submit rating button not found!");
143-
return false;
143+
return;
144144
}
145145

146146
button->activate();
@@ -166,15 +166,15 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
166166

167167
if (!newRateLayer) {
168168
log::warn("RateStarsLayer could not be found!");
169-
return false;
169+
return;
170170
}
171171

172172
// We can just use the first object because it is the only object.
173173
auto newMainLayer = static_cast<CCNode*>(newRateLayer->getChildren()->objectAtIndex(0));
174174

175175
if (!newMainLayer) {
176176
log::warn("Main Layer not found inside RateStarsLayer!");
177-
return false;
177+
return;
178178
}
179179

180180
CCMenu* newMenuLayer = nullptr;
@@ -193,7 +193,7 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
193193

194194
if (!newMenuLayer) {
195195
log::warn("Main CCMenu Layer could not be found!");
196-
return false;
196+
return;
197197
}
198198

199199
CCMenuItemSpriteExtra* newButton;
@@ -202,15 +202,15 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
202202

203203
// Only rate the requested difficulty if the user chose it.
204204
if (Mod::get()->getSettingValue<std::string>("rate-mode-selection") == "Requested Difficulty"){
205-
if (level->m_starsRequested == 0) { // If they never requested any stars (N/A)
205+
if (p0->m_starsRequested == 0) { // If they never requested any stars (N/A)
206206
newButton = static_cast<CCMenuItemSpriteExtra*>(newMenuLayer->getChildren()->objectAtIndex(4));
207207
newStarsRated = 5;
208208
} else {
209-
newButton = static_cast<CCMenuItemSpriteExtra*>(newMenuLayer->getChildren()->objectAtIndex(level->m_starsRequested));
210-
newStarsRated = level->m_starsRequested;
209+
newButton = static_cast<CCMenuItemSpriteExtra*>(newMenuLayer->getChildren()->objectAtIndex(p0->m_starsRequested));
210+
newStarsRated = p0->m_starsRequested;
211211
}
212212
} else if(Mod::get()->getSettingValue<std::string>("rate-mode-selection") == "Current Difficulty") { // Only rate the current difficulty if the user chose it.
213-
newStarsRated = level->getAverageDifficulty();
213+
newStarsRated = p0->getAverageDifficulty();
214214

215215
switch (newStarsRated) {
216216
case 0:
@@ -248,7 +248,7 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
248248
// Check if the difficulty selection button exists
249249
if (!newButton) {
250250
log::warn("Difficulty selection button not found!");
251-
return false;
251+
return;
252252
}
253253

254254
newButton->activate();
@@ -258,14 +258,13 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
258258
// Check if the submit rating button exists
259259
if (!newButton) {
260260
log::warn("Submit rating button not found!");
261-
return false;
261+
return;
262262
}
263263

264264
newButton->activate();
265265

266266
log::info("Successfully rated the level {}*", newStarsRated);
267267

268268
// yay we done :D
269-
return true;
270269
}
271270
};

0 commit comments

Comments
 (0)