Merging Source v1.7.2: scene changes

This commit is contained in:
Evan Debenham 2014-10-18 04:56:57 -04:00
parent c976144fdf
commit 9f9e117c95
12 changed files with 482 additions and 484 deletions

View File

@ -20,6 +20,8 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton;
import com.watabou.input.Touchscreen.Touch; import com.watabou.input.Touchscreen.Touch;
import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.BitmapTextMultiline;
import com.watabou.noosa.Camera; import com.watabou.noosa.Camera;
@ -144,11 +146,15 @@ public class AboutScene extends PixelScene {
archs.setSize( Camera.main.width, Camera.main.height ); archs.setSize( Camera.main.width, Camera.main.height );
addToBack( archs ); addToBack( archs );
ExitButton btnExit = new ExitButton();
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
add( btnExit );
fadeIn(); fadeIn();
} }
@Override @Override
protected void onBackPressed() { protected void onBackPressed() {
Game.switchScene( TitleScene.class ); ShatteredPixelDungeon.switchNoFade(TitleScene.class);
} }
} }

View File

@ -23,6 +23,7 @@ import com.watabou.noosa.Game;
import com.watabou.noosa.Image; import com.watabou.noosa.Image;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions;
import com.shatteredpixel.shatteredpixeldungeon.effects.Flare; import com.shatteredpixel.shatteredpixeldungeon.effects.Flare;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
@ -66,6 +67,7 @@ public class AmuletScene extends PixelScene {
RedButton btnExit = new RedButton( TXT_EXIT ) { RedButton btnExit = new RedButton( TXT_EXIT ) {
@Override @Override
protected void onClick() { protected void onClick() {
Dungeon.win( ResultDescriptions.WIN );
Dungeon.deleteGame( Dungeon.hero.heroClass, true ); Dungeon.deleteGame( Dungeon.hero.heroClass, true );
Game.switchScene( noText ? TitleScene.class : RankingsScene.class ); Game.switchScene( noText ? TitleScene.class : RankingsScene.class );
} }

View File

@ -19,14 +19,15 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.watabou.noosa.BitmapText; import com.watabou.noosa.BitmapText;
import com.watabou.noosa.Camera; import com.watabou.noosa.Camera;
import com.watabou.noosa.Game;
import com.watabou.noosa.NinePatch; import com.watabou.noosa.NinePatch;
import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Music;
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.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs; import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
import com.shatteredpixel.shatteredpixeldungeon.ui.BadgesList; import com.shatteredpixel.shatteredpixeldungeon.ui.BadgesList;
import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane; import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
@ -51,8 +52,8 @@ public class BadgesScene extends PixelScene {
archs.setSize( w, h ); archs.setSize( w, h );
add( archs ); add( archs );
int pw = Math.min( 160, w - 10 ); int pw = Math.min( 160, w - 6 );
int ph = h - 24; int ph = h - 30;
NinePatch panel = Chrome.get( Chrome.Type.WINDOW ); NinePatch panel = Chrome.get( Chrome.Type.WINDOW );
panel.size( pw, ph ); panel.size( pw, ph );
@ -78,11 +79,15 @@ public class BadgesScene extends PixelScene {
panel.innerWidth(), panel.innerWidth(),
panel.innerHeight() ); panel.innerHeight() );
ExitButton btnExit = new ExitButton();
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
add( btnExit );
fadeIn(); fadeIn();
} }
@Override @Override
protected void onBackPressed() { protected void onBackPressed() {
Game.switchScene( TitleScene.class ); ShatteredPixelDungeon.switchNoFade(TitleScene.class);
} }
} }

View File

@ -600,8 +600,9 @@ public class GameScene extends PixelScene {
private static final CellSelector.Listener defaultCellListener = new CellSelector.Listener() { private static final CellSelector.Listener defaultCellListener = new CellSelector.Listener() {
@Override @Override
public void onSelect( Integer cell ) { public void onSelect( Integer cell ) {
if (cell != -1) { if (Dungeon.hero.handle( cell )) {
Dungeon.hero.handle( cell ); // Actor.next();
Dungeon.hero.next();
} }
} }
@Override @Override

View File

@ -238,6 +238,7 @@ public class InterlevelScene extends PixelScene {
Game.switchScene( StartScene.class ); Game.switchScene( StartScene.class );
}; };
} ); } );
error = null;
} }
break; break;
} }

