v2.5.0: moved story text to the inter level scene
This commit is contained in:
@@ -119,7 +119,6 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
|||||||
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.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory;
|
|
||||||
import com.watabou.glwrap.Blending;
|
import com.watabou.glwrap.Blending;
|
||||||
import com.watabou.input.ControllerHandler;
|
import com.watabou.input.ControllerHandler;
|
||||||
import com.watabou.input.KeyBindings;
|
import com.watabou.input.KeyBindings;
|
||||||
@@ -428,17 +427,6 @@ public class GameScene extends PixelScene {
|
|||||||
break;
|
break;
|
||||||
case DESCEND:
|
case DESCEND:
|
||||||
case FALL:
|
case FALL:
|
||||||
if (Dungeon.depth == Statistics.deepestFloor){
|
|
||||||
switch (Dungeon.depth) {
|
|
||||||
case 1: case 6: case 11: case 16: case 21:
|
|
||||||
int region = (Dungeon.depth+4)/5;
|
|
||||||
if (!Document.INTROS.isPageRead(region)) {
|
|
||||||
add(new WndStory(Document.INTROS.pageBody(region)).setDelays(0.6f, 1.4f));
|
|
||||||
Document.INTROS.readPage(region);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Dungeon.hero.isAlive()) {
|
if (Dungeon.hero.isAlive()) {
|
||||||
Badges.validateNoKilling();
|
Badges.validateNoKilling();
|
||||||
}
|
}
|
||||||
|
|||||||
+69
-21
@@ -22,6 +22,7 @@
|
|||||||
package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
|
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||||
@@ -29,8 +30,10 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.ShadowBox;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.LostBackpack;
|
import com.shatteredpixel.shatteredpixeldungeon.items.LostBackpack;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
|
||||||
@@ -38,7 +41,9 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.StyledButton;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndError;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndError;
|
||||||
import com.watabou.gltextures.TextureCache;
|
import com.watabou.gltextures.TextureCache;
|
||||||
import com.watabou.noosa.Camera;
|
import com.watabou.noosa.Camera;
|
||||||
@@ -82,7 +87,11 @@ public class InterlevelScene extends PixelScene {
|
|||||||
private Phase phase;
|
private Phase phase;
|
||||||
private float timeLeft;
|
private float timeLeft;
|
||||||
|
|
||||||
private RenderedTextBlock message;
|
private RenderedTextBlock loadingText;
|
||||||
|
|
||||||
|
private RenderedTextBlock storyMessage;
|
||||||
|
private ShadowBox storyBG;
|
||||||
|
private StyledButton btnContinue;
|
||||||
|
|
||||||
private static Thread thread;
|
private static Thread thread;
|
||||||
private static Exception error = null;
|
private static Exception error = null;
|
||||||
@@ -196,7 +205,7 @@ public class InterlevelScene extends PixelScene {
|
|||||||
Random.popGenerator();
|
Random.popGenerator();
|
||||||
|
|
||||||
if (DeviceCompat.isDebug()){
|
if (DeviceCompat.isDebug()){
|
||||||
fadeTime = 0f;
|
fadeTime = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image background = new Image(loadingAsset);
|
Image background = new Image(loadingAsset);
|
||||||
@@ -244,13 +253,44 @@ public class InterlevelScene extends PixelScene {
|
|||||||
|
|
||||||
String text = Messages.get(Mode.class, mode.name());
|
String text = Messages.get(Mode.class, mode.name());
|
||||||
|
|
||||||
message = PixelScene.renderTextBlock( text, 9 );
|
loadingText = PixelScene.renderTextBlock( text, 9 );
|
||||||
message.setPos(
|
loadingText.setPos(
|
||||||
(Camera.main.width - message.width() - 8),
|
(Camera.main.width - loadingText.width() - 8),
|
||||||
(Camera.main.height - message.height() - 6)
|
(Camera.main.height - loadingText.height() - 6)
|
||||||
);
|
);
|
||||||
align(message);
|
align(loadingText);
|
||||||
add( message );
|
add(loadingText);
|
||||||
|
|
||||||
|
//TODo this is functional and doesn't look awful, but there's still improving to be done here
|
||||||
|
if (mode == Mode.DESCEND){
|
||||||
|
if (Dungeon.hero == null || (loadingDepth > Statistics.deepestFloor && loadingDepth % 5 == 1)){
|
||||||
|
storyMessage = PixelScene.renderTextBlock(Document.INTROS.pageBody(region), 6);
|
||||||
|
storyMessage.maxWidth( PixelScene.landscape() ? 180 : 125);
|
||||||
|
storyMessage.setPos((Camera.main.width-storyMessage.width())/2f, (Camera.main.height-storyMessage.height())/2f);
|
||||||
|
|
||||||
|
storyBG = new ShadowBox();
|
||||||
|
storyBG.boxRect(storyMessage.left()-10, storyMessage.top()-10, storyMessage.width()+20, storyMessage.height()+20);
|
||||||
|
storyBG.alpha(0.75f);
|
||||||
|
add(storyBG);
|
||||||
|
add(storyMessage);
|
||||||
|
|
||||||
|
btnContinue = new StyledButton(Chrome.Type.TOAST_TR, "Continue", 9){
|
||||||
|
@Override
|
||||||
|
protected void onClick() {
|
||||||
|
phase = Phase.FADE_OUT;
|
||||||
|
timeLeft = fadeTime;
|
||||||
|
|
||||||
|
btnContinue.enable(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
btnContinue.icon(Icons.STAIRS.get());
|
||||||
|
btnContinue.setSize(btnContinue.reqWidth()+10, 22);
|
||||||
|
btnContinue.enable(false);
|
||||||
|
|
||||||
|
btnContinue.setPos((Camera.main.width - btnContinue.width())/2f, storyMessage.bottom()+10);
|
||||||
|
add(btnContinue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
phase = Phase.FADE_IN;
|
phase = Phase.FADE_IN;
|
||||||
timeLeft = fadeTime;
|
timeLeft = fadeTime;
|
||||||
@@ -296,8 +336,7 @@ public class InterlevelScene extends PixelScene {
|
|||||||
|
|
||||||
synchronized (thread) {
|
synchronized (thread) {
|
||||||
if (phase == Phase.STATIC && error == null) {
|
if (phase == Phase.STATIC && error == null) {
|
||||||
phase = Phase.FADE_OUT;
|
afterLoading();
|
||||||
timeLeft = fadeTime;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -320,13 +359,13 @@ public class InterlevelScene extends PixelScene {
|
|||||||
dots = (int)Math.ceil(waitingTime / ((2*fadeTime)/3f))%3;
|
dots = (int)Math.ceil(waitingTime / ((2*fadeTime)/3f))%3;
|
||||||
switch (dots){
|
switch (dots){
|
||||||
case 1: default:
|
case 1: default:
|
||||||
message.text(text + ".");
|
loadingText.text(text + ".");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
message.text(text + "..");
|
loadingText.text(text + "..");
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
message.text(text + "...");
|
loadingText.text(text + "...");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,12 +373,11 @@ public class InterlevelScene extends PixelScene {
|
|||||||
switch (phase) {
|
switch (phase) {
|
||||||
|
|
||||||
case FADE_IN:
|
case FADE_IN:
|
||||||
message.alpha( Math.max(0, fadeTime - (timeLeft-0.333f)));
|
loadingText.alpha( Math.max(0, fadeTime - (timeLeft-0.333f)));
|
||||||
if ((timeLeft -= Game.elapsed) <= 0) {
|
if ((timeLeft -= Game.elapsed) <= 0) {
|
||||||
synchronized (thread) {
|
synchronized (thread) {
|
||||||
if (!thread.isAlive() && error == null) {
|
if (!thread.isAlive() && error == null) {
|
||||||
phase = Phase.FADE_OUT;
|
afterLoading();
|
||||||
timeLeft = fadeTime;
|
|
||||||
} else {
|
} else {
|
||||||
phase = Phase.STATIC;
|
phase = Phase.STATIC;
|
||||||
}
|
}
|
||||||
@@ -348,7 +386,7 @@ public class InterlevelScene extends PixelScene {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FADE_OUT:
|
case FADE_OUT:
|
||||||
message.alpha( Math.min(1, timeLeft+0.333f) );
|
loadingText.alpha( Math.min(1, timeLeft+0.333f) );
|
||||||
|
|
||||||
if ((timeLeft -= Game.elapsed) <= 0) {
|
if ((timeLeft -= Game.elapsed) <= 0) {
|
||||||
Game.switchScene( GameScene.class );
|
Game.switchScene( GameScene.class );
|
||||||
@@ -395,14 +433,24 @@ public class InterlevelScene extends PixelScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mode == Mode.FALL) {
|
if (mode == Mode.FALL) {
|
||||||
message.setPos(
|
loadingText.setPos(
|
||||||
(Camera.main.width - message.width() - 4) + Random.NormalFloat(-1, 1),
|
(Camera.main.width - loadingText.width() - 4) + Random.NormalFloat(-1, 1),
|
||||||
(Camera.main.height - message.height() - 6) + Random.NormalFloat(-1, 1)
|
(Camera.main.height - loadingText.height() - 6) + Random.NormalFloat(-1, 1)
|
||||||
);
|
);
|
||||||
align(message);
|
align(loadingText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void afterLoading(){
|
||||||
|
if (btnContinue != null){
|
||||||
|
btnContinue.enable(true);
|
||||||
|
} else {
|
||||||
|
phase = Phase.FADE_OUT;
|
||||||
|
timeLeft = fadeTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void descend() throws IOException {
|
private void descend() throws IOException {
|
||||||
|
|
||||||
if (Dungeon.hero == null) {
|
if (Dungeon.hero == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user