v0.6.4: implemented challenge selection in start window

game now starts right from the play button when where there are no saves
This commit is contained in:
Evan Debenham 2018-03-18 13:45:33 -04:00
parent f342a51cd6
commit 8aa55c4aad
7 changed files with 89 additions and 46 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -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();

View File

@ -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,8 +116,12 @@ public class TitleScene extends PixelScene {
DashboardItem btnPlay = new DashboardItem( Messages.get(this, "play"), 0 ) {
@Override
protected void onClick() {
if (GamesInProgress.checkAll().size() == 0){
TitleScene.this.add( new WndStartGame(1) );
} else {
ShatteredPixelDungeon.switchNoFade( StartScene.class );
}
}
};
add( btnPlay );

View File

@ -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,9 +98,14 @@ public class WelcomeScene extends PixelScene {
@Override
protected void onClick() {
super.onClick();
if (previousVersion == 0){
SPDSettings.version(ShatteredPixelDungeon.versionCode);
WelcomeScene.this.add(new WndStartGame(1));
} else {
updateVersion(previousVersion);
ShatteredPixelDungeon.switchScene(TitleScene.class);
}
}
};
if (previousVersion != 0){

View File

@ -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 ) );

View File

@ -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<? extends PixelScene>) ShatteredPixelDungeon.scene().getClass());
if (GamesInProgress.checkAll().size() > 0) {
ShatteredPixelDungeon.switchNoFade(StartScene.class);
} else {
ShatteredPixelDungeon.switchNoFade(TitleScene.class);
}
}
}
} );

View File

@ -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);
}