@@ -173,31 +173,18 @@ struct CustomMenuLayer : Modify<CustomMenuLayer, MenuLayer> {
173
173
174
174
// Check for mod updates
175
175
static bool checkedModUpdates = false ;
176
+ static bool foundModUpdates = false ;
176
177
if (!checkedModUpdates) {
177
178
// only run it once
178
179
checkedModUpdates = true ;
179
180
m_fields->m_updateCheckTask = ModsLayer::checkInstalledModsForUpdates ().map (
180
181
[this ](server::ServerRequest<std::vector<std::string>>::Value* result) {
181
182
if (result->isOk ()) {
182
183
auto updatesFound = result->unwrap ();
183
- if (updatesFound.size () && m_fields-> m_geodeButton && !m_fields-> m_geodeButton -> getChildByID ( " updates-available " ) ) {
184
+ if (updatesFound.size ()) {
184
185
log::info (" Found updates for mods: {}!" , updatesFound);
185
-
186
- if (auto icon = CCSprite::createWithSpriteFrameName (" updates-available.png" _spr)) {
187
- // Remove errors icon if it was added, to prevent overlap
188
- if (m_fields->m_exclamation ) {
189
- m_fields->m_exclamation ->removeFromParent ();
190
- m_fields->m_exclamation = nullptr ;
191
- }
192
-
193
- icon->setPosition (
194
- m_fields->m_geodeButton ->getContentSize () - CCSize { 10 .f , 10 .f }
195
- );
196
- icon->setID (" updates-available" );
197
- icon->setZOrder (99 );
198
- icon->setScale (.5f );
199
- m_fields->m_geodeButton ->addChild (icon);
200
- }
186
+ showUpdatesFound ();
187
+ foundModUpdates = true ;
201
188
}
202
189
else {
203
190
log::info (" All mods up to date!" );
@@ -213,6 +200,11 @@ struct CustomMenuLayer : Modify<CustomMenuLayer, MenuLayer> {
213
200
);
214
201
}
215
202
203
+ // also display if updates were found in a previous MenuLayer iteration
204
+ if (foundModUpdates) {
205
+ showUpdatesFound ();
206
+ }
207
+
216
208
for (auto mod : Loader::get ()->getAllMods ()) {
217
209
if (mod->getMetadata ().usesDeprecatedIDForm ()) {
218
210
log::error (
@@ -226,6 +218,26 @@ struct CustomMenuLayer : Modify<CustomMenuLayer, MenuLayer> {
226
218
return true ;
227
219
}
228
220
221
+ void showUpdatesFound () {
222
+ if (m_fields->m_geodeButton && !m_fields->m_geodeButton ->getChildByID (" updates-available" )) {
223
+ if (auto icon = CCSprite::createWithSpriteFrameName (" updates-available.png" _spr)) {
224
+ // Remove errors icon if it was added, to prevent overlap
225
+ if (m_fields->m_exclamation ) {
226
+ m_fields->m_exclamation ->removeFromParent ();
227
+ m_fields->m_exclamation = nullptr ;
228
+ }
229
+
230
+ icon->setPosition (
231
+ m_fields->m_geodeButton ->getContentSize () - CCSize { 10 .f , 10 .f }
232
+ );
233
+ icon->setID (" updates-available" );
234
+ icon->setZOrder (99 );
235
+ icon->setScale (.5f );
236
+ m_fields->m_geodeButton ->addChild (icon);
237
+ }
238
+ }
239
+ }
240
+
229
241
void fixSocialMenu () {
230
242
// I did NOT have fun doing this
231
243
auto socialMenu = static_cast <CCMenu*>(this ->getChildByID (" social-media-menu" ));
0 commit comments