Merging 1.9.1 source: scene changes

This commit is contained in:
Evan Debenham 2015-11-10 00:48:02 -05:00
parent c36f6d4bcf
commit 46a0f2b319
4 changed files with 116 additions and 58 deletions

View File

@ -20,28 +20,30 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.effects.BadgeBanner;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBadge;
import com.watabou.noosa.BitmapText;
import com.watabou.noosa.Camera;
import com.watabou.noosa.Game;
import com.watabou.noosa.NinePatch;
import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Music;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
import com.shatteredpixel.shatteredpixeldungeon.ui.BadgesList;
import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.ui.Button;
import com.watabou.utils.Callback;
import com.watabou.utils.Random;
import java.util.List;
public class BadgesScene extends PixelScene {
private static final String TXT_TITLE = "Your Badges";
private static final int MAX_PANE_WIDTH = 160;
@Override
public void create() {
@ -59,32 +61,38 @@ public class BadgesScene extends PixelScene {
archs.setSize( w, h );
add( archs );
int pw = Math.min( MAX_PANE_WIDTH, w - 6 );
int ph = h - 30;
float pw = Math.min( w, (ShatteredPixelDungeon.landscape() ? MIN_WIDTH_L : MIN_WIDTH_P) * 3 ) - 16;
float ph = Math.min( h, (ShatteredPixelDungeon.landscape() ? MIN_HEIGHT_L : MIN_HEIGHT_P) * 3 ) - 32;
NinePatch panel = Chrome.get( Chrome.Type.WINDOW );
panel.size( pw, ph );
panel.x = (w - pw) / 2;
panel.y = (h - ph) / 2;
add( panel );
float size = (float)Math.sqrt( pw * ph / 27f );
int nCols = (int)Math.ceil( pw / size );
int nRows = (int)Math.ceil( ph / size );
size = Math.min( pw / nCols, ph / nRows );
float left = (w - size * nCols) / 2;
float top = (h - size * nRows) / 2;
BitmapText title = PixelScene.createText( TXT_TITLE, 9 );
title.hardlight(Window.TITLE_COLOR);
title.measure();
title.x = (w - title.width()) / 2 ;
title.y = (panel.y - title.baseLine()) / 2;
title.y = (top - title.baseLine()) / 2 ;
add(title);
Badges.loadGlobal();
ScrollPane list = new BadgesList( true );
add( list );
list.setRect(
panel.x + panel.marginLeft(),
panel.y + panel.marginTop(),
panel.innerWidth(),
panel.innerHeight() );
List<Badges.Badge> badges = Badges.filtered( true );
for (int i=0; i < nRows; i++) {
for (int j=0; j < nCols; j++) {
int index = i * nCols + j;
Badges.Badge b = index < badges.size() ? badges.get( index ) : null;
BadgeButton button = new BadgeButton( b );
button.setPos(
left + j * size + (size - button.width()) / 2,
top + i * size + (size - button.height()) / 2);
add( button );
}
}
ExitButton btnExit = new ExitButton();
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
@ -115,4 +123,46 @@ public class BadgesScene extends PixelScene {
protected void onBackPressed() {
ShatteredPixelDungeon.switchNoFade( TitleScene.class );
}
private static class BadgeButton extends Button {
private Badges.Badge badge;
private Image icon;
public BadgeButton( Badges.Badge badge ) {
super();
this.badge = badge;
active = (badge != null);
icon = active ? BadgeBanner.image(badge.image) : new Image( Assets.LOCKED );
add(icon);
setSize( icon.width(), icon.height() );
}
@Override
protected void layout() {
super.layout();
icon.x = x + (width - icon.width()) / 2;
icon.y = y + (height - icon.height()) / 2;
}
@Override
public void update() {
super.update();
if (Random.Float() < Game.elapsed * 0.1) {
BadgeBanner.highlight( icon, badge.image );
}
}
@Override
protected void onClick() {
Sample.INSTANCE.play( Assets.SND_CLICK, 0.7f, 0.7f, 1.2f );
Game.scene().add( new WndBadge( badge ) );
}
}
}

View File

@ -276,33 +276,6 @@ public class GameScene extends PixelScene {
layoutTags();
if (Dungeon.depth < Statistics.deepestFloor) {
GLog.i(TXT_WELCOME_BACK, Dungeon.depth);
} else {
GLog.i(TXT_WELCOME, Dungeon.depth);
if (InterlevelScene.mode == InterlevelScene.Mode.DESCEND) Sample.INSTANCE.play(Assets.SND_DESCEND);
}
switch (Dungeon.level.feeling) {
case CHASM:
GLog.w( TXT_CHASM );
break;
case WATER:
GLog.w( TXT_WATER );
break;
case GRASS:
GLog.w( TXT_GRASS );
break;
case DARK:
GLog.w( TXT_DARK );
break;
default:
}
if (Dungeon.level instanceof RegularLevel &&
((RegularLevel)Dungeon.level).secretDoors > Random.IntRange( 3, 4 )) {
GLog.w( TXT_SECRETS );
}
busy = new BusyIndicator();
busy.camera = uiCamera;
busy.x = 1;
@ -344,7 +317,6 @@ public class GameScene extends PixelScene {
break;
default:
}
InterlevelScene.mode = InterlevelScene.Mode.CONTINUE;
ArrayList<Item> dropped = Dungeon.droppedItems.get( Dungeon.depth );
if (dropped != null) {
@ -366,8 +338,40 @@ public class GameScene extends PixelScene {
Dungeon.hero.next();
Camera.main.target = hero;
if (InterlevelScene.mode != InterlevelScene.Mode.NONE) {
if (Dungeon.depth < Statistics.deepestFloor) {
GLog.h(TXT_WELCOME_BACK, Dungeon.depth);
} else {
GLog.h(TXT_WELCOME, Dungeon.depth);
Sample.INSTANCE.play(Assets.SND_DESCEND);
}
switch (Dungeon.level.feeling) {
case CHASM:
GLog.w(TXT_CHASM);
break;
case WATER:
GLog.w(TXT_WATER);
break;
case GRASS:
GLog.w(TXT_GRASS);
break;
case DARK:
GLog.w(TXT_DARK);
break;
default:
}
if (Dungeon.level instanceof RegularLevel &&
((RegularLevel) Dungeon.level).secretDoors > Random.IntRange(3, 4)) {
GLog.w(TXT_SECRETS);
}
InterlevelScene.mode = InterlevelScene.Mode.NONE;
fadeIn();
}
}
public void destroy() {

View File

@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndError;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory;
import com.watabou.noosa.BitmapText;
@ -56,7 +57,7 @@ public class InterlevelScene extends PixelScene {
"it may mean this save game is corrupted. Sorry about that.";
public static enum Mode {
DESCEND, ASCEND, CONTINUE, RESURRECT, RETURN, FALL, RESET
DESCEND, ASCEND, CONTINUE, RESURRECT, RETURN, FALL, RESET, NONE
};
public static Mode mode;
@ -227,6 +228,7 @@ public class InterlevelScene extends PixelScene {
Dungeon.chapters.add( WndStory.ID_SEWERS );
noStory = false;
}
GameLog.wipe();
} else {
Dungeon.saveLevel();
}
@ -279,6 +281,8 @@ public class InterlevelScene extends PixelScene {
Actor.fixTime();
GameLog.wipe();
Dungeon.loadGame( StartScene.curClass );
if (Dungeon.depth == -1) {
Dungeon.depth = Statistics.deepestFloor;

View File

@ -29,6 +29,7 @@ import com.watabou.noosa.Game;
import com.watabou.noosa.Group;
import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.particles.BitmaskEmitter;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.ui.Button;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
@ -421,7 +422,7 @@ public class StartScene extends PixelScene {
name = PixelScene.createText( 9 );
add( name );
emitter = new Emitter();
emitter = new BitmaskEmitter( avatar );
add( emitter );
}
@ -436,7 +437,6 @@ public class StartScene extends PixelScene {
name.x = x + (width - name.width()) / 2;
name.y = avatar.y + avatar.height() + SCALE;
emitter.pos( avatar.x, avatar.y, avatar.width(), avatar.height() );
}
@Override