Merging 1.7.5 Source: scenes changes
This commit is contained in:
parent
a2670f2a36
commit
e2ee042c38
src/com/shatteredpixel/shatteredpixeldungeon/scenes
|
@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
|
||||
//FIXME: fix in landscape mode
|
||||
public class AboutScene extends PixelScene {
|
||||
|
||||
private static final String TTL_SHPX = "Shattered Pixel Dungeon";
|
||||
|
|
|
@ -19,6 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
|||
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.audio.Music;
|
||||
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.ScrollPane;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.utils.Callback;
|
||||
|
||||
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() {
|
||||
|
||||
|
||||
super.create();
|
||||
|
||||
|
||||
Music.INSTANCE.play( Assets.THEME, true );
|
||||
Music.INSTANCE.volume( 1f );
|
||||
|
||||
|
||||
uiCamera.visible = false;
|
||||
|
||||
|
||||
int w = Camera.main.width;
|
||||
int h = Camera.main.height;
|
||||
|
||||
|
||||
Archs archs = new Archs();
|
||||
archs.setSize( w, h );
|
||||
add( archs );
|
||||
|
||||
int pw = Math.min( 160, w - 6 );
|
||||
|
||||
int pw = Math.min( MAX_PANE_WIDTH, w - 6 );
|
||||
int ph = h - 30;
|
||||
|
||||
|
||||
NinePatch panel = Chrome.get( Chrome.Type.WINDOW );
|
||||
panel.size( pw, ph );
|
||||
panel.x = (w - pw) / 2;
|
||||
panel.y = (h - ph) / 2;
|
||||
add( panel );
|
||||
|
||||
|
||||
BitmapText title = PixelScene.createText( TXT_TITLE, 9 );
|
||||
title.hardlight( Window.TITLE_COLOR );
|
||||
title.measure();
|
||||
title.x = align( (w - title.width()) / 2 );
|
||||
title.y = align( (panel.y - 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() );
|
||||
|
||||
ExitButton btnExit = new ExitButton();
|
||||
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
|
||||
add( btnExit );
|
||||
|
||||
list.setRect(
|
||||
panel.x + panel.marginLeft(),
|
||||
panel.y + panel.marginTop(),
|
||||
panel.innerWidth(),
|
||||
panel.innerHeight() );
|
||||
|
||||
ExitButton btnExit = new ExitButton();
|
||||
btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
|
||||
add( btnExit );
|
||||
|
||||
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
|
||||
protected void onBackPressed() {
|
||||
ShatteredPixelDungeon.switchNoFade(TitleScene.class);
|
||||
ShatteredPixelDungeon.switchNoFade( TitleScene.class );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -603,7 +603,6 @@ public class GameScene extends PixelScene {
|
|||
@Override
|
||||
public void onSelect( Integer cell ) {
|
||||
if (Dungeon.hero.handle( cell )) {
|
||||
// Actor.next();
|
||||
Dungeon.hero.next();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,48 +119,6 @@ public class InterlevelScene extends PixelScene {
|
|||
|
||||
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) {
|
||||
case DESCEND:
|
||||
descend();
|
||||
|
@ -366,7 +324,7 @@ public class InterlevelScene extends PixelScene {
|
|||
if (Dungeon.level.locked) {
|
||||
Dungeon.hero.resurrect( Dungeon.depth );
|
||||
Dungeon.depth--;
|
||||
Level level = Dungeon.newLevel(/* true */);
|
||||
Level level = Dungeon.newLevel();
|
||||
Dungeon.switchLevel( level, level.entrance );
|
||||
} else {
|
||||
Dungeon.hero.resurrect( -1 );
|
||||
|
@ -376,5 +334,6 @@ public class InterlevelScene extends PixelScene {
|
|||
|
||||
@Override
|
||||
protected void onBackPressed() {
|
||||
//Do nothing
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
|||
import com.watabou.input.Touchscreen;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.BitmapText.Font;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.BitmapTextMultiline;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
|
@ -38,16 +37,19 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.BadgeBanner;
|
|||
import com.watabou.utils.BitmapCache;
|
||||
|
||||
public class PixelScene extends Scene {
|
||||
|
||||
public static final float MIN_WIDTH = 128;
|
||||
public static final float MIN_HEIGHT = 224;
|
||||
|
||||
|
||||
// Minimum virtual display size for portrait orientation
|
||||
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 minZoom;
|
||||
public static float maxZoom;
|
||||
|
||||
public static boolean landscapeAvailable;
|
||||
|
||||
public static Camera uiCamera;
|
||||
|
||||
public static BitmapText.Font font1x;
|
||||
|
@ -62,23 +64,30 @@ public class PixelScene extends Scene {
|
|||
super.create();
|
||||
|
||||
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 );
|
||||
while ((
|
||||
Game.width / defaultZoom < MIN_WIDTH ||
|
||||
Game.height / defaultZoom < MIN_HEIGHT
|
||||
Game.width / defaultZoom < minWidth ||
|
||||
Game.height / defaultZoom < minHeight
|
||||
) && defaultZoom > 1) {
|
||||
|
||||
defaultZoom--;
|
||||
}
|
||||
|
||||
landscapeAvailable =
|
||||
Game.height / defaultZoom >= MIN_WIDTH &&
|
||||
Game.width / defaultZoom >= MIN_HEIGHT;
|
||||
|
||||
if (ShatteredPixelDungeon.scaleUp()) {
|
||||
while ((Game.width / (defaultZoom + 1) >= MIN_WIDTH && Game.height / (defaultZoom + 1) >= MIN_HEIGHT)) {
|
||||
defaultZoom++;
|
||||
while (
|
||||
Game.width / (defaultZoom + 1) >= minWidth &&
|
||||
Game.height / (defaultZoom + 1) >= minHeight) {
|
||||
defaultZoom++;
|
||||
}
|
||||
}
|
||||
minZoom = 1;
|
||||
|
@ -123,11 +132,6 @@ public class PixelScene extends Scene {
|
|||
font3x.baseLine = 17;
|
||||
font3x.tracking = -2;
|
||||
}
|
||||
|
||||
Sample.INSTANCE.load(
|
||||
Assets.SND_CLICK,
|
||||
Assets.SND_BADGE,
|
||||
Assets.SND_GOLD );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -140,9 +144,13 @@ public class PixelScene extends Scene {
|
|||
public static float scale;
|
||||
|
||||
public static void chooseFont( float size ) {
|
||||
|
||||
float pt = size * defaultZoom;
|
||||
|
||||
chooseFont( size, defaultZoom );
|
||||
}
|
||||
|
||||
public static void chooseFont( float size, float zoom ) {
|
||||
|
||||
float pt = size * zoom;
|
||||
|
||||
if (pt >= 19) {
|
||||
|
||||
scale = pt / 19;
|
||||
|
@ -194,7 +202,7 @@ public class PixelScene extends Scene {
|
|||
|
||||
}
|
||||
|
||||
scale /= defaultZoom;
|
||||
scale /= zoom;
|
||||
}
|
||||
|
||||
public static BitmapText createText( float size ) {
|
||||
|
@ -228,7 +236,8 @@ public class PixelScene extends Scene {
|
|||
public static float align( Camera camera, float pos ) {
|
||||
return ((int)(pos * camera.zoom)) / camera.zoom;
|
||||
}
|
||||
|
||||
|
||||
// This one should be used for UI elements
|
||||
public static float align( float pos ) {
|
||||
return ((int)(pos * defaultZoom)) / defaultZoom;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndError;
|
||||
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 {
|
||||
|
||||
private static final String TXT_TITLE = "Top Rankings";
|
||||
|
|
|
@ -46,6 +46,7 @@ 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.watabou.utils.Callback;
|
||||
|
||||
public class StartScene extends PixelScene {
|
||||
|
||||
|
@ -68,11 +69,17 @@ public class StartScene extends PixelScene {
|
|||
private static final String TXT_WIN_THE_GAME =
|
||||
"To unlock \"Challenges\", win the game with any character class.";
|
||||
|
||||
private static final float WIDTH = 116;
|
||||
private static final float HEIGHT = 220;
|
||||
private static final float WIDTH_P = 116;
|
||||
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 float buttonX;
|
||||
private float buttonY;
|
||||
|
||||
private GameButton btnLoad;
|
||||
private GameButton btnNewGame;
|
||||
|
||||
|
@ -93,8 +100,17 @@ public class StartScene extends PixelScene {
|
|||
int w = Camera.main.width;
|
||||
int h = Camera.main.height;
|
||||
|
||||
float left = (w - WIDTH) / 2;
|
||||
float top = (h - HEIGHT) / 2;
|
||||
float width, height;
|
||||
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;
|
||||
|
||||
Archs archs = new Archs();
|
||||
|
@ -103,9 +119,12 @@ public class StartScene extends PixelScene {
|
|||
|
||||
Image title = BannerSprites.get( Type.SELECT_YOUR_HERO );
|
||||
title.x = align( (w - title.width()) / 2 );
|
||||
title.y = top;
|
||||
title.y = align( top );
|
||||
add( title );
|
||||
|
||||
buttonX = left;
|
||||
buttonY = bottom - BUTTON_HEIGHT;
|
||||
|
||||
btnNewGame = new GameButton( TXT_NEW ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
|
@ -135,43 +154,66 @@ public class StartScene extends PixelScene {
|
|||
};
|
||||
add( btnLoad );
|
||||
|
||||
float centralHeight = buttonY - title.y - title.height();
|
||||
|
||||
HeroClass[] classes = {
|
||||
HeroClass.WARRIOR, HeroClass.MAGE, HeroClass.ROGUE, HeroClass.HUNTRESS
|
||||
};
|
||||
float shieldW = WIDTH / 2;
|
||||
float shieldH = Math.min( (bottom - BUTTON_HEIGHT - title.y - title.height()) / 2, shieldW * 1.2f );
|
||||
top = (bottom - BUTTON_HEIGHT + title.y + title.height() - shieldH * 2) / 2;
|
||||
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 );
|
||||
for (HeroClass cl : classes) {
|
||||
ClassShield shield = new ClassShield( cl );
|
||||
shields.put( cl, 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();
|
||||
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 ))) {
|
||||
|
||||
BitmapTextMultiline text = PixelScene.createMultiline( TXT_UNLOCK, 9 );
|
||||
text.maxWidth = (int)WIDTH;
|
||||
text.maxWidth = (int)width;
|
||||
text.measure();
|
||||
|
||||
float pos = (bottom - BUTTON_HEIGHT) + (BUTTON_HEIGHT - text.height()) / 2;
|
||||
for (BitmapText line : text.new LineSplitter().split()) {
|
||||
line.measure();
|
||||
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 );
|
||||
unlock.add( line );
|
||||
|
||||
|
@ -187,6 +229,25 @@ public class StartScene extends PixelScene {
|
|||
updateClass( HeroClass.values()[ShatteredPixelDungeon.lastClass()] );
|
||||
|
||||
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 ) {
|
||||
|
@ -205,31 +266,27 @@ public class StartScene extends PixelScene {
|
|||
|
||||
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 );
|
||||
if (info != null) {
|
||||
|
||||
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.secondary( TXT_ERASE );
|
||||
btnNewGame.secondary( TXT_ERASE, false );
|
||||
|
||||
float w = (WIDTH - GAP) / 2;
|
||||
float w = (Camera.main.width - GAP) / 2 - buttonX;
|
||||
|
||||
btnLoad.setRect(
|
||||
left, buttonPos, w, BUTTON_HEIGHT );
|
||||
buttonX, buttonY, w, BUTTON_HEIGHT );
|
||||
btnNewGame.setRect(
|
||||
btnLoad.right() + GAP, buttonPos, w, BUTTON_HEIGHT );
|
||||
btnLoad.right() + GAP, buttonY, w, BUTTON_HEIGHT );
|
||||
|
||||
} else {
|
||||
btnLoad.visible = false;
|
||||
|
||||
btnNewGame.visible = true;
|
||||
btnNewGame.secondary( null );
|
||||
btnNewGame.setRect( left, buttonPos, WIDTH, BUTTON_HEIGHT );
|
||||
btnNewGame.secondary( null, false );
|
||||
btnNewGame.setRect( buttonX, buttonY, Camera.main.width - buttonX * 2, BUTTON_HEIGHT );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -261,7 +318,8 @@ public class StartScene extends PixelScene {
|
|||
|
||||
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;
|
||||
|
||||
|
@ -276,7 +334,6 @@ public class StartScene extends PixelScene {
|
|||
super.createChildren();
|
||||
|
||||
secondary = createText( 6 );
|
||||
secondary.hardlight( SECONDARY_COLOR );
|
||||
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.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 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 HEIGHT = 32;
|
||||
private static final float SCALE = 1.75f;
|
||||
|
@ -316,6 +381,9 @@ public class StartScene extends PixelScene {
|
|||
|
||||
private float brightness;
|
||||
|
||||
private int normal;
|
||||
private int highlighted;
|
||||
|
||||
public ClassShield( HeroClass cl ) {
|
||||
super();
|
||||
|
||||
|
@ -324,8 +392,17 @@ public class StartScene extends PixelScene {
|
|||
avatar.frame( cl.ordinal() * WIDTH, 0, WIDTH, HEIGHT );
|
||||
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.measure();
|
||||
name.hardlight( normal );
|
||||
|
||||
brightness = MIN_BRIGHTNESS;
|
||||
updateBrightness();
|
||||
|
@ -385,10 +462,10 @@ public class StartScene extends PixelScene {
|
|||
public void highlight( boolean value ) {
|
||||
if (value) {
|
||||
brightness = 1.0f;
|
||||
name.hardlight( 0xCACFC2 );
|
||||
name.hardlight( highlighted );
|
||||
} else {
|
||||
brightness = 0.999f;
|
||||
name.hardlight( 0x444444 );
|
||||
name.hardlight( normal );
|
||||
}
|
||||
|
||||
updateBrightness();
|
||||
|
@ -433,7 +510,7 @@ public class StartScene extends PixelScene {
|
|||
@Override
|
||||
protected void onClick() {
|
||||
if (Badges.isUnlocked( Badges.Badge.VICTORY )) {
|
||||
add( new WndChallenges( ShatteredPixelDungeon.challenges(), true ) {
|
||||
StartScene.this.add(new WndChallenges(ShatteredPixelDungeon.challenges(), true) {
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
image.copy( Icons.get( ShatteredPixelDungeon.challenges() > 0 ?
|
||||
|
@ -441,7 +518,7 @@ public class StartScene extends PixelScene {
|
|||
};
|
||||
} );
|
||||
} else {
|
||||
add( new WndMessage( TXT_WIN_THE_GAME ) );
|
||||
StartScene.this.add( new WndMessage( TXT_WIN_THE_GAME ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,10 +46,18 @@ import com.watabou.utils.Point;
|
|||
import com.watabou.utils.Random;
|
||||
|
||||
public class SurfaceScene extends PixelScene {
|
||||
|
||||
private static final int WIDTH = 80;
|
||||
private static final int HEIGHT = 112;
|
||||
|
||||
|
||||
private static final int FRAME_WIDTH = 88;
|
||||
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 NCLOUDS = 5;
|
||||
|
||||
|
@ -71,12 +79,12 @@ public class SurfaceScene extends PixelScene {
|
|||
archs.reversed = true;
|
||||
archs.setSize( w, h );
|
||||
add( archs );
|
||||
|
||||
float vx = align( (w - WIDTH) / 2 );
|
||||
float vy = align( (h - HEIGHT) / 2 );
|
||||
|
||||
|
||||
float vx = align( (w - SKY_WIDTH) / 2 );
|
||||
float vy = align( (h - SKY_HEIGHT - BUTTON_HEIGHT) / 2 );
|
||||
|
||||
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 );
|
||||
|
||||
Group window = new Group();
|
||||
|
@ -86,21 +94,21 @@ public class SurfaceScene extends PixelScene {
|
|||
boolean dayTime = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 7;
|
||||
|
||||
Sky sky = new Sky( dayTime );
|
||||
sky.scale.set( WIDTH, HEIGHT );
|
||||
sky.scale.set( SKY_WIDTH, SKY_HEIGHT );
|
||||
window.add( sky );
|
||||
|
||||
if (!dayTime) {
|
||||
for (int i=0; i < NSTARS; i++) {
|
||||
float size = Random.Float();
|
||||
ColorBlock star = new ColorBlock( size, size, 0xFFFFFFFF );
|
||||
star.x = Random.Float( WIDTH ) - size / 2;
|
||||
star.y = Random.Float( HEIGHT ) - size / 2;
|
||||
star.am = size * (1 - star.y / HEIGHT);
|
||||
star.x = Random.Float( SKY_WIDTH ) - size / 2;
|
||||
star.y = Random.Float( SKY_HEIGHT ) - size / 2;
|
||||
star.am = size * (1 - star.y / SKY_HEIGHT);
|
||||
window.add( star );
|
||||
}
|
||||
}
|
||||
|
||||
float range = HEIGHT * 2 / 3;
|
||||
float range = SKY_HEIGHT * 2 / 3;
|
||||
for (int i=0; i < NCLOUDS; i++) {
|
||||
Cloud cloud = new Cloud( (NCLOUDS - 1 - i) * (range / NCLOUDS) + Random.Float( range / NCLOUDS ), dayTime );
|
||||
window.add( cloud );
|
||||
|
@ -109,7 +117,7 @@ public class SurfaceScene extends PixelScene {
|
|||
int nPatches = (int)(sky.width() / GrassPatch.WIDTH + 1);
|
||||
|
||||
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 );
|
||||
window.add( patch );
|
||||
}
|
||||
|
@ -117,21 +125,16 @@ public class SurfaceScene extends PixelScene {
|
|||
Avatar a = new Avatar( Dungeon.hero.heroClass );
|
||||
// Removing semitransparent contour
|
||||
a.am = 2; a.aa = -1;
|
||||
a.x = PixelScene.align( (WIDTH - a.width) / 2 );
|
||||
a.y = HEIGHT - a.height + 1;
|
||||
a.x = PixelScene.align( (SKY_WIDTH - a.width) / 2 );
|
||||
a.y = SKY_HEIGHT - a.height;
|
||||
window.add( a );
|
||||
|
||||
final Pet pet = new Pet();
|
||||
pet.rm = pet.gm = pet.bm = 1.2f;
|
||||
pet.x = WIDTH / 2 + 2;
|
||||
pet.y = HEIGHT - pet.height;
|
||||
pet.x = SKY_WIDTH / 2 + 2;
|
||||
pet.y = SKY_HEIGHT - pet.height;
|
||||
window.add( pet );
|
||||
|
||||
if (dayTime) {
|
||||
a.brightness( 1.2f );
|
||||
pet.brightness( 1.2f );
|
||||
}
|
||||
|
||||
window.add( new TouchArea( sky ) {
|
||||
protected void onClick( Touch touch ) {
|
||||
pet.jump();
|
||||
|
@ -139,27 +142,32 @@ public class SurfaceScene extends PixelScene {
|
|||
} );
|
||||
|
||||
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 );
|
||||
window.add( patch );
|
||||
}
|
||||
|
||||
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.frame( 0, 0, 88, 125 );
|
||||
frame.x = vx - 4;
|
||||
frame.y = vy - 9;
|
||||
add( frame );
|
||||
|
||||
|
||||
RedButton gameOver = new RedButton( "Game Over" ) {
|
||||
protected void onClick() {
|
||||
Game.switchScene( TitleScene.class );
|
||||
}
|
||||
};
|
||||
gameOver.setSize( WIDTH - 10, 20 );
|
||||
gameOver.setPos( 5 + frame.x + 4, frame.y + frame.height + 4 );
|
||||
gameOver.setSize( SKY_WIDTH - FRAME_MARGIN_X * 2, BUTTON_HEIGHT );
|
||||
gameOver.setPos( frame.x + FRAME_MARGIN_X * 2, frame.y + frame.height + 4 );
|
||||
add( gameOver );
|
||||
|
||||
Badges.validateHappyEnd();
|
||||
|
@ -269,9 +277,9 @@ public class SurfaceScene extends PixelScene {
|
|||
lastIndex = index;
|
||||
|
||||
this.y = y;
|
||||
|
||||
scale.set( 1 - y / HEIGHT );
|
||||
x = Random.Float( WIDTH + width() ) - width();
|
||||
|
||||
scale.set( 1 - y / SKY_HEIGHT );
|
||||
x = Random.Float( SKY_WIDTH + width() ) - width();
|
||||
speed.x = scale.x * (dayTime ? +8 : -8);
|
||||
|
||||
if (dayTime) {
|
||||
|
@ -285,10 +293,10 @@ public class SurfaceScene extends PixelScene {
|
|||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
if (speed.x > 0 && x > WIDTH) {
|
||||
if (speed.x > 0 && x > SKY_WIDTH) {
|
||||
x = -width();
|
||||
} else if (speed.x < 0 && x < -width()) {
|
||||
x = WIDTH;
|
||||
x = SKY_WIDTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
||||
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import android.opengl.GLES20;
|
||||
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
|
@ -63,20 +67,39 @@ public class TitleScene extends PixelScene {
|
|||
int w = Camera.main.width;
|
||||
int h = Camera.main.height;
|
||||
|
||||
float height = 180;
|
||||
|
||||
Archs archs = new Archs();
|
||||
archs.setSize( w, h );
|
||||
add( archs );
|
||||
|
||||
Image title = BannerSprites.get( BannerSprites.Type.PIXEL_DUNGEON );
|
||||
add( title );
|
||||
|
||||
|
||||
float height = title.height +
|
||||
(ShatteredPixelDungeon.landscape() ? DashboardItem.SIZE : DashboardItem.SIZE * 2);
|
||||
|
||||
title.x = (w - title.width()) / 2;
|
||||
title.y = (h - height) / 2;
|
||||
|
||||
placeTorch( title.x + 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 ) {
|
||||
@Override
|
||||
|
@ -84,7 +107,6 @@ public class TitleScene extends PixelScene {
|
|||
ShatteredPixelDungeon.switchNoFade( BadgesScene.class );
|
||||
}
|
||||
};
|
||||
btnBadges.setPos( w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE );
|
||||
add( btnBadges );
|
||||
|
||||
DashboardItem btnAbout = new DashboardItem( TXT_ABOUT, 1 ) {
|
||||
|
@ -93,7 +115,6 @@ public class TitleScene extends PixelScene {
|
|||
ShatteredPixelDungeon.switchNoFade( AboutScene.class );
|
||||
}
|
||||
};
|
||||
btnAbout.setPos( w / 2, (h + height) / 2 - DashboardItem.SIZE );
|
||||
add( btnAbout );
|
||||
|
||||
DashboardItem btnPlay = new DashboardItem( TXT_PLAY, 0 ) {
|
||||
|
@ -102,7 +123,6 @@ public class TitleScene extends PixelScene {
|
|||
ShatteredPixelDungeon.switchNoFade( StartScene.class );
|
||||
}
|
||||
};
|
||||
btnPlay.setPos( w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE );
|
||||
add( btnPlay );
|
||||
|
||||
DashboardItem btnHighscores = new DashboardItem( TXT_HIGHSCORES, 2 ) {
|
||||
|
@ -111,10 +131,22 @@ public class TitleScene extends PixelScene {
|
|||
ShatteredPixelDungeon.switchNoFade( RankingsScene.class );
|
||||
}
|
||||
};
|
||||
btnHighscores.setPos( w / 2, btnPlay.top() );
|
||||
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.hardlight( 0x444444 );
|
||||
source.x = w - source.width();
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.watabou.noosa.BitmapTextMultiline;
|
|||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
|
||||
//FIXME: overhaul this in this update
|
||||
public class WelcomeScene extends PixelScene {
|
||||
|
||||
private static final String TTL_Welcome = "Welcome!";
|
||||
|
|
Loading…
Reference in New Issue
Block a user