From 605c4a5577782acbe6936f7b611a65134324ef62 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 14 Aug 2020 17:08:06 -0400 Subject: [PATCH] v0.8.2a: tweaked logic for news last read time --- .../shatteredpixeldungeon/SPDSettings.java | 3 +-- .../shatteredpixeldungeon/scenes/NewsScene.java | 5 ++++- .../shatteredpixeldungeon/scenes/TitleScene.java | 15 +++++++++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java index 3ba043753..f5769bf8c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java @@ -302,8 +302,7 @@ public class SPDSettings extends GameSettings { } public static long newsLastRead(){ - //returns the current time when none is stored, so historical news isn't seen as unread - return getLong(KEY_NEWS_LAST_READ, Game.realTime); + return getLong(KEY_NEWS_LAST_READ, 0); } //Window management (desktop only atm) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/NewsScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/NewsScene.java index af122429c..a70bbbcbc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/NewsScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/NewsScene.java @@ -266,7 +266,10 @@ public class NewsScene extends PixelScene { this.article = article; icon(News.parseArticleIcon(article)); - if (article.date.getTime() > SPDSettings.newsLastRead()) textColor(Window.SHPX_COLOR); + long lastRead = SPDSettings.newsLastRead(); + if (lastRead > 0 && article.date.getTime() > lastRead) { + textColor(Window.SHPX_COLOR); + } Calendar cal = Calendar.getInstance(); cal.setTime(article.date); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java index abe5aa739..e1cf9a3c3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java @@ -228,10 +228,17 @@ public class TitleScene extends PixelScene { super.update(); if (unreadCount == -1 && News.articlesAvailable()){ - unreadCount = News.unreadArticles(new Date(SPDSettings.newsLastRead())); - if (unreadCount > 0){ - unreadCount = Math.min(unreadCount, 9); - text(text() + "(" + unreadCount + ")"); + long lastRead = SPDSettings.newsLastRead(); + if (lastRead == 0){ + if (News.articles().get(0) != null) { + SPDSettings.newsLastRead(News.articles().get(0).date.getTime()); + } + } else { + unreadCount = News.unreadArticles(new Date(SPDSettings.newsLastRead())); + if (unreadCount > 0) { + unreadCount = Math.min(unreadCount, 9); + text(text() + "(" + unreadCount + ")"); + } } }