Merging 1.9.1 source: scene changes
This commit is contained in:
parent
c36f6d4bcf
commit
46a0f2b319
|
@ -20,28 +20,30 @@
|
||||||
*/
|
*/
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
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.BitmapText;
|
||||||
import com.watabou.noosa.Camera;
|
import com.watabou.noosa.Camera;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
import com.watabou.noosa.NinePatch;
|
import com.watabou.noosa.Image;
|
||||||
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.ShatteredPixelDungeon;
|
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.ExitButton;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
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.Callback;
|
||||||
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
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() {
|
||||||
|
|
||||||
|
@ -59,32 +61,38 @@ public class BadgesScene extends PixelScene {
|
||||||
archs.setSize( w, h );
|
archs.setSize( w, h );
|
||||||
add( archs );
|
add( archs );
|
||||||
|
|
||||||
int pw = Math.min( MAX_PANE_WIDTH, w - 6 );
|
float pw = Math.min( w, (ShatteredPixelDungeon.landscape() ? MIN_WIDTH_L : MIN_WIDTH_P) * 3 ) - 16;
|
||||||
int ph = h - 30;
|
float ph = Math.min( h, (ShatteredPixelDungeon.landscape() ? MIN_HEIGHT_L : MIN_HEIGHT_P) * 3 ) - 32;
|
||||||
|
|
||||||
NinePatch panel = Chrome.get( Chrome.Type.WINDOW );
|
float size = (float)Math.sqrt( pw * ph / 27f );
|
||||||
panel.size( pw, ph );
|
int nCols = (int)Math.ceil( pw / size );
|
||||||
panel.x = (w - pw) / 2;
|
int nRows = (int)Math.ceil( ph / size );
|
||||||
panel.y = (h - ph) / 2;
|
size = Math.min( pw / nCols, ph / nRows );
|
||||||
add( panel );
|
|
||||||
|
float left = (w - size * nCols) / 2;
|
||||||
|
float top = (h - size * nRows) / 2;
|
||||||
|
|
||||||
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 = (w - title.width()) / 2;
|
title.x = (w - title.width()) / 2 ;
|
||||||
title.y = (panel.y - title.baseLine()) / 2;
|
title.y = (top - title.baseLine()) / 2 ;
|
||||||
add( title );
|
add(title);
|
||||||
|
|
||||||
Badges.loadGlobal();
|
Badges.loadGlobal();
|
||||||
|
|
||||||
ScrollPane list = new BadgesList( true );
|
List<Badges.Badge> badges = Badges.filtered( true );
|
||||||
add( list );
|
for (int i=0; i < nRows; i++) {
|
||||||
|
for (int j=0; j < nCols; j++) {
|
||||||
list.setRect(
|
int index = i * nCols + j;
|
||||||
panel.x + panel.marginLeft(),
|
Badges.Badge b = index < badges.size() ? badges.get( index ) : null;
|
||||||
panel.y + panel.marginTop(),
|
BadgeButton button = new BadgeButton( b );
|
||||||
panel.innerWidth(),
|
button.setPos(
|
||||||
panel.innerHeight() );
|
left + j * size + (size - button.width()) / 2,
|
||||||
|
top + i * size + (size - button.height()) / 2);
|
||||||
|
add( button );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ExitButton btnExit = new ExitButton();
|
ExitButton btnExit = new ExitButton();
|
||||||
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
|
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
|
||||||
|
@ -115,4 +123,46 @@ public class BadgesScene extends PixelScene {
|
||||||
protected void onBackPressed() {
|
protected void onBackPressed() {
|
||||||
ShatteredPixelDungeon.switchNoFade( TitleScene.class );
|
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 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,33 +276,6 @@ public class GameScene extends PixelScene {
|
||||||
|
|
||||||
layoutTags();
|
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 = new BusyIndicator();
|
||||||
busy.camera = uiCamera;
|
busy.camera = uiCamera;
|
||||||
busy.x = 1;
|
busy.x = 1;
|
||||||
|
@ -344,7 +317,6 @@ public class GameScene extends PixelScene {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
InterlevelScene.mode = InterlevelScene.Mode.CONTINUE;
|
|
||||||
|
|
||||||
ArrayList<Item> dropped = Dungeon.droppedItems.get( Dungeon.depth );
|
ArrayList<Item> dropped = Dungeon.droppedItems.get( Dungeon.depth );
|
||||||
if (dropped != null) {
|
if (dropped != null) {
|
||||||
|
@ -366,7 +338,39 @@ public class GameScene extends PixelScene {
|
||||||
Dungeon.hero.next();
|
Dungeon.hero.next();
|
||||||
|
|
||||||
Camera.main.target = hero;
|
Camera.main.target = hero;
|
||||||
fadeIn();
|
|
||||||
|
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() {
|
public void destroy() {
|
||||||
|
|
|
@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndError;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndError;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory;
|
||||||
import com.watabou.noosa.BitmapText;
|
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.";
|
"it may mean this save game is corrupted. Sorry about that.";
|
||||||
|
|
||||||
public static enum Mode {
|
public static enum Mode {
|
||||||
DESCEND, ASCEND, CONTINUE, RESURRECT, RETURN, FALL, RESET
|
DESCEND, ASCEND, CONTINUE, RESURRECT, RETURN, FALL, RESET, NONE
|
||||||
};
|
};
|
||||||
public static Mode mode;
|
public static Mode mode;
|
||||||
|
|
||||||
|
@ -227,6 +228,7 @@ public class InterlevelScene extends PixelScene {
|
||||||
Dungeon.chapters.add( WndStory.ID_SEWERS );
|
Dungeon.chapters.add( WndStory.ID_SEWERS );
|
||||||
noStory = false;
|
noStory = false;
|
||||||
}
|
}
|
||||||
|
GameLog.wipe();
|
||||||
} else {
|
} else {
|
||||||
Dungeon.saveLevel();
|
Dungeon.saveLevel();
|
||||||
}
|
}
|
||||||
|
@ -279,6 +281,8 @@ public class InterlevelScene extends PixelScene {
|
||||||
|
|
||||||
Actor.fixTime();
|
Actor.fixTime();
|
||||||
|
|
||||||
|
GameLog.wipe();
|
||||||
|
|
||||||
Dungeon.loadGame( StartScene.curClass );
|
Dungeon.loadGame( StartScene.curClass );
|
||||||
if (Dungeon.depth == -1) {
|
if (Dungeon.depth == -1) {
|
||||||
Dungeon.depth = Statistics.deepestFloor;
|
Dungeon.depth = Statistics.deepestFloor;
|
||||||
|
|
|
@ -29,6 +29,7 @@ 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.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
|
import com.watabou.noosa.particles.BitmaskEmitter;
|
||||||
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.Assets;
|
||||||
|
@ -421,7 +422,7 @@ public class StartScene extends PixelScene {
|
||||||
name = PixelScene.createText( 9 );
|
name = PixelScene.createText( 9 );
|
||||||
add( name );
|
add( name );
|
||||||
|
|
||||||
emitter = new Emitter();
|
emitter = new BitmaskEmitter( avatar );
|
||||||
add( emitter );
|
add( emitter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,7 +437,6 @@ public class StartScene extends PixelScene {
|
||||||
name.x = x + (width - name.width()) / 2;
|
name.x = x + (width - name.width()) / 2;
|
||||||
name.y = avatar.y + avatar.height() + SCALE;
|
name.y = avatar.y + avatar.height() + SCALE;
|
||||||
|
|
||||||
emitter.pos( avatar.x, avatar.y, avatar.width(), avatar.height() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user