Save-confirm dialog in game

v5stable
Ondřej Hruška 11 years ago
parent 1ca0b9e0e9
commit 2699d8d549
  1. BIN
      res/img/logo.png
  2. BIN
      res/img/logo.xcf
  3. 4
      src/mightypork/gamecore/app/BaseApp.java
  4. 61
      src/mightypork/gamecore/gui/components/layout/ColumnHolder.java
  5. 45
      src/mightypork/gamecore/gui/components/layout/ColumnLayout.java
  6. 61
      src/mightypork/gamecore/gui/components/layout/RowHolder.java
  7. 45
      src/mightypork/gamecore/gui/components/layout/RowLayout.java
  8. 18
      src/mightypork/gamecore/gui/screens/Overlay.java
  9. 6
      src/mightypork/gamecore/gui/screens/impl/CrossfadeOverlay.java
  10. 6
      src/mightypork/rogue/App.java
  11. 4
      src/mightypork/rogue/Res.java
  12. 156
      src/mightypork/rogue/screens/game/AskSaveLayer.java
  13. 95
      src/mightypork/rogue/screens/game/DeathLayer.java
  14. 89
      src/mightypork/rogue/screens/game/ScreenGame.java
  15. 31
      src/mightypork/rogue/screens/menu/ScreenMainMenu.java
  16. 41
      src/mightypork/rogue/screens/select_world/ScreenSelectWorld.java
  17. 2
      src/mightypork/rogue/world/item/impl/active/ItemHeartPiece.java

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

@ -80,7 +80,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
} }
// only here it makes sense to log. // only here it makes sense to log.
Log.i("=== Commencing initialization sequence ==="); Log.i("=== Starting initialization sequence ===");
/* /*
@ -145,7 +145,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
initScreens(screenRegistry); initScreens(screenRegistry);
postInit(); postInit();
Log.i("=== Initialized sequence completed ==="); Log.i("=== Initialization sequence completed ===");
} }

@ -1,61 +0,0 @@
package mightypork.gamecore.gui.components.layout;
import mightypork.gamecore.app.AppAccess;
import mightypork.gamecore.gui.components.Component;
import mightypork.gamecore.gui.components.LayoutComponent;
import mightypork.gamecore.util.math.constraints.rect.builders.TiledRect;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
/**
* Holder with evenly spaced columns
*
* @author MightyPork
*/
public class ColumnHolder extends LayoutComponent {
private final TiledRect tiler;
private int col = 0;
/**
* @param app app access
* @param context context
* @param cols number of columns
*/
public ColumnHolder(AppAccess app, RectBound context, int cols)
{
super(app, context);
this.tiler = columns(cols);
}
/**
* make a new holder.<br>
* Context must be assigned before rendering.
*
* @param app app access
* @param cols number of columns
*/
public ColumnHolder(AppAccess app, int cols)
{
this(app, null, cols);
}
/**
* Add a row to the holder.
*
* @param elem
*/
public void add(final Component elem)
{
if (elem == null) return;
elem.setRect(tiler.column(col++));
attach(elem);
}
}

@ -0,0 +1,45 @@
package mightypork.gamecore.gui.components.layout;
import mightypork.gamecore.app.AppAccess;
import mightypork.gamecore.gui.components.Component;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
public class ColumnLayout extends GridLayout {
private int col = 0;
public ColumnLayout(AppAccess app, int rows)
{
this(app, null, rows);
}
public ColumnLayout(AppAccess app, RectBound context, int cols)
{
super(app, context, 1, cols);
}
public void add(final Component elem)
{
add(elem, 1);
}
public void add(final Component elem, int colSpan)
{
if (elem == null) return;
put(elem, 0, col, 1, colSpan);
col += colSpan;
}
public void skip(int cols)
{
col += cols;
}
}

@ -1,61 +0,0 @@
package mightypork.gamecore.gui.components.layout;
import mightypork.gamecore.app.AppAccess;
import mightypork.gamecore.gui.components.Component;
import mightypork.gamecore.gui.components.LayoutComponent;
import mightypork.gamecore.util.math.constraints.rect.builders.TiledRect;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
/**
* Holder with evenly spaced rows
*
* @author MightyPork
*/
public class RowHolder extends LayoutComponent {
private final TiledRect tiler;
private int row = 0;
/**
* Make a row holder.<br>
* Context must be assigned before rendering.
*
* @param app app access
* @param rows number of rows
*/
public RowHolder(AppAccess app, int rows)
{
this(app, null, rows);
}
/**
* @param app app access
* @param context bounding context
* @param rows number of rows
*/
public RowHolder(AppAccess app, RectBound context, int rows)
{
super(app, context);
this.tiler = rows(rows);
}
/**
* Add a row to the holder.
*
* @param elem
*/
public void add(final Component elem)
{
if (elem == null) return;
elem.setRect(tiler.row(row++));
attach(elem);
}
}

