some shifting around and refactoring.

master
Ondřej Hruška 11 years ago
parent c5fa77d395
commit 87d0c9d500
  1. 6
      src/junk/AppInitOptions.java
  2. 14
      src/junk/BaseApp.java
  3. 2
      src/mightypork/gamecore/WorkDir.java
  4. 6
      src/mightypork/gamecore/backend/lwjgl/InitTaskRedirectSlickLog.java
  5. 5
      src/mightypork/gamecore/backend/lwjgl/LwjglGraphicsModule.java
  6. 6
      src/mightypork/gamecore/backend/lwjgl/SlickAudio.java
  7. 6
      src/mightypork/gamecore/backend/lwjgl/SlickTexture.java
  8. 84
      src/mightypork/gamecore/config/Config.java
  9. 54
      src/mightypork/gamecore/config/KeyStrokeProperty.java
  10. 88
      src/mightypork/gamecore/core/App.java
  11. 36
      src/mightypork/gamecore/core/InitTask.java
  12. 80
      src/mightypork/gamecore/core/InitTaskConfig.java
  13. 8
      src/mightypork/gamecore/core/InitTaskCrashHandler.java
  14. 8
      src/mightypork/gamecore/core/InitTaskDisplay.java
  15. 8
      src/mightypork/gamecore/core/InitTaskIonizables.java
  16. 17
      src/mightypork/gamecore/core/InitTaskLog.java
  17. 10
      src/mightypork/gamecore/core/InitTaskLogHeader.java
  18. 37
      src/mightypork/gamecore/core/InitTaskWorkdir.java
  19. 6
      src/mightypork/gamecore/core/InitTasks.java
  20. 5
      src/mightypork/gamecore/core/MainLoop.java
  21. 54
      src/mightypork/gamecore/core/config/KeyProperty.java
  22. 2
      src/mightypork/gamecore/core/events/MainLoopRequest.java
  23. 4
      src/mightypork/gamecore/core/events/ShudownRequest.java
  24. 58
      src/mightypork/gamecore/gui/components/LayoutComponent.java
  25. 8
      src/mightypork/gamecore/gui/components/layout/ColumnLayout.java
  26. 2
      src/mightypork/gamecore/gui/components/layout/ConstraintLayout.java
  27. 8
      src/mightypork/gamecore/gui/components/layout/FlowColumnLayout.java
  28. 9
      src/mightypork/gamecore/gui/components/layout/FlowRowLayout.java
  29. 10
      src/mightypork/gamecore/gui/components/layout/GridLayout.java
  30. 8
      src/mightypork/gamecore/gui/components/layout/RowLayout.java
  31. 14
      src/mightypork/gamecore/gui/components/layout/linear/LinearLayout.java
  32. 2
      src/mightypork/gamecore/gui/components/painters/ImagePainter.java
  33. 2
      src/mightypork/gamecore/gui/components/painters/QuadPainter.java
  34. 2
      src/mightypork/gamecore/gui/components/painters/TextPainter.java
  35. 2
      src/mightypork/gamecore/gui/screens/Overlay.java
  36. 2
      src/mightypork/gamecore/gui/screens/Screen.java
  37. 2
      src/mightypork/gamecore/gui/screens/ScreenRegistry.java
  38. 4
      src/mightypork/gamecore/gui/screens/impl/CrossfadeOverlay.java
  39. 2
      src/mightypork/gamecore/input/InputSystem.java
  40. 2
      src/mightypork/gamecore/plugins/AppPlugin.java
  41. 2
      src/mightypork/gamecore/plugins/screenshot/ScreenshotPlugin.java
  42. 4
      src/mightypork/gamecore/plugins/screenshot/TaskTakeScreenshot.java
  43. 2
      src/mightypork/gamecore/render/Grad.java
  44. 25
      src/mightypork/gamecore/render/GraphicsModule.java
  45. 3
      src/mightypork/gamecore/render/Screenshot.java
  46. 15
      src/mightypork/gamecore/render/events/DisplayReadyEvent.java
  47. 7
      src/mightypork/gamecore/render/events/DisplayReadyListener.java
  48. 2
      src/mightypork/gamecore/resources/AsyncResourceLoader.java
  49. 2
      src/mightypork/gamecore/resources/audio/AudioModule.java
  50. 2
      src/mightypork/gamecore/resources/audio/DeferredAudio.java
  51. 2
      src/mightypork/gamecore/resources/audio/SoundRegistry.java
  52. 2
      src/mightypork/gamecore/resources/fonts/FontRegistry.java
  53. 2
      src/mightypork/gamecore/resources/fonts/FontRenderer.java
  54. 4
      src/mightypork/gamecore/resources/fonts/impl/LazyFont.java
  55. 2
      src/mightypork/gamecore/resources/textures/TextureRegistry.java
  56. 2
      src/mightypork/rogue/Launcher.java
  57. 8
      src/mightypork/rogue/RogueApp.java
  58. 12
      src/mightypork/rogue/RogueConfig.java
  59. 4
      src/mightypork/rogue/RogueKeys.java
  60. 4
      src/mightypork/rogue/RogueRoutes.java
  61. 6
      src/mightypork/rogue/screens/FpsOverlay.java
  62. 2
      src/mightypork/rogue/screens/game/HeartBar.java
  63. 2
      src/mightypork/rogue/screens/game/IngameNav.java
  64. 2
      src/mightypork/rogue/screens/game/InvSlot.java
  65. 12
      src/mightypork/rogue/screens/game/LayerAskSave.java
  66. 8
      src/mightypork/rogue/screens/game/LayerDeath.java
  67. 16
      src/mightypork/rogue/screens/game/LayerInv.java
  68. 6
      src/mightypork/rogue/screens/game/LayerWin.java
  69. 2
      src/mightypork/rogue/screens/game/NavButton.java
  70. 22
      src/mightypork/rogue/screens/game/ScreenGame.java
  71. 4
      src/mightypork/rogue/screens/menu/ScreenMainMenu.java
  72. 6
      src/mightypork/rogue/screens/select_world/ScreenSelectWorld.java
  73. 4
      src/mightypork/rogue/screens/story/ScreenStory.java
  74. 2
      src/mightypork/rogue/world/WorldRenderer.java
  75. 2
      src/mightypork/rogue/world/entity/render/EntityRendererMobLR.java
  76. 2
      src/mightypork/rogue/world/gui/MapView.java
  77. 2
      src/mightypork/rogue/world/gui/Minimap.java
  78. 10
      src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java
  79. 2
      src/mightypork/rogue/world/item/render/QuadItemRenderer.java
  80. 2
      src/mightypork/rogue/world/tile/TileRenderer.java
  81. 2
      src/mightypork/rogue/world/tile/render/BasicTileRenderer.java
  82. 2
      src/mightypork/rogue/world/tile/render/ChestRenderer.java
  83. 2
      src/mightypork/rogue/world/tile/render/DoorTileRenderer.java
  84. 2
      src/mightypork/rogue/world/tile/render/OneFrameTileRenderer.java
  85. 2
      src/mightypork/rogue/world/tile/render/TwoHighTileRenderer.java

@ -1,4 +1,4 @@
package mightypork.gamecore.core.modules;
package junk;
import java.io.File;
@ -7,8 +7,8 @@ import java.util.List;
import java.util.logging.Level;
import mightypork.gamecore.backend.Backend;
import mightypork.gamecore.core.config.ConfigSetup;
import mightypork.gamecore.core.config.KeySetup;
import mightypork.gamecore.config.ConfigSetup;
import mightypork.gamecore.config.KeySetup;
import mightypork.gamecore.resources.AsyncResourceLoader;
import mightypork.gamecore.resources.ResourceLoader;
import mightypork.gamecore.resources.ResourceSetup;

