Merging 1.7.5 Source: scenes changes

This commit is contained in:
Evan Debenham 2015-02-05 01:25:24 -05:00
parent a2670f2a36
commit e2ee042c38
10 changed files with 291 additions and 182 deletions

View File

@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
//FIXME: fix in landscape mode
public class AboutScene extends PixelScene { public class AboutScene extends PixelScene {
private static final String TTL_SHPX = "Shattered Pixel Dungeon"; private static final String TTL_SHPX = "Shattered Pixel Dungeon";

View File

@ -19,6 +19,7 @@ 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;
@ -30,64 +31,85 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.BadgesList;
import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton; 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;
import com.watabou.utils.Callback;
public class BadgesScene extends PixelScene { public class BadgesScene extends PixelScene {
private static final String TXT_TITLE = "Your Badges"; private static final String TXT_TITLE = "Your Badges";
private static final int MAX_PANE_WIDTH = 160;
@Override @Override
public void create() { public void create() {
super.create(); super.create();
Music.INSTANCE.play( Assets.THEME, true ); Music.INSTANCE.play( Assets.THEME, true );
Music.INSTANCE.volume( 1f ); Music.INSTANCE.volume( 1f );
uiCamera.visible = false; uiCamera.visible = false;
int w = Camera.main.width; int w = Camera.main.width;
int h = Camera.main.height; int h = Camera.main.height;
Archs archs = new Archs(); Archs archs = new Archs();
archs.setSize( w, h ); archs.setSize( w, h );
add( archs ); add( archs );
int pw = Math.min( 160, w - 6 ); int pw = Math.min( MAX_PANE_WIDTH, w - 6 );
int ph = h - 30; 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 );
panel.x = (w - pw) / 2; panel.x = (w - pw) / 2;
panel.y = (h - ph) / 2; panel.y = (h - ph) / 2;
add( panel ); add( panel );
BitmapText title = PixelScene.createText( TXT_TITLE, 9 ); BitmapText title = PixelScene.createText( TXT_TITLE, 9 );
title.hardlight( Window.TITLE_COLOR ); title.hardlight( Window.TITLE_COLOR );
title.measure(); title.measure();
title.x = align( (w - title.width()) / 2 ); title.x = align( (w - title.width()) / 2 );
title.y = align( (panel.y - title.baseLine()) / 2 ); title.y = align( (panel.y - title.baseLine()) / 2 );
add( title ); add( title );
Badges.loadGlobal(); Badges.loadGlobal();
ScrollPane list = new BadgesList( true ); ScrollPane list = new BadgesList( true );
add( list ); add( list );
list.setRect(
panel.x + panel.marginLeft(),
panel.y + panel.marginTop(),
panel.innerWidth(),
panel.innerHeight() );
ExitButton btnExit = new ExitButton(); list.setRect(
btnExit.setPos( Camera.main.width - btnExit.width(), 0 ); panel.x + panel.marginLeft(),
add( btnExit ); panel.y + panel.marginTop(),
panel.innerWidth(),
panel.innerHeight() );
ExitButton btnExit = new ExitButton();
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
add( btnExit );
fadeIn(); fadeIn();
Badges.loadingListener = new Callback() {
@Override
public void call() {
if (Game.scene() == BadgesScene.this) {
ShatteredPixelDungeon.switchNoFade( BadgesScene.class );
}
}
};
} }
@Override
public void destroy() {
Badges.saveGlobal();
Badges.loadingListener = null;
super.destroy();
}
@Override @Override
protected void onBackPressed() { protected void onBackPressed() {
ShatteredPixelDungeon.switchNoFade(TitleScene.class); ShatteredPixelDungeon.switchNoFade( TitleScene.class );
} }
} }

View File

@ -603,7 +603,6 @@ public class GameScene extends PixelScene {
@Override @Override
public void onSelect( Integer cell ) { public void onSelect( Integer cell ) {
if (Dungeon.hero.handle( cell )) { if (Dungeon.hero.handle( cell )) {
// Actor.next();
Dungeon.hero.next(); Dungeon.hero.next();
} }
} }

View File

@ -119,48 +119,6 @@ public class InterlevelScene extends PixelScene {
Generator.reset(); Generator.reset();
Sample.INSTANCE.load(
Assets.SND_OPEN,
Assets.SND_UNLOCK,
Assets.SND_ITEM,
Assets.SND_DEWDROP,
Assets.SND_HIT,
Assets.SND_MISS,
Assets.SND_STEP,
Assets.SND_WATER,
Assets.SND_DESCEND,
Assets.SND_EAT,
Assets.SND_READ,
Assets.SND_LULLABY,
Assets.SND_DRINK,
Assets.SND_SHATTER,
Assets.SND_ZAP,
Assets.SND_LIGHTNING,
Assets.SND_LEVELUP,
Assets.SND_DEATH,
Assets.SND_CHALLENGE,
Assets.SND_CURSED,
Assets.SND_EVOKE,
Assets.SND_TRAP,
Assets.SND_TOMB,
Assets.SND_ALERT,
Assets.SND_MELD,
Assets.SND_BOSS,
Assets.SND_BLAST,
Assets.SND_PLANT,
Assets.SND_RAY,
Assets.SND_BEACON,
Assets.SND_TELEPORT,
Assets.SND_CHARMS,
Assets.SND_MASTERY,
Assets.SND_PUFF,
Assets.SND_ROCKS,
Assets.SND_BURNING,
Assets.SND_FALLING,
Assets.SND_GHOST,
Assets.SND_SECRET,
Assets.SND_BONES );
switch (mode) { switch (mode) {
case DESCEND: case DESCEND:
descend(); descend();
@ -366,7 +324,7 @@ public class InterlevelScene extends PixelScene {
if (Dungeon.level.locked) { if (Dungeon.level.locked) {
Dungeon.hero.resurrect( Dungeon.depth ); Dungeon.hero.resurrect( Dungeon.depth );
Dungeon.depth--; Dungeon.depth--;
Level level = Dungeon.newLevel(/* true */); Level level = Dungeon.newLevel();
Dungeon.switchLevel( level, level.entrance ); Dungeon.switchLevel( level, level.entrance );
} else { } else {
Dungeon.hero.resurrect( -1 ); Dungeon.hero.resurrect( -1 );
@ -376,5 +334,6 @@ public class InterlevelScene extends PixelScene {
@Override @Override
protected void onBackPressed() { protected void onBackPressed() {
//Do nothing
} }
} }

View File

@ -25,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.watabou.input.Touchscreen; import com.watabou.input.Touchscreen;
import com.watabou.noosa.BitmapText; import com.watabou.noosa.BitmapText;
import com.watabou.noosa.BitmapText.Font; import com.watabou.noosa.BitmapText.Font;
import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.BitmapTextMultiline;
import com.watabou.noosa.Camera; import com.watabou.noosa.Camera;
import com.watabou.noosa.ColorBlock; import com.watabou.noosa.ColorBlock;
@ -38,16 +37,19 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.BadgeBanner;
import com.watabou.utils.BitmapCache; import com.watabou.utils.BitmapCache;
public class PixelScene extends Scene { public class PixelScene extends Scene {
public static final float MIN_WIDTH = 128; // Minimum virtual display size for portrait orientation
public static final float MIN_HEIGHT = 224; public static final float MIN_WIDTH_P = 128;
public static final float MIN_HEIGHT_P = 224;
// Minimum virtual display size for landscape orientation
public static final float MIN_WIDTH_L = 224;
public static final float MIN_HEIGHT_L = 160;
public static float defaultZoom = 0; public static float defaultZoom = 0;
public static float minZoom; public static float minZoom;
public static float maxZoom; public static float maxZoom;
public static boolean landscapeAvailable;
public static Camera uiCamera; public static Camera uiCamera;
public static BitmapText.Font font1x; public static BitmapText.Font font1x;
@ -62,23 +64,30 @@ public class PixelScene extends Scene {
super.create(); super.create();
GameScene.scene = null; GameScene.scene = null;
float minWidth, minHeight;
if (ShatteredPixelDungeon.landscape()) {
minWidth = MIN_WIDTH_L;
minHeight = MIN_HEIGHT_L;
} else {
minWidth = MIN_WIDTH_P;
minHeight = MIN_HEIGHT_P;
}
defaultZoom = (int)Math.ceil( Game.density * 2.5 ); defaultZoom = (int)Math.ceil( Game.density * 2.5 );
while (( while ((
Game.width / defaultZoom < MIN_WIDTH || Game.width / defaultZoom < minWidth ||
Game.height / defaultZoom < MIN_HEIGHT Game.height / defaultZoom < minHeight
) && defaultZoom > 1) { ) && defaultZoom > 1) {
defaultZoom--; defaultZoom--;
} }
landscapeAvailable =
Game.height / defaultZoom >= MIN_WIDTH &&
Game.width / defaultZoom >= MIN_HEIGHT;
if (ShatteredPixelDungeon.scaleUp()) { if (ShatteredPixelDungeon.scaleUp()) {
while ((Game.width / (defaultZoom + 1) >= MIN_WIDTH && Game.height / (defaultZoom + 1) >= MIN_HEIGHT)) { while (
defaultZoom++; Game.width / (defaultZoom + 1) >= minWidth &&
Game.height / (defaultZoom + 1) >= minHeight) {
defaultZoom++;
} }
} }
minZoom = 1; minZoom = 1;
@ -123,11 +132,6 @@ public class PixelScene extends Scene {
font3x.baseLine = 17; font3x.baseLine = 17;
font3x.tracking = -2; font3x.tracking = -2;
} }
Sample.INSTANCE.load(
Assets.SND_CLICK,
Assets.SND_BADGE,
Assets.SND_GOLD );
} }
@Override @Override
@ -140,9 +144,13 @@ public class PixelScene extends Scene {
public static float scale; public static float scale;
public static void chooseFont( float size ) { public static void chooseFont( float size ) {
chooseFont( size, defaultZoom );
float pt = size * defaultZoom; }
public static void chooseFont( float size, float zoom ) {
float pt = size * zoom;
if (pt >= 19) { if (pt >= 19) {
scale = pt / 19; scale = pt / 19;
@ -194,7 +202,7 @@ public class PixelScene extends Scene {
} }
scale /= defaultZoom; scale /= zoom;
} }
public static BitmapText createText( float size ) { public static BitmapText createText( float size ) {
@ -228,7 +236,8 @@ public class PixelScene extends Scene {
public static float align( Camera camera, float pos ) { public static float align( Camera camera, float pos ) {
return ((int)(pos * camera.zoom)) / camera.zoom; return ((int)(pos * camera.zoom)) / camera.zoom;
} }
// This one should be used for UI elements
public static float align( float pos ) { public static float align( float pos ) {
return ((int)(pos * defaultZoom)) / defaultZoom; return ((int)(pos * defaultZoom)) / defaultZoom;
} }

View File

@ -37,6 +37,7 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndError; import com.shatteredpixel.shatteredpixeldungeon.windows.WndError;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndRanking; import com.shatteredpixel.shatteredpixeldungeon.windows.WndRanking;
//FIXME: need to modify this to properly account for new landscape logic, more than just a merge.
public class RankingsScene extends PixelScene { public class RankingsScene extends PixelScene {
private static final String TXT_TITLE = "Top Rankings"; private static final String TXT_TITLE = "Top Rankings";

View File

@ -46,6 +46,7 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndChallenges;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndClass; import com.shatteredpixel.shatteredpixeldungeon.windows.WndClass;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage; import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.utils.Callback;
public class StartScene extends PixelScene { public class StartScene extends PixelScene {
@ -68,11 +69,17 @@ public class StartScene extends PixelScene {
private static final String TXT_WIN_THE_GAME = private static final String TXT_WIN_THE_GAME =
"To unlock \"Challenges\", win the game with any character class."; "To unlock \"Challenges\", win the game with any character class.";
private static final float WIDTH = 116; private static final float WIDTH_P = 116;
private static final float HEIGHT = 220; private static final float HEIGHT_P = 220;
private static final float WIDTH_L = 224;
private static final float HEIGHT_L = 124;
private static HashMap<HeroClass, ClassShield> shields = new HashMap<HeroClass, ClassShield>(); private static HashMap<HeroClass, ClassShield> shields = new HashMap<HeroClass, ClassShield>();
private float buttonX;
private float buttonY;
private GameButton btnLoad; private GameButton btnLoad;
private GameButton btnNewGame; private GameButton btnNewGame;
@ -93,8 +100,17 @@ 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;
float left = (w - WIDTH) / 2; float width, height;
float top = (h - HEIGHT) / 2; if (ShatteredPixelDungeon.landscape()) {
width = WIDTH_L;
height = HEIGHT_L;
} else {
width = WIDTH_P;
height = HEIGHT_P;
}
float left = (w - width) / 2;
float top = (h - height) / 2;
float bottom = h - top; float bottom = h - top;
Archs archs = new Archs(); Archs archs = new Archs();
@ -103,9 +119,12 @@ public class StartScene extends PixelScene {
Image title = BannerSprites.get( Type.SELECT_YOUR_HERO ); Image title = BannerSprites.get( Type.SELECT_YOUR_HERO );
title.x = align( (w - title.width()) / 2 ); title.x = align( (w - title.width()) / 2 );
title.y = top; title.y = align( top );
add( title ); add( title );
buttonX = left;
buttonY = bottom - BUTTON_HEIGHT;
btnNewGame = new GameButton( TXT_NEW ) { btnNewGame = new GameButton( TXT_NEW ) {
@Override @Override
protected void onClick() { protected void onClick() {
@ -135,43 +154,66 @@ public class StartScene extends PixelScene {
}; };
add( btnLoad ); add( btnLoad );
float centralHeight = buttonY - title.y - title.height();
HeroClass[] classes = { HeroClass[] classes = {
HeroClass.WARRIOR, HeroClass.MAGE, HeroClass.ROGUE, HeroClass.HUNTRESS HeroClass.WARRIOR, HeroClass.MAGE, HeroClass.ROGUE, HeroClass.HUNTRESS
}; };
float shieldW = WIDTH / 2; for (HeroClass cl : classes) {
float shieldH = Math.min( (bottom - BUTTON_HEIGHT - title.y - title.height()) / 2, shieldW * 1.2f ); ClassShield shield = new ClassShield( cl );
top = (bottom - BUTTON_HEIGHT + title.y + title.height() - shieldH * 2) / 2; shields.put( cl, shield );
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 ); add( shield );
}
if (ShatteredPixelDungeon.landscape()) {
float shieldW = width / 4;
float shieldH = Math.min( centralHeight, shieldW );
top = title.y + title.height + (centralHeight - shieldH) / 2;
for (int i=0; i < classes.length; i++) {
ClassShield shield = shields.get( classes[i] );
shield.setRect( left + i * shieldW, top, shieldW, shieldH );
}
ChallengeButton challenge = new ChallengeButton();
challenge.setPos(
w / 2 - challenge.width() / 2,
top + shieldH - challenge.height() / 2 );
add( challenge );
} else {
float shieldW = width / 2;
float shieldH = Math.min( centralHeight / 2, shieldW * 1.2f );
top = title.y + title.height() + centralHeight / 2 - shieldH;
for (int i=0; i < classes.length; i++) {
ClassShield shield = shields.get( classes[i] );
shield.setRect(
left + (i % 2) * shieldW,
top + (i / 2) * shieldH,
shieldW, shieldH );
}
ChallengeButton challenge = new ChallengeButton();
challenge.setPos(
w / 2 - challenge.width() / 2,
top + shieldH - challenge.height() / 2 );
add( challenge );
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, 9 ); BitmapTextMultiline text = PixelScene.createMultiline( TXT_UNLOCK, 9 );
text.maxWidth = (int)WIDTH; text.maxWidth = (int)width;
text.measure(); text.measure();
float pos = (bottom - BUTTON_HEIGHT) + (BUTTON_HEIGHT - 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( left + WIDTH / 2 - line.width() / 2 ); line.x = PixelScene.align( w / 2 - line.width() / 2 );
line.y = PixelScene.align( pos ); line.y = PixelScene.align( pos );
unlock.add( line ); unlock.add( line );
@ -187,6 +229,25 @@ public class StartScene extends PixelScene {
updateClass( HeroClass.values()[ShatteredPixelDungeon.lastClass()] ); updateClass( HeroClass.values()[ShatteredPixelDungeon.lastClass()] );
fadeIn(); fadeIn();
Badges.loadingListener = new Callback() {
@Override
public void call() {
if (Game.scene() == StartScene.this) {
ShatteredPixelDungeon.switchNoFade( StartScene.class );
}
}
};
}
@Override
public void destroy() {
Badges.saveGlobal();
Badges.loadingListener = null;
super.destroy();
} }
private void updateClass( HeroClass cl ) { private void updateClass( HeroClass cl ) {
@ -205,31 +266,27 @@ public class StartScene extends PixelScene {
unlock.visible = false; unlock.visible = false;
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) {
btnLoad.visible = true; btnLoad.visible = true;
btnLoad.secondary( Utils.format( TXT_DPTH_LVL, info.depth, info.level ) ); btnLoad.secondary( Utils.format( TXT_DPTH_LVL, info.depth, info.level ), info.challenges );
btnNewGame.visible = true; btnNewGame.visible = true;
btnNewGame.secondary( TXT_ERASE ); btnNewGame.secondary( TXT_ERASE, false );
float w = (WIDTH - GAP) / 2; float w = (Camera.main.width - GAP) / 2 - buttonX;
btnLoad.setRect( btnLoad.setRect(
left, buttonPos, w, BUTTON_HEIGHT ); buttonX, buttonY, w, BUTTON_HEIGHT );
btnNewGame.setRect( btnNewGame.setRect(
btnLoad.right() + GAP, buttonPos, w, BUTTON_HEIGHT ); btnLoad.right() + GAP, buttonY, w, BUTTON_HEIGHT );
} else { } else {
btnLoad.visible = false; btnLoad.visible = false;
btnNewGame.visible = true; btnNewGame.visible = true;
btnNewGame.secondary( null ); btnNewGame.secondary( null, false );
btnNewGame.setRect( left, buttonPos, WIDTH, BUTTON_HEIGHT ); btnNewGame.setRect( buttonX, buttonY, Camera.main.width - buttonX * 2, BUTTON_HEIGHT );
} }
} else { } else {
@ -261,7 +318,8 @@ public class StartScene extends PixelScene {
private static class GameButton extends RedButton { private static class GameButton extends RedButton {
private static final int SECONDARY_COLOR = 0xCACFC2; private static final int SECONDARY_COLOR_N = 0xCACFC2;
private static final int SECONDARY_COLOR_H = 0xFFFF88;
private BitmapText secondary; private BitmapText secondary;
@ -276,7 +334,6 @@ public class StartScene extends PixelScene {
super.createChildren(); super.createChildren();
secondary = createText( 6 ); secondary = createText( 6 );
secondary.hardlight( SECONDARY_COLOR );
add( secondary ); add( secondary );
} }
@ -294,9 +351,11 @@ public class StartScene extends PixelScene {
} }
} }
public void secondary( String text ) { public void secondary( String text, boolean highlighted ) {
secondary.text( text ); secondary.text( text );
secondary.measure(); secondary.measure();
secondary.hardlight( highlighted ? SECONDARY_COLOR_H : SECONDARY_COLOR_N );
} }
} }
@ -304,6 +363,12 @@ public class StartScene extends PixelScene {
private static final float MIN_BRIGHTNESS = 0.6f; private static final float MIN_BRIGHTNESS = 0.6f;
private static final int BASIC_NORMAL = 0x444444;
private static final int BASIC_HIGHLIGHTED = 0xCACFC2;
private static final int MASTERY_NORMAL = 0x666644;
private static final int MASTERY_HIGHLIGHTED= 0xFFFF88;
private static final int WIDTH = 24; private static final int WIDTH = 24;
private static final int HEIGHT = 32; private static final int HEIGHT = 32;
private static final float SCALE = 1.75f; private static final float SCALE = 1.75f;
@ -316,6 +381,9 @@ public class StartScene extends PixelScene {
private float brightness; private float brightness;
private int normal;
private int highlighted;
public ClassShield( HeroClass cl ) { public ClassShield( HeroClass cl ) {
super(); super();
@ -324,8 +392,17 @@ public class StartScene extends PixelScene {
avatar.frame( cl.ordinal() * WIDTH, 0, WIDTH, HEIGHT ); avatar.frame( cl.ordinal() * WIDTH, 0, WIDTH, HEIGHT );
avatar.scale.set( SCALE ); avatar.scale.set( SCALE );
if (Badges.isUnlocked( cl.masteryBadge() )) {
normal = MASTERY_NORMAL;
highlighted = MASTERY_HIGHLIGHTED;
} else {
normal = BASIC_NORMAL;
highlighted = BASIC_HIGHLIGHTED;
}
name.text( cl.name() ); name.text( cl.name() );
name.measure(); name.measure();
name.hardlight( normal );
brightness = MIN_BRIGHTNESS; brightness = MIN_BRIGHTNESS;
updateBrightness(); updateBrightness();
@ -385,10 +462,10 @@ public class StartScene extends PixelScene {
public void highlight( boolean value ) { public void highlight( boolean value ) {
if (value) { if (value) {
brightness = 1.0f; brightness = 1.0f;
name.hardlight( 0xCACFC2 ); name.hardlight( highlighted );
} else { } else {
brightness = 0.999f; brightness = 0.999f;
name.hardlight( 0x444444 ); name.hardlight( normal );
} }
updateBrightness(); updateBrightness();
@ -433,7 +510,7 @@ public class StartScene extends PixelScene {
@Override @Override
protected void onClick() { protected void onClick() {
if (Badges.isUnlocked( Badges.Badge.VICTORY )) { if (Badges.isUnlocked( Badges.Badge.VICTORY )) {
add( new WndChallenges( ShatteredPixelDungeon.challenges(), true ) { StartScene.this.add(new WndChallenges(ShatteredPixelDungeon.challenges(), true) {
public void onBackPressed() { public void onBackPressed() {
super.onBackPressed(); super.onBackPressed();
image.copy( Icons.get( ShatteredPixelDungeon.challenges() > 0 ? image.copy( Icons.get( ShatteredPixelDungeon.challenges() > 0 ?
@ -441,7 +518,7 @@ public class StartScene extends PixelScene {
}; };
} ); } );
} else { } else {
add( new WndMessage( TXT_WIN_THE_GAME ) ); StartScene.this.add( new WndMessage( TXT_WIN_THE_GAME ) );
} }
} }

View File

@ -46,10 +46,18 @@ import com.watabou.utils.Point;
import com.watabou.utils.Random; import com.watabou.utils.Random;
public class SurfaceScene extends PixelScene { public class SurfaceScene extends PixelScene {
private static final int WIDTH = 80; private static final int FRAME_WIDTH = 88;
private static final int HEIGHT = 112; private static final int FRAME_HEIGHT = 125;
private static final int FRAME_MARGIN_TOP = 9;
private static final int FRAME_MARGIN_X = 4;
private static final int BUTTON_HEIGHT = 20;
private static final int SKY_WIDTH = 80;
private static final int SKY_HEIGHT = 112;
private static final int NSTARS = 100; private static final int NSTARS = 100;
private static final int NCLOUDS = 5; private static final int NCLOUDS = 5;
@ -71,12 +79,12 @@ public class SurfaceScene extends PixelScene {
archs.reversed = true; archs.reversed = true;
archs.setSize( w, h ); archs.setSize( w, h );
add( archs ); add( archs );
float vx = align( (w - WIDTH) / 2 ); float vx = align( (w - SKY_WIDTH) / 2 );
float vy = align( (h - HEIGHT) / 2 ); float vy = align( (h - SKY_HEIGHT - BUTTON_HEIGHT) / 2 );
Point s = Camera.main.cameraToScreen( vx, vy ); Point s = Camera.main.cameraToScreen( vx, vy );
viewport = new Camera( s.x, s.y, WIDTH, HEIGHT, defaultZoom ); viewport = new Camera( s.x, s.y, SKY_WIDTH, SKY_HEIGHT, defaultZoom );
Camera.add( viewport ); Camera.add( viewport );
Group window = new Group(); Group window = new Group();
@ -86,21 +94,21 @@ public class SurfaceScene extends PixelScene {
boolean dayTime = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 7; boolean dayTime = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 7;
Sky sky = new Sky( dayTime ); Sky sky = new Sky( dayTime );
sky.scale.set( WIDTH, HEIGHT ); sky.scale.set( SKY_WIDTH, SKY_HEIGHT );
window.add( sky ); window.add( sky );
if (!dayTime) { if (!dayTime) {
for (int i=0; i < NSTARS; i++) { for (int i=0; i < NSTARS; i++) {
float size = Random.Float(); float size = Random.Float();
ColorBlock star = new ColorBlock( size, size, 0xFFFFFFFF ); ColorBlock star = new ColorBlock( size, size, 0xFFFFFFFF );
star.x = Random.Float( WIDTH ) - size / 2; star.x = Random.Float( SKY_WIDTH ) - size / 2;
star.y = Random.Float( HEIGHT ) - size / 2; star.y = Random.Float( SKY_HEIGHT ) - size / 2;
star.am = size * (1 - star.y / HEIGHT); star.am = size * (1 - star.y / SKY_HEIGHT);
window.add( star ); window.add( star );
} }
} }
float range = HEIGHT * 2 / 3; float range = SKY_HEIGHT * 2 / 3;
for (int i=0; i < NCLOUDS; i++) { for (int i=0; i < NCLOUDS; i++) {
Cloud cloud = new Cloud( (NCLOUDS - 1 - i) * (range / NCLOUDS) + Random.Float( range / NCLOUDS ), dayTime ); Cloud cloud = new Cloud( (NCLOUDS - 1 - i) * (range / NCLOUDS) + Random.Float( range / NCLOUDS ), dayTime );
window.add( cloud ); window.add( cloud );
@ -109,7 +117,7 @@ public class SurfaceScene extends PixelScene {
int nPatches = (int)(sky.width() / GrassPatch.WIDTH + 1); int nPatches = (int)(sky.width() / GrassPatch.WIDTH + 1);
for (int i=0; i < nPatches * 4; i++) { for (int i=0; i < nPatches * 4; i++) {
GrassPatch patch = new GrassPatch( (i - 0.75f) * GrassPatch.WIDTH / 4, HEIGHT + 1, dayTime ); GrassPatch patch = new GrassPatch( (i - 0.75f) * GrassPatch.WIDTH / 4, SKY_HEIGHT + 1, dayTime );
patch.brightness( dayTime ? 0.7f : 0.4f ); patch.brightness( dayTime ? 0.7f : 0.4f );
window.add( patch ); window.add( patch );
} }
@ -117,21 +125,16 @@ public class SurfaceScene extends PixelScene {
Avatar a = new Avatar( Dungeon.hero.heroClass ); Avatar a = new Avatar( Dungeon.hero.heroClass );
// Removing semitransparent contour // Removing semitransparent contour
a.am = 2; a.aa = -1; a.am = 2; a.aa = -1;
a.x = PixelScene.align( (WIDTH - a.width) / 2 ); a.x = PixelScene.align( (SKY_WIDTH - a.width) / 2 );
a.y = HEIGHT - a.height + 1; a.y = SKY_HEIGHT - a.height;
window.add( a ); window.add( a );
final Pet pet = new Pet(); final Pet pet = new Pet();
pet.rm = pet.gm = pet.bm = 1.2f; pet.rm = pet.gm = pet.bm = 1.2f;
pet.x = WIDTH / 2 + 2; pet.x = SKY_WIDTH / 2 + 2;
pet.y = HEIGHT - pet.height; pet.y = SKY_HEIGHT - pet.height;
window.add( pet ); window.add( pet );
if (dayTime) {
a.brightness( 1.2f );
pet.brightness( 1.2f );
}
window.add( new TouchArea( sky ) { window.add( new TouchArea( sky ) {
protected void onClick( Touch touch ) { protected void onClick( Touch touch ) {
pet.jump(); pet.jump();
@ -139,27 +142,32 @@ public class SurfaceScene extends PixelScene {
} ); } );
for (int i=0; i < nPatches; i++) { for (int i=0; i < nPatches; i++) {
GrassPatch patch = new GrassPatch( (i - 0.5f) * GrassPatch.WIDTH, HEIGHT, dayTime ); GrassPatch patch = new GrassPatch( (i - 0.5f) * GrassPatch.WIDTH, SKY_HEIGHT, dayTime );
patch.brightness( dayTime ? 1.0f : 0.8f ); patch.brightness( dayTime ? 1.0f : 0.8f );
window.add( patch ); window.add( patch );
} }
Image frame = new Image( Assets.SURFACE ); Image frame = new Image( Assets.SURFACE );
if (!dayTime) {
frame.frame( 0, 0, FRAME_WIDTH, FRAME_HEIGHT );
frame.x = vx - FRAME_MARGIN_X;
frame.y = vy - FRAME_MARGIN_TOP;
add( frame );
if (dayTime) {
a.brightness( 1.2f );
pet.brightness( 1.2f );
} else {
frame.hardlight( 0xDDEEFF ); frame.hardlight( 0xDDEEFF );
} }
frame.frame( 0, 0, 88, 125 );
frame.x = vx - 4;
frame.y = vy - 9;
add( frame );
RedButton gameOver = new RedButton( "Game Over" ) { RedButton gameOver = new RedButton( "Game Over" ) {
protected void onClick() { protected void onClick() {
Game.switchScene( TitleScene.class ); Game.switchScene( TitleScene.class );
} }
}; };
gameOver.setSize( WIDTH - 10, 20 ); gameOver.setSize( SKY_WIDTH - FRAME_MARGIN_X * 2, BUTTON_HEIGHT );
gameOver.setPos( 5 + frame.x + 4, frame.y + frame.height + 4 ); gameOver.setPos( frame.x + FRAME_MARGIN_X * 2, frame.y + frame.height + 4 );
add( gameOver ); add( gameOver );
Badges.validateHappyEnd(); Badges.validateHappyEnd();
@ -269,9 +277,9 @@ public class SurfaceScene extends PixelScene {
lastIndex = index; lastIndex = index;
this.y = y; this.y = y;
scale.set( 1 - y / HEIGHT ); scale.set( 1 - y / SKY_HEIGHT );
x = Random.Float( WIDTH + width() ) - width(); x = Random.Float( SKY_WIDTH + width() ) - width();
speed.x = scale.x * (dayTime ? +8 : -8); speed.x = scale.x * (dayTime ? +8 : -8);
if (dayTime) { if (dayTime) {
@ -285,10 +293,10 @@ public class SurfaceScene extends PixelScene {
@Override @Override
public void update() { public void update() {
super.update(); super.update();
if (speed.x > 0 && x > WIDTH) { if (speed.x > 0 && x > SKY_WIDTH) {
x = -width(); x = -width();
} else if (speed.x < 0 && x < -width()) { } else if (speed.x < 0 && x < -width()) {
x = WIDTH; x = SKY_WIDTH;
} }
} }
} }

View File

@ -17,6 +17,10 @@
*/ */
package com.shatteredpixel.shatteredpixeldungeon.scenes; package com.shatteredpixel.shatteredpixeldungeon.scenes;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLES20;
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;
@ -63,20 +67,39 @@ public class TitleScene extends PixelScene {
int w = Camera.main.width; int w = Camera.main.width;
int h = Camera.main.height; int h = Camera.main.height;
float height = 180;
Archs archs = new Archs(); Archs archs = new Archs();
archs.setSize( w, h ); archs.setSize( w, h );
add( archs ); add( archs );
Image title = BannerSprites.get( BannerSprites.Type.PIXEL_DUNGEON ); Image title = BannerSprites.get( BannerSprites.Type.PIXEL_DUNGEON );
add( title ); add( title );
float height = title.height +
(ShatteredPixelDungeon.landscape() ? DashboardItem.SIZE : DashboardItem.SIZE * 2);
title.x = (w - title.width()) / 2; title.x = (w - title.width()) / 2;
title.y = (h - height) / 2; title.y = (h - height) / 2;
placeTorch( title.x + 18, title.y + 20 ); placeTorch( title.x + 18, title.y + 20 );
placeTorch( title.x + title.width - 18, title.y + 20 ); placeTorch( title.x + title.width - 18, title.y + 20 );
Image signs = new Image( BannerSprites.get( BannerSprites.Type.PIXEL_DUNGEON_SIGNS ) ) {
private float time = 0;
@Override
public void update() {
super.update();
am = (float)Math.sin( -(time += Game.elapsed) );
}
@Override
public void draw() {
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE );
super.draw();
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA );
}
};
signs.x = title.x;
signs.y = title.y;
add( signs );
DashboardItem btnBadges = new DashboardItem( TXT_BADGES, 3 ) { DashboardItem btnBadges = new DashboardItem( TXT_BADGES, 3 ) {
@Override @Override
@ -84,7 +107,6 @@ public class TitleScene extends PixelScene {
ShatteredPixelDungeon.switchNoFade( BadgesScene.class ); ShatteredPixelDungeon.switchNoFade( BadgesScene.class );
} }
}; };
btnBadges.setPos( w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE );
add( btnBadges ); add( btnBadges );
DashboardItem btnAbout = new DashboardItem( TXT_ABOUT, 1 ) { DashboardItem btnAbout = new DashboardItem( TXT_ABOUT, 1 ) {
@ -93,7 +115,6 @@ public class TitleScene extends PixelScene {
ShatteredPixelDungeon.switchNoFade( AboutScene.class ); ShatteredPixelDungeon.switchNoFade( AboutScene.class );
} }
}; };
btnAbout.setPos( w / 2, (h + height) / 2 - DashboardItem.SIZE );
add( btnAbout ); add( btnAbout );
DashboardItem btnPlay = new DashboardItem( TXT_PLAY, 0 ) { DashboardItem btnPlay = new DashboardItem( TXT_PLAY, 0 ) {
@ -102,7 +123,6 @@ public class TitleScene extends PixelScene {
ShatteredPixelDungeon.switchNoFade( StartScene.class ); ShatteredPixelDungeon.switchNoFade( StartScene.class );
} }
}; };
btnPlay.setPos( w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE );
add( btnPlay ); add( btnPlay );
DashboardItem btnHighscores = new DashboardItem( TXT_HIGHSCORES, 2 ) { DashboardItem btnHighscores = new DashboardItem( TXT_HIGHSCORES, 2 ) {
@ -111,10 +131,22 @@ public class TitleScene extends PixelScene {
ShatteredPixelDungeon.switchNoFade( RankingsScene.class ); ShatteredPixelDungeon.switchNoFade( RankingsScene.class );
} }
}; };
btnHighscores.setPos( w / 2, btnPlay.top() );
add( btnHighscores ); add( btnHighscores );
BitmapText source = new BitmapText( "PD source v 1.7.2a", font1x ); if (ShatteredPixelDungeon.landscape()) {
float y = (h + height) / 2 - DashboardItem.SIZE;
btnHighscores .setPos( w / 2 - btnHighscores.width(), y );
btnBadges .setPos( w / 2, y );
btnPlay .setPos( btnHighscores.left() - btnPlay.width(), y );
btnAbout .setPos( btnBadges.right(), y );
} else {
btnBadges.setPos( w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE );
btnAbout.setPos( w / 2, (h + height) / 2 - DashboardItem.SIZE );
btnPlay.setPos( w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE );
btnHighscores.setPos( w / 2, btnPlay.top() );
}
BitmapText source = new BitmapText( "PD source v 1.7.5a", font1x );
source.measure(); source.measure();
source.hardlight( 0x444444 ); source.hardlight( 0x444444 );
source.x = w - source.width(); source.x = w - source.width();

View File

@ -10,6 +10,7 @@ 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;
//FIXME: overhaul this in this update
public class WelcomeScene extends PixelScene { public class WelcomeScene extends PixelScene {
private static final String TTL_Welcome = "Welcome!"; private static final String TTL_Welcome = "Welcome!";