@ -0,0 +1,45 @@
package mightypork.gamecore.gui.components.layout;
import mightypork.gamecore.app.AppAccess;
import mightypork.gamecore.gui.components.Component;
import mightypork.gamecore.util.math.constraints.rect.proxy.RectBound;
public class RowLayout extends GridLayout {
private int row = 0;
public RowLayout(AppAccess app, int rows)
{
this(app, null, rows);
}
public RowLayout(AppAccess app, RectBound context, int rows)
{
super(app, context, rows, 1);
}
public void add(final Component elem)
{
add(elem, 1);
}
public void add(final Component elem, int rowSpan)
{
if (elem == null) return;
put(elem, row, 0, rowSpan, 1);
row += rowSpan;
}
public void skip(int rows)
{
row += rows;
}
}

@ -87,17 +87,21 @@ public abstract class Overlay extends AppSubModule implements Comparable<Overlay
@Override @Override
public void setVisible(boolean visible) public void setVisible(boolean visible)
{ {
if (visible != this.visible) {
this.visible = visible; this.visible = visible;
root.setVisible(visible); root.setVisible(visible);
} }
}
@Override @Override
public void setEnabled(boolean yes) public void setEnabled(boolean yes)
{ {
if (enabled != yes) {
this.enabled = yes; this.enabled = yes;
root.setEnabled(yes); root.setEnabled(yes);
} }
}
@Override @Override
@ -189,4 +193,18 @@ public abstract class Overlay extends AppSubModule implements Comparable<Overlay
{ {
this.alphaMul = Num.make(alpha); this.alphaMul = Num.make(alpha);
} }
public void show()
{
setVisible(true);
setEnabled(true);
}
public void hide()
{
setVisible(false);
setEnabled(false);
}
} }

