From 8aa55c4aadc7bcafe29b181d251c1b2e6e64b044 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 18 Mar 2018 13:45:33 -0400 Subject: [PATCH] v0.6.4: implemented challenge selection in start window game now starts right from the play button when where there are no saves --- core/src/main/assets/icons.png | Bin 2213 -> 2113 bytes .../scenes/StartScene.java | 47 ++++-------------- .../scenes/TitleScene.java | 8 ++- .../scenes/WelcomeScene.java | 10 +++- .../shatteredpixeldungeon/ui/Icons.java | 4 +- .../windows/WndGameInProgress.java | 33 ++++++++++-- .../windows/WndStartGame.java | 33 ++++++++++++ 7 files changed, 89 insertions(+), 46 deletions(-) diff --git a/core/src/main/assets/icons.png b/core/src/main/assets/icons.png index 400c154f9f070ff7878d067e7819f472a04e33ed..e0a5104ad1fd9cecd89539a6a0fe6eea21262d8d 100644 GIT binary patch delta 1193 zcmV;a1XlZ{5y23UBmth0CAbfJfOBJJT>tcd|Hc~3oIR1<9vF0x%6+HVZ-T*Yfxu{q zv!OLG%F4a1h=7wT0i_7M5Lglb004E9*a29RGXfz9=6N}i000Huvs?nJ0e|ylp&LgK zgJJ(tKv=FgFHkXr87DAl@R;%aAE9>Kz4a|=T20|Q8jJpKJ*3-C*|B3HEFj8Oh3vjz zMkSXKOIv}x1^aePz}D8*!NI}dAt3qhj*gCxk55j3Qh`%u*Nj#yWC#&R@>$>j%+Wi^ zXMtm&RKRqAiu~3j)?f9BP;Ok z-R0$VUH~cp6@Uuhmju?=zkXep7YmTPakm2hW;$@mzJJ+KuQ(UlzE$7P1122&923K=iu;o&^*h1)KwnP5~*TQ$R}S6r3q6;2$1%3i#x8 z_c9C>I5YyE`MT07bP+C}0}q}J9OwH7N_pH*v14NF(QB*VZTPg{Sp*)u^6)@W2oQKl z5CL*GHxCaFH#d&r6Mudb$0z(UibVKz{D1N)P!0eT5ipq&Nq((X%NRhYBWnJ;25i}E zHj(7F7;B*a>FPk-{I(TnzUy?gmV9AZ0KHy4dOmCeI;*Kbzu#8@liwZ~f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gg6oq-y?+wT0(`?PfV;;J zpFsil@rZ|gpTK?)gkdmIPf`3Yj$n`^X{toB6FS#I0h<3iEb!Gy3SgNPMg$g1tS=WN;IGP6Symh%n9x2KSkF>a7!bgErdi;&0DndW zmYb#hZK=S@_e-Ay0)H0x2L}>Zr?d5-0LJrNXXgSA3cTtRK)|kJf3f37fCdl%`~-Mk zVVxr+f&ll|S$0>zIWzVS&^`(%pQs=ZvcNHbN=N{2LV7Qdu|Redpa5JzMlRq%Kvjfr z3hgw$a7b_7gpBtgFuyJEN&&l$9|VZKlBfX=!rFGY70|qY5PukNE}sJQUoN&sfkqT) zyPBWE?W;(SpY|c}4)6%DZ~t~j0m;BXpstNnK=b{-SHSyU6uScK4h5Q~>7@c~+qL!V z{xD*m3d~vHL+tI{H=+Rq02-L}jR2iLe8GnWXqp6iSpXQk23G;pC(?s~0;VQ~x;3UY z>Pr##A%On);wRUBu|O~FE5k5fEP(wV<$L#^0WMA?(aZO}E&u=k07*qoM6N<$g2<>* A*Z=?k diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/StartScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/StartScene.java index e751ba7e7..1c2bd2168 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/StartScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/StartScene.java @@ -23,7 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Chrome; -import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress; import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; @@ -32,10 +31,8 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.Archs; import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton; -import com.shatteredpixel.shatteredpixeldungeon.ui.IconButton; import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; -import com.shatteredpixel.shatteredpixeldungeon.windows.WndChallenges; import com.shatteredpixel.shatteredpixeldungeon.windows.WndGameInProgress; import com.shatteredpixel.shatteredpixeldungeon.windows.WndStartGame; import com.watabou.noosa.BitmapText; @@ -52,8 +49,6 @@ public class StartScene extends PixelScene { private static final int SLOT_WIDTH = 120; private static final int SLOT_HEIGHT = 30; - private static final int CHALLENGE_SIZE = 22; - @Override public void create() { super.create(); @@ -109,38 +104,6 @@ public class StartScene extends PixelScene { add(newGame); } - IconButton challengeButton = new IconButton( - Icons.get( SPDSettings.challenges() > 0 ? Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF)){ - @Override - protected void onClick() { - ShatteredPixelDungeon.scene().add(new WndChallenges(SPDSettings.challenges(), true) { - public void onBackPressed() { - super.onBackPressed(); - icon( Icons.get( SPDSettings.challenges() > 0 ? - Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF ) ); - } - } ); - } - }; - - if (SPDSettings.landscape()){ - challengeButton.setRect(4*slotGap + (w + SLOT_WIDTH - CHALLENGE_SIZE)/2, 8 + (h - CHALLENGE_SIZE)/2f, - CHALLENGE_SIZE, CHALLENGE_SIZE); - - } else { - challengeButton.setRect((w - CHALLENGE_SIZE)/2f, yPos + 2*slotGap - CHALLENGE_SIZE/2f, - CHALLENGE_SIZE, CHALLENGE_SIZE); - - } - align(challengeButton); - - if (Badges.isUnlocked(Badges.Badge.VICTORY)){ - add(challengeButton); - } else { - Dungeon.challenges = 0; - SPDSettings.challenges(0); - } - GamesInProgress.curSlot = 0; ActionIndicator.action = null; @@ -226,6 +189,16 @@ public class StartScene extends PixelScene { level.text(Integer.toString(info.level)); level.measure(); + if (info.challenges > 0){ + name.hardlight(Window.TITLE_COLOR); + depth.hardlight(Window.TITLE_COLOR); + level.hardlight(Window.TITLE_COLOR); + } else { + name.resetColor(); + depth.resetColor(); + level.resetColor(); + } + } layout(); 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 b290a5db8..34d38447d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress; import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites; @@ -32,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.ChangesButton; import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton; import com.shatteredpixel.shatteredpixeldungeon.ui.LanguageButton; import com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndStartGame; import com.watabou.glwrap.Blending; import com.watabou.noosa.BitmapText; import com.watabou.noosa.Camera; @@ -114,7 +116,11 @@ public class TitleScene extends PixelScene { DashboardItem btnPlay = new DashboardItem( Messages.get(this, "play"), 0 ) { @Override protected void onClick() { - ShatteredPixelDungeon.switchNoFade( StartScene.class ); + if (GamesInProgress.checkAll().size() == 0){ + TitleScene.this.add( new WndStartGame(1) ); + } else { + ShatteredPixelDungeon.switchNoFade( StartScene.class ); + } } }; add( btnPlay ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java index 7ce254f31..090ef7682 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java @@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndStartGame; import com.watabou.glwrap.Blending; import com.watabou.noosa.Camera; import com.watabou.noosa.Game; @@ -97,8 +98,13 @@ public class WelcomeScene extends PixelScene { @Override protected void onClick() { super.onClick(); - updateVersion(previousVersion); - ShatteredPixelDungeon.switchScene(TitleScene.class); + if (previousVersion == 0){ + SPDSettings.version(ShatteredPixelDungeon.versionCode); + WelcomeScene.this.add(new WndStartGame(1)); + } else { + updateVersion(previousVersion); + ShatteredPixelDungeon.switchScene(TitleScene.class); + } } }; 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 89198d49c..51f5c37ab 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java @@ -155,10 +155,10 @@ public enum Icons { icon.frame( icon.texture.uvRect( 95, 42, 107, 51 ) ); break; case CHALLENGE_OFF: - icon.frame( icon.texture.uvRect( 78, 16, 102, 40 ) ); + icon.frame( icon.texture.uvRect( 78, 12, 92, 24 ) ); break; case CHALLENGE_ON: - icon.frame( icon.texture.uvRect( 102, 16, 126, 40 ) ); + icon.frame( icon.texture.uvRect( 92, 12, 108, 24 ) ); break; case RESUME: icon.frame( icon.texture.uvRect( 13, 53, 24, 64 ) ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGameInProgress.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGameInProgress.java index 91cba27a9..15fceade1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGameInProgress.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGameInProgress.java @@ -28,9 +28,12 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; +import com.shatteredpixel.shatteredpixeldungeon.scenes.StartScene; +import com.shatteredpixel.shatteredpixeldungeon.scenes.TitleScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; +import com.watabou.noosa.Game; import com.watabou.noosa.RenderedText; import com.watabou.utils.FileUtils; @@ -41,13 +44,13 @@ public class WndGameInProgress extends Window { private static final int WIDTH = 120; private static final int HEIGHT = 120; - private static final int GAP = 5; + private int GAP = 5; private float pos; public WndGameInProgress(final int slot){ - GamesInProgress.Info info = GamesInProgress.check(slot); + final GamesInProgress.Info info = GamesInProgress.check(slot); IconTitle title = new IconTitle(); title.icon( HeroSprite.avatar(info.heroClass, info.armorTier) ); @@ -56,7 +59,25 @@ public class WndGameInProgress extends Window { title.setRect( 0, 0, WIDTH, 0 ); add(title); - pos = title.bottom() + 2*GAP; + if (info.challenges > 0) GAP -= 2; + + pos = title.bottom() + GAP; + + if (info.challenges > 0) { + RedButton btnChallenges = new RedButton( "Challenges" ) { + @Override + protected void onClick() { + Game.scene().add( new WndChallenges( info.challenges, false ) ); + } + }; + float btnW = btnChallenges.reqWidth() + 2; + btnChallenges.setRect( (WIDTH - btnW)/2, pos, btnW , btnChallenges.reqHeight() + 2 ); + add( btnChallenges ); + + pos = btnChallenges.bottom() + GAP; + } + + pos += GAP; statSlot( Messages.get(this, "str"), info.str ); if (info.shld > 0) statSlot( Messages.get(this, "health"), info.hp + "+" + info.shld + "/" + info.ht ); @@ -97,7 +118,11 @@ public class WndGameInProgress extends Window { if (index == 0) { FileUtils.deleteDir(GamesInProgress.gameFolder(slot)); GamesInProgress.setUnknown(slot); - ShatteredPixelDungeon.switchNoFade((Class) ShatteredPixelDungeon.scene().getClass()); + if (GamesInProgress.checkAll().size() > 0) { + ShatteredPixelDungeon.switchNoFade(StartScene.class); + } else { + ShatteredPixelDungeon.switchNoFade(TitleScene.class); + } } } } ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndStartGame.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndStartGame.java index 727f341ba..2470ae537 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndStartGame.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndStartGame.java @@ -29,6 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; +import com.shatteredpixel.shatteredpixeldungeon.journal.Journal; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.IntroScene; @@ -54,6 +55,7 @@ public class WndStartGame extends Window { public WndStartGame(final int slot){ Badges.loadGlobal(); + Journal.loadGlobal(); RenderedText title = PixelScene.renderText(Messages.get(this, "title"), 12 ); title.hardlight(Window.TITLE_COLOR); @@ -112,6 +114,37 @@ public class WndStartGame extends Window { start.setRect(0, HEIGHT - 20, WIDTH, 20); add(start); + if (Badges.isUnlocked(Badges.Badge.VICTORY)){ + IconButton challengeButton = new IconButton( + Icons.get( SPDSettings.challenges() > 0 ? Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF)){ + @Override + protected void onClick() { + ShatteredPixelDungeon.scene().add(new WndChallenges(SPDSettings.challenges(), true) { + public void onBackPressed() { + super.onBackPressed(); + icon( Icons.get( SPDSettings.challenges() > 0 ? + Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF ) ); + } + } ); + } + + @Override + public void update() { + if( !visible && GamesInProgress.selectedClass != null){ + visible = true; + } + super.update(); + } + }; + challengeButton.setRect(WIDTH - 20, HEIGHT - 20, 20, 20); + challengeButton.visible = false; + add(challengeButton); + + } else { + Dungeon.challenges = 0; + SPDSettings.challenges(0); + } + resize(WIDTH, HEIGHT); }