Adapted to use new gamecore. UGLY. to be done. Also no sounds.

master
Ondřej Hruška 11 years ago
parent f0401d0184
commit 60e76ecfcc
  1. 169
      src/mightypork/rogue/Launcher.java
  2. 137
      src/mightypork/rogue/RogueApp.java
  3. 19
      src/mightypork/rogue/RogueConfig.java
  4. 63
      src/mightypork/rogue/RogueInitConfig.java
  5. 13
      src/mightypork/rogue/RogueInitResources.java
  6. 24
      src/mightypork/rogue/RogueInitWorkdir.java
  7. 46
      src/mightypork/rogue/RogueKeys.java
  8. 14
      src/mightypork/rogue/RogueRoutes.java
  9. 10
      src/mightypork/rogue/world/WorldProvider.java
  10. 7
      src/mightypork/rogue/world/gui/Minimap.java
  11. 34
      src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java

@ -5,7 +5,36 @@ import java.io.File;
import java.util.logging.Level; import java.util.logging.Level;
import mightypork.gamecore.core.App; import mightypork.gamecore.core.App;
import mightypork.gamecore.core.DeltaMainLoop;
import mightypork.gamecore.core.MainLoop;
import mightypork.gamecore.core.init.InitTaskCrashHandler;
import mightypork.gamecore.core.init.InitTaskCustom;
import mightypork.gamecore.core.init.InitTaskDisplay;
import mightypork.gamecore.core.init.InitTaskIonizables;
import mightypork.gamecore.core.init.InitTaskLog;
import mightypork.gamecore.core.init.InitTaskLogHeader;
import mightypork.gamecore.core.init.InitTaskMainLoop;
import mightypork.gamecore.core.init.InitTaskResourceLoaderAsync;
import mightypork.gamecore.core.init.InitTaskScreens;
import mightypork.gamecore.core.plugins.screenshot.InitTaskPluginScreenshot;
import mightypork.gamecore.core.plugins.screenshot.ScreenshotRequest;
import mightypork.gamecore.graphics.FullscreenToggleRequest;
import mightypork.gamecore.graphics.Renderable;
import mightypork.gamecore.gui.screens.ScreenRegistry;
import mightypork.gamecore.gui.screens.impl.CrossfadeOverlay;
import mightypork.gamecore.input.Trigger;
import mightypork.rogue.screens.FpsOverlay;
import mightypork.rogue.screens.LoadingOverlay;
import mightypork.rogue.screens.game.ScreenGame;
import mightypork.rogue.screens.menu.ScreenMainMenu;
import mightypork.rogue.screens.select_world.ScreenSelectWorld;
import mightypork.rogue.screens.story.ScreenStory;
import mightypork.rogue.world.Inventory;
import mightypork.rogue.world.WorldProvider;
import mightypork.utils.eventbus.BusEvent;
import mightypork.utils.files.OsUtils; import mightypork.utils.files.OsUtils;
import mightypork.utils.ion.Ion;
import mightypork.utils.logging.Log;
public class Launcher { public class Launcher {
@ -79,11 +108,143 @@ public class Launcher {
final App app = new RogueApp(); final App app = new RogueApp();
app.getInitOptions().setWorkdir(workdir); App.bus().detailedLogging = true;
app.getInitOptions().setSigleInstance(true);
app.addInitTask(new RogueInitWorkdir(workdir));
app.addInitTask(new RogueInitConfig());
app.addInitTask(new InitTaskResourceLoaderAsync());
app.addInitTask(new RogueInitResources());
app.addInitTask(new InitTaskCrashHandler());
app.addInitTask(new InitTaskPluginScreenshot("screenshots"));
app.addInitTask(new InitTaskIonizables() {
@Override
public void after()
{
Ion.register(mightypork.rogue.world.level.Level.class);
Ion.register(Inventory.class);
}
});
final Level logLevelWrite = llFile, logLevelPrint = llSyso;
app.addInitTask(new InitTaskLog() {
@Override
public void init()
{
setArchiveCount(5);
setLevels(logLevelWrite, logLevelPrint);
setLogDir("logs");
setLogName("runtime");
}
});
app.addInitTask(new InitTaskLogHeader() {
@Override
public void before()
{
Log.i("## Starting Rogue v." + Const.VERSION + " ##");
}
});
app.addInitTask(new InitTaskDisplay() {
@Override
public void init()
{
final int w = App.cfg().getValue("display.width");
final int h = App.cfg().getValue("display.height");
final boolean fs = App.cfg().getValue("display.fullscreen");
setSize(w, h);
setResizable(true);
setFullscreen(fs);
setTitle(Const.TITLEBAR);
setTargetFps(Const.FPS_RENDER);
}
});
app.addInitTask(new InitTaskCustom("global_keys", new String[] { "config" }) {
@Override
public void run()
{
bindEventToKey(new FullscreenToggleRequest(), "global.fullscreen");
bindEventToKey(new ScreenshotRequest(), "global.screenshot");
final Runnable quitTask = new Runnable() {
@Override
public void run()
{
App.shutdown();
}
};
App.input().bindKey(App.cfg().getKeyStroke("global.quit"), Trigger.RISING, quitTask);
App.input().bindKey(App.cfg().getKeyStroke("global.quit_force"), Trigger.RISING, quitTask);
}
private void bindEventToKey(final BusEvent<?> event, String strokeName)
{
App.input().bindKey(App.cfg().getKeyStroke(strokeName), Trigger.RISING, new Runnable() {
@Override
public void run()
{
App.bus().send(event);
}
});
}
});
app.addInitTask(new InitTaskMainLoop() {
@Override
protected MainLoop getLoopImpl()
{
final MainLoop loop = new DeltaMainLoop();
return loop;
}
});
app.addInitTask(new InitTaskScreens() {
@Override
protected Renderable getMainRenderableImpl()
{
final ScreenRegistry screens = new ScreenRegistry();
app.addChildClient(screens);
/* game screen references world provider instance */
App.bus().subscribe(new RogueStateManager());
App.bus().subscribe(WorldProvider.get());
screens.addOverlay(new CrossfadeOverlay());
screens.addScreen("main_menu", new ScreenMainMenu());
screens.addScreen("select_world", new ScreenSelectWorld());
screens.addScreen("game", new ScreenGame());
screens.addScreen("story", new ScreenStory());
screens.addOverlay(new FpsOverlay());
screens.addOverlay(new LoadingOverlay());
return screens;
}
});
app.getInitOptions().setLogLevel(llFile, llSyso);
app.getInitOptions().setBusLogging(logBus);
app.start(); app.start();
} }

@ -1,35 +1,15 @@
package mightypork.rogue; package mightypork.rogue;
import junk.AppInitOptions;
import mightypork.gamecore.backends.lwjgl.LwjglBackend; import mightypork.gamecore.backends.lwjgl.LwjglBackend;
import mightypork.gamecore.backends.lwjgl.LwjglInputModule;
import mightypork.gamecore.core.App; import mightypork.gamecore.core.App;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.events.MainLoopRequest; import mightypork.gamecore.core.events.MainLoopRequest;
import mightypork.gamecore.core.events.ShutdownEvent; import mightypork.gamecore.core.plugins.screenshot.ScreenshotRequestListener;
import mightypork.gamecore.core.plugins.screenshot.ScreenshotRequest;
import mightypork.gamecore.graphics.FullscreenToggleRequest;
import mightypork.gamecore.graphics.GraphicsModule;
import mightypork.gamecore.gui.events.ViewportChangeEvent; import mightypork.gamecore.gui.events.ViewportChangeEvent;
import mightypork.gamecore.gui.events.ViewportChangeListener; import mightypork.gamecore.gui.events.ViewportChangeListener;
import mightypork.gamecore.gui.screens.ScreenRegistry;
import mightypork.gamecore.input.Trigger;
import mightypork.gamecore.resources.Res; import mightypork.gamecore.resources.Res;
import mightypork.rogue.RogueStateManager.RogueState; import mightypork.rogue.RogueStateManager.RogueState;
import mightypork.rogue.events.RogueStateRequest; import mightypork.rogue.events.RogueStateRequest;
import mightypork.rogue.screens.FpsOverlay;
import mightypork.rogue.screens.LoadingOverlay;
import mightypork.rogue.screens.game.ScreenGame;
import mightypork.rogue.screens.menu.ScreenMainMenu;
import mightypork.rogue.screens.select_world.ScreenSelectWorld;
import mightypork.rogue.screens.story.ScreenStory;
import mightypork.rogue.world.Inventory;
import mightypork.rogue.world.WorldProvider;
import mightypork.rogue.world.level.Level;
import mightypork.utils.eventbus.BusEvent;
import mightypork.utils.ion.Ion;
import mightypork.utils.logging.Log;
/** /**
@ -37,111 +17,34 @@ import mightypork.utils.logging.Log;
* *
* @author Ondřej Hruška (MightyPork) * @author Ondřej Hruška (MightyPork)
*/ */
public final class RogueApp extends App implements ViewportChangeListener { public final class RogueApp extends App implements ViewportChangeListener, ScreenshotRequestListener {
public RogueApp() public RogueApp()
{ {
super(new LwjglBackend()); super(new LwjglBackend());
final AppInitOptions opt = getInitOptions();
opt.addRoutes(new RogueRoutes());
opt.addResources(new RogueResources());
opt.addKeys(new RogueKeys());
opt.addConfig(new RogueConfig());
opt.setBusLogging(true);
opt.setConfigFile("config.ini", "Rogue config file");
opt.setLogOptions("logs", "runtime", 5, java.util.logging.Level.ALL);
} }
@Override @Override
protected void registerIonizables() public void onScreenshotRequest()
{
super.registerIonizables();
Ion.register(Level.class);
Ion.register(Inventory.class);
}
@Override
protected void initDisplay(GraphicsModule gfx)
{
// init based on config
final int w = Config.getValue("display.width");
final int h = Config.getValue("display.height");
final boolean fs = Config.getValue("display.fullscreen");
gfx.setSize(w, h);
gfx.setResizable(true);
gfx.setFullscreen(fs);
gfx.setTitle(Const.TITLEBAR);
gfx.setTargetFps(Const.FPS_RENDER);
gfx.createDisplay();
}
@Override
protected void initScreens(ScreenRegistry screens)
{
super.initScreens(screens);
/* game screen references world provider instance */
WorldProvider.setBaseDir(this);
getEventBus().subscribe(new RogueStateManager(this));
screens.addScreen("main_menu", new ScreenMainMenu(this));
screens.addScreen("select_world", new ScreenSelectWorld(this));
screens.addScreen("game", new ScreenGame(this));
screens.addScreen("story", new ScreenStory(this));
screens.addOverlay(new FpsOverlay(this));
screens.addOverlay(new LoadingOverlay(this));
}
@Override
protected void initInputSystem(LwjglInputModule input)
{
// this will work only with reusable events (such as requests)
bindEventToKey(new FullscreenToggleRequest(), "global.fullscreen");
bindEventToKey(new ScreenshotRequest(), "global.screenshot");
bindEventToKey(new ShutdownEvent(), "global.quit");
bindEventToKey(new ShutdownEvent(), "global.quit_force");
}
private void bindEventToKey(final BusEvent<?> event, String strokeName)
{
getInput().bindKey(Config.getKeyStroke(strokeName), Trigger.RISING, new Runnable() {
@Override
public void run()
{ {
getEventBus().send(event); Res.sound("gui.shutter").play(0.8);
}
});
} }
@Override @Override
protected void postInit() protected void postInit()
{ {
bus().send(new MainLoopRequest(new Runnable() {
getEventBus().send(new MainLoopRequest(new Runnable() {
@Override @Override
public void run() public void run()
{ {
if (Config.getValue("opt.show_story")) { if (cfg().getValue("opt.show_story")) {
Config.setValue("opt.show_story", false); cfg().setValue("opt.show_story", false);
getEventBus().send(new RogueStateRequest(RogueState.STORY, true)); bus().send(new RogueStateRequest(RogueState.STORY, true));
} else { } else {
getEventBus().send(new RogueStateRequest(RogueState.MAIN_MENU, true)); bus().send(new RogueStateRequest(RogueState.MAIN_MENU, true));
} }
} }
}, false)); }, false));
@ -154,27 +57,11 @@ public final class RogueApp extends App implements ViewportChangeListener {
// save viewport size to config file // save viewport size to config file
final boolean fs = gfx().isFullscreen(); final boolean fs = gfx().isFullscreen();
Config.setValue("display.fullscreen", fs); cfg().setValue("display.fullscreen", fs);
if (!fs) { if (!fs) {
Config.setValue("display.width", gfx().getWidth()); cfg().setValue("display.width", gfx().getWidth());
Config.setValue("display.height", gfx().getHeight()); cfg().setValue("display.height", gfx().getHeight());
} }
} }
@Override
public void onScreenshotRequest()
{
// screenshot sound
Res.sound("gui.shutter").play(0.8);
}
@Override
protected void writeLogHeader()
{
Log.i("## Starting Rogue v." + Const.VERSION + " ##");
super.writeLogHeader();
}
} }

@ -1,19 +0,0 @@
package mightypork.rogue;
import mightypork.utils.config.propmgr.PropertyManager;
public class RogueConfig implements ConfigSetup {
@Override
public void addOptions(PropertyManager prop)
{
prop.addBoolean("display.fullscreen", false, "Start in fullscreen (remembers state at exit)");
prop.addInteger("display.width", 1024, "Initial width (remembers from last time)");
prop.addInteger("display.height", 768, "Initial height (remembers from last time)");
prop.addBoolean("opt.show_story", true, "Show story on start-up.");
}
}

@ -0,0 +1,63 @@
package mightypork.rogue;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.config.InitTaskConfig;
public class RogueInitConfig extends InitTaskConfig {
@Override
protected Config buildConfig()
{
final Config cfg = new Config("config.ini", "Rogue config file");
cfg.addBoolean("display.fullscreen", false, "Start in fullscreen (remembers state at exit)");
cfg.addInteger("display.width", 1024, "Initial width (remembers from last time)");
cfg.addInteger("display.height", 768, "Initial height (remembers from last time)");
cfg.addBoolean("opt.show_story", true, "Show story on start-up.");
// keys
cfg.addKeyStroke("global.quit", "CTRL+Q", "Quit the game");
cfg.addKeyStroke("global.quit_force", "CTRL+SHIFT+Q", "Quit the game without asking, low-level");
cfg.addKeyStroke("global.screenshot", "F2", "Take screenshot (save into working directory)");
cfg.addKeyStroke("global.fullscreen", "F11", "Toggle fullscreen");
cfg.addKeyStroke("global.fps_meter", "F3", "Toggle FPS meter overlay");
cfg.addKeyStroke("general.close", "ESC", "Leave a dialog or screen");
cfg.addKeyStroke("general.cancel", "ESC", "\"Cancel\" option in dialogs");
cfg.addKeyStroke("general.confirm", "ENTER", "\"Confirm\" option in dialogs");
cfg.addKeyStroke("general.yes", "Y", "\"Yes\" option in dialogs");
cfg.addKeyStroke("general.no", "N", "\"No\" option in dialogs");
cfg.addKeyStroke("game.quit", "ESC", "Quit to menu");
cfg.addKeyStroke("game.save", "CTRL+S", "Save to file");
cfg.addKeyStroke("game.load", "CTRL+L", "Load from file");
cfg.addKeyStroke("game.zoom", "Z", "Toggle zoom");
cfg.addKeyStroke("game.minimap", "M", "Toggle minimap");
cfg.addKeyStroke("game.eat", "E", "Eat smallest food item");
cfg.addKeyStroke("game.drop", "D", "Drop last picked item");
cfg.addKeyStroke("game.inventory", "I", "Toggle inventory view");
cfg.addKeyStroke("game.pause", "P", "Pause the game");
cfg.addKeyStroke("game.walk.up", "UP", "Walk north");
cfg.addKeyStroke("game.walk.down", "DOWN", "Walk south");
cfg.addKeyStroke("game.walk.left", "LEFT", "Walk west");
cfg.addKeyStroke("game.walk.right", "RIGHT", "Walk east");
cfg.addKeyStroke("game.cheat.xray", "CTRL+SHIFT+X", "Cheat to see unexplored tiles");
cfg.addKeyStroke("game.inv.use", "E", "Use (eat or equip) the selected item");
cfg.addKeyStroke("game.inv.drop", "D", "Drop the selected item");
cfg.addKeyStroke("game.inv.move.left", "LEFT", "Move inventory cursor left");
cfg.addKeyStroke("game.inv.move.right", "RIGHT", "Move inventory cursor right");
cfg.addKeyStroke("game.inv.move.up", "UP", "Move inventory cursor up");
cfg.addKeyStroke("game.inv.move.down", "DOWN", "Move inventory cursor down");
return cfg;
}
}

@ -2,7 +2,8 @@ package mightypork.rogue;
import mightypork.gamecore.audio.SoundRegistry; import mightypork.gamecore.audio.SoundRegistry;
import mightypork.gamecore.backends.lwjgl.graphics.font.LwjglFont; import mightypork.gamecore.core.App;
import mightypork.gamecore.core.init.InitTaskResources;
import mightypork.gamecore.graphics.fonts.DeferredFont; import mightypork.gamecore.graphics.fonts.DeferredFont;
import mightypork.gamecore.graphics.fonts.FontRegistry; import mightypork.gamecore.graphics.fonts.FontRegistry;
import mightypork.gamecore.graphics.fonts.Glyphs; import mightypork.gamecore.graphics.fonts.Glyphs;
@ -11,11 +12,10 @@ import mightypork.gamecore.graphics.textures.ITexture;
import mightypork.gamecore.graphics.textures.QuadGrid; import mightypork.gamecore.graphics.textures.QuadGrid;
import mightypork.gamecore.graphics.textures.TextureRegistry; import mightypork.gamecore.graphics.textures.TextureRegistry;
import mightypork.gamecore.graphics.textures.WrapMode; import mightypork.gamecore.graphics.textures.WrapMode;
import mightypork.gamecore.resources.ResourceInitializer;
import mightypork.utils.math.constraints.rect.Rect; import mightypork.utils.math.constraints.rect.Rect;
public class RogueResources implements ResourceInitializer { public class RogueInitResources extends InitTaskResources {
@Override @Override
public void addFonts(FontRegistry fonts) public void addFonts(FontRegistry fonts)
@ -23,12 +23,12 @@ public class RogueResources implements ResourceInitializer {
DeferredFont font; DeferredFont font;
//fonts.loadFont("polygon_pixel", new DeferredFont("/res/font/PolygonPixel5x7Standard.ttf", Glyphs.basic, 16)); //fonts.loadFont("polygon_pixel", new DeferredFont("/res/font/PolygonPixel5x7Standard.ttf", Glyphs.basic, 16));
fonts.addFont("press_start", font = new LwjglFont("/res/font/PressStart2P.ttf", Glyphs.basic, 16)); fonts.addFont("press_start", font = App.gfx().createFont("/res/font/PressStart2P.ttf", Glyphs.basic, 16));
fonts.addFont("battlenet", font = new LwjglFont("/res/font/battlenet.ttf", Glyphs.basic, 16)); fonts.addFont("battlenet", font = App.gfx().createFont("/res/font/battlenet.ttf", Glyphs.basic, 16));
font.setDiscardRatio(3 / 16D, 2 / 16D); font.setDiscardRatio(3 / 16D, 2 / 16D);
fonts.addFont("tinyutf", font = new LwjglFont("/res/font/TinyUnicode2.ttf", Glyphs.basic, 16)); fonts.addFont("tinyutf", font = App.gfx().createFont("/res/font/TinyUnicode2.ttf", Glyphs.basic, 16));
font.setDiscardRatio(5 / 16D, 3 / 16D); font.setDiscardRatio(5 / 16D, 3 / 16D);
// aliases // aliases
@ -41,7 +41,6 @@ public class RogueResources implements ResourceInitializer {
@Override @Override
public void addSounds(SoundRegistry sounds) public void addSounds(SoundRegistry sounds)
{ {
//sounds.addLoop("music.dungeon", "/res/audio/music/Lightless_Dawn.ogg", 1, 1, 3, 1.5); //sounds.addLoop("music.dungeon", "/res/audio/music/Lightless_Dawn.ogg", 1, 1, 3, 1.5);
sounds.addLoop("music.menu", "/res/audio/music/Home_Base_Groove.ogg", 1, 0.7, 3, 1.5); sounds.addLoop("music.menu", "/res/audio/music/Home_Base_Groove.ogg", 1, 0.7, 3, 1.5);
sounds.addLoop("music.dungeon", "/res/audio/music/8bit_Dungeon_Level.ogg", 1, 0.6, 3, 1.5); sounds.addLoop("music.dungeon", "/res/audio/music/8bit_Dungeon_Level.ogg", 1, 0.6, 3, 1.5);

@ -0,0 +1,24 @@
package mightypork.rogue;
import java.io.File;
import mightypork.gamecore.core.init.InitTaskWorkdir;
public class RogueInitWorkdir extends InitTaskWorkdir {
public RogueInitWorkdir(File workdir)
{
super(workdir, true);
}
@Override
public void init()
{
addPath("slot1", "saves/slot_1.ion");
addPath("slot2", "saves/slot_2.ion");
addPath("slot3", "saves/slot_3.ion");
}
}

@ -1,46 +0,0 @@
package mightypork.rogue;
public class RogueKeys implements KeySetup {
@Override
public void addKeys(KeyOpts keys)
{
keys.addKey("global.quit", "CTRL+Q", "Quit the game");
keys.addKey("global.quit_force", "CTRL+SHIFT+Q", "Quit the game without asking, low-level");
keys.addKey("global.screenshot", "F2", "Take screenshot (save into working directory)");
keys.addKey("global.fullscreen", "F11", "Toggle fullscreen");
keys.addKey("global.fps_meter", "F3", "Toggle FPS meter overlay");
keys.addKey("general.close", "ESC", "Leave a dialog or screen");
keys.addKey("general.cancel", "ESC", "\"Cancel\" option in dialogs");
keys.addKey("general.confirm", "ENTER", "\"Confirm\" option in dialogs");
keys.addKey("general.yes", "Y", "\"Yes\" option in dialogs");
keys.addKey("general.no", "N", "\"No\" option in dialogs");
keys.addKey("game.quit", "ESC", "Quit to menu");
keys.addKey("game.save", "CTRL+S", "Save to file");
keys.addKey("game.load", "CTRL+L", "Load from file");
keys.addKey("game.zoom", "Z", "Toggle zoom");
keys.addKey("game.minimap", "M", "Toggle minimap");
keys.addKey("game.eat", "E", "Eat smallest food item");
keys.addKey("game.drop", "D", "Drop last picked item");
keys.addKey("game.inventory", "I", "Toggle inventory view");
keys.addKey("game.pause", "P", "Pause the game");
keys.addKey("game.walk.up", "UP", "Walk north");
keys.addKey("game.walk.down", "DOWN", "Walk south");
keys.addKey("game.walk.left", "LEFT", "Walk west");
keys.addKey("game.walk.right", "RIGHT", "Walk east");
keys.addKey("game.cheat.xray", "CTRL+SHIFT+X", "Cheat to see unexplored tiles");
keys.addKey("game.inv.use", "E", "Use (eat or equip) the selected item");
keys.addKey("game.inv.drop", "D", "Drop the selected item");
keys.addKey("game.inv.move.left", "LEFT", "Move inventory cursor left");
keys.addKey("game.inv.move.right", "RIGHT", "Move inventory cursor right");
keys.addKey("game.inv.move.up", "UP", "Move inventory cursor up");
keys.addKey("game.inv.move.down", "DOWN", "Move inventory cursor down");
}
}

@ -1,14 +0,0 @@
package mightypork.rogue;
public class RogueRoutes implements RouteSetup {
@Override
public void addRoutes(RouteOpts routeOpts)
{
routeOpts.addPath("slot1", "saves/slot_1.ion");
routeOpts.addPath("slot2", "saves/slot_2.ion");
routeOpts.addPath("slot3", "saves/slot_3.ion");
}
}

@ -19,20 +19,12 @@ import mightypork.utils.logging.Log;
*/ */
public class WorldProvider extends BusNode { public class WorldProvider extends BusNode {
public static synchronized void init()
{
if (inst == null) {
inst = new WorldProvider();
}
}
public WorldProvider() public WorldProvider()
{ {
setListening(false); setListening(false);
} }
private static WorldProvider inst; private static WorldProvider inst = new WorldProvider();
public static WorldProvider get() public static WorldProvider get()

@ -1,15 +1,12 @@
package mightypork.rogue.world.gui; package mightypork.rogue.world.gui;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.components.InputComponent; import mightypork.gamecore.gui.components.InputComponent;
import mightypork.gamecore.input.events.MouseButtonEvent; import mightypork.gamecore.input.events.MouseButtonEvent;
import mightypork.gamecore.input.events.MouseButtonHandler; import mightypork.gamecore.input.events.MouseButtonHandler;
import mightypork.rogue.Const;
import mightypork.rogue.world.PlayerFacade; import mightypork.rogue.world.PlayerFacade;
import mightypork.rogue.world.WorldProvider; import mightypork.rogue.world.WorldProvider;
import mightypork.rogue.world.level.Level; import mightypork.rogue.world.level.Level;
import mightypork.rogue.world.tile.Tile;
import mightypork.utils.math.algo.Coord; import mightypork.utils.math.algo.Coord;
import mightypork.utils.math.color.Color; import mightypork.utils.math.color.Color;
import mightypork.utils.math.color.pal.RGB; import mightypork.utils.math.color.pal.RGB;
@ -47,7 +44,7 @@ public class Minimap extends InputComponent implements MouseButtonHandler {
final Coord point = new Coord(tl.xi(), tl.yi()); final Coord point = new Coord(tl.xi(), tl.yi());
// FIXME do not use LWJGL directly // FIXME do not use LWJGL directly
/*
GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBegin(GL11.GL_QUADS); GL11.glBegin(GL11.GL_QUADS);
@ -80,7 +77,7 @@ public class Minimap extends InputComponent implements MouseButtonHandler {
GL11.glVertex2d(plx + unit, ply + unit); GL11.glVertex2d(plx + unit, ply + unit);
GL11.glVertex2d(plx, ply + unit); GL11.glVertex2d(plx, ply + unit);
GL11.glEnd(); GL11.glEnd();*/
Color.popAlpha(); Color.popAlpha();
} }

@ -5,7 +5,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import mightypork.gamecore.backends.lwjgl.LwjglInputModule; import mightypork.gamecore.core.App;
import mightypork.gamecore.core.config.Config; import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.input.KeyBindingPool; import mightypork.gamecore.input.KeyBindingPool;
import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
@ -25,25 +25,33 @@ public class MIPKeyboard extends MapInteractionPlugin implements DelegatingClien
// FIXME cannot be static. // FIXME cannot be static.
//@formatter:off
private static final KeyStroke[] keys = {
Config.getKeyStroke("game.walk.left"),
Config.getKeyStroke("game.walk.right"),
Config.getKeyStroke("game.walk.up"),
Config.getKeyStroke("game.walk.down")
};
private static final Move[] sides = { Moves.W, Moves.E, Moves.N, Moves.S }; private static final Move[] sides = { Moves.W, Moves.E, Moves.N, Moves.S };
//@formatter:on
private final KeyBindingPool kbp = new KeyBindingPool(); private final KeyBindingPool kbp = new KeyBindingPool();
private final List<Object> clients = new ArrayList<>(); private final List<Object> clients = new ArrayList<>();
{ {
clients.add(kbp); clients.add(kbp);
} }
private KeyStroke[] getKeys()
{
//@formatter:off
final Config cfg = App.cfg();
return new KeyStroke[] {
cfg.getKeyStroke("game.walk.left"),
cfg.getKeyStroke("game.walk.right"),
cfg.getKeyStroke("game.walk.up"),
cfg.getKeyStroke("game.walk.down")
};
//@formatter:on
}
@Override @Override
public boolean doesDelegate() public boolean doesDelegate()
{ {
@ -62,6 +70,8 @@ public class MIPKeyboard extends MapInteractionPlugin implements DelegatingClien
{ {
super(mapView); super(mapView);
final KeyStroke[] keys = getKeys();
// bind keys // bind keys
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
@ -106,7 +116,9 @@ public class MIPKeyboard extends MapInteractionPlugin implements DelegatingClien
if (mapView.plc.getPlayer().getMoveProgress() < 0.8) return false; if (mapView.plc.getPlayer().getMoveProgress() < 0.8) return false;
if (LwjglInputModule.getActiveKeyMod() != Keys.MOD_NONE) return false; if (Keys.getActiveMods() != Keys.MOD_NONE) return false;
final KeyStroke[] keys = getKeys();
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (keys[i].isDown()) { if (keys[i].isDown()) {

Loading…
Cancel
Save