@ -15,8 +15,8 @@ import mightypork.rogue.events.ActionRequest.RequestType;
public class CrossfadeOverlay extends Overlay { public class CrossfadeOverlay extends Overlay {
private static final double T_IN = 0.5; private static final double T_IN = 0.4;
private static final double T_OUT = 0.7; private static final double T_OUT = 0.6;
NumAnimated alpha = new NumAnimated(0); NumAnimated alpha = new NumAnimated(0);
String requestedScreenName; String requestedScreenName;
@ -41,7 +41,7 @@ public class CrossfadeOverlay extends Overlay {
{ {
super(app); super(app);
final QuadPainter qp = new QuadPainter(RGB.BLACK); final QuadPainter qp = new QuadPainter(RGB.BLACK); // TODO allow custom colors
qp.setRect(root); qp.setRect(root);
root.add(qp); root.add(qp);

@ -134,8 +134,8 @@ public final class App extends BaseApp {
bindEventToKey(new ActionRequest(RequestType.FULLSCREEN), Keys.F11); bindEventToKey(new ActionRequest(RequestType.FULLSCREEN), Keys.F11);
bindEventToKey(new ActionRequest(RequestType.SCREENSHOT), Keys.F2); bindEventToKey(new ActionRequest(RequestType.SCREENSHOT), Keys.F2);
bindEventToKey(new GameStateRequest(GameState.EXIT), Keys.Q, Keys.MOD_CONTROL); bindEventToKey(new GameStateRequest(GameState.EXIT), Keys.Q, Keys.MOD_SHIFT | Keys.MOD_CONTROL);
bindEventToKey(new GameStateRequest(GameState.MAIN_MENU), Keys.M, Keys.MOD_CONTROL); bindEventToKey(new GameStateRequest(GameState.MAIN_MENU), Keys.M, Keys.MOD_SHIFT | Keys.MOD_CONTROL);
} }
@ -145,7 +145,7 @@ public final class App extends BaseApp {
} }
private void bindEventToKey(final BusEvent<?> event, int key, byte mod) private void bindEventToKey(final BusEvent<?> event, int key, int mod)
{ {
getInput().bindKey(new KeyStroke(key, mod), new Runnable() { getInput().bindKey(new KeyStroke(key, mod), new Runnable() {

@ -118,6 +118,8 @@ public final class Res {
// logo // logo
texture = textures.loadTexture("/res/img/logo.png", FilterMode.NEAREST, WrapMode.CLAMP); texture = textures.loadTexture("/res/img/logo.png", FilterMode.NEAREST, WrapMode.CLAMP);
textures.add("logo", texture.makeQuad(Rect.make(0, 0, 0.543, 0.203))); textures.add("logo", texture.makeQuad(Rect.make(0, 0, 0.543, 0.203)));
grid = texture.grid(8, 8);
textures.add("death", grid.makeQuad(0, 2));
// tiles // tiles
@ -171,7 +173,7 @@ public final class Res {
textures.add("item.bone", grid.makeQuad(5, 0)); textures.add("item.bone", grid.makeQuad(5, 0));
textures.add("item.cheese", grid.makeQuad(6, 0)); textures.add("item.cheese", grid.makeQuad(6, 0));
textures.add("item.sandwich", grid.makeQuad(7, 0)); textures.add("item.sandwich", grid.makeQuad(7, 0));
textures.add("item.heart_piece", grid.makeQuad(0, 1)); textures.add("item.heart", grid.makeQuad(0, 1));
textures.add("item.knife", grid.makeQuad(1, 1)); textures.add("item.knife", grid.makeQuad(1, 1));
textures.add("item.twig", grid.makeQuad(2, 1)); textures.add("item.twig", grid.makeQuad(2, 1));
} }

@ -0,0 +1,156 @@
package mightypork.rogue.screens.game;
import java.io.IOException;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.layout.ColumnLayout;
import mightypork.gamecore.gui.components.layout.RowLayout;
import mightypork.gamecore.gui.components.painters.QuadPainter;
import mightypork.gamecore.gui.components.painters.TextPainter;
import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys;
import mightypork.gamecore.logging.Log;
import mightypork.gamecore.resources.fonts.GLFont;
import mightypork.gamecore.util.math.Easing;
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.timing.TimedTask;
import mightypork.rogue.Res;
import mightypork.rogue.screens.PushButton;
import mightypork.rogue.screens.game.ScreenGame.GScrState;
import mightypork.rogue.world.WorldProvider;
public class AskSaveLayer extends ScreenLayer {
public Runnable task;
NumAnimated numa = new NumAnimated(0, Easing.QUADRATIC_OUT);
TimedTask hideTT = new TimedTask() {
@Override
public void run()
{
gscreen.setState(GScrState.WORLD); // go back..
}
};
private final ScreenGame gscreen;
public void setTask(Runnable task)
{
this.task = task;
}
public AskSaveLayer(final ScreenGame screen)
{
super(screen);
this.gscreen = 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, 2);
rl.setRect(root.shrink(Num.ZERO, root.height().perc(40)).moveY(root.height().perc(-10)));
root.add(rl);
final TextPainter txp = new TextPainter(thick_font, AlignX.CENTER, RGB.WHITE, "Save the game?");
rl.add(txp, 1);
txp.setPaddingHPerc(0, 25);
final ColumnLayout cl = new ColumnLayout(root, 21);
cl.skip(2);
rl.add(cl);
final PushButton btn1 = new PushButton(thick_font, "Yes", ScreenGame.COLOR_BTN_GOOD);
btn1.textPainter.setAlign(AlignX.RIGHT);
btn1.textPainter.setPaddingHPerc(25, 20);
btn1.disableHover();
cl.add(btn1, 6);
final PushButton btn2 = new PushButton(thick_font, "No", ScreenGame.COLOR_BTN_BAD);
btn2.textPainter.setAlign(AlignX.CENTER);
btn2.textPainter.setPaddingHPerc(25, 20);
btn2.disableHover();
cl.add(btn2, 3);
final PushButton btn3 = new PushButton(thick_font, "Cancel", ScreenGame.COLOR_BTN_CANCEL);
btn3.textPainter.setAlign(AlignX.LEFT);
btn3.textPainter.setPaddingHPerc(25, 20);
btn3.disableHover();
cl.add(btn3, 10);
final Action cancel = new Action() {
@Override
protected void execute()
{
if (numa.isFinished()) {
numa.fadeOut(0.3);
hideTT.start(0.3);
}
}
};
btn1.setAction(new Action() {
@Override
protected void execute()
{
try {
WorldProvider.get().saveWorld();
if (task != null) task.run();
} catch (final IOException e) {
Log.e(e);
}
}
});
btn2.setAction(new Action() {
@Override
protected void execute()
{
if (task != null) task.run();
}
});
btn3.setAction(cancel);
bindKey(new KeyStroke(Keys.ESCAPE), cancel);
updated.add(numa);
updated.add(hideTT);
setAlpha(numa);
}
@Override
public int getZIndex()
{
return 301;
}
@Override
public void show()
{
if (!isVisible()) {
super.show();
numa.fadeIn(0.3);
hideTT.stop();
}
}
}

@ -0,0 +1,95 @@
package mightypork.rogue.screens.game;
import java.io.IOException;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.layout.ColumnLayout;
import mightypork.gamecore.gui.components.layout.RowLayout;
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.ScreenLayer;
import mightypork.gamecore.logging.Log;
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.GameStateManager.GameState;
import mightypork.rogue.Res;
import mightypork.rogue.events.GameStateRequest;
import mightypork.rogue.screens.PushButton;
import mightypork.rogue.screens.game.ScreenGame.GScrState;
import mightypork.rogue.world.WorldProvider;
public class DeathLayer extends ScreenLayer {
public DeathLayer(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(20)));
root.add(rl);
final TextPainter txp = new TextPainter(thick_font, AlignX.CENTER, RGB.YELLOW, "You're dead!");
rl.add(txp, 1);
txp.setPaddingHPerc(0, 15);
final ImagePainter img = new ImagePainter(Res.getTxQuad("death"));
img.keepAspectRatio();
rl.add(img, 3);
final ColumnLayout cl = new ColumnLayout(root, 2);
rl.add(cl);
final PushButton btn1 = new PushButton(thick_font, "Retry", ScreenGame.COLOR_BTN_GOOD);
btn1.textPainter.setAlign(AlignX.RIGHT);
btn1.textPainter.setPaddingHPerc(20, 25);
cl.add(btn1);
final PushButton btn2 = new PushButton(thick_font, "Quit", ScreenGame.COLOR_BTN_BAD);
btn2.textPainter.setAlign(AlignX.LEFT);
btn2.textPainter.setPaddingHPerc(20, 25);
cl.add(btn2);
btn1.setAction(new Action() {
@Override
protected void execute()
{
try {
WorldProvider.get().loadWorld(WorldProvider.get().getWorld().getSaveFile());
screen.setState(GScrState.WORLD);
} catch (final IOException e) {
Log.e(e);
}
}
});
btn2.setAction(new Action() {
@Override
protected void execute()
{
getEventBus().send(new GameStateRequest(GameState.MAIN_MENU));
}
});
}
@Override
public int getZIndex()
{
return 300;
}
}

@ -10,16 +10,22 @@ import mightypork.gamecore.gui.screens.LayeredScreen;
import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys; import mightypork.gamecore.input.Keys;
import mightypork.gamecore.logging.Log; import mightypork.gamecore.logging.Log;
import mightypork.gamecore.util.math.color.Color;
import mightypork.rogue.Config; import mightypork.rogue.Config;
import mightypork.rogue.GameStateManager.GameState; import mightypork.rogue.GameStateManager.GameState;
import mightypork.rogue.events.GameStateRequest; import mightypork.rogue.events.GameStateRequest;
import mightypork.rogue.world.PlayerFacade; import mightypork.rogue.world.PlayerFacade;
import mightypork.rogue.world.WorldProvider; import mightypork.rogue.world.WorldProvider;
import mightypork.rogue.world.events.PlayerKilledListener;
import mightypork.rogue.world.events.WorldPauseRequest; import mightypork.rogue.world.events.WorldPauseRequest;
import mightypork.rogue.world.events.WorldPauseRequest.PauseAction; import mightypork.rogue.world.events.WorldPauseRequest.PauseAction;
public class ScreenGame extends LayeredScreen { public class ScreenGame extends LayeredScreen implements PlayerKilledListener {
public static final Color COLOR_BTN_GOOD = Color.fromHex(0x28CB2D);
public static final Color COLOR_BTN_BAD = Color.fromHex(0xCB2828);
public static final Color COLOR_BTN_CANCEL = Color.fromHex(0xFFFB55);
/** /**
* Game gui state. * Game gui state.
@ -28,15 +34,16 @@ public class ScreenGame extends LayeredScreen {
*/ */
public enum GScrState public enum GScrState
{ {
WORLD, INV; WORLD, INV, DEATH, GOTO_MENU, GOTO_QUIT;
} }
private InventoryLayer invLayer; private InventoryLayer invLayer;
private HudLayer hudLayer; private HudLayer hudLayer;
private DeathLayer deathLayer;
private WorldLayer worldLayer; private WorldLayer worldLayer;
private GScrState state = GScrState.WORLD; private GScrState state = null;
private final ActionGroup worldActions = new ActionGroup(); private final ActionGroup worldActions = new ActionGroup();
@ -124,9 +131,16 @@ public class ScreenGame extends LayeredScreen {
@Override @Override
public void execute() public void execute()
{ {
// TODO ask to save setState(GScrState.GOTO_MENU);
}
};
getEventBus().send(new GameStateRequest(GameState.MAIN_MENU)); public Action actionQuit = new Action() {
@Override
public void execute()
{
setState(GScrState.GOTO_QUIT);
} }
}; };
@ -140,6 +154,7 @@ public class ScreenGame extends LayeredScreen {
pl.dropItem(pl.getInventory().getLastAddIndex()); pl.dropItem(pl.getInventory().getLastAddIndex());
} }
}; };
private AskSaveLayer askSaveLayer;
/** /**
@ -160,15 +175,47 @@ public class ScreenGame extends LayeredScreen {
if (nstate == GScrState.WORLD) { if (nstate == GScrState.WORLD) {
getEventBus().send(new WorldPauseRequest(PauseAction.RESUME)); getEventBus().send(new WorldPauseRequest(PauseAction.RESUME));
invLayer.setVisible(false); // hide all extra layers invLayer.hide();
invLayer.setEnabled(false); deathLayer.hide();
askSaveLayer.hide();
worldActions.setEnabled(true); worldActions.setEnabled(true);
} }
if (nstate == GScrState.INV) { if (nstate == GScrState.INV) {
invLayer.setVisible(true); invLayer.show();
invLayer.setEnabled(true); }
if (nstate == GScrState.DEATH) {
deathLayer.show();
}
if (nstate == GScrState.GOTO_MENU) {
askSaveLayer.setTask(new Runnable() {
@Override
public void run()
{
getEventBus().send(new GameStateRequest(GameState.MAIN_MENU));
}
});
askSaveLayer.show();
}
if (nstate == GScrState.GOTO_QUIT) {
askSaveLayer.setTask(new Runnable() {
@Override
public void run()
{
getEventBus().send(new GameStateRequest(GameState.EXIT));
}
});
askSaveLayer.show();
} }
this.state = nstate; this.state = nstate;
@ -186,16 +233,10 @@ public class ScreenGame extends LayeredScreen {
super(app); super(app);
addLayer(invLayer = new InventoryLayer(this)); addLayer(invLayer = new InventoryLayer(this));
invLayer.setEnabled(false); addLayer(deathLayer = new DeathLayer(this));
invLayer.setVisible(false);
addLayer(hudLayer = new HudLayer(this)); addLayer(hudLayer = new HudLayer(this));
hudLayer.setEnabled(true);
hudLayer.setVisible(true);
addLayer(worldLayer = new WorldLayer(this)); addLayer(worldLayer = new WorldLayer(this));
worldLayer.setEnabled(true); addLayer(askSaveLayer = new AskSaveLayer(this));
worldLayer.setVisible(true);
//pause key //pause key
bindKey(new KeyStroke(Keys.P), actionTogglePause); bindKey(new KeyStroke(Keys.P), actionTogglePause);
@ -210,6 +251,8 @@ public class ScreenGame extends LayeredScreen {
bindKey(new KeyStroke(Keys.L, Keys.MOD_CONTROL), actionLoad); bindKey(new KeyStroke(Keys.L, Keys.MOD_CONTROL), actionLoad);
bindKey(new KeyStroke(Keys.S, Keys.MOD_CONTROL), actionSave); bindKey(new KeyStroke(Keys.S, Keys.MOD_CONTROL), actionSave);
bindKey(new KeyStroke(Keys.Q, Keys.MOD_CONTROL), actionQuit);
bindKey(new KeyStroke(Keys.ESCAPE), actionMenu);
// add as actions - enableables. // add as actions - enableables.
worldActions.add(worldLayer); worldActions.add(worldLayer);
@ -223,12 +266,13 @@ public class ScreenGame extends LayeredScreen {
worldActions.add(actionSave); worldActions.add(actionSave);
worldActions.add(actionLoad); worldActions.add(actionLoad);
worldActions.add(actionMenu); worldActions.add(actionMenu);
worldActions.add(actionQuit);
worldActions.add(actionDropLastPickedItem); worldActions.add(actionDropLastPickedItem);
worldActions.setEnabled(true); worldActions.setEnabled(true);
// CHEAT - X-ray // CHEAT - X-ray
bindKey(new KeyStroke(Keys.F10, Keys.MOD_CONTROL), new Runnable() { bindKey(new KeyStroke(Keys.MULTIPLY, Keys.MOD_CONTROL), new Runnable() {
@Override @Override
public void run() public void run()
@ -244,6 +288,8 @@ public class ScreenGame extends LayeredScreen {
{ {
super.onScreenEnter(); super.onScreenEnter();
WorldProvider.get().setListening(true); WorldProvider.get().setListening(true);
setState(GScrState.WORLD);
} }
@ -253,4 +299,11 @@ public class ScreenGame extends LayeredScreen {
super.onScreenLeave(); super.onScreenLeave();
WorldProvider.get().setListening(false); WorldProvider.get().setListening(false);
} }
@Override
public void onPlayerKilled()
{
setState(GScrState.DEATH);
}
} }

@ -3,12 +3,14 @@ package mightypork.rogue.screens.menu;
import mightypork.gamecore.app.AppAccess; import mightypork.gamecore.app.AppAccess;
import mightypork.gamecore.gui.Action; import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.components.layout.GridLayout; import mightypork.gamecore.gui.components.layout.RowLayout;
import mightypork.gamecore.gui.components.painters.ImagePainter; import mightypork.gamecore.gui.components.painters.ImagePainter;
import mightypork.gamecore.gui.components.painters.QuadPainter; import mightypork.gamecore.gui.components.painters.QuadPainter;
import mightypork.gamecore.gui.screens.LayeredScreen; import mightypork.gamecore.gui.screens.LayeredScreen;
import mightypork.gamecore.gui.screens.Screen; import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer; import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys;
import mightypork.gamecore.resources.fonts.GLFont; import mightypork.gamecore.resources.fonts.GLFont;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.color.pal.PAL16; import mightypork.gamecore.util.math.color.pal.PAL16;
@ -59,15 +61,14 @@ public class ScreenMainMenu extends LayeredScreen {
bg.setRect(root); bg.setRect(root);
root.add(bg); root.add(bg);
final GridLayout layout = new GridLayout(root, menuBox, 10, 1); final RowLayout rows = new RowLayout(root, menuBox, 10);
layout.enableCaching(true); rows.enableCaching(true);
root.add(layout); root.add(rows);
int r = 0;
final ImagePainter ip = new ImagePainter(Res.getTxQuad("logo")); final ImagePainter ip = new ImagePainter(Res.getTxQuad("logo"));
ip.keepAspectRatio(); ip.keepAspectRatio();
layout.put(ip, r, 0, 4, 1); rows.add(ip, 4);
r += 5; rows.skip(1);
PushButton btn; PushButton btn;
@ -83,8 +84,8 @@ public class ScreenMainMenu extends LayeredScreen {
getEventBus().send(new GameStateRequest(GameState.SELECT_WORLD)); getEventBus().send(new GameStateRequest(GameState.SELECT_WORLD));
} }
}); });
layout.put(btn, r, 0, 2, 1); rows.add(btn, 2);
r += 3; rows.skip(1);
/* /*
// bouncy text button // bouncy text button
@ -111,7 +112,17 @@ public class ScreenMainMenu extends LayeredScreen {
getEventBus().send(new GameStateRequest(GameState.EXIT)); getEventBus().send(new GameStateRequest(GameState.EXIT));
} }
}); });
layout.put(btn, r, 0, 2, 1); rows.add(btn, 2);
bindKey(new KeyStroke(Keys.ESCAPE), new Runnable() {
@Override
public void run()
{
getEventBus().send(new GameStateRequest(GameState.EXIT));
}
});
} }

@ -3,18 +3,22 @@ package mightypork.rogue.screens.select_world;
import mightypork.gamecore.app.AppAccess; import mightypork.gamecore.app.AppAccess;
import mightypork.gamecore.gui.AlignX; import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.layout.GridLayout; import mightypork.gamecore.gui.components.layout.RowLayout;
import mightypork.gamecore.gui.components.painters.QuadPainter; import mightypork.gamecore.gui.components.painters.QuadPainter;
import mightypork.gamecore.gui.components.painters.TextPainter; import mightypork.gamecore.gui.components.painters.TextPainter;
import mightypork.gamecore.gui.screens.LayeredScreen; import mightypork.gamecore.gui.screens.LayeredScreen;
import mightypork.gamecore.gui.screens.Screen; import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer; import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys;
import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.color.pal.PAL16; import mightypork.gamecore.util.math.color.pal.PAL16;
import mightypork.gamecore.util.math.color.pal.RGB; import mightypork.gamecore.util.math.color.pal.RGB;
import mightypork.gamecore.util.math.constraints.rect.Rect; import mightypork.gamecore.util.math.constraints.rect.Rect;
import mightypork.rogue.GameStateManager.GameState;
import mightypork.rogue.Paths; import mightypork.rogue.Paths;
import mightypork.rogue.Res; import mightypork.rogue.Res;
import mightypork.rogue.events.GameStateRequest;
/** /**
@ -50,31 +54,50 @@ public class ScreenSelectWorld extends LayeredScreen {
private void init() private void init()
{ {
final Rect menuBox = root.shrink(root.width().perc(25), root.height().perc(20)); final Rect menuBox = root.shrink(root.width().perc(25), root.height().perc(30)).moveY(root.height().perc(-10));
final QuadPainter bg = QuadPainter.gradV(Color.fromHex(0x007eb3), PAL16.SEABLUE); final QuadPainter bg = QuadPainter.gradV(Color.fromHex(0x007eb3), PAL16.SEABLUE);
bg.setRect(root); bg.setRect(root);
root.add(bg); root.add(bg);
final GridLayout layout = new GridLayout(root, menuBox, 7, 1); final RowLayout rows = new RowLayout(root, menuBox, 4);
layout.enableCaching(true); rows.enableCaching(true);
root.add(layout); root.add(rows);
TextPainter tp; TextPainter tp;
layout.put(tp = new TextPainter(Res.getFont("thick"), AlignX.CENTER, RGB.YELLOW, "Save slot:"), 0, 0, 1, 1); rows.add(tp = new TextPainter(Res.getFont("thick"), AlignX.CENTER, RGB.YELLOW, "Save slot:"));
tp.setPaddingHPerc(0, 20); tp.setPaddingHPerc(0, 20);
tp.setShadow(RGB.BLACK_50, tp.height().mul(0.6 / 8D).toVectXY()); tp.setShadow(RGB.BLACK_50, tp.height().mul(0.6 / 8D).toVectXY());
slot1 = new WorldSlot(root, Paths.SAVE_SLOT_1); slot1 = new WorldSlot(root, Paths.SAVE_SLOT_1);
layout.put(slot1, 1, 0, 1, 1); rows.add(slot1);
slot2 = new WorldSlot(root, Paths.SAVE_SLOT_2); slot2 = new WorldSlot(root, Paths.SAVE_SLOT_2);
layout.put(slot2, 2, 0, 1, 1); rows.add(slot2);
slot3 = new WorldSlot(root, Paths.SAVE_SLOT_3); slot3 = new WorldSlot(root, Paths.SAVE_SLOT_3);
layout.put(slot3, 3, 0, 1, 1); rows.add(slot3);
// escape to quitn from here
bindKey(new KeyStroke(Keys.ESCAPE), new Runnable() {
@Override
public void run()
{
getEventBus().send(new GameStateRequest(GameState.MAIN_MENU));
}
});
bindKey(new KeyStroke(Keys.Q, Keys.MOD_CONTROL), new Runnable() {
@Override
public void run()
{
getEventBus().send(new GameStateRequest(GameState.EXIT));
}
});
} }

@ -21,7 +21,7 @@ public class ItemHeartPiece extends Item {
@Override @Override
protected ItemRenderer makeRenderer() protected ItemRenderer makeRenderer()
{ {
return new QuadItemRenderer(this, Res.getTxQuad("item.heart_piece")); return new QuadItemRenderer(this, Res.getTxQuad("item.heart"));
} }

Loading…
Cancel
Save