Fixed what could be fixed easily

master
Ondřej Hruška 11 years ago
parent 23fe35db4a
commit 84789ccf47
  1. 2
      .classpath
  2. 3
      src/mightypork/rogue/Launcher.java
  3. 3
      src/mightypork/rogue/RogueApp.java
  4. 18
      src/mightypork/rogue/RogueStateManager.java
  5. 5
      src/mightypork/rogue/screens/FpsOverlay.java
  6. 3
      src/mightypork/rogue/screens/LoadingOverlay.java
  7. 7
      src/mightypork/rogue/screens/RogueScreen.java
  8. 12
      src/mightypork/rogue/screens/game/IngameNav.java
  9. 16
      src/mightypork/rogue/screens/game/LayerAskSave.java
  10. 11
      src/mightypork/rogue/screens/game/LayerDeath.java
  11. 2
      src/mightypork/rogue/screens/game/LayerGameUi.java
  12. 18
      src/mightypork/rogue/screens/game/LayerInv.java
  13. 9
      src/mightypork/rogue/screens/game/LayerWin.java
  14. 36
      src/mightypork/rogue/screens/game/ScreenGame.java
  15. 23
      src/mightypork/rogue/screens/menu/ScreenMainMenu.java
  16. 17
      src/mightypork/rogue/screens/select_world/ScreenSelectWorld.java
  17. 12
      src/mightypork/rogue/screens/select_world/WorldSlot.java
  18. 10
      src/mightypork/rogue/screens/story/ScreenStory.java
  19. 22
      src/mightypork/rogue/world/World.java
  20. 12
      src/mightypork/rogue/world/WorldProvider.java
  21. 3
      src/mightypork/rogue/world/entity/impl/EntityBossRat.java
  22. 5
      src/mightypork/rogue/world/entity/impl/EntityPlayer.java
  23. 2
      src/mightypork/rogue/world/gui/Minimap.java
  24. 2
      src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java
  25. 9
      src/mightypork/rogue/world/gui/interaction/MIPMouse.java
  26. 9
      src/mightypork/rogue/world/level/Level.java
  27. 9
      src/mightypork/rogue/world/tile/Tile.java
  28. 3
      src/mightypork/rogue/world/tile/impl/TileBaseEntrance.java
  29. 3
      src/mightypork/rogue/world/tile/impl/TileBaseExit.java

@ -3,5 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry combineaccessrules="false" kind="src" path="/MightyUtils"/>
<classpathentry combineaccessrules="false" kind="src" path="/GameCore"/>
<classpathentry combineaccessrules="false" kind="src" path="/GameCore-LWJGL"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -5,6 +5,7 @@ import java.io.File;
import java.util.logging.Level;
import junk.BaseApp;
import mightypork.gamecore.core.App;
import mightypork.utils.files.OsUtils;
@ -77,7 +78,7 @@ public class Launcher {
System.exit(1);
}
final BaseApp app = new RogueApp();
final App app = new RogueApp();
app.getInitOptions().setWorkdir(workdir);
app.getInitOptions().setSigleInstance(true);

