v2.5.0: added a 'hide story text' button to interlevelscene

This commit is contained in:
Evan Debenham
2024-08-21 17:03:21 -04:00
parent 961dc23162
commit 1f1d9fed78
4 changed files with 79 additions and 4 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

@@ -280,7 +280,7 @@ public class HeroSelectScene extends PixelScene {
startBtn.setPos((leftArea - startBtn.width())/2f, title.top() + uiHeight - startBtn.height()); startBtn.setPos((leftArea - startBtn.width())/2f, title.top() + uiHeight - startBtn.height());
align(startBtn); align(startBtn);
btnFade = new IconButton(Icons.COMPASS.get()){ btnFade = new IconButton(Icons.CHEVRON.get()){
@Override @Override
protected void onClick() { protected void onClick() {
enable(false); enable(false);
@@ -41,6 +41,7 @@ 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.IconButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; 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.ui.StyledButton;
@@ -49,6 +50,7 @@ import com.watabou.gltextures.TextureCache;
import com.watabou.noosa.Camera; import com.watabou.noosa.Camera;
import com.watabou.noosa.Game; import com.watabou.noosa.Game;
import com.watabou.noosa.Image; import com.watabou.noosa.Image;
import com.watabou.noosa.tweeners.Tweener;
import com.watabou.utils.BArray; import com.watabou.utils.BArray;
import com.watabou.utils.DeviceCompat; import com.watabou.utils.DeviceCompat;
import com.watabou.utils.GameMath; import com.watabou.utils.GameMath;
@@ -92,6 +94,7 @@ public class InterlevelScene extends PixelScene {
private RenderedTextBlock storyMessage; private RenderedTextBlock storyMessage;
private ShadowBox storyBG; private ShadowBox storyBG;
private StyledButton btnContinue; private StyledButton btnContinue;
private IconButton btnHideStory;
private static Thread thread; private static Thread thread;
private static Exception error = null; private static Exception error = null;
@@ -242,7 +245,7 @@ public class InterlevelScene extends PixelScene {
if (lastRegion == 6) aa = 1; if (lastRegion == 6) aa = 1;
else if (phase == Phase.FADE_IN) aa = Math.max( 0, 2*(timeLeft - (fadeTime - 0.333f))); else if (phase == Phase.FADE_IN) aa = Math.max( 0, 2*(timeLeft - (fadeTime - 0.333f)));
else if (phase == Phase.FADE_OUT) aa = Math.max( 0, 2*(0.333f - timeLeft)); else if (phase == Phase.FADE_OUT) aa = Math.max( 0, 2*(0.333f - timeLeft));
else aa = 0; //else aa = 0;
} }
}; };
im.angle = 90; im.angle = 90;
@@ -289,9 +292,69 @@ public class InterlevelScene extends PixelScene {
btnContinue.setPos((Camera.main.width - btnContinue.width())/2f, storyMessage.bottom()+10); btnContinue.setPos((Camera.main.width - btnContinue.width())/2f, storyMessage.bottom()+10);
add(btnContinue); add(btnContinue);
btnHideStory = new IconButton(Icons.CHEVRON.get()){
@Override
protected void onClick() {
if (icon.visible) {
enable(false);
//button is effectively screen-sized, but invisible
parent.add(new Tweener(parent, 0.5f) {
@Override
protected void updateValues(float progress) {
float uiAlpha = 1 - progress;
btnContinue.alpha(uiAlpha);
storyBG.alpha(uiAlpha * 0.75f);
storyMessage.alpha(uiAlpha);
icon.alpha(uiAlpha);
loadingText.alpha(uiAlpha);
im.am = uiAlpha;
}
@Override
protected void onComplete() {
super.onComplete();
setRect(0, 0, Camera.main.width, Camera.main.height);
enable(true);
icon.visible = false;
}
});
} else {
setRect(btnContinue.right()+2, btnContinue.top(), 20, 21);
align(this);
icon.visible = true;
parent.add(new Tweener(parent, 0.5f) {
@Override
protected void updateValues(float progress) {
float uiAlpha = progress;
btnContinue.alpha(uiAlpha);
storyBG.alpha(uiAlpha*0.75f);
storyMessage.alpha(uiAlpha);
icon.alpha(uiAlpha);
loadingText.alpha(uiAlpha);
im.am = uiAlpha;
}
});
}
}
@Override
protected void onPointerDown() {
if (icon.visible) {
super.onPointerDown();
}
}
};
btnHideStory.icon().originToCenter();
btnHideStory.icon().angle = 180f;
btnHideStory.setRect(btnContinue.right()+2, btnContinue.top(), 20, 21);
align(btnHideStory);
btnHideStory.enable(false);
add(btnHideStory);
btnContinue.alpha(0); btnContinue.alpha(0);
storyBG.alpha(0); storyBG.alpha(0);
storyMessage.alpha(0); storyMessage.alpha(0);
btnHideStory.icon().alpha(0);
} }
} }
@@ -350,6 +413,7 @@ public class InterlevelScene extends PixelScene {
} }
private int dots = 0; private int dots = 0;
private boolean textFadingIn = true;
@Override @Override
public void update() { public void update() {
@@ -394,9 +458,10 @@ public class InterlevelScene extends PixelScene {
loadingText.alpha( Math.min(1, timeLeft+0.333f) ); loadingText.alpha( Math.min(1, timeLeft+0.333f) );
if (btnContinue != null){ if (btnContinue != null){
btnContinue.alpha(timeLeft/fadeTime); btnContinue.alpha((timeLeft/fadeTime));
storyMessage.alpha(btnContinue.alpha()); storyMessage.alpha(btnContinue.alpha());
storyBG.alpha(btnContinue.alpha()*0.75f); storyBG.alpha(btnContinue.alpha()*0.75f);
btnHideStory.icon().alpha(btnContinue.alpha());
} }
if ((timeLeft -= Game.elapsed) <= 0) { if ((timeLeft -= Game.elapsed) <= 0) {
@@ -408,10 +473,16 @@ public class InterlevelScene extends PixelScene {
case STATIC: case STATIC:
if (btnContinue != null) { if (btnContinue != null && textFadingIn) {
btnContinue.alpha(Math.min(1, btnContinue.alpha() + Game.elapsed)); btnContinue.alpha(Math.min(1, btnContinue.alpha() + Game.elapsed));
storyMessage.alpha(btnContinue.alpha()); storyMessage.alpha(btnContinue.alpha());
storyBG.alpha(btnContinue.alpha()*0.75f); storyBG.alpha(btnContinue.alpha()*0.75f);
btnHideStory.icon().alpha(btnContinue.alpha());
if (btnContinue.alpha() == 1){
btnHideStory.enable(true);
textFadingIn = false;
}
} }
if (error != null) { if (error != null) {
@@ -61,6 +61,7 @@ public enum Icons {
LEFTARROW, LEFTARROW,
RIGHTARROW, RIGHTARROW,
CALENDAR, CALENDAR,
CHEVRON,
//misc larger icons, mainly used for buttons, tabs, and journal, spacing for 16x16 //misc larger icons, mainly used for buttons, tabs, and journal, spacing for 16x16
TARGET, TARGET,
@@ -220,6 +221,9 @@ public enum Icons {
case CALENDAR: case CALENDAR:
icon.frame( icon.texture.uvRectBySize( 224, 16, 15, 12 ) ); icon.frame( icon.texture.uvRectBySize( 224, 16, 15, 12 ) );
break; break;
case CHEVRON:
icon.frame( icon.texture.uvRectBySize( 240, 16, 13, 10 ) );
break;
case TARGET: case TARGET:
icon.frame( icon.texture.uvRectBySize( 0, 32, 16, 16 ) ); icon.frame( icon.texture.uvRectBySize( 0, 32, 16, 16 ) );