Skip to content

Commit 3d93935

Browse files
authored
add more settings yippeeeeee
1 parent 5c6ef80 commit 3d93935

File tree

3 files changed

+92
-12
lines changed

3 files changed

+92
-12
lines changed

about.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +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)
17+
1618
Made with love from Sweep <3

mod.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
"geode": "4.5.0",
33
"gd": {
44
"win": "2.2074",
5-
"android": "2.2074",
6-
"ios": "2.2074",
7-
"mac": "2.2074"
5+
"android": "2.2074"
86
},
97
"id": "sweep.auto-rater",
108
"name": "Auto Rater",
@@ -24,19 +22,21 @@
2422
"name": "Enable Auto-Rater",
2523
"default": true
2624
},
27-
"toggle-override-difficulty-rate": {
28-
"type": "bool",
29-
"name": "Enable Override Rate Difficulty",
30-
"default": false
25+
"rate-mode-selection": {
26+
"type": "string",
27+
"name": "Rate Mode",
28+
"default": "Requested Difficulty",
29+
"one-of": ["Requested Difficulty", "Current Difficulty", "Override"],
30+
"enable-if": "setting:enable-auto-rater"
3131
},
3232
"override-difficulty-rate": {
3333
"type": "int",
3434
"name": "Override Rate Difficulty",
3535
"description": "Rates all levels with this difficulty (in stars) instead of matching with the current level's difficulty. (0: don't override)",
3636
"min": 1,
3737
"max": 10,
38-
"default": 0,
39-
"enable-if": "setting:toggle-override-difficulty-rate",
38+
"default": 5,
39+
"enable-if": "setting:enable-auto-rater",
4040
"control": {
4141
"slider": false
4242
}

src/main.cpp

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,51 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
8282
starsRated = Mod::get()->getSettingValue<int>("override-difficulty-rate");
8383
}
8484

85+
// Only rate the requested difficulty if the user chose it.
86+
if (Mod::get()->getSettingValue<std::string>("rate-mode-selection") == "Requested Difficulty"){
87+
if (p0->m_starsRequested == 0) { // If they never requested any stars (N/A)
88+
button = static_cast<CCMenuItemSpriteExtra*>(menuLayer->getChildren()->objectAtIndex(4));
89+
starsRated = 5;
90+
} else {
91+
button = static_cast<CCMenuItemSpriteExtra*>(menuLayer->getChildren()->objectAtIndex(p0->m_starsRequested));
92+
starsRated = p0->m_starsRequested;
93+
}
94+
} else if(Mod::get()->getSettingValue<std::string>("rate-mode-selection") == "Current Difficulty") { // Only rate the current difficulty if the user chose it.
95+
starsRated = p0->getAverageDifficulty();
96+
97+
switch (starsRated) {
98+
case 0:
99+
starsRated = 5;
100+
break;
101+
case 1:
102+
starsRated = 2;
103+
break;
104+
case 2:
105+
starsRated = 3;
106+
break;
107+
case 3:
108+
starsRated = 4;
109+
break;
110+
case 4:
111+
starsRated = 6;
112+
break;
113+
case 5:
114+
starsRated = 8;
115+
break;
116+
case 6:
117+
starsRated = 10;
118+
break;
119+
case 7:
120+
starsRated = 1;
121+
break;
122+
}
123+
124+
button = static_cast<CCMenuItemSpriteExtra*>(menuLayer->getChildren()->objectAtIndex(starsRated - 1));
125+
} else { // If the user chose override.
126+
button = static_cast<CCMenuItemSpriteExtra*>(menuLayer->getChildren()->objectAtIndex(Mod::get()->getSettingValue<int>("override-difficulty-rate") - 1));
127+
starsRated = Mod::get()->getSettingValue<int>("override-difficulty-rate");
128+
}
129+
85130
// Check if the difficulty selection button exists
86131
if (!button) {
87132
log::warn("Difficulty selection button not found!");
@@ -155,16 +200,47 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
155200

156201
int newStarsRated = 0; // Used to log the amount of stars that the level got rated
157202

158-
// Only rate the requested difficulty if the user doesn't have a difficulty override.
159-
if (!Mod::get()->getSettingValue<bool>("toggle-override-difficulty-rate")){
203+
// Only rate the requested difficulty if the user chose it.
204+
if (Mod::get()->getSettingValue<std::string>("rate-mode-selection") == "Requested Difficulty"){
160205
if (p0->m_starsRequested == 0) { // If they never requested any stars (N/A)
161206
newButton = static_cast<CCMenuItemSpriteExtra*>(newMenuLayer->getChildren()->objectAtIndex(4));
162207
newStarsRated = 5;
163208
} else {
164209
newButton = static_cast<CCMenuItemSpriteExtra*>(newMenuLayer->getChildren()->objectAtIndex(p0->m_starsRequested));
165210
newStarsRated = p0->m_starsRequested;
166211
}
167-
} else { // This is if the user specified a difficulty override.
212+
} else if(Mod::get()->getSettingValue<std::string>("rate-mode-selection") == "Current Difficulty") { // Only rate the current difficulty if the user chose it.
213+
newStarsRated = p0->getAverageDifficulty();
214+
215+
switch (newStarsRated) {
216+
case 0:
217+
newStarsRated = 5;
218+
break;
219+
case 1:
220+
newStarsRated = 2;
221+
break;
222+
case 2:
223+
newStarsRated = 3;
224+
break;
225+
case 3:
226+
newStarsRated = 4;
227+
break;
228+
case 4:
229+
newStarsRated = 6;
230+
break;
231+
case 5:
232+
newStarsRated = 8;
233+
break;
234+
case 6:
235+
newStarsRated = 10;
236+
break;
237+
case 7:
238+
newStarsRated = 1;
239+
break;
240+
}
241+
242+
newButton = static_cast<CCMenuItemSpriteExtra*>(newMenuLayer->getChildren()->objectAtIndex(newStarsRated - 1));
243+
} else { // If the user chose override.
168244
newButton = static_cast<CCMenuItemSpriteExtra*>(newMenuLayer->getChildren()->objectAtIndex(Mod::get()->getSettingValue<int>("override-difficulty-rate") - 1));
169245
newStarsRated = Mod::get()->getSettingValue<int>("override-difficulty-rate");
170246
}
@@ -187,6 +263,8 @@ class $modify(AutoLevelRate, LevelInfoLayer) {
187263

188264
newButton->activate();
189265

266+
log::info("Successfully rated the level {}*", newStarsRated);
267+
190268
// yay we done :D
191269
}
192270
};

0 commit comments

Comments
 (0)