@ -5,6 +5,7 @@ import junk.AppInitOptions;
import junk.BaseApp;
import mightypork.gamecore.backends.lwjgl.LwjglBackend;
import mightypork.gamecore.backends.lwjgl.LwjglInputModule;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.events.MainLoopRequest;
import mightypork.gamecore.core.events.ShutdownEvent;
@ -37,7 +38,7 @@ import mightypork.utils.logging.Log;
*
* @author Ondřej Hruška (MightyPork)
*/
public final class RogueApp extends BaseApp implements ViewportChangeListener, ScreenshotRequestListener {
public final class RogueApp extends App implements ViewportChangeListener {
public RogueApp() {
super(new LwjglBackend());

@ -1,15 +1,13 @@
package mightypork.rogue;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.screens.impl.CrossfadeRequest;
import mightypork.utils.eventbus.clients.BusNode;
import mightypork.utils.logging.Log;
public class RogueStateManager extends AppModule {
public RogueStateManager(AppAccess app) {
super(app);
}
public class RogueStateManager extends BusNode {
public static enum RogueState
{
@ -21,23 +19,23 @@ public class RogueStateManager extends AppModule {
{
switch (state) {
case MAIN_MENU:
getEventBus().send(new CrossfadeRequest("main_menu", fromDark));
App.bus().send(new CrossfadeRequest("main_menu", fromDark));
break;
case SELECT_WORLD:
getEventBus().send(new CrossfadeRequest("select_world", fromDark));
App.bus().send(new CrossfadeRequest("select_world", fromDark));
break;
case PLAY_WORLD:
getEventBus().send(new CrossfadeRequest("game", fromDark));
App.bus().send(new CrossfadeRequest("game", fromDark));
break;
case STORY:
getEventBus().send(new CrossfadeRequest("story", fromDark));
App.bus().send(new CrossfadeRequest("story", fromDark));
break;
case EXIT:
getEventBus().send(new CrossfadeRequest(null));
App.bus().send(new CrossfadeRequest(null));
break;
default:

@ -27,13 +27,12 @@ public class FpsOverlay extends Overlay {
TextPainter tp;
public FpsOverlay(AppAccess screen) {
super(screen);
public FpsOverlay() {
/*
* Toggle key: F3
*/
bindKey(Config.getKeyStroke("global.fps_meter"), Trigger.RISING, new Action() {
bindKey(App.cfg().getKeyStroke("global.fps_meter"), Trigger.RISING, new Action() {
@Override
public void execute()

@ -63,8 +63,7 @@ public class LoadingOverlay extends Overlay {
};
public LoadingOverlay(AppAccess app) {
super(app);
public LoadingOverlay() {
final QuadPainter qp = new QuadPainter(PAL16.SEABLUE);
qp.setRect(root);

@ -1,6 +1,7 @@
package mightypork.rogue.screens;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.events.ShutdownEvent;
import mightypork.gamecore.core.events.ShutdownListener;
import mightypork.gamecore.gui.screens.LayeredScreen;
@ -11,16 +12,12 @@ import mightypork.utils.annotations.Stub;
public class RogueScreen extends LayeredScreen implements ShutdownListener {
public RogueScreen(AppAccess app) {
super(app);
}
@Override
@Stub
public void onShutdown(ShutdownEvent event)
{
getEventBus().send(new RogueStateRequest(RogueState.EXIT));
App.bus().send(new RogueStateRequest(RogueState.EXIT));
event.consume();
}
}

@ -20,17 +20,17 @@ public class IngameNav extends LayoutComponent {
private final TxQuad bg;
public IngameNav(AppAccess app) {
this(app, null);
public IngameNav() {
this(null);
}
public IngameNav(AppAccess app, RectBound context) {
super(app, context);
public IngameNav(RectBound context) {
super(context);
final Rect shr = this.shrink(height().perc(5));
leftFlow = new FlowColumnLayout(app, context, shr.height(), AlignX.LEFT);
rightFlow = new FlowColumnLayout(app, context, shr.height(), AlignX.RIGHT);
leftFlow = new FlowColumnLayout(context, shr.height(), AlignX.LEFT);
rightFlow = new FlowColumnLayout(context, shr.height(), AlignX.RIGHT);
leftFlow.setRect(shr);
rightFlow.setRect(shr);

@ -3,6 +3,7 @@ package mightypork.rogue.screens.game;
import java.io.IOException;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.graphics.fonts.IFont;
import mightypork.gamecore.gui.Action;
@ -44,7 +45,8 @@ public class LayerAskSave extends FadingLayer {
}
public LayerAskSave(final ScreenGame screen) {
public LayerAskSave(final ScreenGame screen)
{
super(screen);
this.gscreen = screen;
@ -121,13 +123,15 @@ public class LayerAskSave extends FadingLayer {
btn2.setAction(discard);
btn3.setAction(cancel);
bindKey(Config.getKeyStroke("general.close"), Trigger.RISING, cancel);
bindKey(Config.getKeyStroke("general.cancel"), Trigger.RISING, cancel);
Config cfg = App.cfg();
bindKey(cfg.getKeyStroke("general.close"), Trigger.RISING, cancel);
bindKey(cfg.getKeyStroke("general.cancel"), Trigger.RISING, cancel);
bindKey(Config.getKeyStroke("general.yes"), Trigger.RISING, save);
bindKey(Config.getKeyStroke("general.confirm"), Trigger.RISING, save);
bindKey(cfg.getKeyStroke("general.yes"), Trigger.RISING, save);
bindKey(cfg.getKeyStroke("general.confirm"), Trigger.RISING, save);
bindKey(Config.getKeyStroke("general.no"), Trigger.RISING, discard);
bindKey(cfg.getKeyStroke("general.no"), Trigger.RISING, discard);
}

@ -3,6 +3,7 @@ package mightypork.rogue.screens.game;
import java.io.IOException;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.graphics.fonts.IFont;
import mightypork.gamecore.gui.Action;
@ -82,16 +83,18 @@ public class LayerDeath extends FadingLayer {
@Override
protected void execute()
{
getEventBus().send(new RogueStateRequest(RogueState.MAIN_MENU));
App.bus().send(new RogueStateRequest(RogueState.MAIN_MENU));
}
};
btn1.setAction(load);
btn2.setAction(quit);
bindKey(Config.getKeyStroke("game.load"), Trigger.RISING, load);
bindKey(Config.getKeyStroke("general.confirm"), Trigger.RISING, load);
bindKey(Config.getKeyStroke("general.close"), Trigger.RISING, quit);
Config cfg = App.cfg();
bindKey(cfg.getKeyStroke("game.load"), Trigger.RISING, load);
bindKey(cfg.getKeyStroke("general.confirm"), Trigger.RISING, load);
bindKey(cfg.getKeyStroke("general.close"), Trigger.RISING, quit);
}

@ -111,7 +111,7 @@ public class LayerGameUi extends ScreenLayer {
private void buildNav()
{
final IngameNav nav = new IngameNav(this);
final IngameNav nav = new IngameNav();
nav.setRect(root.bottomEdge().growUp(root.height().perc(12)));
root.add(nav);

@ -1,6 +1,7 @@
package mightypork.rogue.screens.game;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.gui.components.layout.ConstraintLayout;
import mightypork.gamecore.gui.components.layout.FlowColumnLayout;
@ -29,9 +30,9 @@ public class LayerInv extends FadingLayer {
private static final int SLOT_COUNT = 8;
private static final int SLOT_ROW = 4;
private final KeyStroke keyUse = Config.getKeyStroke("game.inv.use");
private final KeyStroke keyDrop = Config.getKeyStroke("game.inv.drop");
private final KeyStroke keyClose = Config.getKeyStroke("general.close");
private final KeyStroke keyUse = App.cfg().getKeyStroke("game.inv.use");
private final KeyStroke keyDrop = App.cfg().getKeyStroke("game.inv.drop");
private final KeyStroke keyClose = App.cfg().getKeyStroke("general.close");
private final StringProvider contextStrProv = new StringProvider() {
@ -116,7 +117,7 @@ public class LayerInv extends FadingLayer {
int pos = 0;
final GridLayout gl = new GridLayout(root, fg, 10, 1);
final GridLayout gl = new GridLayout(fg, 10, 1);
root.add(gl);
final TextPainter txp = new TextPainter(Res.getFont("thick"), AlignX.CENTER, RGB.YELLOW, "Inventory");
@ -232,8 +233,9 @@ public class LayerInv extends FadingLayer {
private void setupGridWalkKeys()
{
Config cfg = App.cfg();
bindKey(Config.getKeyStroke("game.inv.move.left"), Trigger.RISING, new Runnable() {
bindKey(cfg.getKeyStroke("game.inv.move.left"), Trigger.RISING, new Runnable() {
@Override
public void run()
@ -250,7 +252,7 @@ public class LayerInv extends FadingLayer {
}
});
bindKey(Config.getKeyStroke("game.inv.move.right"), Trigger.RISING, new Runnable() {
bindKey(cfg.getKeyStroke("game.inv.move.right"), Trigger.RISING, new Runnable() {
@Override
public void run()
@ -267,7 +269,7 @@ public class LayerInv extends FadingLayer {
}
});
bindKey(Config.getKeyStroke("game.inv.move.up"), Trigger.RISING, new Runnable() {
bindKey(cfg.getKeyStroke("game.inv.move.up"), Trigger.RISING, new Runnable() {
@Override
public void run()
@ -284,7 +286,7 @@ public class LayerInv extends FadingLayer {
}
});
bindKey(Config.getKeyStroke("game.inv.move.down"), Trigger.RISING, new Runnable() {
bindKey(cfg.getKeyStroke("game.inv.move.down"), Trigger.RISING, new Runnable() {
@Override
public void run()

@ -3,6 +3,7 @@ package mightypork.rogue.screens.game;
import java.io.File;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.graphics.fonts.IFont;
import mightypork.gamecore.gui.Action;
@ -63,14 +64,14 @@ public class LayerWin extends FadingLayer {
final File f = WorldProvider.get().getWorld().getSaveFile();
f.delete();
getEventBus().send(new RogueStateRequest(RogueState.MAIN_MENU));
App.bus().send(new RogueStateRequest(RogueState.MAIN_MENU));
}
};
btn1.setAction(quit);
bindKey(Config.getKeyStroke("general.confirm"), Trigger.RISING, quit);
bindKey(Config.getKeyStroke("general.close"), Trigger.RISING, quit);
bindKey(App.cfg().getKeyStroke("general.confirm"), Trigger.RISING, quit);
bindKey(App.cfg().getKeyStroke("general.close"), Trigger.RISING, quit);
}
@ -84,7 +85,7 @@ public class LayerWin extends FadingLayer {
@Override
protected void onShowFinished()
{
getSoundSystem().fadeOutAllLoops();
App.audio().fadeOutAllLoops();
Res.getSoundEffect("game.win").play(1);
}

@ -3,6 +3,7 @@ package mightypork.rogue.screens.game;
import java.io.File;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.events.ShutdownEvent;
import mightypork.gamecore.gui.Action;
@ -84,7 +85,7 @@ public class ScreenGame extends RogueScreen implements PlayerDeathHandler, GameW
@Override
public void execute()
{
getEventBus().send(new WorldPauseRequest(PauseAction.TOGGLE));
App.bus().send(new WorldPauseRequest(PauseAction.TOGGLE));
}
};
@ -176,7 +177,7 @@ public class ScreenGame extends RogueScreen implements PlayerDeathHandler, GameW
final boolean gameOver = WorldProvider.get().getWorld().isGameOver();
if (nstate != GScrState.WORLD && state == GScrState.WORLD) { // leaving world.
getEventBus().send(new WorldPauseRequest(PauseAction.PAUSE));
App.bus().send(new WorldPauseRequest(PauseAction.PAUSE));
worldActions.setEnabled(false); // disable world actions
}
@ -189,7 +190,7 @@ public class ScreenGame extends RogueScreen implements PlayerDeathHandler, GameW
Runnable task;
switch (nstate) {
case WORLD:
getEventBus().send(new WorldPauseRequest(PauseAction.RESUME));
App.bus().send(new WorldPauseRequest(PauseAction.RESUME));
worldActions.setEnabled(true);
break;
@ -214,7 +215,7 @@ public class ScreenGame extends RogueScreen implements PlayerDeathHandler, GameW
@Override
public void run()
{
getEventBus().send(new RogueStateRequest(goal));
App.bus().send(new RogueStateRequest(goal));
}
};
@ -236,8 +237,7 @@ public class ScreenGame extends RogueScreen implements PlayerDeathHandler, GameW
}
public ScreenGame(AppAccess app) {
super(app);
public ScreenGame() {
addLayer(invLayer = new LayerInv(this));
addLayer(deathLayer = new LayerDeath(this));
@ -246,17 +246,19 @@ public class ScreenGame extends RogueScreen implements PlayerDeathHandler, GameW
addLayer(worldLayer = new LayerMapView(this));
addLayer(askSaveLayer = new LayerAskSave(this));
bindKey(Config.getKeyStroke("game.pause"), Trigger.RISING, actionTogglePause);
Config cfg = App.cfg();
bindKey(Config.getKeyStroke("game.inventory"), Trigger.RISING, actionToggleInv);
bindKey(Config.getKeyStroke("game.drop"), Trigger.RISING, actionDropLastPickedItem);
bindKey(Config.getKeyStroke("game.eat"), Trigger.RISING, actionEat);
bindKey(Config.getKeyStroke("game.minimap"), Trigger.RISING, actionToggleMinimap);
bindKey(Config.getKeyStroke("game.zoom"), Trigger.RISING, actionToggleZoom);
bindKey(cfg.getKeyStroke("game.pause"), Trigger.RISING, actionTogglePause);
bindKey(Config.getKeyStroke("game.load"), Trigger.RISING, actionLoad);
bindKey(Config.getKeyStroke("game.save"), Trigger.RISING, actionSave);
bindKey(Config.getKeyStroke("game.quit"), Trigger.RISING, actionMenu);
bindKey(cfg.getKeyStroke("game.inventory"), Trigger.RISING, actionToggleInv);
bindKey(cfg.getKeyStroke("game.drop"), Trigger.RISING, actionDropLastPickedItem);
bindKey(cfg.getKeyStroke("game.eat"), Trigger.RISING, actionEat);
bindKey(cfg.getKeyStroke("game.minimap"), Trigger.RISING, actionToggleMinimap);
bindKey(cfg.getKeyStroke("game.zoom"), Trigger.RISING, actionToggleZoom);
bindKey(cfg.getKeyStroke("game.load"), Trigger.RISING, actionLoad);
bindKey(cfg.getKeyStroke("game.save"), Trigger.RISING, actionSave);
bindKey(cfg.getKeyStroke("game.quit"), Trigger.RISING, actionMenu);
// bindKey(new KeyStroke(Keys.W), Edge.RISING, new Runnable() {
//
@ -284,7 +286,7 @@ public class ScreenGame extends RogueScreen implements PlayerDeathHandler, GameW
worldActions.setEnabled(true);
// CHEAT - X-ray
bindKey(Config.getKeyStroke("game.cheat.xray"), Trigger.RISING, new Runnable() {
bindKey(cfg.getKeyStroke("game.cheat.xray"), Trigger.RISING, new Runnable() {
@Override
public void run()
@ -304,7 +306,7 @@ public class ScreenGame extends RogueScreen implements PlayerDeathHandler, GameW
setState(GScrState.WORLD);
hideAllPopups();
getSoundSystem().fadeOutAllLoops();
App.audio().fadeOutAllLoops();
Res.getSoundLoop("music.dungeon").fadeIn();
}

@ -1,6 +1,7 @@
package mightypork.rogue.screens.menu;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.events.ShutdownEvent;
import mightypork.gamecore.graphics.fonts.IFont;
@ -38,7 +39,8 @@ public class ScreenMainMenu extends RogueScreen {
*/
class MenuLayer extends ScreenLayer {
public MenuLayer(Screen screen) {
public MenuLayer(Screen screen)
{
super(screen);
init();
@ -53,7 +55,7 @@ public class ScreenMainMenu extends RogueScreen {
bg.setRect(root);
root.add(bg);
final RowLayout rows = new RowLayout(root, menuBox, 13);
final RowLayout rows = new RowLayout(menuBox, 13);
rows.enableCaching(true);
root.add(rows);
@ -73,7 +75,7 @@ public class ScreenMainMenu extends RogueScreen {
@Override
protected void execute()
{
getEventBus().send(new RogueStateRequest(RogueState.SELECT_WORLD));
App.bus().send(new RogueStateRequest(RogueState.SELECT_WORLD));
}
});
rows.add(btn, 2);
@ -85,7 +87,7 @@ public class ScreenMainMenu extends RogueScreen {
@Override
protected void execute()
{
getEventBus().send(new RogueStateRequest(RogueState.STORY));
App.bus().send(new RogueStateRequest(RogueState.STORY));
}
});
rows.add(btn, 2);
@ -98,17 +100,17 @@ public class ScreenMainMenu extends RogueScreen {
@Override
protected void execute()
{
getEventBus().send(new ShutdownEvent());
App.shutdown();
}
});
rows.add(btn, 2);
bindKey(Config.getKeyStroke("general.close"), Trigger.RISING, new Runnable() {
bindKey(App.cfg().getKeyStroke("general.close"), Trigger.RISING, new Runnable() {
@Override
public void run()
{
getEventBus().send(new ShutdownEvent());
App.shutdown();
}
});
}
@ -123,9 +125,8 @@ public class ScreenMainMenu extends RogueScreen {
}
public ScreenMainMenu(AppAccess app) {
super(app);
public ScreenMainMenu()
{
addLayer(new MenuLayer(this));
}
@ -135,7 +136,7 @@ public class ScreenMainMenu extends RogueScreen {
{
super.onScreenEnter();
getSoundSystem().fadeOutAllLoops();
App.audio().fadeOutAllLoops();
Res.getSoundLoop("music.menu").fadeIn();
}
}

@ -1,6 +1,7 @@
package mightypork.rogue.screens.select_world;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.WorkDir;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.gui.components.layout.RowLayout;
@ -28,9 +29,7 @@ import mightypork.utils.math.constraints.rect.Rect;
*/
public class ScreenSelectWorld extends RogueScreen {
public ScreenSelectWorld(AppAccess app) {
super(app);
public ScreenSelectWorld() {
addLayer(new WorldsLayer(this));
}
@ -56,7 +55,7 @@ public class ScreenSelectWorld extends RogueScreen {
bg.setRect(root);
root.add(bg);
final RowLayout rows = new RowLayout(root, menuBox, 4);
final RowLayout rows = new RowLayout(menuBox, 4);
rows.enableCaching(true);
root.add(rows);
@ -66,22 +65,22 @@ public class ScreenSelectWorld extends RogueScreen {
tp.setVPaddingPercent(20);
tp.setShadow(RGB.BLACK_50, tp.height().mul(0.6 / 8D).toVectXY());
slot1 = new WorldSlot(root, WorkDir.getFile("slot1"));
slot1 = new WorldSlot(WorkDir.getFile("slot1"));
rows.add(slot1);
slot2 = new WorldSlot(root, WorkDir.getFile("slot2"));
slot2 = new WorldSlot(WorkDir.getFile("slot2"));
rows.add(slot2);
slot3 = new WorldSlot(root, WorkDir.getFile("slot3"));
slot3 = new WorldSlot(WorkDir.getFile("slot3"));
rows.add(slot3);
// escape to quitn from here
bindKey(Config.getKeyStroke("general.close"), Trigger.RISING, new Runnable() {
bindKey(App.cfg().getKeyStroke("general.close"), Trigger.RISING, new Runnable() {
@Override
public void run()
{
getEventBus().send(new RogueStateRequest(RogueState.MAIN_MENU));
App.bus().send(new RogueStateRequest(RogueState.MAIN_MENU));
}
});
}

@ -3,6 +3,7 @@ package mightypork.rogue.screens.select_world;
import java.io.File;
import mightypork.gamecore.core.App;
import mightypork.gamecore.graphics.fonts.IFont;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.components.input.TextButton;
@ -45,8 +46,7 @@ public class WorldSlot extends ConstraintLayout {
private TextButton delBtn;
public WorldSlot(AppAccess app, File worldFile) {
super(app);
public WorldSlot(File worldFile) {
this.file = worldFile;
@ -64,7 +64,7 @@ public class WorldSlot extends ConstraintLayout {
qp.setRect(innerRect);
add(qp);
final GridLayout gridl = new GridLayout(app, 1, 8);
final GridLayout gridl = new GridLayout(1, 8);
final Num shrinkH = width().perc(8);
final Num shrinkV = height().perc(10);
gridl.setRect(innerRect.shrink(shrinkH, shrinkH, shrinkV, shrinkV.half()));
@ -91,7 +91,7 @@ public class WorldSlot extends ConstraintLayout {
msg = "Creating world...";
}
getEventBus().send(new LoadingOverlayRequest(msg, new Runnable() {
App.bus().send(new LoadingOverlayRequest(msg, new Runnable() {
@Override
public void run()
@ -106,7 +106,7 @@ public class WorldSlot extends ConstraintLayout {
WorldProvider.get().saveWorld();
getEventBus().send(new ScreenRequest("game"));
App.bus().send(new ScreenRequest("game"));
} catch (final Exception t) {
Log.e("Could not create & save the world.", t);
@ -120,7 +120,7 @@ public class WorldSlot extends ConstraintLayout {
w.load((IonDataBundle) worldBundle.get("world"));
WorldProvider.get().setWorld(w);
getEventBus().send(new ScreenRequest("game"));
App.bus().send(new ScreenRequest("game"));
} catch (final Exception e) {
Log.e("Could not load the world.", e);

@ -1,6 +1,7 @@
package mightypork.rogue.screens.story;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.components.layout.RowLayout;
@ -202,13 +203,12 @@ public class ScreenStory extends RogueScreen implements MouseButtonHandler {
@Override
protected void execute()
{
getEventBus().send(new RogueStateRequest(RogueState.MAIN_MENU));
App.bus().send(new RogueStateRequest(RogueState.MAIN_MENU));
}
};
public ScreenStory(AppAccess app) {
super(app);
public ScreenStory() {
addLayer(new LayerColor(this, Color.fromHex(0x040c1e), 0));
addLayer(slideLayer = new LayerSlide(this));
@ -217,7 +217,7 @@ public class ScreenStory extends RogueScreen implements MouseButtonHandler {
bindKey(new KeyStroke(Keys.RIGHT), Trigger.RISING, next);
bindKey(new KeyStroke(Keys.BACKSPACE), Trigger.RISING, prev);
bindKey(new KeyStroke(Keys.LEFT), Trigger.RISING, prev);
bindKey(Config.getKeyStroke("general.close"), Trigger.RISING, close);
bindKey(App.cfg().getKeyStroke("general.close"), Trigger.RISING, close);
}
private int slide = 0;
@ -248,7 +248,7 @@ public class ScreenStory extends RogueScreen implements MouseButtonHandler {
break;
case 3:
getEventBus().send(new RogueStateRequest(RogueState.MAIN_MENU));
App.bus().send(new RogueStateRequest(RogueState.MAIN_MENU));
}
}

@ -26,14 +26,13 @@ import mightypork.utils.math.algo.Coord;
*
* @author Ondřej Hruška (MightyPork)
*/
public class World implements DelegatingClient, BusAccess, IonBundled, Pauseable, Updateable, PlayerDeathHandler, GameWinHandler {
public class World implements DelegatingClient, IonBundled, Pauseable, Updateable, PlayerDeathHandler, GameWinHandler {
// not saved stuffs
private final PlayerFacade playerFacade = new PlayerFacade(this);
final WorldConsole console = new WorldConsole();
Entity playerEntity;
private BusAccess bus;
private int pauseDepth = 0;
private boolean gameOver = false;
@ -175,25 +174,6 @@ public class World implements DelegatingClient, BusAccess, IonBundled, Pauseable
}
/**
* Attach to an event bus
*
* @param bus event bus
*/
public void assignBus(BusAccess bus)
{
this.bus = bus;
}
@Override
public EventBus getEventBus()
{
if (bus == null) throw new NullPointerException("World doesn't have a bus assigned.");
return bus.getEventBus();
}
@Override
public void pause()
{

@ -6,6 +6,7 @@ import java.io.IOException;
import mightypork.rogue.world.gen.WorldCreator;
import mightypork.rogue.world.level.Level;
import mightypork.utils.eventbus.clients.BusNode;
import mightypork.utils.ion.Ion;
import mightypork.utils.ion.IonDataBundle;
import mightypork.utils.logging.Log;
@ -16,18 +17,18 @@ import mightypork.utils.logging.Log;
*
* @author Ondřej Hruška (MightyPork)
*/
public class WorldProvider extends RootBusNode {
public class WorldProvider extends BusNode {
public static synchronized void init(BusAccess busAccess)
public static synchronized void init()
{
if (inst == null) {
inst = new WorldProvider(busAccess);
inst = new WorldProvider();
}
}
public WorldProvider(BusAccess busAccess) {
super(busAccess);
public WorldProvider()
{
setListening(false);
}
@ -82,7 +83,6 @@ public class WorldProvider extends RootBusNode {
if (newWorld == null) return;
world.assignBus(this); // connect to bus (for event dispatching)
addChildClient(world);
}

@ -1,6 +1,7 @@
package mightypork.rogue.world.entity.impl;
import mightypork.gamecore.core.App;
import mightypork.rogue.world.entity.Entity;
import mightypork.rogue.world.entity.EntityModel;
import mightypork.rogue.world.entity.EntityPathFinder;
@ -64,7 +65,7 @@ public class EntityBossRat extends Entity {
public void onKilled()
{
// send kill event to listeners, after the entity has despawned (disappeared)
getWorld().getEventBus().sendDelayed(new GameWinEvent(), getDespawnDelay() * 1.5); // dramatic pause
App.bus().sendDelayed(new GameWinEvent(), getDespawnDelay() * 1.5); // dramatic pause
}

@ -1,6 +1,7 @@
package mightypork.rogue.world.entity.impl;
import mightypork.gamecore.core.App;
import mightypork.rogue.world.entity.*;
import mightypork.rogue.world.entity.modules.EntityMoveListener;
import mightypork.rogue.world.entity.render.EntityRendererMobLR;
@ -62,7 +63,7 @@ public class EntityPlayer extends Entity {
private void fireEvt()
{
getWorld().getEventBus().send(new PlayerStepEndEvent(EntityPlayer.this));
App.bus().send(new PlayerStepEndEvent(EntityPlayer.this));
}
@ -134,7 +135,7 @@ public class EntityPlayer extends Entity {
public void onKilled()
{
// send kill event to listeners, after the entity has despawned (disappeared)
getWorld().getEventBus().sendDelayed(new PlayerKilledEvent(), getDespawnDelay());
App.bus().sendDelayed(new PlayerKilledEvent(), getDespawnDelay());
getWorld().getConsole().msgDie(lastAttacker);
}

@ -48,6 +48,8 @@ public class Minimap extends InputComponent implements MouseButtonHandler {
final Coord point = new Coord(tl.xi(), tl.yi());
// FIXME do not use LWJGL directly
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBegin(GL11.GL_QUADS);

@ -23,6 +23,8 @@ import mightypork.utils.math.constraints.vect.Vect;
public class MIPKeyboard extends MapInteractionPlugin implements DelegatingClient, PlayerStepEndListener, Updateable {
// FIXME cannot be static.
//@formatter:off
private static final KeyStroke[] keys = {
Config.getKeyStroke("game.walk.left"),

@ -2,6 +2,7 @@ package mightypork.rogue.world.gui.interaction;
import mightypork.gamecore.backends.lwjgl.LwjglInputModule;
import mightypork.gamecore.core.App;
import mightypork.rogue.world.entity.impl.EntityPlayer;
import mightypork.rogue.world.events.PlayerStepEndListener;
import mightypork.rogue.world.gui.MapView;
@ -30,10 +31,10 @@ public class MIPMouse extends MapInteractionPlugin implements PlayerStepEndListe
{
if (isImmobile()) return;
final Vect pos = LwjglInputModule.getMousePos();
final Vect pos = App.input().getMousePos();
if (!pos.isInside(mapView)) return;
if (LwjglInputModule.isMouseButtonDown(LEFT)) {
if (App.input().isMouseButtonDown(LEFT)) {
if (mouseWalk(pos)) return;
if (mapView.plc.getPlayer().isMoving() && troToNav(pos)) return;
}
@ -117,10 +118,10 @@ public class MIPMouse extends MapInteractionPlugin implements PlayerStepEndListe
{
if (isImmobile()) return;
final Vect pos = LwjglInputModule.getMousePos();
final Vect pos = App.input().getMousePos();
if (!pos.isInside(mapView)) return;
if (LwjglInputModule.isMouseButtonDown(LEFT)) {
if (App.input().isMouseButtonDown(LEFT)) {
if (mouseWalk(pos)) return;
if (mapView.plc.getPlayer().isMoving() && troToNav(pos)) return;
}

@ -36,7 +36,7 @@ import mightypork.utils.math.noise.NoiseGen;
*
* @author Ondřej Hruška (MightyPork)
*/
public class Level implements BusAccess, Updateable, DelegatingClient, ToggleableClient, IonBinary {
public class Level implements Updateable, DelegatingClient, ToggleableClient, IonBinary {
private final FloodFill exploreFiller = new FloodFill() {
@ -636,13 +636,6 @@ public class Level implements BusAccess, Updateable, DelegatingClient, Toggleabl
}
@Override
public EventBus getEventBus()
{
return world.getEventBus();
}
@Override
public boolean isListening()
{

@ -23,7 +23,7 @@ import mightypork.utils.math.color.Color;
*
* @author Ondřej Hruška (MightyPork)
*/
public abstract class Tile implements BusAccess, IonBinary {
public abstract class Tile implements IonBinary {
// tmp extras
public final TileGenData genData = new TileGenData();
@ -274,11 +274,4 @@ public abstract class Tile implements BusAccess, IonBinary {
return level.getWorld();
}
@Override
public EventBus getEventBus()
{
return level.getEventBus();
}
}

@ -1,6 +1,7 @@
package mightypork.rogue.world.tile.impl;
import mightypork.gamecore.core.App;
import mightypork.rogue.world.events.WorldAscendRequest;
import mightypork.rogue.world.tile.TileColors;
import mightypork.rogue.world.tile.TileModel;
@ -21,7 +22,7 @@ public abstract class TileBaseEntrance extends TileBaseStairs {
final Coord plpos = getWorld().getPlayer().getCoord();
if (!plpos.equals(getLevel().getEnterPoint())) return false;
getEventBus().send(new WorldAscendRequest());
App.bus().send(new WorldAscendRequest());
return true;
}

@ -1,6 +1,7 @@
package mightypork.rogue.world.tile.impl;
import mightypork.gamecore.core.App;
import mightypork.rogue.world.events.WorldDescendRequest;
import mightypork.rogue.world.tile.TileColors;
import mightypork.rogue.world.tile.TileModel;
@ -21,7 +22,7 @@ public abstract class TileBaseExit extends TileBaseStairs {
final Coord plpos = getWorld().getPlayer().getCoord();
if (!plpos.equals(getLevel().getExitPoint())) return false;
getEventBus().send(new WorldDescendRequest());
App.bus().send(new WorldDescendRequest());
return true;
}

Loading…
Cancel
Save