@ -1,14 +1,16 @@
package mightypork.gamecore.core.modules;
package junk;
import java.lang.Thread.UncaughtExceptionHandler;
import mightypork.gamecore.WorkDir;
import mightypork.gamecore.WorkDir.RouteSetup;
import mightypork.gamecore.backend.Backend;
import mightypork.gamecore.core.WorkDir;
import mightypork.gamecore.core.WorkDir.RouteSetup;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.config.ConfigSetup;
import mightypork.gamecore.core.config.KeySetup;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.config.ConfigSetup;
import mightypork.gamecore.config.KeySetup;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.MainLoop;
import mightypork.gamecore.gui.screens.ScreenRegistry;
import mightypork.gamecore.gui.screens.impl.CrossfadeOverlay;
import mightypork.gamecore.input.InputSystem;

@ -1,4 +1,4 @@
package mightypork.gamecore.core;
package mightypork.gamecore;
import java.io.File;

@ -1,8 +1,8 @@
package mightypork.gamecore.backend.lwjgl;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.initializers.InitTask;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.InitTask;
import mightypork.gamecore.util.SlickLogRedirector;
import mightypork.utils.logging.writers.LogWriter;
@ -15,7 +15,7 @@ import mightypork.utils.logging.writers.LogWriter;
public class InitTaskRedirectSlickLog extends InitTask {
@Override
public void run(App app)
public void run()
{
LogWriter ml = mightypork.utils.logging.Log.getMainLogger();
SlickLogRedirector slr = new SlickLogRedirector(ml);

@ -6,11 +6,10 @@ import static org.lwjgl.opengl.GL11.*;
import java.nio.ByteBuffer;
import java.util.Stack;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.render.Grad;
import mightypork.gamecore.render.GraphicsModule;
import mightypork.gamecore.render.Screenshot;
import mightypork.gamecore.render.events.DisplayReadyEvent;
import mightypork.gamecore.render.events.ViewportChangeEvent;
import mightypork.gamecore.resources.textures.DeferredTexture;
import mightypork.gamecore.resources.textures.TxQuad;
@ -439,8 +438,6 @@ public class LwjglGraphicsModule extends GraphicsModule {
fullscreenSetRequested = false;
}
App.bus().send(new DisplayReadyEvent());
} catch (final Exception e) {
throw new RuntimeException("Could not initialize display.", e);
}

@ -5,7 +5,7 @@ import java.io.IOException;
import java.io.InputStream;
import mightypork.gamecore.resources.audio.DeferredAudio;
import mightypork.utils.files.FileUtils;
import mightypork.utils.files.FileUtil;
import org.lwjgl.openal.AL10;
import org.newdawn.slick.openal.Audio;
import org.newdawn.slick.openal.SoundStore;
@ -37,9 +37,9 @@ public class SlickAudio extends DeferredAudio {
@Override
protected void loadResource(String resource) throws IOException
{
final String ext = FileUtils.getExtension(resource);
final String ext = FileUtil.getExtension(resource);
try (final InputStream stream = FileUtils.getResource(resource)) {
try (final InputStream stream = FileUtil.getResource(resource)) {
if (ext.equalsIgnoreCase("ogg")) {
backingAudio = SoundStore.get().getOgg(resource, stream);

@ -7,7 +7,7 @@ import mightypork.gamecore.resources.MustLoadInRenderingContext;
import mightypork.gamecore.resources.textures.DeferredTexture;
import mightypork.utils.annotations.Alias;
import mightypork.utils.exceptions.IllegalValueException;
import mightypork.utils.files.FileUtils;
import mightypork.utils.files.FileUtil;
import mightypork.utils.logging.Log;
import org.lwjgl.opengl.GL11;
@ -41,7 +41,7 @@ public class SlickTexture extends DeferredTexture {
protected synchronized void loadResource(String path)
{
try {
final String ext = FileUtils.getExtension(path).toUpperCase();
final String ext = FileUtil.getExtension(path).toUpperCase();
final int filtering;
switch (filter) {
@ -55,7 +55,7 @@ public class SlickTexture extends DeferredTexture {
throw new IllegalValueException("Unsupported filtering mode.");
}
final Texture texture = TextureLoader.getTexture(ext, FileUtils.getResource(path), false, filtering);
final Texture texture = TextureLoader.getTexture(ext, FileUtil.getResource(path), false, filtering);
if (texture == null) {
Log.w("Texture " + path + " could not be loaded.");

@ -1,40 +1,52 @@
package mightypork.gamecore.core.config;
package mightypork.gamecore.config;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import mightypork.gamecore.WorkDir;
import mightypork.gamecore.input.KeyStroke;
import mightypork.utils.files.config.Property;
import mightypork.utils.files.config.PropertyManager;
import mightypork.utils.config.propmgr.Property;
import mightypork.utils.config.propmgr.PropertyManager;
import mightypork.utils.config.propmgr.PropertyStore;
import mightypork.utils.config.propmgr.store.PropertyFile;
import mightypork.utils.logging.Log;
/**
* Static application configuration; wrapper around {@link PropertyManager}
* Settings repository.
*
* @author Ondřej Hruška (MightyPork)
*/
public class Config {
private static Map<String, KeyProperty> strokes = new HashMap<>();
private Map<String, KeyStrokeProperty> strokes = new HashMap<>();
private static PropertyManager propertyManager;
private PropertyManager propertyManager;
/**
* Initialize property manger for a file
* Initialize property manager for a file
*
* @param file config file
* @param file config file, relative to workdir
* @param headComment file comment
*/
public static void init(File file, String headComment)
{
propertyManager = new PropertyManager(file, headComment);
public Config(String file, String headComment) {
this(new PropertyFile(WorkDir.getFile(file), headComment));
}
/**
* Initialize property manager for a given store
*
* @param store property store backing the property manager
*/
public Config(PropertyStore store) {
if (propertyManager != null) {
throw new IllegalStateException("Config already initialized.");
}
propertyManager.cfgNewlineBeforeComments(true);
propertyManager.cfgSeparateSections(true);
propertyManager = new PropertyManager(store);
}
@ -45,11 +57,11 @@ public class Config {
* @param defval default value (keystroke datastring)
* @param comment optional comment, can be null
*/
public void addKeyProperty(String key, String defval, String comment)
public void addKeyStroke(String key, String defval, String comment)
{
final KeyProperty kprop = new KeyProperty(Config.prefixKey(key), KeyStroke.createFromDataString(defval), comment);
strokes.put(Config.prefixKey(key), kprop);
propertyManager.putProperty(kprop);
final KeyStrokeProperty kprop = new KeyStrokeProperty(prefixKeyStroke(key), KeyStroke.createFromDataString(defval), comment);
strokes.put(prefixKeyStroke(key), kprop);
propertyManager.addProperty(kprop);
}
@ -60,9 +72,9 @@ public class Config {
* @param defval default value
* @param comment optional comment, can be null
*/
public void addBooleanProperty(String key, boolean defval, String comment)
public void addBoolean(String key, boolean defval, String comment)
{
propertyManager.putBoolean(key, defval, comment);
propertyManager.addBoolean(key, defval, comment);
}
@ -73,9 +85,9 @@ public class Config {
* @param defval default value
* @param comment optional comment, can be null
*/
public void addIntegerProperty(String key, int defval, String comment)
public void addInteger(String key, int defval, String comment)
{
propertyManager.putInteger(key, defval, comment);
propertyManager.addInteger(key, defval, comment);
}
@ -86,9 +98,9 @@ public class Config {
* @param defval default value
* @param comment optional comment, can be null
*/
public void addDoubleProperty(String key, double defval, String comment)
public void addDouble(String key, double defval, String comment)
{
propertyManager.putDouble(key, defval, comment);
propertyManager.addDouble(key, defval, comment);
}
@ -99,9 +111,9 @@ public class Config {
* @param defval default value
* @param comment optional comment, can be null
*/
public void addStringProperty(String key, String defval, String comment)
public void addString(String key, String defval, String comment)
{
propertyManager.putString(key, defval, comment);
propertyManager.addString(key, defval, comment);
}
@ -112,14 +124,14 @@ public class Config {
*/
public <T> void addProperty(Property<T> prop)
{
propertyManager.putProperty(prop);
propertyManager.addProperty(prop);
}
/**
* Load config from file
*/
public static void load()
public void load()
{
propertyManager.load();
}
@ -128,7 +140,7 @@ public class Config {
/**
* Save config to file
*/
public static void save()
public void save()
{
Log.f3("Saving config.");
propertyManager.save();
@ -141,7 +153,7 @@ public class Config {
* @param key
* @return option value
*/
public static <T> T getValue(String key)
public <T> T getValue(String key)
{
try {
if (propertyManager.getProperty(key) == null) {
@ -162,7 +174,7 @@ public class Config {
* @param key option key
* @param value value to set
*/
public static <T> void setValue(String key, T value)
public <T> void setValue(String key, T value)
{
if (propertyManager.getProperty(key) == null) {
throw new IllegalArgumentException("No such property: " + key);
@ -178,7 +190,7 @@ public class Config {
* @param cfgKey config key
* @return key. + cfgKey
*/
private static String prefixKey(String cfgKey)
private String prefixKeyStroke(String cfgKey)
{
return "key." + cfgKey;
}
@ -190,9 +202,9 @@ public class Config {
* @param cfgKey stroke identifier in config file
* @return the stroke
*/
public static KeyStroke getKey(String cfgKey)
public KeyStroke getKeyStroke(String cfgKey)
{
final KeyProperty kp = strokes.get(prefixKey(cfgKey));
final KeyStrokeProperty kp = strokes.get(prefixKeyStroke(cfgKey));
if (kp == null) {
throw new IllegalArgumentException("No such stroke: " + cfgKey);
}
@ -208,9 +220,9 @@ public class Config {
* @param key stroke key
* @param mod stroke modifiers
*/
public static void setKey(String cfgKey, int key, int mod)
public void setKeyStroke(String cfgKey, int key, int mod)
{
final KeyProperty kp = strokes.get(prefixKey(cfgKey));
final KeyStrokeProperty kp = strokes.get(prefixKeyStroke(cfgKey));
if (kp == null) {
throw new IllegalArgumentException("No such stroke: " + cfgKey);
}

@ -0,0 +1,54 @@
package mightypork.gamecore.config;
import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys;
import mightypork.utils.config.propmgr.Property;
/**
* Key property.<br>
* The stored value must stay the same instance ({@link KeyStroke} is mutable).<br>
* That ensures that bindings based on this keystroke are automatically updated
* when the settings change.
*
* @author Ondřej Hruška (MightyPork)
*/
public class KeyStrokeProperty extends Property<KeyStroke> {
public KeyStrokeProperty(String key, KeyStroke defaultValue, String comment) {
super(key, defaultValue, comment);
}
@Override
public void fromString(String string)
{
if (string != null) {
// keep the same instance
final int backup_key = value.getKey();
final int backup_mod = value.getMod();
value.fromDataString(string);
if (value.getKey() == Keys.NONE) {
value.setTo(backup_key, backup_mod);
}
}
}
@Override
public String toString()
{
return value.toDataString();
}
@Override
public void setValue(Object value)
{
// keep the same instance
this.value.setTo(((KeyStroke) value).getKey(), ((KeyStroke) value).getMod());
}
}

@ -1,4 +1,4 @@
package mightypork.gamecore.core.modules;
package mightypork.gamecore.core;
import java.util.ArrayList;
@ -8,8 +8,7 @@ import java.util.List;
import java.util.Map;
import mightypork.gamecore.backend.Backend;
import mightypork.gamecore.initializers.InitTask;
import mightypork.gamecore.initializers.InitTaskResolver;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.plugins.AppPlugin;
import mightypork.gamecore.render.GraphicsModule;
import mightypork.gamecore.resources.audio.AudioModule;
@ -30,15 +29,18 @@ import mightypork.utils.logging.Log;
*/
public class App extends BusNode {
private static App runningInstance;
private static App instance;
protected final Backend backend;
protected final EventBus eventBus;
protected boolean started = false;
private final Backend backend;
private final EventBus eventBus = new EventBus();
private boolean started = false;
protected final DelegatingList plugins;
protected final DelegatingList plugins = new DelegatingList();
protected final List<InitTask> initializers = new ArrayList<>();
// visible to Config init task.
final Map<String, Config> configs = new HashMap<>();
/**
* Create an app with given backend.
@ -46,21 +48,17 @@ public class App extends BusNode {
* @param backend
*/
public App(Backend backend) {
if (App.runningInstance != null) {
if (App.instance != null) {
throw new IllegalStateException("App already initialized");
}
// store current instance in static field
App.runningInstance = this;
// create an event bus
this.eventBus = new EventBus();
App.instance = this;
// join the bus
this.eventBus.subscribe(this);
// create plugin registry attached to bus
this.plugins = new DelegatingList();
this.eventBus.subscribe(this.plugins);
// initialize and use backend
@ -90,7 +88,6 @@ public class App extends BusNode {
/**
* Add an initializer to the app.
*
* @param order
* @param initializer
*/
public void addInitializer(InitTask initializer)
@ -133,11 +130,13 @@ public class App extends BusNode {
Log.i("=== Starting initialization sequence ===");
// sort initializers by order.
List<InitTask> orderedInitializers = InitTaskResolver.order(initializers);
List<InitTask> orderedInitializers = InitTasks.inOrder(initializers);
for (InitTask initializer : orderedInitializers) {
Log.f1("Running init task \"" + initializer.getName() + "\"...");
initializer.run(this);
initializer.bind(this);
initializer.init();
initializer.run();
}
Log.i("=== Initialization sequence completed ===");
@ -168,16 +167,17 @@ public class App extends BusNode {
public static void shutdown()
{
if (runningInstance == null) throw new IllegalStateException("App is not running.");
if (instance == null) throw new IllegalStateException("App is not running.");
Log.i("Shutting down subsystems...");
// TODO send some shutdown notify event
try {
if (bus() != null) {
bus().send(new DestroyEvent());
bus().destroy();
final EventBus bus = bus();
if (bus != null) {
bus.send(new DestroyEvent());
bus.destroy();
}
} catch (final Throwable e) {
Log.e(e);
@ -188,6 +188,17 @@ public class App extends BusNode {
}
/**
* Get the currently running App instance.
*
* @return app instance
*/
public static App instance()
{
return instance;
}
/**
* Get graphics module from the backend
*
@ -195,7 +206,7 @@ public class App extends BusNode {
*/
public static GraphicsModule gfx()
{
return runningInstance.backend.getGraphics();
return instance.backend.getGraphics();
}
@ -206,7 +217,7 @@ public class App extends BusNode {
*/
public static AudioModule audio()
{
return runningInstance.backend.getAudio();
return instance.backend.getAudio();
}
@ -217,6 +228,35 @@ public class App extends BusNode {
*/
public static EventBus bus()
{
return runningInstance.eventBus;
return instance.eventBus;
}
/**
* Get the main config, if initialized.
*
* @return main config
* @throws IllegalArgumentException if there is no such config.
*/
public static Config cfg()
{
return cfg("main");
}
/**
* Get a config by alias.
*
* @param alias config alias
* @return the config
* @throws IllegalArgumentException if there is no such config.
*/
public static Config cfg(String alias)
{
Config c = instance.configs.get(alias);
if (c == null) {
throw new IllegalArgumentException("There is no config with alias \"" + alias + "\"");
}
return c;
}
}

@ -1,7 +1,6 @@
package mightypork.gamecore.initializers;
package mightypork.gamecore.core;
import mightypork.gamecore.core.modules.App;
import mightypork.utils.annotations.Stub;
@ -14,12 +13,39 @@ import mightypork.utils.annotations.Stub;
*/
public abstract class InitTask {
protected App app;
/**
* Run the initalizer on app.
* Assign the initialized app instance to a protected "app" field.
*
* @param app the app instance.
* @param app app
*/
public void bind(App app)
{
if (this.app != null) {
throw new IllegalStateException("App instance is already set.");
}
this.app = app;
}
/**
* An intialization method that is called before the run() method.<br>
* This method should be left unimplemented in the task, and can be used to
* configure the init task when using it as anonymous inner type.
*/
@Stub
public void init()
{
}
/**
* Run the initalizer on app.
*/
public abstract void run(App app);
public abstract void run();
/**

@ -0,0 +1,80 @@
package mightypork.gamecore.core;
import mightypork.gamecore.config.Config;
import mightypork.utils.annotations.Stub;
import mightypork.utils.exceptions.IllegalValueException;
/**
* Initialize config. To apply this initializer, you must extend it. That
* ensures that the workdir initializer has already finished when the code is
* executed (such as resolving a file path for the config file).
*
* @author Ondřej Hruška (MightyPork)
*/
public abstract class InitTaskConfig extends InitTask {
/**
* Add a config with given alias
*
* @param alias config alias
* @param config config to add
*/
protected void addConfig(String alias, Config config)
{
if (app.configs.containsKey(alias)) {
throw new IllegalValueException("The alias is already used.");
}
app.configs.put(alias, config);
}
/**
* Initialize the main config.
*
* @return the main config.
*/
protected abstract Config buildConfig();
/**
* Initialize extra configs.<br>
* the addConfig() method can be used to register configs.
*/
@Stub
protected void buildExtraConfigs()
{
}
// locked uninitialized to encourage the use of the build* methods.
@Override
public final void init()
{
}
@Override
public final void run()
{
addConfig("main", buildConfig());
buildExtraConfigs();
}
@Override
public String getName()
{
return "config";
}
@Override
public String[] getDependencies()
{
return new String[] { "workdir" };
}
}

@ -1,10 +1,8 @@
package mightypork.gamecore.initializers.tasks;
package mightypork.gamecore.core;
import java.lang.Thread.UncaughtExceptionHandler;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.initializers.InitTask;
import mightypork.utils.annotations.Stub;
import mightypork.utils.logging.Log;
@ -16,10 +14,10 @@ import mightypork.utils.logging.Log;
*
* @author Ondřej Hruška (MightyPork)
*/
public class InitTaskSetupCrashHandler extends InitTask implements UncaughtExceptionHandler {
public class InitTaskCrashHandler extends InitTask implements UncaughtExceptionHandler {
@Override
public void run(App app)
public void run()
{
Thread.setDefaultUncaughtExceptionHandler(this);
}

@ -1,8 +1,6 @@
package mightypork.gamecore.initializers.tasks;
package mightypork.gamecore.core;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.initializers.InitTask;
import mightypork.gamecore.render.GraphicsModule;
@ -11,7 +9,7 @@ import mightypork.gamecore.render.GraphicsModule;
*
* @author Ondřej Hruška (MightyPork)
*/
public class InitTaskSetupDisplay extends InitTask {
public class InitTaskDisplay extends InitTask {
private int width = 800, height = 600, fps = 60;
private boolean resizable, fullscreen;
@ -76,7 +74,7 @@ public class InitTaskSetupDisplay extends InitTask {
@Override
public void run(App app)
public void run()
{
GraphicsModule gfx = app.getBackend().getGraphics();

@ -1,10 +1,8 @@
package mightypork.gamecore.initializers.tasks;
package mightypork.gamecore.core;
import java.io.IOException;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.initializers.InitTask;
import mightypork.utils.ion.Ion;
import mightypork.utils.ion.IonInput;
import mightypork.utils.ion.IonOutput;
@ -19,10 +17,10 @@ import mightypork.utils.math.algo.Move;
*
* @author Ondřej Hruška (MightyPork)
*/
public class InitTaskRegisterIonizables extends InitTask {
public class InitTaskIonizables extends InitTask {
@Override
public void run(App app)
public void run()
{
Ion.registerIndirect(255, new IonizerBinary<Coord>() {

@ -1,14 +1,14 @@
package mightypork.gamecore.initializers.tasks;
package mightypork.gamecore.core;
import java.io.File;
import java.util.logging.Level;
import mightypork.gamecore.core.WorkDir;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.initializers.InitTask;
import mightypork.gamecore.WorkDir;
import mightypork.utils.files.FileUtil;
import mightypork.utils.logging.Log;
import mightypork.utils.logging.writers.LogWriter;
import mightypork.utils.string.StringUtil;
/**
@ -17,7 +17,7 @@ import mightypork.utils.logging.writers.LogWriter;
*
* @author Ondřej Hruška (MightyPork)
*/
public class InitTaskSetupLog extends InitTask {
public class InitTaskLog extends InitTask {
private String logDir = "log";
private String logName = "runtime";
@ -48,7 +48,10 @@ public class InitTaskSetupLog extends InitTask {
*/
public void setLogName(String logName)
{
// TODO validate characters
if (!StringUtil.isValidFilenameString(logName)) {
throw new IllegalArgumentException("Invalid log name.");
}
this.logName = logName;
}
@ -81,7 +84,7 @@ public class InitTaskSetupLog extends InitTask {
@Override
public void run(App app)
public void run()
{
final LogWriter log = Log.create(logName, new File(WorkDir.getDir(logDir), logName + ".log"), archiveCount);
Log.setMainLogger(log);

@ -1,11 +1,9 @@
package mightypork.gamecore.initializers.tasks;
package mightypork.gamecore.core;
import java.io.IOException;
import mightypork.gamecore.core.WorkDir;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.initializers.InitTask;
import mightypork.gamecore.WorkDir;
import mightypork.utils.logging.Log;
@ -15,10 +13,10 @@ import mightypork.utils.logging.Log;
*
* @author Ondřej Hruška (MightyPork)
*/
public class InitTaskWriteLogHeader extends InitTask {
public class InitTaskLogHeader extends InitTask {
@Override
public void run(App app)
public void run()
{
String txt = "";

@ -1,4 +1,4 @@
package mightypork.gamecore.initializers.tasks;
package mightypork.gamecore.core;
import java.io.File;
@ -8,9 +8,7 @@ import java.util.Map.Entry;
import javax.swing.JOptionPane;
import mightypork.gamecore.core.WorkDir;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.initializers.InitTask;
import mightypork.gamecore.WorkDir;
import mightypork.utils.annotations.Stub;
import mightypork.utils.files.InstanceLock;
import mightypork.utils.logging.Log;
@ -21,9 +19,9 @@ import mightypork.utils.logging.Log;
*
* @author Ondřej Hruška (MightyPork)
*/
public class InitTaskSetupWorkdir extends InitTask {
public class InitTaskWorkdir extends InitTask {
private final File workdirPath;
private File workdirPath;
private boolean doLock;
private String lockFile = ".lock";
private Map<String, String> namedPaths = new HashMap<>();
@ -33,12 +31,35 @@ public class InitTaskSetupWorkdir extends InitTask {
* @param workdir path to the working directory
* @param lock whether to lock the directory (single instance mode)
*/
public InitTaskSetupWorkdir(File workdir, boolean lock) {
public InitTaskWorkdir(File workdir, boolean lock) {
this.workdirPath = workdir;
this.doLock = lock;
}
/**
* Set workdir root path
*
* @param path workdir path
*/
public void setWorkdirPath(File path)
{
this.workdirPath = path;
}
/**
* Set whether the workdir should be locked when the app is running, to
* prevent other instances from running simultaneously.
*
* @param lock
*/
public void setInstanceLock(boolean lock)
{
this.doLock = lock;
}
/**
* Set name of the lock file.
*
@ -63,7 +84,7 @@ public class InitTaskSetupWorkdir extends InitTask {
@Override
public void run(App app)
public void run()
{
WorkDir.init(workdirPath);

@ -1,4 +1,4 @@
package mightypork.gamecore.initializers;
package mightypork.gamecore.core;
import java.util.ArrayList;
@ -10,7 +10,7 @@ import java.util.Set;
import mightypork.utils.logging.Log;
public class InitTaskResolver {
public class InitTasks {
/**
* Order init tasks so that all dependencies are loaded before thye are
@ -19,7 +19,7 @@ public class InitTaskResolver {
* @param tasks task list
* @return task list ordered
*/
public static List<InitTask> order(List<InitTask> tasks)
public static List<InitTask> inOrder(List<InitTask> tasks)
{
List<InitTask> remaining = new ArrayList<>(tasks);

@ -1,14 +1,11 @@
package mightypork.gamecore.core.modules;
package mightypork.gamecore.core;
import java.util.Deque;
import java.util.concurrent.ConcurrentLinkedDeque;
import mightypork.gamecore.gui.screens.ScreenRegistry;
import mightypork.gamecore.plugins.screenshot.TaskTakeScreenshot;
import mightypork.gamecore.render.Renderable;
import mightypork.gamecore.render.events.ScreenshotRequestListener;
import mightypork.utils.Support;
import mightypork.utils.annotations.Stub;
import mightypork.utils.eventbus.clients.BusNode;
import mightypork.utils.eventbus.events.UpdateEvent;

@ -1,54 +0,0 @@
package mightypork.gamecore.core.config;
import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys;
import mightypork.utils.files.config.Property;
/**
* Key property.<br>
* The stored value must be invariant ({@link KeyStroke} is mutable).
*
* @author Ondřej Hruška (MightyPork)
*/
public class KeyProperty extends Property<KeyStroke> {
public KeyProperty(String key, KeyStroke defaultValue, String comment) {
super(key, defaultValue, comment);
}
@Override
public KeyStroke decode(String string, KeyStroke defval)
{
if (string != null) {
// keep it invariant
final int backup_key = getValue().getKey();
final int backup_mod = getValue().getMod();
getValue().fromDataString(string);
if (getValue().getKey() == Keys.NONE) {
getValue().setTo(backup_key, backup_mod);
}
}
return getValue();
}
@Override
public String encode(KeyStroke value)
{
return value.toDataString();
}
@Override
public void setValue(Object value)
{
// keep it invariant
getValue().setTo(((KeyStroke) value).getKey(), ((KeyStroke) value).getMod());
}
}

@ -1,7 +1,7 @@
package mightypork.gamecore.core.events;
import mightypork.gamecore.core.modules.MainLoop;
import mightypork.gamecore.core.MainLoop;
import mightypork.utils.eventbus.BusEvent;
import mightypork.utils.eventbus.events.flags.SingleReceiverEvent;

@ -1,8 +1,8 @@
package mightypork.gamecore.core.events;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.modules.MainLoop;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.MainLoop;
import mightypork.utils.eventbus.BusEvent;
import mightypork.utils.eventbus.events.flags.NonConsumableEvent;
import mightypork.utils.eventbus.events.flags.SingleReceiverEvent;

@ -4,91 +4,61 @@ package mightypork.gamecore.gui.components;
import java.util.Collection;
import java.util.LinkedList;
import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.resources.audio.SoundSystem;
import mightypork.utils.eventbus.EventBus;
import mightypork.utils.eventbus.clients.ClientHub;
import mightypork.utils.eventbus.clients.DelegatingList;
import mightypork.utils.math.constraints.rect.RectBound;
public abstract class LayoutComponent extends BaseComponent implements ClientHub, AppAccess {
public abstract class LayoutComponent extends BaseComponent implements ClientHub {
private final AppSubModule subModule;
private final DelegatingList clientList;
final LinkedList<Component> components = new LinkedList<>();
public LayoutComponent(AppAccess app, RectBound context) {
this.subModule = new AppSubModule(app);
public LayoutComponent(RectBound context) {
this.clientList = new DelegatingList();
setRect(context);
enableCaching(true); // layout is typically updated only when screen resizes.
}
public LayoutComponent(AppAccess app) {
this(app, null);
}
@Override
public EventBus getEventBus()
{
return subModule.getEventBus();
public LayoutComponent() {
this(null);
}
@Override
public Collection<Object> getChildClients()
{
return subModule.getChildClients();
return clientList;
}
@Override
public boolean doesDelegate()
{
return subModule.doesDelegate();
return clientList.doesDelegate();
}
@Override
public boolean isListening()
{
return subModule.isListening();
}
@Override
public SoundSystem getSoundSystem()
{
return subModule.getSoundSystem();
}
@Override
public InputSystem getInput()
{
return subModule.getInput();
}
@Override
public void shutdown()
{
subModule.shutdown();
return clientList.isListening();
}
@Override
public void addChildClient(Object client)
{
subModule.addChildClient(client);
clientList.add(client);
}
@Override
public void removeChildClient(Object client)
{
subModule.removeChildClient(client);
clientList.remove(client);
}
@ -113,7 +83,9 @@ public abstract class LayoutComponent extends BaseComponent implements ClientHub
protected final void attach(Component component)
{
if (component == null) return;
if (component == this) throw new IllegalArgumentException("Uruboros. (infinite recursion evaded)");
if (component == this) {
throw new IllegalArgumentException("Uruboros. (infinite recursion evaded)");
}
components.add(component);
addChildClient(component);

@ -10,13 +10,13 @@ public class ColumnLayout extends GridLayout {
private int col = 0;
public ColumnLayout(AppAccess app, int rows) {
this(app, null, rows);
public ColumnLayout(int rows) {
this(null, rows);
}
public ColumnLayout(AppAccess app, RectBound context, int cols) {
super(app, context, 1, cols);
public ColumnLayout(RectBound context, int cols) {
super(context, 1, cols);
}

@ -18,7 +18,7 @@ public class ConstraintLayout extends LayoutComponent {
public ConstraintLayout(RectBound context) {
super(app, context);
super(context);
}

@ -27,8 +27,8 @@ public class FlowColumnLayout extends LayoutComponent {
* @param elementWidth width of all elements
* @param align component align. Legal values are LEFT and RIGHT.
*/
public FlowColumnLayout(AppAccess app, RectBound context, Num elementWidth, AlignX align) {
super(app, context);
public FlowColumnLayout(RectBound context, Num elementWidth, AlignX align) {
super(context);
this.elementWidth = elementWidth;
this.align = align;
@ -46,8 +46,8 @@ public class FlowColumnLayout extends LayoutComponent {
* @param elementWidth width of all elements
* @param align component align. Legal values are LEFT and RIGHT.
*/
public FlowColumnLayout(AppAccess app, Num elementWidth, AlignX align) {
this(app, null, elementWidth, align);
public FlowColumnLayout(Num elementWidth, AlignX align) {
this(null, elementWidth, align);
}

@ -22,13 +22,12 @@ public class FlowRowLayout extends LayoutComponent {
/**
* @param app app access
* @param context context
* @param elementHeight height of all elements
* @param align component align. Legal values are TOP and BOTTOM.
*/
public FlowRowLayout(AppAccess app, RectBound context, Num elementHeight, AlignY align) {
super(app, context);
public FlowRowLayout(RectBound context, Num elementHeight, AlignY align) {
super(context);
this.elementHeight = elementHeight;
this.align = align;
@ -46,8 +45,8 @@ public class FlowRowLayout extends LayoutComponent {
* @param elementHeight height of all elements
* @param align component align. Legal values are TOP and BOTTOM.
*/
public FlowRowLayout(AppAccess app, Num elementHeight, AlignY align) {
this(app, null, elementHeight, align);
public FlowRowLayout(Num elementHeight, AlignY align) {
this(null, elementHeight, align);
}

@ -18,13 +18,12 @@ public class GridLayout extends LayoutComponent {
/**
* @param app app access
* @param context context
* @param rows number of rows
* @param cols number of columns
*/
public GridLayout(AppAccess app, RectBound context, int rows, int cols) {
super(app, context);
public GridLayout(RectBound context, int rows, int cols) {
super(context);
this.tiler = tiles(cols, rows);
}
@ -33,12 +32,11 @@ public class GridLayout extends LayoutComponent {
* make a new holder.<br>
* Context must be assigned before rendering.
*
* @param app app access
* @param rows number of rows
* @param cols number of columns
*/
public GridLayout(AppAccess app, int rows, int cols) {
this(app, null, rows, cols);
public GridLayout(int rows, int cols) {
this(null, rows, cols);
}

@ -10,13 +10,13 @@ public class RowLayout extends GridLayout {
private int row = 0;
public RowLayout(AppAccess app, int rows) {
this(app, null, rows);
public RowLayout(int rows) {
this(null, rows);
}
public RowLayout(AppAccess app, RectBound context, int rows) {
super(app, context, rows, 1);
public RowLayout(RectBound context, int rows) {
super(context, rows, 1);
}

@ -12,16 +12,22 @@ import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.proxy.VectAdapter;
/**
* Layout that aligns elements while taking into account their actual
* dimensions.<br>
* Useful eg. for buttons that stretch based on text length.
*
* @author Ondřej Hruška (MightyPork)
*/
public class LinearLayout extends LayoutComponent {
public LinearLayout(AppAccess app, AlignX align) {
super(app);
public LinearLayout(AlignX align) {
this.align = align;
}
public LinearLayout(AppAccess app, RectBound context, AlignX align) {
super(app, context);
public LinearLayout(RectBound context, AlignX align) {
super(context);
this.align = align;
}

@ -1,7 +1,7 @@
package mightypork.gamecore.gui.components.painters;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.components.BaseComponent;
import mightypork.gamecore.gui.components.DynamicWidthComponent;
import mightypork.gamecore.resources.textures.TxQuad;

@ -1,7 +1,7 @@
package mightypork.gamecore.gui.components.painters;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.components.BaseComponent;
import mightypork.gamecore.render.Grad;
import mightypork.utils.annotations.FactoryMethod;

@ -1,7 +1,7 @@
package mightypork.gamecore.gui.components.painters;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.BaseComponent;
import mightypork.gamecore.gui.components.DynamicWidthComponent;

@ -4,7 +4,7 @@ package mightypork.gamecore.gui.screens;
import java.util.ArrayList;
import java.util.Collection;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.Hideable;
import mightypork.gamecore.gui.components.layout.ConstraintLayout;
import mightypork.gamecore.gui.events.LayoutChangeListener;

@ -1,7 +1,7 @@
package mightypork.gamecore.gui.screens;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.events.LayoutChangeEvent;
import mightypork.gamecore.gui.events.LayoutChangeListener;
import mightypork.gamecore.input.Edge;

@ -6,7 +6,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.TreeSet;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.events.LayoutChangeEvent;
import mightypork.gamecore.gui.events.ScreenRequestListener;
import mightypork.gamecore.render.Renderable;

@ -1,8 +1,8 @@
package mightypork.gamecore.gui.screens.impl;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.events.ShudownRequest;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.gui.components.painters.QuadPainter;
import mightypork.gamecore.gui.events.ScreenRequest;
import mightypork.gamecore.gui.screens.Overlay;
@ -66,7 +66,7 @@ public class CrossfadeOverlay extends Overlay {
if (screen == null) {
// going for halt
getSoundSystem().fadeOutAllLoops();
App.audio().fadeOutAllLoops();
}
if (fromDark) {

@ -1,8 +1,8 @@
package mightypork.gamecore.input;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.events.UserQuitRequest;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.input.events.InputReadyEvent;
import mightypork.gamecore.input.events.KeyEvent;
import mightypork.gamecore.input.events.MouseButtonEvent;

@ -1,7 +1,7 @@
package mightypork.gamecore.plugins;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.utils.annotations.Stub;
import mightypork.utils.eventbus.clients.BusNode;

@ -1,8 +1,8 @@
package mightypork.gamecore.plugins.screenshot;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.events.MainLoopRequest;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.plugins.AppPlugin;
import mightypork.utils.Support;

@ -4,8 +4,8 @@ package mightypork.gamecore.plugins.screenshot;
import java.io.File;
import java.io.IOException;
import mightypork.gamecore.core.WorkDir;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.WorkDir;
import mightypork.gamecore.core.App;
import mightypork.gamecore.render.Screenshot;
import mightypork.utils.Support;
import mightypork.utils.logging.Log;

@ -5,7 +5,7 @@ import mightypork.utils.math.color.Color;
/**
* Linear gradient (each vertex can have different color)
* Linear gradient (each corner can have different color)
*
* @author MightyPork
*/

@ -308,7 +308,8 @@ public abstract class GraphicsModule extends BackendModule {
/**
* Take screenshot (expensive processing should be done in separate thread
* when screenshot is saved).
* when screenshot is saved).<br>
* This method is utilized by the Screenshot plugin.
*
* @return screenshot object
*/
@ -316,7 +317,7 @@ public abstract class GraphicsModule extends BackendModule {
/**
* FIXME This should be moved to inout module
* FIXME This should probably be moved to input module
*
* @return true if close was requested recently (i.e. click on cross)
*/
@ -345,7 +346,7 @@ public abstract class GraphicsModule extends BackendModule {
/**
* Set titlebar text
* Set window titlebar text
*
* @param title titlebar text
*/
@ -369,7 +370,7 @@ public abstract class GraphicsModule extends BackendModule {
/**
* Get screen rect. Should always return the same Vect instance.
* Get screen rect. Should always return the same Rect instance.
*
* @return the rect
*/
@ -393,21 +394,21 @@ public abstract class GraphicsModule extends BackendModule {
/**
* @return screen width
* Get screen size. Should always return the same Vect instance.
*
* @return size
*/
public abstract int getWidth();
public abstract Vect getSize();
/**
* @return screen height
* @return screen width
*/
public abstract int getHeight();
public abstract int getWidth();
/**
* Get screen size. Should always return the same Vect instance.
*
* @return size
* @return screen height
*/
public abstract Vect getSize();
public abstract int getHeight();
}

@ -7,7 +7,8 @@ import java.io.IOException;
/**
* <p>
* Screenshot object, can be used to save image to file.
* Screenshot object used to save screenshot to a file. The Screenshot object is
* created by the Graphics module.
* </p>
* <p>
* Screenshot typically takes a byte buffer and converts it to image before

@ -1,15 +0,0 @@
package mightypork.gamecore.render.events;
import mightypork.utils.eventbus.BusEvent;
public class DisplayReadyEvent extends BusEvent<DisplayReadyListener> {
@Override
protected void handleBy(DisplayReadyListener handler)
{
handler.onDisplayReady();
}
}

@ -1,7 +0,0 @@
package mightypork.gamecore.render.events;
public interface DisplayReadyListener {
void onDisplayReady();
}

@ -5,8 +5,8 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import mightypork.gamecore.core.App;
import mightypork.gamecore.core.events.MainLoopRequest;
import mightypork.gamecore.core.modules.App;
import mightypork.utils.Reflect;
import mightypork.utils.Support;
import mightypork.utils.interfaces.Destroyable;

@ -9,7 +9,7 @@ import org.newdawn.slick.openal.SoundStore;
import mightypork.gamecore.backend.BackendModule;
import mightypork.gamecore.backend.lwjgl.SlickAudio;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.resources.ResourceLoadRequest;
import mightypork.gamecore.resources.audio.players.EffectPlayer;
import mightypork.gamecore.resources.audio.players.LoopPlayer;

@ -1,7 +1,7 @@
package mightypork.gamecore.resources.audio;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.resources.BaseDeferredResource;
import mightypork.utils.annotations.Alias;
import mightypork.utils.math.constraints.vect.Vect;

@ -4,7 +4,7 @@ package mightypork.gamecore.resources.audio;
import java.util.HashMap;
import java.util.Map;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.resources.audio.players.EffectPlayer;
import mightypork.gamecore.resources.audio.players.LoopPlayer;

@ -3,7 +3,7 @@ package mightypork.gamecore.resources.fonts;
import java.util.HashMap;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.resources.ResourceLoadRequest;
import mightypork.gamecore.resources.fonts.impl.LazyFont;
import mightypork.utils.eventbus.clients.BusNode;

@ -1,7 +1,7 @@
package mightypork.gamecore.resources.fonts;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.AlignX;
import mightypork.utils.math.color.Color;
import mightypork.utils.math.color.pal.RGB;

@ -11,7 +11,7 @@ import mightypork.gamecore.resources.MustLoadInRenderingContext;
import mightypork.gamecore.resources.fonts.IFont;
import mightypork.gamecore.resources.textures.FilterMode;
import mightypork.utils.annotations.Alias;
import mightypork.utils.files.FileUtils;
import mightypork.utils.files.FileUtil;
import mightypork.utils.math.color.Color;
import mightypork.utils.math.constraints.vect.Vect;
@ -131,7 +131,7 @@ public class LazyFont extends BaseDeferredResource implements IFont {
*/
protected Font getAwtFont(String resource, float size, int style) throws IOException
{
try (InputStream in = FileUtils.getResource(resource)) {
try (InputStream in = FileUtil.getResource(resource)) {
Font awtFont = Font.createFont(Font.TRUETYPE_FONT, in);

@ -4,7 +4,7 @@ package mightypork.gamecore.resources.textures;
import java.util.HashMap;
import java.util.Map;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.resources.ResourceLoadRequest;
import mightypork.utils.exceptions.KeyAlreadyExistsException;
import mightypork.utils.math.constraints.rect.Rect;

@ -4,7 +4,7 @@ package mightypork.rogue;
import java.io.File;
import java.util.logging.Level;
import mightypork.gamecore.core.modules.BaseApp;
import junk.BaseApp;
import mightypork.utils.files.OsUtils;

@ -1,13 +1,13 @@
package mightypork.rogue;
import junk.AppInitOptions;
import junk.BaseApp;
import mightypork.gamecore.backend.lwjgl.LwjglBackend;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.core.events.MainLoopRequest;
import mightypork.gamecore.core.events.ShudownRequest;
import mightypork.gamecore.core.events.UserQuitRequest;
import mightypork.gamecore.core.modules.AppInitOptions;
import mightypork.gamecore.core.modules.BaseApp;
import mightypork.gamecore.gui.screens.ScreenRegistry;
import mightypork.gamecore.input.Edge;
import mightypork.gamecore.input.InputSystem;
@ -118,7 +118,7 @@ public final class RogueApp extends BaseApp implements ViewportChangeListener, S
private void bindEventToKey(final BusEvent<?> event, String strokeName)
{
getInput().bindKey(Config.getKey(strokeName), Edge.RISING, new Runnable() {
getInput().bindKey(Config.getKeyStroke(strokeName), Edge.RISING, new Runnable() {
@Override
public void run()

@ -1,8 +1,8 @@
package mightypork.rogue;
import mightypork.gamecore.core.config.ConfigSetup;
import mightypork.utils.files.config.PropertyManager;
import mightypork.gamecore.config.ConfigSetup;
import mightypork.utils.config.propmgr.PropertyManager;
public class RogueConfig implements ConfigSetup {
@ -10,11 +10,11 @@ public class RogueConfig implements ConfigSetup {
@Override
public void addOptions(PropertyManager prop)
{
prop.putBoolean("display.fullscreen", false, "Start in fullscreen (remembers state at exit)");
prop.putInteger("display.width", 1024, "Initial width (remembers from last time)");
prop.putInteger("display.height", 768, "Initial height (remembers from last time)");
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.putBoolean("opt.show_story", true, "Show story on start-up.");
prop.addBoolean("opt.show_story", true, "Show story on start-up.");
}
}

@ -1,8 +1,8 @@
package mightypork.rogue;
import mightypork.gamecore.core.config.KeyOpts;
import mightypork.gamecore.core.config.KeySetup;
import mightypork.gamecore.config.KeyOpts;
import mightypork.gamecore.config.KeySetup;
public class RogueKeys implements KeySetup {

@ -1,8 +1,8 @@
package mightypork.rogue;
import mightypork.gamecore.core.WorkDir.RouteOpts;
import mightypork.gamecore.core.WorkDir.RouteSetup;
import mightypork.gamecore.WorkDir.RouteOpts;
import mightypork.gamecore.WorkDir.RouteSetup;
public class RogueRoutes implements RouteSetup {

@ -1,8 +1,8 @@
package mightypork.rogue.screens;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.painters.TextPainter;
@ -33,7 +33,7 @@ public class FpsOverlay extends Overlay {
/*
* Toggle key: F3
*/
bindKey(Config.getKey("global.fps_meter"), Edge.RISING, new Action() {
bindKey(Config.getKeyStroke("global.fps_meter"), Edge.RISING, new Action() {
@Override
public void execute()

@ -1,7 +1,7 @@
package mightypork.rogue.screens.game;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.BaseComponent;
import mightypork.gamecore.resources.textures.TxQuad;

@ -1,7 +1,7 @@
package mightypork.rogue.screens.game;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.LayoutComponent;
import mightypork.gamecore.gui.components.layout.FlowColumnLayout;

@ -1,7 +1,7 @@
package mightypork.rogue.screens.game;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.input.ClickableComponent;

@ -3,7 +3,7 @@ package mightypork.rogue.screens.game;
import java.io.IOException;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.input.TextButton;
@ -121,13 +121,13 @@ public class LayerAskSave extends FadingLayer {
btn2.setAction(discard);
btn3.setAction(cancel);
bindKey(Config.getKey("general.close"), Edge.RISING, cancel);
bindKey(Config.getKey("general.cancel"), Edge.RISING, cancel);
bindKey(Config.getKeyStroke("general.close"), Edge.RISING, cancel);
bindKey(Config.getKeyStroke("general.cancel"), Edge.RISING, cancel);
bindKey(Config.getKey("general.yes"), Edge.RISING, save);
bindKey(Config.getKey("general.confirm"), Edge.RISING, save);
bindKey(Config.getKeyStroke("general.yes"), Edge.RISING, save);
bindKey(Config.getKeyStroke("general.confirm"), Edge.RISING, save);
bindKey(Config.getKey("general.no"), Edge.RISING, discard);
bindKey(Config.getKeyStroke("general.no"), Edge.RISING, discard);
}

@ -3,7 +3,7 @@ package mightypork.rogue.screens.game;
import java.io.IOException;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.input.TextButton;
@ -89,9 +89,9 @@ public class LayerDeath extends FadingLayer {
btn1.setAction(load);
btn2.setAction(quit);
bindKey(Config.getKey("game.load"), Edge.RISING, load);
bindKey(Config.getKey("general.confirm"), Edge.RISING, load);
bindKey(Config.getKey("general.close"), Edge.RISING, quit);
bindKey(Config.getKeyStroke("game.load"), Edge.RISING, load);
bindKey(Config.getKeyStroke("general.confirm"), Edge.RISING, load);
bindKey(Config.getKeyStroke("general.close"), Edge.RISING, quit);
}

@ -1,7 +1,7 @@
package mightypork.rogue.screens.game;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.layout.ConstraintLayout;
import mightypork.gamecore.gui.components.layout.FlowColumnLayout;
@ -29,9 +29,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.getKey("game.inv.use");
private final KeyStroke keyDrop = Config.getKey("game.inv.drop");
private final KeyStroke keyClose = Config.getKey("general.close");
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 StringProvider contextStrProv = new StringProvider() {
@ -233,7 +233,7 @@ public class LayerInv extends FadingLayer {
private void setupGridWalkKeys()
{
bindKey(Config.getKey("game.inv.move.left"), Edge.RISING, new Runnable() {
bindKey(Config.getKeyStroke("game.inv.move.left"), Edge.RISING, new Runnable() {
@Override
public void run()
@ -250,7 +250,7 @@ public class LayerInv extends FadingLayer {
}
});
bindKey(Config.getKey("game.inv.move.right"), Edge.RISING, new Runnable() {
bindKey(Config.getKeyStroke("game.inv.move.right"), Edge.RISING, new Runnable() {
@Override
public void run()
@ -267,7 +267,7 @@ public class LayerInv extends FadingLayer {
}
});
bindKey(Config.getKey("game.inv.move.up"), Edge.RISING, new Runnable() {
bindKey(Config.getKeyStroke("game.inv.move.up"), Edge.RISING, new Runnable() {
@Override
public void run()
@ -284,7 +284,7 @@ public class LayerInv extends FadingLayer {
}
});
bindKey(Config.getKey("game.inv.move.down"), Edge.RISING, new Runnable() {
bindKey(Config.getKeyStroke("game.inv.move.down"), Edge.RISING, new Runnable() {
@Override
public void run()

@ -3,7 +3,7 @@ package mightypork.rogue.screens.game;
import java.io.File;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.input.TextButton;
@ -69,8 +69,8 @@ public class LayerWin extends FadingLayer {
btn1.setAction(quit);
bindKey(Config.getKey("general.confirm"), Edge.RISING, quit);
bindKey(Config.getKey("general.close"), Edge.RISING, quit);
bindKey(Config.getKeyStroke("general.confirm"), Edge.RISING, quit);
bindKey(Config.getKeyStroke("general.close"), Edge.RISING, quit);
}

@ -1,7 +1,7 @@
package mightypork.rogue.screens.game;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.components.input.ClickableComponent;
import mightypork.gamecore.resources.Res;
import mightypork.gamecore.resources.textures.TxQuad;

@ -3,7 +3,7 @@ package mightypork.rogue.screens.game;
import java.io.File;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.core.events.UserQuitRequest;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.ActionGroup;
@ -246,17 +246,17 @@ public class ScreenGame extends RogueScreen implements PlayerDeathHandler, GameW
addLayer(worldLayer = new LayerMapView(this));
addLayer(askSaveLayer = new LayerAskSave(this));
bindKey(Config.getKey("game.pause"), Edge.RISING, actionTogglePause);
bindKey(Config.getKeyStroke("game.pause"), Edge.RISING, actionTogglePause);
bindKey(Config.getKey("game.inventory"), Edge.RISING, actionToggleInv);
bindKey(Config.getKey("game.drop"), Edge.RISING, actionDropLastPickedItem);
bindKey(Config.getKey("game.eat"), Edge.RISING, actionEat);
bindKey(Config.getKey("game.minimap"), Edge.RISING, actionToggleMinimap);
bindKey(Config.getKey("game.zoom"), Edge.RISING, actionToggleZoom);
bindKey(Config.getKeyStroke("game.inventory"), Edge.RISING, actionToggleInv);
bindKey(Config.getKeyStroke("game.drop"), Edge.RISING, actionDropLastPickedItem);
bindKey(Config.getKeyStroke("game.eat"), Edge.RISING, actionEat);
bindKey(Config.getKeyStroke("game.minimap"), Edge.RISING, actionToggleMinimap);
bindKey(Config.getKeyStroke("game.zoom"), Edge.RISING, actionToggleZoom);
bindKey(Config.getKey("game.load"), Edge.RISING, actionLoad);
bindKey(Config.getKey("game.save"), Edge.RISING, actionSave);
bindKey(Config.getKey("game.quit"), Edge.RISING, actionMenu);
bindKey(Config.getKeyStroke("game.load"), Edge.RISING, actionLoad);
bindKey(Config.getKeyStroke("game.save"), Edge.RISING, actionSave);
bindKey(Config.getKeyStroke("game.quit"), Edge.RISING, actionMenu);
// bindKey(new KeyStroke(Keys.W), Edge.RISING, new Runnable() {
//
@ -284,7 +284,7 @@ public class ScreenGame extends RogueScreen implements PlayerDeathHandler, GameW
worldActions.setEnabled(true);
// CHEAT - X-ray
bindKey(Config.getKey("game.cheat.xray"), Edge.RISING, new Runnable() {
bindKey(Config.getKeyStroke("game.cheat.xray"), Edge.RISING, new Runnable() {
@Override
public void run()

@ -1,7 +1,7 @@
package mightypork.rogue.screens.menu;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.core.events.UserQuitRequest;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
@ -103,7 +103,7 @@ public class ScreenMainMenu extends RogueScreen {
});
rows.add(btn, 2);
bindKey(Config.getKey("general.close"), Edge.RISING, new Runnable() {
bindKey(Config.getKeyStroke("general.close"), Edge.RISING, new Runnable() {
@Override
public void run()

@ -1,8 +1,8 @@
package mightypork.rogue.screens.select_world;
import mightypork.gamecore.core.WorkDir;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.WorkDir;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.layout.RowLayout;
import mightypork.gamecore.gui.components.painters.QuadPainter;
@ -76,7 +76,7 @@ public class ScreenSelectWorld extends RogueScreen {
rows.add(slot3);
// escape to quitn from here
bindKey(Config.getKey("general.close"), Edge.RISING, new Runnable() {
bindKey(Config.getKeyStroke("general.close"), Edge.RISING, new Runnable() {
@Override
public void run()

@ -1,7 +1,7 @@
package mightypork.rogue.screens.story;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.layout.RowLayout;
@ -217,7 +217,7 @@ public class ScreenStory extends RogueScreen implements MouseButtonHandler {
bindKey(new KeyStroke(Keys.RIGHT), Edge.RISING, next);
bindKey(new KeyStroke(Keys.BACKSPACE), Edge.RISING, prev);
bindKey(new KeyStroke(Keys.LEFT), Edge.RISING, prev);
bindKey(Config.getKey("general.close"), Edge.RISING, close);
bindKey(Config.getKeyStroke("general.close"), Edge.RISING, close);
}
private int slide = 0;

@ -1,7 +1,7 @@
package mightypork.rogue.world;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.render.GradH;
import mightypork.gamecore.render.GradV;
import mightypork.gamecore.render.GraphicsModule;

@ -1,7 +1,7 @@
package mightypork.rogue.world.entity.render;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.resources.Res;
import mightypork.gamecore.resources.textures.TxQuad;
import mightypork.gamecore.resources.textures.TxSheet;

@ -5,7 +5,7 @@ import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.components.InputComponent;
import mightypork.gamecore.input.events.MouseButtonEvent;
import mightypork.gamecore.input.events.MouseButtonHandler;

@ -1,7 +1,7 @@
package mightypork.rogue.world.gui;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.gui.components.InputComponent;
import mightypork.gamecore.input.events.MouseButtonEvent;
import mightypork.gamecore.input.events.MouseButtonHandler;

@ -5,7 +5,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.config.Config;
import mightypork.gamecore.input.Edge;
import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.input.KeyBindingPool;
@ -25,10 +25,10 @@ public class MIPKeyboard extends MapInteractionPlugin implements DelegatingClien
//@formatter:off
private static final KeyStroke[] keys = {
Config.getKey("game.walk.left"),
Config.getKey("game.walk.right"),
Config.getKey("game.walk.up"),
Config.getKey("game.walk.down")
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 };

@ -1,7 +1,7 @@
package mightypork.rogue.world.item.render;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.resources.textures.TxQuad;
import mightypork.rogue.world.item.Item;
import mightypork.rogue.world.item.ItemRenderer;

@ -1,7 +1,7 @@
package mightypork.rogue.world.tile;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.render.GraphicsModule;
import mightypork.gamecore.resources.Res;
import mightypork.gamecore.resources.textures.TxQuad;

@ -1,7 +1,7 @@
package mightypork.rogue.world.tile.render;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.resources.textures.TxSheet;
import mightypork.rogue.world.level.render.TileRenderContext;
import mightypork.rogue.world.tile.Tile;

@ -1,7 +1,7 @@
package mightypork.rogue.world.tile.render;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.resources.textures.TxQuad;
import mightypork.rogue.world.level.render.TileRenderContext;
import mightypork.rogue.world.tile.TileRenderer;

@ -1,7 +1,7 @@
package mightypork.rogue.world.tile.render;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.resources.textures.TxSheet;
import mightypork.rogue.world.level.render.TileRenderContext;
import mightypork.rogue.world.tile.TileRenderer;

@ -1,7 +1,7 @@
package mightypork.rogue.world.tile.render;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.resources.textures.TxQuad;
import mightypork.rogue.world.level.render.TileRenderContext;
import mightypork.rogue.world.tile.Tile;

@ -1,7 +1,7 @@
package mightypork.rogue.world.tile.render;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.core.App;
import mightypork.gamecore.resources.textures.TxQuad;
import mightypork.rogue.world.level.render.TileRenderContext;
import mightypork.rogue.world.tile.Tile;

Loading…
Cancel
Save