| 
		 After Width: | Height: | Size: 4.6 KiB  | 
| 
		 Before Width: | Height: | Size: 2.1 KiB  | 
| 
		 Before Width: | Height: | Size: 519 B After Width: | Height: | Size: 519 B  | 
| 
		 Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 1.6 KiB  | 
| 
		 Before Width: | Height: | Size: 1.6 KiB  | 
| 
		 Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB  | 
| 
		 Before Width: | Height: | Size: 320 KiB After Width: | Height: | Size: 8.9 KiB  | 
| 
		 Before Width: | Height: | Size: 8.9 KiB  | 
| 
		 After Width: | Height: | Size: 2.0 KiB  | 
| 
		 After Width: | Height: | Size: 20 KiB  | 
| 
		 After Width: | Height: | Size: 320 KiB  | 
@ -0,0 +1,74 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.screens.game; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.app.AppAccess; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.AlignX; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.LayoutComponent; | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.layout.HorizontalFixedFlowLayout; | 
				
			||||||
 | 
					import mightypork.gamecore.render.Render; | 
				
			||||||
 | 
					import mightypork.gamecore.resources.textures.TxQuad; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.constraints.rect.Rect; | 
				
			||||||
 | 
					import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound; | 
				
			||||||
 | 
					import mightypork.rogue.Res; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class IngameNav extends LayoutComponent { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private final HorizontalFixedFlowLayout leftFlow; | 
				
			||||||
 | 
						private final HorizontalFixedFlowLayout rightFlow; | 
				
			||||||
 | 
						private final Rect paintHelper; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private final TxQuad bg; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public IngameNav(AppAccess app) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							this(app, null); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public IngameNav(AppAccess app, RectBound context) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							super(app, context); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							final Rect shr = this.shrink(height().perc(5)); | 
				
			||||||
 | 
							leftFlow = new HorizontalFixedFlowLayout(app, context, shr.height(), AlignX.LEFT); | 
				
			||||||
 | 
							rightFlow = new HorizontalFixedFlowLayout(app, context, shr.height(), AlignX.RIGHT); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							leftFlow.setRect(shr); | 
				
			||||||
 | 
							rightFlow.setRect(shr); | 
				
			||||||
 | 
							attach(leftFlow); | 
				
			||||||
 | 
							attach(rightFlow); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							paintHelper = leftEdge().growRight(height().mul(4)); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							bg = Res.txq("nav.bg"); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public void addLeft(NavButton comp) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							leftFlow.add(comp); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public void addRight(NavButton comp) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							rightFlow.add(comp); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						public void renderComponent() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							// draw BG (manually repeat)
 | 
				
			||||||
 | 
							for (int i = 0; i < Math.ceil(width().value() / paintHelper.width().value()); i++) { | 
				
			||||||
 | 
								Render.quadTextured(paintHelper.moveX(paintHelper.width().value() * i), bg); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							super.renderComponent(); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,47 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.screens.game; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mightypork.gamecore.gui.components.ClickableComponent; | 
				
			||||||
 | 
					import mightypork.gamecore.render.Render; | 
				
			||||||
 | 
					import mightypork.gamecore.resources.textures.TxQuad; | 
				
			||||||
 | 
					import mightypork.rogue.Res; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * Button in the ingame nav | 
				
			||||||
 | 
					 *  | 
				
			||||||
 | 
					 * @author MightyPork | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					public class NavButton extends ClickableComponent { | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private final TxQuad base, hover, down, fg; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public NavButton(TxQuad fg) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							super(); | 
				
			||||||
 | 
							this.base = Res.txq("nav.button.bg.base"); | 
				
			||||||
 | 
							this.hover = Res.txq("nav.button.bg.hover"); | 
				
			||||||
 | 
							this.down = Res.txq("nav.button.bg.down"); | 
				
			||||||
 | 
							this.fg = fg; | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						@Override | 
				
			||||||
 | 
						protected void renderComponent() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							TxQuad bg; | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							if (btnDownOver) { | 
				
			||||||
 | 
								bg = down; | 
				
			||||||
 | 
							} else if (isMouseOver()) { | 
				
			||||||
 | 
								bg = hover; | 
				
			||||||
 | 
							} else { | 
				
			||||||
 | 
								bg = base; | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							Render.quadTextured(this, bg); | 
				
			||||||
 | 
							Render.quadTextured(this, fg); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -1,89 +0,0 @@ | 
				
			|||||||
package mightypork.rogue.screens.game; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.eventbus.events.Updateable; | 
					 | 
				
			||||||
import mightypork.gamecore.gui.components.ClickableComponent; | 
					 | 
				
			||||||
import mightypork.gamecore.input.events.MouseMotionEvent; | 
					 | 
				
			||||||
import mightypork.gamecore.input.events.MouseMotionListener; | 
					 | 
				
			||||||
import mightypork.gamecore.render.Render; | 
					 | 
				
			||||||
import mightypork.gamecore.resources.textures.TxQuad; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.Easing; | 
					 | 
				
			||||||
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.constraints.rect.caching.RectCache; | 
					 | 
				
			||||||
import mightypork.gamecore.util.math.constraints.vect.Vect; | 
					 | 
				
			||||||
import mightypork.rogue.Res; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class NavItemSlot extends ClickableComponent implements MouseMotionListener, Updateable { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private final TxQuad image; | 
					 | 
				
			||||||
	private final TxQuad frame; | 
					 | 
				
			||||||
	private final RectCache paintBox; | 
					 | 
				
			||||||
	private final NumAnimated yOffset; | 
					 | 
				
			||||||
	private boolean wasInside = false; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public NavItemSlot(TxQuad image) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		this.image = image; | 
					 | 
				
			||||||
		this.frame = Res.txq("item_frame"); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		final Rect ref = shrink(height().perc(8)); | 
					 | 
				
			||||||
		yOffset = new NumAnimated(0, Easing.LINEAR); | 
					 | 
				
			||||||
		yOffset.setDefaultDuration(0.05); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		final Num h = ref.width().min(ref.height()); | 
					 | 
				
			||||||
		this.paintBox = ref.bottomLeft().startRect().grow(Num.ZERO, h, h, Num.ZERO).moveY(yOffset.mul(h.perc(-5))).cached(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	protected void renderComponent() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		Render.quadTextured(paintBox, frame); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		Render.pushMatrix(); | 
					 | 
				
			||||||
		Render.translateXY(paintBox.center()); | 
					 | 
				
			||||||
		Render.scaleXY(0.7); | 
					 | 
				
			||||||
		Render.rotateZ(45); | 
					 | 
				
			||||||
		Render.quadTextured(Rect.make(paintBox.height()).centerTo(Vect.ZERO), image); | 
					 | 
				
			||||||
		Render.popMatrix(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void updateLayout() | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		paintBox.poll(); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void receive(MouseMotionEvent event) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (event.getPos().isInside(this) != wasInside) { | 
					 | 
				
			||||||
			if (wasInside) { | 
					 | 
				
			||||||
				// left
 | 
					 | 
				
			||||||
				yOffset.fadeOut(); | 
					 | 
				
			||||||
			} else { | 
					 | 
				
			||||||
				// entered
 | 
					 | 
				
			||||||
				yOffset.fadeIn(); | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			wasInside = !wasInside; | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void update(double delta) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		if (yOffset.isInProgress()) { | 
					 | 
				
			||||||
			yOffset.update(delta); | 
					 | 
				
			||||||
			paintBox.poll(); | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||