View File

@ -239,9 +239,14 @@ public class PixelScene extends Scene {
v.y = align( c, v.y ); v.y = align( c, v.y );
} }
public static boolean noFade = false;
protected void fadeIn() { protected void fadeIn() {
if (noFade) {
noFade = false;
} else {
fadeIn( 0xFF000000, false ); fadeIn( 0xFF000000, false );
} }
}
protected void fadeIn( int color, boolean light ) { protected void fadeIn( int color, boolean light ) {
add( new Fader( color, light ) ); add( new Fader( color, light ) );

View File

@ -20,16 +20,17 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.watabou.noosa.BitmapText; import com.watabou.noosa.BitmapText;
import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.BitmapTextMultiline;
import com.watabou.noosa.Camera; import com.watabou.noosa.Camera;
import com.watabou.noosa.Game;
import com.watabou.noosa.Image; import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Music;
import com.watabou.noosa.ui.Button; import com.watabou.noosa.ui.Button;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.Rankings; import com.shatteredpixel.shatteredpixeldungeon.Rankings;
import com.shatteredpixel.shatteredpixeldungeon.effects.Flare; import com.shatteredpixel.shatteredpixeldungeon.effects.Flare;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs; import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
@ -110,12 +111,16 @@ public class RankingsScene extends PixelScene {
} }
ExitButton btnExit = new ExitButton();
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
add( btnExit );
fadeIn(); fadeIn();
} }
@Override @Override
protected void onBackPressed() { protected void onBackPressed() {
Game.switchScene( TitleScene.class ); ShatteredPixelDungeon.switchNoFade(TitleScene.class);
} }
public static class Record extends Button { public static class Record extends Button {

View File

@ -19,41 +19,39 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
import java.util.HashMap; import java.util.HashMap;
import com.shatteredpixel.shatteredpixeldungeon.*;
import com.watabou.input.Touchscreen;
import com.watabou.noosa.BitmapText; import com.watabou.noosa.BitmapText;
import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.BitmapTextMultiline;
import com.watabou.noosa.Camera; import com.watabou.noosa.Camera;
import com.watabou.noosa.Game; import com.watabou.noosa.Game;
import com.watabou.noosa.Group; import com.watabou.noosa.Group;
import com.watabou.noosa.Image; import com.watabou.noosa.Image;
import com.watabou.noosa.NinePatch;
import com.watabou.noosa.TextureFilm;
import com.watabou.noosa.TouchArea;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.particles.Emitter; import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.ui.Button; import com.watabou.noosa.ui.Button;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites.Type;
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs; import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.SimpleButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndList; import com.shatteredpixel.shatteredpixeldungeon.windows.WndChallenges;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndClass;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndTitledMessage;
public class StartScene extends PixelScene { public class StartScene extends PixelScene {
private static final float BUTTON_HEIGHT = 24; private static final float BUTTON_HEIGHT = 24;
private static final float GAP = 2; private static final float GAP = 2;
private static final String TXT_TITLE = "Select Your Hero";
private static final String TXT_LOAD = "Load Game"; private static final String TXT_LOAD = "Load Game";
private static final String TXT_NEW = "New Game"; private static final String TXT_NEW = "New Game";
@ -67,18 +65,13 @@ public class StartScene extends PixelScene {
private static final String TXT_UNLOCK = "To unlock this character class, slay the 3rd boss with any other class"; private static final String TXT_UNLOCK = "To unlock this character class, slay the 3rd boss with any other class";
private float width; private static final String TXT_WIN_THE_GAME =
private float height; "To unlock \"Challenges\", win the game with any character class.";
private float top;
private float left;
private static HashMap<HeroClass, GemButton> gems = new HashMap<HeroClass, StartScene.GemButton>(); private static final float WIDTH = 116;
private static final float HEIGHT = 220;
private Avatar avatar; private static HashMap<HeroClass, ClassShield> shields = new HashMap<HeroClass, ClassShield>();
private NinePatch frame;
private BitmapText className;
private SimpleButton btnMastery;
private GameButton btnLoad; private GameButton btnLoad;
private GameButton btnNewGame; private GameButton btnNewGame;
@ -100,46 +93,19 @@ public class StartScene extends PixelScene {
int w = Camera.main.width; int w = Camera.main.width;
int h = Camera.main.height; int h = Camera.main.height;
width = 128; float left = (w - WIDTH) / 2;
height = 220; float top = (h - HEIGHT) / 2;
left = (w - width) / 2; float bottom = h - top;
top = (h - height) / 2;
Archs archs = new Archs(); Archs archs = new Archs();
archs.setSize( w, h ); archs.setSize( w, h );
add( archs ); add( archs );
BitmapText title = PixelScene.createText( TXT_TITLE, 9 ); Image title = BannerSprites.get( Type.SELECT_YOUR_HERO );
title.hardlight( Window.TITLE_COLOR );
title.measure();
title.x = align( (w - title.width()) / 2 ); title.x = align( (w - title.width()) / 2 );
title.y = align( top ); title.y = top;
add( title ); add( title );
float pos = title.y + title.height() + GAP;
GemButton btns[] = {
new GemButton( HeroClass.WARRIOR ),
new GemButton( HeroClass.MAGE ),
new GemButton( HeroClass.ROGUE ),
new GemButton( HeroClass.HUNTRESS ) };
float space = width;
for (GemButton btn : btns) {
space -= btn.width();
}
float p = 0;
for (GemButton btn : btns) {
add( btn );
btn.setPos( align( left + p ), align( pos ) );
p += btn.width() + space / 3;
}
frame = Chrome.get( Chrome.Type.TOAST_TR );
add( frame );
btnNewGame = new GameButton( TXT_NEW ) { btnNewGame = new GameButton( TXT_NEW ) {
@Override @Override
protected void onClick() { protected void onClick() {
@ -169,80 +135,43 @@ public class StartScene extends PixelScene {
}; };
add( btnLoad ); add( btnLoad );
frame.size( width, BUTTON_HEIGHT + frame.marginVer() ); HeroClass[] classes = {
frame.x = align( left ); HeroClass.WARRIOR, HeroClass.MAGE, HeroClass.ROGUE, HeroClass.HUNTRESS
frame.y = align( h - top - frame.height() );
avatar = new Avatar();
NinePatch avFrame = Chrome.get( Chrome.Type.TOAST_TR );
avFrame.size( avatar.width() * 1.6f, avatar.height() * 1.6f );
avFrame.x = align( (w - avFrame.width()) / 2 );
avFrame.y = align( (frame.y + btns[0].bottom() - avFrame.height()) / 2 );
add( avFrame );
className = PixelScene.createText( "Placeholder", 9 );
className.measure();
className.y = align( avFrame.y + avFrame.innerBottom() - className.height() );
add( className );
avatar.point( avFrame.center() );
avatar.camera = Camera.main;
align( avatar );
add( avatar );
Image iconInfo = Icons.INFO.get();
iconInfo.x = avFrame.x + avFrame.innerRight() - iconInfo.width();
iconInfo.y = avFrame.y + avFrame.marginTop();
add( iconInfo );
add( new TouchArea( avFrame ) {
@Override
protected void onClick( Touchscreen.Touch touch ) {
add( new WndList( curClass.perks() ) );
}
} );
btnMastery = new SimpleButton( Icons.MASTERY.get() ) {
@Override
protected void onClick() {
String text = null;
switch (curClass) {
case WARRIOR:
text = HeroSubClass.GLADIATOR.desc() + "\n\n" + HeroSubClass.BERSERKER.desc();
break;
case MAGE:
text = HeroSubClass.BATTLEMAGE.desc() + "\n\n" + HeroSubClass.WARLOCK.desc();
break;
case ROGUE:
text = HeroSubClass.FREERUNNER.desc() + "\n\n" + HeroSubClass.ASSASSIN.desc();
break;
case HUNTRESS:
text = HeroSubClass.SNIPER.desc() + "\n\n" + HeroSubClass.WARDEN.desc();
break;
}
StartScene.this.add( new WndTitledMessage( Icons.MASTERY.get(), "Mastery", text ) );
}
}; };
btnMastery.setPos( float shieldW = WIDTH / 2;
avFrame.x + avFrame.innerRight() - btnMastery.width(), float shieldH = Math.min( (bottom - BUTTON_HEIGHT - title.y - title.height()) / 2, shieldW * 1.2f );
avFrame.y + avFrame.innerBottom() - btnMastery.height() ); top = (bottom - BUTTON_HEIGHT + title.y + title.height() - shieldH * 2) / 2;
add( btnMastery ); for (int i=0; i < classes.length; i++) {
ClassShield shield = new ClassShield( classes[i] );
shield.setRect(
left + (i % 2) * shieldW,
top + (i / 2) * shieldH,
shieldW, shieldH );
add( shield );
shields.put( classes[i], shield );
}
unlock = new Group(); unlock = new Group();
add( unlock ); add( unlock );
ChallengeButton challenge = new ChallengeButton();
challenge.setPos(
w / 2 - challenge.width() / 2,
top + shieldH - challenge.height() / 2 );
add( challenge );
if (!(huntressUnlocked = Badges.isUnlocked( Badges.Badge.BOSS_SLAIN_3 ))) { if (!(huntressUnlocked = Badges.isUnlocked( Badges.Badge.BOSS_SLAIN_3 ))) {
BitmapTextMultiline text = PixelScene.createMultiline( TXT_UNLOCK, 5 ); BitmapTextMultiline text = PixelScene.createMultiline( TXT_UNLOCK, 9 );
text.maxWidth = (int)frame.innerWidth(); text.maxWidth = (int)WIDTH;
text.measure(); text.measure();
pos = frame.center().y - text.height() / 2; float pos = (bottom - BUTTON_HEIGHT) + (BUTTON_HEIGHT - text.height()) / 2;
for (BitmapText line : text.new LineSplitter().split()) { for (BitmapText line : text.new LineSplitter().split()) {
line.measure(); line.measure();
line.hardlight( 0xFFFF00 ); line.hardlight( 0xFFFF00 );
line.x = PixelScene.align( frame.center().x - line.width() / 2 ); line.x = PixelScene.align( left + WIDTH / 2 - line.width() / 2 );
line.y = PixelScene.align( pos ); line.y = PixelScene.align( pos );
unlock.add( line ); unlock.add( line );
@ -250,6 +179,10 @@ public class StartScene extends PixelScene {
} }
} }
ExitButton btnExit = new ExitButton();
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
add( btnExit );
curClass = null; curClass = null;
updateClass( HeroClass.values()[ShatteredPixelDungeon.lastClass()] ); updateClass( HeroClass.values()[ShatteredPixelDungeon.lastClass()] );
@ -259,24 +192,22 @@ public class StartScene extends PixelScene {
private void updateClass( HeroClass cl ) { private void updateClass( HeroClass cl ) {
if (curClass == cl) { if (curClass == cl) {
add( new WndClass( cl ) );
return; return;
} }
if (curClass != null) { if (curClass != null) {
gems.get( curClass ).highlight( false ); shields.get( curClass ).highlight( false );
} }
shields.get( curClass = cl ).highlight( true );
gems.get( curClass = cl ).highlight( true );
className.text( Utils.capitalize( cl.title() ) );
className.measure();
className.x = align( frame.center().x - className.width() / 2 );
if (cl != HeroClass.HUNTRESS || huntressUnlocked) { if (cl != HeroClass.HUNTRESS || huntressUnlocked) {
unlock.visible = false; unlock.visible = false;
float buttonPos = frame.y + frame.innerBottom() - BUTTON_HEIGHT; float buttonPos = (Camera.main.height + HEIGHT) / 2 - BUTTON_HEIGHT;
float left = (Camera.main.width - WIDTH) / 2;
GamesInProgress.Info info = GamesInProgress.check( curClass ); GamesInProgress.Info info = GamesInProgress.check( curClass );
if (info != null) { if (info != null) {
@ -286,10 +217,10 @@ public class StartScene extends PixelScene {
btnNewGame.visible = true; btnNewGame.visible = true;
btnNewGame.secondary( TXT_ERASE ); btnNewGame.secondary( TXT_ERASE );
float w = (frame.innerWidth() - GAP) / 2; float w = (WIDTH - GAP) / 2;
btnLoad.setRect( btnLoad.setRect(
frame.x + frame.marginLeft(), buttonPos, w, BUTTON_HEIGHT ); left, buttonPos, w, BUTTON_HEIGHT );
btnNewGame.setRect( btnNewGame.setRect(
btnLoad.right() + GAP, buttonPos, w, BUTTON_HEIGHT ); btnLoad.right() + GAP, buttonPos, w, BUTTON_HEIGHT );
@ -298,39 +229,16 @@ public class StartScene extends PixelScene {
btnNewGame.visible = true; btnNewGame.visible = true;
btnNewGame.secondary( null ); btnNewGame.secondary( null );
btnNewGame.setRect( btnNewGame.setRect( left, buttonPos, WIDTH, BUTTON_HEIGHT );
frame.x + frame.marginLeft(), buttonPos, frame.innerWidth(), BUTTON_HEIGHT );
} }
Badges.Badge badgeToCheck = null;
switch (curClass) {
case WARRIOR:
badgeToCheck = Badges.Badge.MASTERY_WARRIOR;
break;
case MAGE:
badgeToCheck = Badges.Badge.MASTERY_MAGE;
break;
case ROGUE:
badgeToCheck = Badges.Badge.MASTERY_ROGUE;
break;
case HUNTRESS:
badgeToCheck = Badges.Badge.MASTERY_HUNTRESS;
break;
}
btnMastery.active =
btnMastery.visible =
Badges.isUnlocked( badgeToCheck );
} else { } else {
unlock.visible = true; unlock.visible = true;
btnLoad.visible = false; btnLoad.visible = false;
btnNewGame.visible = false; btnNewGame.visible = false;
btnMastery.active = btnMastery.visible = false;
} }
avatar.selectClass( curClass );
} }
private void startNewGame() { private void startNewGame() {
@ -348,119 +256,7 @@ public class StartScene extends PixelScene {
@Override @Override
protected void onBackPressed() { protected void onBackPressed() {
Game.switchScene( TitleScene.class ); ShatteredPixelDungeon.switchNoFade( TitleScene.class );
}
private static class Avatar extends Image {
private static final int WIDTH = 24;
private static final int HEIGHT = 32;
private static final int SCALE = 2;
private TextureFilm frames;
private float brightness = 0;
public Avatar() {
super( Assets.AVATARS );
frames = new TextureFilm( texture, WIDTH, HEIGHT );
selectClass( HeroClass.WARRIOR );
scale.set( SCALE );
origin.set( width() / 2, height() / 2 );
}
public void selectClass( HeroClass cl ) {
frame( frames.get( cl.ordinal() ) );
}
public void flash() {
brightness = 1f;
}
@Override
public void update() {
super.update();
if (brightness > 0) {
ra = ga = ba = brightness;
brightness -= Game.elapsed * 4;
if (brightness < 0) {
resetColor();
}
}
}
}
private class GemButton extends Button {
private NinePatch bg;
private Image icon;
private HeroClass cl;
public GemButton( HeroClass cl ) {
super();
this.cl = cl;
gems.put( cl, this );
icon.copy( Icons.get( cl ) );
setSize( 32, 32 );
highlight( false );
}
@Override
protected void createChildren() {
super.createChildren();
bg = Chrome.get( Chrome.Type.GEM );
add( bg );
icon = new Image();
add( icon );
}
@Override
protected void layout() {
super.layout();
bg.x = x;
bg.y = y;
bg.size( width, height );
icon.x = x + (width - icon.width) / 2;
icon.y = y + (height - icon.height) / 2;
}
@Override
protected void onTouchDown() {
Emitter emitter = (Emitter)recycle( Emitter.class );
emitter.revive();
emitter.pos( bg );
emitter.burst( Speck.factory( Speck.LIGHT ), 3 );
updateClass( cl );
avatar.flash();
Sample.INSTANCE.play( Assets.SND_CLICK, 1, 1, 1.2f );
}
public void highlight( boolean value ) {
if (value) {
bg.rm = 1.2f;
bg.gm = 1.2f;
bg.bm = 1.1f;
bg.am = 0.8f;
} else {
bg.rm = 1.0f;
bg.gm = 1.0f;
bg.bm = 1.0f;
bg.am = 0.6f;
}
}
} }
private static class GameButton extends RedButton { private static class GameButton extends RedButton {
@ -489,12 +285,12 @@ public class StartScene extends PixelScene {
super.layout(); super.layout();
if (secondary.text().length() > 0) { if (secondary.text().length() > 0) {
text.y = y + (height - text.height() - secondary.baseLine()) / 2; text.y = align( y + (height - text.height() - secondary.baseLine()) / 2 );
secondary.x = align( x + (width - secondary.width()) / 2 ); secondary.x = align( x + (width - secondary.width()) / 2 );
secondary.y = align( text.y + text.height() ); secondary.y = align( text.y + text.height() );
} else { } else {
text.y = y + (height - text.baseLine()) / 2; text.y = align( y + (height - text.baseLine()) / 2 );
} }
} }
@ -503,4 +299,155 @@ public class StartScene extends PixelScene {
secondary.measure(); secondary.measure();
} }
} }
private class ClassShield extends Button {
private static final float MIN_BRIGHTNESS = 0.6f;
private static final int WIDTH = 24;
private static final int HEIGHT = 32;
private static final float SCALE = 1.75f;
private HeroClass cl;
private Image avatar;
private BitmapText name;
private Emitter emitter;
private float brightness;
public ClassShield( HeroClass cl ) {
super();
this.cl = cl;
avatar.frame( cl.ordinal() * WIDTH, 0, WIDTH, HEIGHT );
avatar.scale.set( SCALE );
name.text( cl.name() );
name.measure();
brightness = MIN_BRIGHTNESS;
updateBrightness();
}
@Override
protected void createChildren() {
super.createChildren();
avatar = new Image( Assets.AVATARS );
add( avatar );
name = PixelScene.createText( 9 );
add( name );
emitter = new Emitter();
add( emitter );
}
@Override
protected void layout() {
super.layout();
avatar.x = align( x + (width - avatar.width()) / 2 );
avatar.y = align( y + (height - avatar.height() - name.height()) / 2 );
name.x = align( x + (width - name.width()) / 2 );
name.y = avatar.y + avatar.height() + SCALE;
emitter.pos( avatar.x, avatar.y, avatar.width(), avatar.height() );
}
@Override
protected void onTouchDown() {
emitter.revive();
emitter.start( Speck.factory( Speck.LIGHT ), 0.05f, 7 );
Sample.INSTANCE.play( Assets.SND_CLICK, 1, 1, 1.2f );
updateClass( cl );
}
@Override
public void update() {
super.update();
if (brightness < 1.0f && brightness > MIN_BRIGHTNESS) {
if ((brightness -= Game.elapsed) <= MIN_BRIGHTNESS) {
brightness = MIN_BRIGHTNESS;
}
updateBrightness();
}
}
public void highlight( boolean value ) {
if (value) {
brightness = 1.0f;
name.hardlight( 0xCACFC2 );
} else {
brightness = 0.999f;
name.hardlight( 0x444444 );
}
updateBrightness();
}
private void updateBrightness() {
avatar.gm = avatar.bm = avatar.rm = avatar.am = brightness;
}
}
private class ChallengeButton extends Button {
private Image image;
public ChallengeButton() {
super();
width = image.width;
height = image.height;
image.am = Badges.isUnlocked( Badges.Badge.VICTORY ) ? 1.0f : 0.5f;
}
@Override
protected void createChildren() {
super.createChildren();
image = Icons.get( ShatteredPixelDungeon.challenges() > 0 ? Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF );
add( image );
}
@Override
protected void layout() {
super.layout();
image.x = align( x );
image.y = align( y );
}
@Override
protected void onClick() {
if (Badges.isUnlocked( Badges.Badge.VICTORY )) {
add( new WndChallenges( ShatteredPixelDungeon.challenges(), true ) {
public void onBackPressed() {
super.onBackPressed();
image.copy( Icons.get( ShatteredPixelDungeon.challenges() > 0 ?
Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF ) );
};
} );
} else {
add( new WndMessage( TXT_WIN_THE_GAME ) );
}
}
@Override
protected void onTouchDown() {
Sample.INSTANCE.play( Assets.SND_CLICK );
}
}
} }

View File

@ -17,7 +17,6 @@
*/ */
package com.shatteredpixel.shatteredpixeldungeon.scenes; package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.watabou.noosa.BitmapText; import com.watabou.noosa.BitmapText;
import com.watabou.noosa.Camera; import com.watabou.noosa.Camera;
import com.watabou.noosa.Game; import com.watabou.noosa.Game;
@ -26,9 +25,11 @@ import com.watabou.noosa.audio.Music;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.ui.Button; import com.watabou.noosa.ui.Button;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites; import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites;
import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball; import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball;
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs; import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton; import com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton;
public class TitleScene extends PixelScene { public class TitleScene extends PixelScene {
@ -80,7 +81,7 @@ public class TitleScene extends PixelScene {
DashboardItem btnBadges = new DashboardItem( TXT_BADGES, 3 ) { DashboardItem btnBadges = new DashboardItem( TXT_BADGES, 3 ) {
@Override @Override
protected void onClick() { protected void onClick() {
Game.switchScene( BadgesScene.class ); ShatteredPixelDungeon.switchNoFade( BadgesScene.class );
} }
}; };
btnBadges.setPos( w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE ); btnBadges.setPos( w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE );
@ -89,7 +90,7 @@ public class TitleScene extends PixelScene {
DashboardItem btnAbout = new DashboardItem( TXT_ABOUT, 1 ) { DashboardItem btnAbout = new DashboardItem( TXT_ABOUT, 1 ) {
@Override @Override
protected void onClick() { protected void onClick() {
Game.switchScene( AboutScene.class ); ShatteredPixelDungeon.switchNoFade( AboutScene.class );
} }
}; };
btnAbout.setPos( w / 2, (h + height) / 2 - DashboardItem.SIZE ); btnAbout.setPos( w / 2, (h + height) / 2 - DashboardItem.SIZE );
@ -98,7 +99,7 @@ public class TitleScene extends PixelScene {
DashboardItem btnPlay = new DashboardItem( TXT_PLAY, 0 ) { DashboardItem btnPlay = new DashboardItem( TXT_PLAY, 0 ) {
@Override @Override
protected void onClick() { protected void onClick() {
Game.switchScene( StartScene.class ); ShatteredPixelDungeon.switchNoFade( StartScene.class );
} }
}; };
btnPlay.setPos( w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE ); btnPlay.setPos( w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE );
@ -107,7 +108,7 @@ public class TitleScene extends PixelScene {
DashboardItem btnHighscores = new DashboardItem( TXT_HIGHSCORES, 2 ) { DashboardItem btnHighscores = new DashboardItem( TXT_HIGHSCORES, 2 ) {
@Override @Override
protected void onClick() { protected void onClick() {
Game.switchScene( RankingsScene.class ); ShatteredPixelDungeon.switchNoFade( RankingsScene.class );
} }
}; };
btnHighscores.setPos( w / 2, btnPlay.top() ); btnHighscores.setPos( w / 2, btnPlay.top() );
@ -128,9 +129,13 @@ public class TitleScene extends PixelScene {
add( version ); add( version );
PrefsButton btnPrefs = new PrefsButton(); PrefsButton btnPrefs = new PrefsButton();
btnPrefs.setPos( w - btnPrefs.width() - 1, 1 ); btnPrefs.setPos( 0, 0 );
add( btnPrefs ); add( btnPrefs );
ExitButton btnExit = new ExitButton();
btnExit.setPos( w - btnExit.width(), 0 );
add( btnExit );
fadeIn(); fadeIn();
} }

View File

@ -0,0 +1,7 @@
package com.shatteredpixel.shatteredpixeldungeon.ui;
/**
* Created by Evan on 18/10/2014.
*/
public class ExitButton {
}

View File

@ -0,0 +1,7 @@
package com.shatteredpixel.shatteredpixeldungeon.windows;
/**
* Created by Evan on 18/10/2014.
*/
public class WndChallenges {
}

View File

@ -0,0 +1,7 @@
package com.shatteredpixel.shatteredpixeldungeon.windows;
/**
* Created by Evan on 18/10/2014.
*/
public class WndClass {
}