v1.3.2: rankings now shows the daily window if you just ended a daily

This commit is contained in:
Evan Debenham
2022-07-21 16:56:46 -04:00
parent 03848f1fa3
commit 987350c11e
3 changed files with 27 additions and 1 deletions
@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.scenes; package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Rankings; import com.shatteredpixel.shatteredpixeldungeon.Rankings;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
@@ -161,9 +162,20 @@ public class RankingsScene extends PixelScene {
add(btnDailies); add(btnDailies);
} }
if (Dungeon.daily){
addToFront(new WndDailies());
}
fadeIn(); fadeIn();
} }
@Override
public void destroy() {
super.destroy();
//so that opening daily records does not trigger WndDailies opening on future visits
Dungeon.daily = false;
}
@Override @Override
protected void onBackPressed() { protected void onBackPressed() {
ShatteredPixelDungeon.switchNoFade(TitleScene.class); ShatteredPixelDungeon.switchNoFade(TitleScene.class);
@@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Chrome; import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress; import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
@@ -145,6 +146,7 @@ public class TitleScene extends PixelScene {
}; };
btnRankings.icon(Icons.get(Icons.RANKINGS)); btnRankings.icon(Icons.get(Icons.RANKINGS));
add(btnRankings); add(btnRankings);
Dungeon.daily = false;
StyledButton btnBadges = new StyledButton(GREY_TR, Messages.get(this, "badges")){ StyledButton btnBadges = new StyledButton(GREY_TR, Messages.get(this, "badges")){
@Override @Override
@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Chrome; import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress; import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
import com.shatteredpixel.shatteredpixeldungeon.Rankings; import com.shatteredpixel.shatteredpixeldungeon.Rankings;
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
@@ -218,6 +219,16 @@ public class WelcomeScene extends PixelScene {
ShatteredPixelDungeon.reportException(e); ShatteredPixelDungeon.reportException(e);
} }
} }
if (Rankings.INSTANCE.latestDaily != null){
try {
Rankings.INSTANCE.loadGameData(Rankings.INSTANCE.latestDaily);
Rankings.INSTANCE.saveGameData(Rankings.INSTANCE.latestDaily);
} catch (Exception e) {
//if we encounter a fatal per-record error, then clear that record
Rankings.INSTANCE.latestDaily = null;
ShatteredPixelDungeon.reportException(e);
}
}
Collections.sort(Rankings.INSTANCE.records, Rankings.scoreComparator); Collections.sort(Rankings.INSTANCE.records, Rankings.scoreComparator);
Rankings.INSTANCE.save(); Rankings.INSTANCE.save();
} catch (Exception e) { } catch (Exception e) {
@@ -225,6 +236,7 @@ public class WelcomeScene extends PixelScene {
FileUtils.deleteFile( Rankings.RANKINGS_FILE ); FileUtils.deleteFile( Rankings.RANKINGS_FILE );
ShatteredPixelDungeon.reportException(e); ShatteredPixelDungeon.reportException(e);
} }
Dungeon.daily = false;
} }