parent
							
								
									4e1d89d3ca
								
							
						
					
					
						commit
						2b8055d1d2
					
				| 
		 Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 27 KiB  | 
									
										Binary file not shown.
									
								
							
						@ -1,9 +1,8 @@ | 
				
			|||||||
package mightypork.gamecore.gui.events; | 
					package mightypork.gamecore.gui.screens.impl; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import mightypork.gamecore.eventbus.BusEvent; | 
					import mightypork.gamecore.eventbus.BusEvent; | 
				
			||||||
import mightypork.gamecore.eventbus.event_flags.SingleReceiverEvent; | 
					import mightypork.gamecore.eventbus.event_flags.SingleReceiverEvent; | 
				
			||||||
import mightypork.gamecore.gui.screens.impl.CrossfadeOverlay; | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** | 
					/** | 
				
			||||||
@ -0,0 +1,149 @@ | 
				
			|||||||
 | 
					package mightypork.gamecore.gui.screens.impl; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.gui.screens.Screen; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.screens.ScreenLayer; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.Easing; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.timing.TimedTask; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * Layer that smoothly appears/disappears when shown/hidden | 
				
			||||||
 | 
					 *  | 
				
			||||||
 | 
					 * @author MightyPork | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					public abstract class FadingLayer extends ScreenLayer { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private final NumAnimated numa; | 
				
			||||||
 | 
						private final TimedTask hideTimer = new TimedTask() { | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							@Override | 
				
			||||||
 | 
							public void run() | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								FadingLayer.super.hide(); | 
				
			||||||
 | 
								fadingOut = false; | 
				
			||||||
 | 
								onHideFinished(); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						}; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private final TimedTask showTimer = new TimedTask() { | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							@Override | 
				
			||||||
 | 
							public void run() | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								fadingIn = false; | 
				
			||||||
 | 
								onShowFinished(); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						}; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private boolean fadingIn = false; | 
				
			||||||
 | 
						private boolean fadingOut = false; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						/** | 
				
			||||||
 | 
						 * Create with default fading time and effect | 
				
			||||||
 | 
						 *  | 
				
			||||||
 | 
						 * @param screen | 
				
			||||||
 | 
						 */ | 
				
			||||||
 | 
						public FadingLayer(Screen screen) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							this(screen, new NumAnimated(1, Easing.QUADRATIC_OUT, 0.3)); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						/** | 
				
			||||||
 | 
						 * @param screen | 
				
			||||||
 | 
						 * @param easingAnim the animation num | 
				
			||||||
 | 
						 */ | 
				
			||||||
 | 
						public FadingLayer(Screen screen, NumAnimated easingAnim) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							super(screen); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							numa = easingAnim; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							updated.add(numa); | 
				
			||||||
 | 
							updated.add(hideTimer); | 
				
			||||||
 | 
							updated.add(showTimer); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							setAlpha(numa); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						/** | 
				
			||||||
 | 
						 * Called after the fade-out was completed | 
				
			||||||
 | 
						 */ | 
				
			||||||
 | 
						protected void onHideFinished() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						/** | 
				
			||||||
 | 
						 * Called after the fade-in was completed | 
				
			||||||
 | 
						 */ | 
				
			||||||
 | 
						protected void onShowFinished() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						/** | 
				
			||||||
 | 
						 * Show with fading | 
				
			||||||
 | 
						 */ | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						public void show() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							if (fadingIn) return; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							if (!isVisible() || fadingOut) { | 
				
			||||||
 | 
								super.show(); | 
				
			||||||
 | 
								numa.fadeIn(); | 
				
			||||||
 | 
								hideTimer.stop(); | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								fadingOut = false; | 
				
			||||||
 | 
								fadingIn = true; | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						/** | 
				
			||||||
 | 
						 * Hide without fading | 
				
			||||||
 | 
						 */ | 
				
			||||||
 | 
						public void hideImmediate() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							hideTimer.stop(); | 
				
			||||||
 | 
							numa.setTo(0); | 
				
			||||||
 | 
							super.hide(); | 
				
			||||||
 | 
							onHideFinished(); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						/** | 
				
			||||||
 | 
						 * Show without fading | 
				
			||||||
 | 
						 */ | 
				
			||||||
 | 
						public void showImmediate() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							hideTimer.stop(); | 
				
			||||||
 | 
							numa.setTo(1); | 
				
			||||||
 | 
							super.show(); | 
				
			||||||
 | 
							onShowFinished(); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						/** | 
				
			||||||
 | 
						 * Hide with fading | 
				
			||||||
 | 
						 */ | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						public void hide() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							if (fadingOut) return; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							if (isVisible()) { | 
				
			||||||
 | 
								numa.fadeOut(); | 
				
			||||||
 | 
								hideTimer.start(numa.getDefaultDuration()); | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								fadingOut = true; | 
				
			||||||
 | 
								fadingIn = false; | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,84 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.screens.game; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.File; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.Config; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.Action; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.AlignX; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.input.TextButton; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.layout.RowLayout; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.layout.linear.LinearLayout; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.painters.ImagePainter; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.painters.QuadPainter; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.painters.TextPainter; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.screens.impl.FadingLayer; | 
				
			||||||
 | 
					import mightypork.gamecore.input.KeyStroke.Edge; | 
				
			||||||
 | 
					import mightypork.gamecore.resources.Res; | 
				
			||||||
 | 
					import mightypork.gamecore.resources.fonts.GLFont; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.color.pal.RGB; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.constraints.num.Num; | 
				
			||||||
 | 
					import mightypork.rogue.RogueStateManager.RogueState; | 
				
			||||||
 | 
					import mightypork.rogue.events.RogueStateRequest; | 
				
			||||||
 | 
					import mightypork.rogue.world.WorldProvider; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class LayerWin extends FadingLayer { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public LayerWin(final ScreenGame screen) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							super(screen); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							// darker down to cover console.
 | 
				
			||||||
 | 
							final QuadPainter qp = new QuadPainter(RGB.BLACK_80); | 
				
			||||||
 | 
							qp.setRect(root); | 
				
			||||||
 | 
							root.add(qp); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							final GLFont thick_font = Res.getFont("thick"); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							final RowLayout rl = new RowLayout(root, 5); | 
				
			||||||
 | 
							rl.setRect(root.shrink(Num.ZERO, root.height().perc(15))); | 
				
			||||||
 | 
							root.add(rl); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							final TextPainter txp = new TextPainter(thick_font, AlignX.CENTER, RGB.YELLOW, "You won!"); | 
				
			||||||
 | 
							rl.add(txp, 1); | 
				
			||||||
 | 
							txp.setVPaddingPercent(13); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							LinearLayout linl = new LinearLayout(root, AlignX.CENTER); | 
				
			||||||
 | 
							linl.add(new ImagePainter(Res.getTxQuad("win"))); | 
				
			||||||
 | 
							rl.add(linl, 3); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							linl = new LinearLayout(root, AlignX.CENTER); | 
				
			||||||
 | 
							rl.add(linl); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							final TextButton btn1 = new TextButton(thick_font, "Leave", ScreenGame.COLOR_BTN_GOOD); | 
				
			||||||
 | 
							btn1.textPainter.setVPaddingPercent(25); | 
				
			||||||
 | 
							linl.add(btn1); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							final Action quit = new Action() { | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								@Override | 
				
			||||||
 | 
								protected void execute() | 
				
			||||||
 | 
								{ | 
				
			||||||
 | 
									// delete the save file
 | 
				
			||||||
 | 
									final File f = WorldProvider.get().getWorld().getSaveFile(); | 
				
			||||||
 | 
									f.delete(); | 
				
			||||||
 | 
									 | 
				
			||||||
 | 
									getEventBus().send(new RogueStateRequest(RogueState.MAIN_MENU)); | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
							}; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							btn1.setAction(quit); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							bindKey(Config.getKey("general.confirm"), Edge.RISING, quit); | 
				
			||||||
 | 
							bindKey(Config.getKey("general.close"), Edge.RISING, quit); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						public int getZIndex() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return 300; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,260 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.screens.story; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.Config; | 
				
			||||||
 | 
					import mightypork.gamecore.core.AppAccess; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.Action; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.AlignX; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.layout.RowLayout; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.layout.linear.LinearLayout; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.painters.ImagePainter; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.painters.QuadPainter; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.painters.TextPainter; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.screens.Screen; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.screens.ScreenLayer; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.screens.impl.FadingLayer; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.screens.impl.LayerColor; | 
				
			||||||
 | 
					import mightypork.gamecore.input.KeyStroke; | 
				
			||||||
 | 
					import mightypork.gamecore.input.Keys; | 
				
			||||||
 | 
					import mightypork.gamecore.input.KeyStroke.Edge; | 
				
			||||||
 | 
					import mightypork.gamecore.input.events.MouseButtonEvent; | 
				
			||||||
 | 
					import mightypork.gamecore.input.events.MouseButtonHandler; | 
				
			||||||
 | 
					import mightypork.gamecore.resources.Res; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.Easing; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.color.Color; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.color.pal.RGB; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.constraints.num.Num; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.constraints.num.mutable.NumAnimated; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.constraints.rect.Rect; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.timing.TimedTask; | 
				
			||||||
 | 
					import mightypork.rogue.RogueStateManager.RogueState; | 
				
			||||||
 | 
					import mightypork.rogue.events.RogueStateRequest; | 
				
			||||||
 | 
					import mightypork.rogue.screens.RogueScreen; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ScreenStory extends RogueScreen implements MouseButtonHandler { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private class LayerSlide extends ScreenLayer { | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							private TextPainter tp1; | 
				
			||||||
 | 
							private TextPainter tp2; | 
				
			||||||
 | 
							private ImagePainter img; | 
				
			||||||
 | 
							private NumAnimated layerAlpha = new NumAnimated(0, Easing.LINEAR, 0.8); | 
				
			||||||
 | 
							private NumAnimated tx1alpha = new NumAnimated(0, Easing.LINEAR, 1); | 
				
			||||||
 | 
							private NumAnimated tx2alpha = new NumAnimated(0, Easing.LINEAR, 1); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							private String nextImg, nextT1, nextT2; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							private TimedTask ttNextSlide = new TimedTask() { | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								@Override | 
				
			||||||
 | 
								public void run() | 
				
			||||||
 | 
								{ | 
				
			||||||
 | 
									img.setTxQuad(Res.getTxQuad(nextImg)); | 
				
			||||||
 | 
									if (nextT1 != null) tp1.setText(nextT1); | 
				
			||||||
 | 
									if (nextT2 != null) tp2.setText(nextT2); | 
				
			||||||
 | 
									 | 
				
			||||||
 | 
									tx1alpha.setTo(0); | 
				
			||||||
 | 
									tx2alpha.setTo(0); | 
				
			||||||
 | 
									 | 
				
			||||||
 | 
									layerAlpha.setTo(0); | 
				
			||||||
 | 
									layerAlpha.fadeIn(); | 
				
			||||||
 | 
									ttText1.start(1.5); | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
							}; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							private TimedTask ttText1 = new TimedTask() { | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								@Override | 
				
			||||||
 | 
								public void run() | 
				
			||||||
 | 
								{ | 
				
			||||||
 | 
									if (nextT1 == null) { | 
				
			||||||
 | 
										ttText2.run(); | 
				
			||||||
 | 
									} else { | 
				
			||||||
 | 
										tx1alpha.fadeIn(); | 
				
			||||||
 | 
										ttText2.start(2); | 
				
			||||||
 | 
									} | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
							}; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							private TimedTask ttText2 = new TimedTask() { | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								@Override | 
				
			||||||
 | 
								public void run() | 
				
			||||||
 | 
								{ | 
				
			||||||
 | 
									if (nextT2 == null) { | 
				
			||||||
 | 
										ttFinish.run(); | 
				
			||||||
 | 
									} else { | 
				
			||||||
 | 
										tx2alpha.fadeIn(); | 
				
			||||||
 | 
										ttFinish.start(2); | 
				
			||||||
 | 
									} | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
							}; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							private TimedTask ttFinish = new TimedTask() { | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								@Override | 
				
			||||||
 | 
								public void run() | 
				
			||||||
 | 
								{ | 
				
			||||||
 | 
									System.out.println("Slide finished."); | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
							}; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							private final Color textColor = Color.fromHex(0x7ad8ff); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							public LayerSlide(Screen screen) | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								super(screen); | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								Rect contentRect = root.shrink(Num.ZERO, root.height().perc(3)); | 
				
			||||||
 | 
								RowLayout rl = new RowLayout(root, 9); | 
				
			||||||
 | 
								rl.setRect(contentRect); | 
				
			||||||
 | 
								root.add(rl); | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								LinearLayout ll = new LinearLayout(root, AlignX.CENTER); | 
				
			||||||
 | 
								rl.add(ll, 7); | 
				
			||||||
 | 
								img = new ImagePainter(Res.getTxQuad("story_1")); | 
				
			||||||
 | 
								ll.add(img); | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								tp1 = new TextPainter(Res.getFont("tiny"), AlignX.CENTER, textColor.withAlpha(tx1alpha), ""); | 
				
			||||||
 | 
								rl.add(tp1); | 
				
			||||||
 | 
								tp1.setVPaddingPercent(20); | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								tp2 = new TextPainter(Res.getFont("tiny"), AlignX.CENTER, textColor.withAlpha(tx2alpha), ""); | 
				
			||||||
 | 
								rl.add(tp2); | 
				
			||||||
 | 
								tp2.setVPaddingPercent(20); | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								updated.add(layerAlpha); | 
				
			||||||
 | 
								updated.add(tx1alpha); | 
				
			||||||
 | 
								updated.add(tx2alpha); | 
				
			||||||
 | 
								updated.add(ttText1); | 
				
			||||||
 | 
								updated.add(ttText2); | 
				
			||||||
 | 
								updated.add(ttFinish); | 
				
			||||||
 | 
								updated.add(ttNextSlide); | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								setAlpha(layerAlpha); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							@Override | 
				
			||||||
 | 
							public int getZIndex() | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								return 1; | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							public void showSlide(String image, String text1, String text2) | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								ttFinish.stop(); | 
				
			||||||
 | 
								ttNextSlide.stop(); | 
				
			||||||
 | 
								ttText1.stop(); | 
				
			||||||
 | 
								ttText2.stop(); | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								this.nextImg = image; | 
				
			||||||
 | 
								this.nextT1 = text1; | 
				
			||||||
 | 
								this.nextT2 = text2; | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								layerAlpha.fadeOut(); | 
				
			||||||
 | 
								ttNextSlide.start(1); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							public void reset() | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								ttFinish.stop(); | 
				
			||||||
 | 
								ttNextSlide.stop(); | 
				
			||||||
 | 
								ttText1.stop(); | 
				
			||||||
 | 
								ttText2.stop(); | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								layerAlpha.setTo(0); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private LayerSlide slideLayer; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private Action next = new Action() { | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							@Override | 
				
			||||||
 | 
							protected void execute() | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								showSlide(++slide); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						}; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private Action prev = new Action() { | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							@Override | 
				
			||||||
 | 
							protected void execute() | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								if (slide > 0) slide--; | 
				
			||||||
 | 
								showSlide(slide); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						}; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private Action close = new Action() { | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							@Override | 
				
			||||||
 | 
							protected void execute() | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								getEventBus().send(new RogueStateRequest(RogueState.MAIN_MENU)); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						}; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public ScreenStory(AppAccess app) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							super(app); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							addLayer(new LayerColor(this, Color.fromHex(0x040c1e), 0)); | 
				
			||||||
 | 
							addLayer(slideLayer = new LayerSlide(this)); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							bindKey(new KeyStroke(Keys.SPACE), Edge.RISING, next); | 
				
			||||||
 | 
							bindKey(new KeyStroke(Keys.RIGHT), Edge.RISING, next); | 
				
			||||||
 | 
							bindKey(new KeyStroke(Keys.BACKSPACE), Edge.RISING, prev); | 
				
			||||||
 | 
							bindKey(new KeyStroke(Keys.LEFT), Edge.RISING, prev); | 
				
			||||||
 | 
							bindKey(Config.getKey("general.close"), Edge.RISING, close); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private int slide = 0; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected void onScreenEnter() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							slide = 0; | 
				
			||||||
 | 
							slideLayer.reset(); | 
				
			||||||
 | 
							showSlide(slide); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private void showSlide(int slide) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							switch (slide) { | 
				
			||||||
 | 
								case 0: | 
				
			||||||
 | 
									slideLayer.showSlide("story_1", "Man, it's so hot today!", "Makes me real thirsty, ya know."); | 
				
			||||||
 | 
									break; | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								case 1: | 
				
			||||||
 | 
									slideLayer.showSlide("story_2", "'Guess I'll go get some booze", "from the cellar."); | 
				
			||||||
 | 
									break; | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								case 2: | 
				
			||||||
 | 
									slideLayer.showSlide("story_3", "Here we go.. HEY GIVE IT BACK!", "I'll hunt you down, thieves!"); | 
				
			||||||
 | 
									break; | 
				
			||||||
 | 
								 | 
				
			||||||
 | 
								case 3: | 
				
			||||||
 | 
									getEventBus().send(new RogueStateRequest(RogueState.MAIN_MENU)); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						public void receive(MouseButtonEvent event) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							if (event.isButtonEvent() && event.isUp()) { | 
				
			||||||
 | 
								if (event.getButton() == 0) next.run(); | 
				
			||||||
 | 
								if (event.getButton() == 1) prev.run(); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,14 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.events; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.eventbus.BusEvent; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class GameWinEvent extends BusEvent<GameWinHandler> { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected void handleBy(GameWinHandler handler) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							handler.onGameWon(); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,8 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world.events; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface GameWinHandler { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						void onGameWon(); | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -1,10 +1,10 @@ | 
				
			|||||||
package mightypork.rogue.world.events; | 
					package mightypork.rogue.world.events; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import mightypork.rogue.world.entity.impl.PlayerEntity; | 
					import mightypork.rogue.world.entity.impl.EntityPlayer; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public interface PlayerStepEndListener { | 
					public interface PlayerStepEndListener { | 
				
			||||||
	 | 
						 | 
				
			||||||
	void onStepFinished(PlayerEntity player); | 
						void onStepFinished(EntityPlayer player); | 
				
			||||||
} | 
					} | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,4 @@ | 
				
			|||||||
package mightypork.rogue.screens.game; | 
					package mightypork.rogue.world.gui; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.Collection; | 
					import java.util.Collection; | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue