diff --git a/core/src/main/assets/interfaces/icons.png b/core/src/main/assets/interfaces/icons.png index c0f143dbf..3085ebc9f 100644 Binary files a/core/src/main/assets/interfaces/icons.png and b/core/src/main/assets/interfaces/icons.png differ diff --git a/core/src/main/assets/messages/scenes/scenes.properties b/core/src/main/assets/messages/scenes/scenes.properties index 6cc589f9a..62cfccc64 100644 --- a/core/src/main/assets/messages/scenes/scenes.properties +++ b/core/src/main/assets/messages/scenes/scenes.properties @@ -70,7 +70,7 @@ scenes.titlescene.support=Support the Game scenes.titlescene$changesbutton.title=An Update is Available! scenes.titlescene$changesbutton.versioned_title=Update Available: %s scenes.titlescene$changesbutton.desc=Shattered Pixel Dungeon is regularly updated with overhauls to existing game content, or entirely new content!\n\nGame balance is also frequently improved in game updates, so that specific items/heroes/enemies aren't too strong or too weak.\n\nUpdates also include fixes for bugs and other various stability improvements. -scenes.titlescene$changesbutton.update=Get The Update +scenes.titlescene$changesbutton.update=Go to Update Page scenes.titlescene$changesbutton.changes=Current Changes Screen scenes.titlescene.patreon_body=Shattered Pixel Dungeon is a completely free game, which means that I depend on support from generous players in order to keep making it.\n\nIf you're interested in supporting me, the best way to do so is through Patreon. Patreon gives me a consistent income source, and allows me to give something back to those who support me!\n\nPatrons get exclusive blog posts every week which let them know about what I'm working on before anyone else!\n\nYou can take a look at my Patreon page for the most up to date information about benefits, Thank you for your consideration!\n\n(Patreon rewards are only available in English) scenes.titlescene.patreon_button=Patreon Page 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 9444f4972..73b7e7a35 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java @@ -30,8 +30,10 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites; import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball; import com.shatteredpixel.shatteredpixeldungeon.messages.Languages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.services.news.News; import com.shatteredpixel.shatteredpixeldungeon.services.updates.AvailableUpdateData; import com.shatteredpixel.shatteredpixeldungeon.services.updates.Updates; +import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.Archs; import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton; import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; @@ -48,6 +50,8 @@ import com.watabou.noosa.audio.Music; import com.watabou.utils.ColorMath; import com.watabou.utils.DeviceCompat; +import java.util.Date; + public class TitleScene extends PixelScene { @Override @@ -99,7 +103,7 @@ public class TitleScene extends PixelScene { add( signs ); final Chrome.Type GREY_TR = Chrome.Type.GREY_BUTTON_TR; - + StyledButton btnPlay = new StyledButton(GREY_TR, Messages.get(this, "enter")){ @Override protected void onClick() { @@ -127,26 +131,7 @@ public class TitleScene extends PixelScene { btnPlay.icon(Icons.get(Icons.ENTER)); add(btnPlay); - //TODO turn this into its own class? - StyledButton btnSupport = new StyledButton(GREY_TR, Messages.get(this, "support")){ - @Override - protected void onClick() { - WndOptions wnd = new WndOptions(Messages.get(TitleScene.class, "support"), - Messages.get(TitleScene.class, "patreon_body"), - Messages.get(TitleScene.class, "patreon_button")){ - @Override - protected void onSelect(int index) { - if (index == 0){ - DeviceCompat.openURI("https://www.patreon.com/ShatteredPixel"); - } else { - hide(); - } - } - }; - parent.add(wnd); - } - }; - btnSupport.icon(Icons.get(Icons.GOLD)); + StyledButton btnSupport = new SupportButton(GREY_TR, Messages.get(this, "support")); add(btnSupport); StyledButton btnRankings = new StyledButton(GREY_TR,Messages.get(this, "rankings")){ @@ -167,15 +152,14 @@ public class TitleScene extends PixelScene { btnBadges.icon(Icons.get(Icons.BADGES)); add(btnBadges); - ChangesButton btnChanges = new ChangesButton(GREY_TR, Messages.get(this, "changes")); + StyledButton btnNews = new NewsButtons(GREY_TR, Messages.get(this, "news")); + btnNews.icon(Icons.get(Icons.NEWS)); + add(btnNews); + + StyledButton btnChanges = new ChangesButton(GREY_TR, Messages.get(this, "changes")); btnChanges.icon(Icons.get(Icons.CHANGES)); add(btnChanges); - //TODO news feed functionality here - StyledButton btnNews = new StyledButton(GREY_TR, Messages.get(this, "news")); - btnNews.icon(Icons.get(Icons.CHANGES)); - add(btnNews); - StyledButton btnSettings = new SettingsButton(GREY_TR, Messages.get(this, "settings")); add(btnSettings); @@ -206,13 +190,13 @@ public class TitleScene extends PixelScene { } else { btnPlay.setRect(title.x, topRegion+GAP, title.width(), BTN_HEIGHT); align(btnPlay); - btnRankings.setRect(btnPlay.left(), btnPlay.bottom()+ GAP, (btnPlay.width()/2)-1, BTN_HEIGHT); + btnSupport.setRect(btnPlay.left(), btnPlay.bottom()+ GAP, btnPlay.width(), BTN_HEIGHT); + btnRankings.setRect(btnPlay.left(), btnSupport.bottom()+ GAP, (btnPlay.width()/2)-1, BTN_HEIGHT); btnBadges.setRect(btnRankings.right()+2, btnRankings.top(), btnRankings.width(), BTN_HEIGHT); btnNews.setRect(btnRankings.left(), btnRankings.bottom()+ GAP, btnRankings.width(), BTN_HEIGHT); btnChanges.setRect(btnNews.right()+2, btnNews.top(), btnNews.width(), BTN_HEIGHT); btnSettings.setRect(btnNews.left(), btnNews.bottom()+GAP, btnRankings.width(), BTN_HEIGHT); btnAbout.setRect(btnSettings.right()+2, btnSettings.top(), btnSettings.width(), BTN_HEIGHT); - btnSupport.setRect(btnPlay.left(), btnAbout.bottom()+ GAP, btnPlay.width(), BTN_HEIGHT); } BitmapText version = new BitmapText( "v" + Game.version, pixelFont); @@ -221,8 +205,6 @@ public class TitleScene extends PixelScene { version.x = w - version.width() - 4; version.y = h - version.height() - 2; add( version ); - - int pos = 2; fadeIn(); } @@ -233,7 +215,41 @@ public class TitleScene extends PixelScene { add( fb ); } - //TODO change icon? + private static class NewsButtons extends StyledButton { + + public NewsButtons( Chrome.Type type, String label ){ + super(type, label); + if (SPDSettings.news()) News.checkForNews(); + } + + int unreadCount = -1; + + @Override + public void update() { + 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 + ")"); + } else { + SPDSettings.newsLastRead(Game.realTime); + } + } + + if (unreadCount > 0){ + textColor(ColorMath.interpolate( 0xFFFFFF, Window.SHPX_COLOR, 0.5f + (float)Math.sin(Game.timeTotal*5)/2f)); + } + } + + @Override + protected void onClick() { + super.onClick(); + //ShatteredPixelDungeon.switchNoFade( NewsScene.class ); + } + } + private static class ChangesButton extends StyledButton { public ChangesButton( Chrome.Type type, String label ){ @@ -252,7 +268,7 @@ public class TitleScene extends PixelScene { updateShown = true; text(Messages.get(TitleScene.class, "update")); } - textColor(ColorMath.interpolate( 0xFFFFFF, Window.SHPX_COLOR, 0.5f + (float)Math.sin(Game.timeTotal*4)/2f)); + textColor(ColorMath.interpolate( 0xFFFFFF, Window.SHPX_COLOR, 0.5f + (float)Math.sin(Game.timeTotal*5)/2f)); } } @@ -285,17 +301,13 @@ public class TitleScene extends PixelScene { } - //TODO maybe have this blink a bit differently than the language button used to private static class SettingsButton extends StyledButton { - boolean blinking; - public SettingsButton( Chrome.Type type, String label ){ super(type, label); if (Messages.lang().status() == Languages.Status.INCOMPLETE){ icon(Icons.get(Icons.LANGS)); icon.hardlight(1.5f, 0, 0); - blinking = true; } else { icon(Icons.get(Icons.PREFS)); } @@ -305,17 +317,43 @@ public class TitleScene extends PixelScene { public void update() { super.update(); - if (blinking){ - icon.am = (float)Math.abs(Math.cos( Game.timeTotal )); + if (Messages.lang().status() == Languages.Status.INCOMPLETE){ + textColor(ColorMath.interpolate( 0xFFFFFF, CharSprite.NEGATIVE, 0.5f + (float)Math.sin(Game.timeTotal*5)/2f)); } } @Override protected void onClick() { - if (blinking){ + if (Messages.lang().status() == Languages.Status.INCOMPLETE){ WndSettings.last_index = 4; } ShatteredPixelDungeon.scene().add(new WndSettings()); } } + + private static class SupportButton extends StyledButton{ + + public SupportButton( Chrome.Type type, String label ){ + super(type, label); + icon(Icons.get(Icons.GOLD)); + textColor(Window.TITLE_COLOR); + } + + @Override + protected void onClick() { + WndOptions wnd = new WndOptions(Messages.get(TitleScene.class, "support"), + Messages.get(TitleScene.class, "patreon_body"), + Messages.get(TitleScene.class, "patreon_button")){ + @Override + protected void onSelect(int index) { + if (index == 0){ + DeviceCompat.openURI("https://www.patreon.com/ShatteredPixel"); + } else { + hide(); + } + } + }; + parent.add(wnd); + } + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java index 2d20d2d55..c2775a2b3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java @@ -69,6 +69,7 @@ public enum Icons { GOLD, RANKINGS, BADGES, + NEWS, CHANGES, SHPX, @@ -193,14 +194,17 @@ public enum Icons { case BADGES: icon.frame( icon.texture.uvRect( 34, 64, 50, 80 ) ); break; + case NEWS: + icon.frame( icon.texture.uvRect( 51, 64, 67, 79 ) ); + break; case CHANGES: - icon.frame( icon.texture.uvRect( 51, 64, 68, 79 ) ); + icon.frame( icon.texture.uvRect( 68, 64, 83, 79 ) ); break; case SHPX: - icon.frame( icon.texture.uvRect( 68, 64, 84, 80 ) ); + icon.frame( icon.texture.uvRect( 85, 64, 101, 80 ) ); break; case GOLD: - icon.frame( icon.texture.uvRect( 85, 64, 102, 80 ) ); + icon.frame( icon.texture.uvRect( 102, 64, 119, 80 ) ); break; case LIBGDX: @@ -231,7 +235,7 @@ public enum Icons { icon.scale.set(PixelScene.align(0.49f)); break; case CUBE_CODE: - icon.frame( icon.texture.uvRect( 101, 39, 128, 69 ) ); + icon.frame( icon.texture.uvRect( 101, 32, 128, 62 ) ); icon.scale.set(PixelScene.align(0.49f)); break; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StyledButton.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StyledButton.java index d19cd3693..aee13a7b6 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StyledButton.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StyledButton.java @@ -104,6 +104,10 @@ public class StyledButton extends Button { text.text( value ); layout(); } + + public String text(){ + return text.text(); + } public void textColor( int value ) { text.hardlight( value );