@@ -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