From 6208a0c2eb7b75a3bdda293bcee310a00760f47e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Mon, 28 Jul 2014 01:24:05 +0200 Subject: [PATCH] Fixed some issues & cleanup --- src/junk/BaseApp.java | 4 ++-- .../gamecore/audio/DeferredAudio.java | 3 ++- .../gamecore/audio/JointVolume.java | 3 ++- src/mightypork/gamecore/audio/Volume.java | 3 ++- .../audio/players/BaseAudioPlayer.java | 3 ++- .../gamecore/audio/players/EffectPlayer.java | 3 ++- .../gamecore/audio/players/LoopPlayer.java | 5 +++-- src/mightypork/gamecore/core/App.java | 7 ++++--- src/mightypork/gamecore/core/InitTask.java | 16 +++++++------- .../gamecore/core/OptionalInitTask.java | 7 ++++++- .../gamecore/core/config/Config.java | 16 +++++++------- .../core/config/KeyStrokeProperty.java | 3 ++- .../gamecore/core/events/MainLoopRequest.java | 6 ++++-- .../gamecore/core/events/ShutdownEvent.java | 5 +++-- .../gamecore/core/init/InitTaskDisplay.java | 2 +- .../gamecore/core/init/InitTaskWorkdir.java | 7 ++++--- .../screenshot/InitTaskPluginScreenshot.java | 6 ++++-- .../plugins/screenshot/ScreenshotPlugin.java | 2 +- .../screenshot/TaskTakeScreenshot.java | 3 ++- .../gamecore/graphics/fonts/DeferredFont.java | 6 ++++-- .../gamecore/graphics/fonts/FontRenderer.java | 6 ++++-- .../graphics/textures/DeferredTexture.java | 3 ++- .../gamecore/graphics/textures/QuadGrid.java | 3 ++- .../gamecore/graphics/textures/TxQuad.java | 9 +++++--- .../gamecore/graphics/textures/TxSheet.java | 3 ++- .../gui/components/BaseComponent.java | 3 ++- .../gui/components/LayoutComponent.java | 6 ++++-- .../gui/components/LinearComponent.java | 3 ++- .../components/input/ClickableWrapper.java | 3 ++- .../gui/components/input/TextButton.java | 3 ++- .../gui/components/layout/ColumnLayout.java | 6 ++++-- .../components/layout/ConstraintLayout.java | 6 ++++-- .../components/layout/FlowColumnLayout.java | 6 ++++-- .../gui/components/layout/FlowRowLayout.java | 6 ++++-- .../gui/components/layout/GridLayout.java | 6 ++++-- .../gui/components/layout/RowLayout.java | 6 ++++-- .../layout/linear/AbstractLinearWrapper.java | 3 ++- .../components/layout/linear/LinearGap.java | 6 ++++-- .../layout/linear/LinearLayout.java | 6 ++++-- .../layout/linear/LinearRectangle.java | 3 ++- .../layout/linear/LinearSquare.java | 3 ++- .../layout/linear/LinearWrapper.java | 3 ++- .../gui/components/painters/ImagePainter.java | 3 ++- .../gui/components/painters/QuadPainter.java | 6 ++++-- .../gui/components/painters/TextPainter.java | 21 ++++++++++++------- .../gui/events/LayoutChangeEvent.java | 3 ++- .../gamecore/gui/events/ScreenRequest.java | 3 ++- .../gui/events/ViewportChangeEvent.java | 3 ++- .../gamecore/gui/screens/LayeredScreen.java | 3 ++- .../gamecore/gui/screens/Overlay.java | 3 ++- .../gamecore/gui/screens/Screen.java | 3 ++- .../gamecore/gui/screens/ScreenLayer.java | 3 ++- .../gui/screens/impl/CrossfadeOverlay.java | 3 ++- .../gui/screens/impl/CrossfadeRequest.java | 6 ++++-- .../gui/screens/impl/FadingLayer.java | 6 ++++-- .../gamecore/gui/screens/impl/LayerColor.java | 3 ++- src/mightypork/gamecore/input/Key.java | 5 +++-- src/mightypork/gamecore/input/KeyBinding.java | 3 ++- src/mightypork/gamecore/input/KeyStroke.java | 6 ++++-- src/mightypork/gamecore/input/Keys.java | 14 ++++++------- .../gamecore/input/events/KeyEvent.java | 13 ++++++------ .../input/events/MouseButtonEvent.java | 3 ++- .../input/events/MouseMotionEvent.java | 3 ++- .../resources/BaseDeferredResource.java | 3 ++- .../loading/AsyncResourceLoader.java | 3 ++- .../loading/MustLoadInRenderingContext.java | 7 ++++++- .../loading/ResourceLoadRequest.java | 3 ++- 67 files changed, 218 insertions(+), 126 deletions(-) diff --git a/src/junk/BaseApp.java b/src/junk/BaseApp.java index 5993226..b1a38a3 100644 --- a/src/junk/BaseApp.java +++ b/src/junk/BaseApp.java @@ -3,7 +3,6 @@ package junk; import java.lang.Thread.UncaughtExceptionHandler; -import mightypork.gamecore.backends.lwjgl.LwjglInputModule; import mightypork.gamecore.core.App; import mightypork.gamecore.core.AppBackend; import mightypork.gamecore.core.MainLoop; @@ -50,7 +49,8 @@ public abstract class BaseApp extends App implements UncaughtExceptionHandler { } - public BaseApp(AppBackend backend) { + public BaseApp(AppBackend backend) + { super(backend); } diff --git a/src/mightypork/gamecore/audio/DeferredAudio.java b/src/mightypork/gamecore/audio/DeferredAudio.java index 8dd72c1..b9b0f4f 100644 --- a/src/mightypork/gamecore/audio/DeferredAudio.java +++ b/src/mightypork/gamecore/audio/DeferredAudio.java @@ -20,7 +20,8 @@ public abstract class DeferredAudio extends BaseDeferredResource implements IAud * * @param resourceName resource to load (when needed) */ - public DeferredAudio(String resourceName) { + public DeferredAudio(String resourceName) + { super(resourceName); } diff --git a/src/mightypork/gamecore/audio/JointVolume.java b/src/mightypork/gamecore/audio/JointVolume.java index ab186ac..7d8f8db 100644 --- a/src/mightypork/gamecore/audio/JointVolume.java +++ b/src/mightypork/gamecore/audio/JointVolume.java @@ -20,7 +20,8 @@ public class JointVolume extends Volume { * @param volumes individual volumes to join */ @SafeVarargs - public JointVolume(Volume... volumes) { + public JointVolume(Volume... volumes) + { super(1D); this.volumes = volumes; } diff --git a/src/mightypork/gamecore/audio/Volume.java b/src/mightypork/gamecore/audio/Volume.java index 3e8a55d..fde5224 100644 --- a/src/mightypork/gamecore/audio/Volume.java +++ b/src/mightypork/gamecore/audio/Volume.java @@ -15,7 +15,8 @@ public class Volume extends Mutable { /** * @param d initial value */ - public Volume(Double d) { + public Volume(Double d) + { super(d); } diff --git a/src/mightypork/gamecore/audio/players/BaseAudioPlayer.java b/src/mightypork/gamecore/audio/players/BaseAudioPlayer.java index 78a240e..99ff14d 100644 --- a/src/mightypork/gamecore/audio/players/BaseAudioPlayer.java +++ b/src/mightypork/gamecore/audio/players/BaseAudioPlayer.java @@ -32,7 +32,8 @@ public abstract class BaseAudioPlayer implements Destroyable { * @param baseGain base gain (volume multiplier) * @param volume colume control */ - public BaseAudioPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume) { + public BaseAudioPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume) + { this.audio = track; this.baseGain = baseGain; diff --git a/src/mightypork/gamecore/audio/players/EffectPlayer.java b/src/mightypork/gamecore/audio/players/EffectPlayer.java index 624ffde..6f1977c 100644 --- a/src/mightypork/gamecore/audio/players/EffectPlayer.java +++ b/src/mightypork/gamecore/audio/players/EffectPlayer.java @@ -19,7 +19,8 @@ public class EffectPlayer extends BaseAudioPlayer { * @param baseGain base gain (volume multiplier) * @param volume volume control */ - public EffectPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume) { + public EffectPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume) + { super(track, (float) basePitch, (float) baseGain, volume); } diff --git a/src/mightypork/gamecore/audio/players/LoopPlayer.java b/src/mightypork/gamecore/audio/players/LoopPlayer.java index 714a6c9..4a607b8 100644 --- a/src/mightypork/gamecore/audio/players/LoopPlayer.java +++ b/src/mightypork/gamecore/audio/players/LoopPlayer.java @@ -15,7 +15,7 @@ import mightypork.utils.math.animation.NumAnimated; */ public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable { - private int sourceID = -1; + private final int sourceID = -1; /** animator for fade in and fade out */ private final NumAnimated fadeAnim = new NumAnimated(0); @@ -38,7 +38,8 @@ public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable * @param baseGain base gain (volume multiplier) * @param volume volume control */ - public LoopPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume) { + public LoopPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume) + { super(track, (float) basePitch, (float) baseGain, volume); paused = true; diff --git a/src/mightypork/gamecore/core/App.java b/src/mightypork/gamecore/core/App.java index fbb9817..f0a61aa 100644 --- a/src/mightypork/gamecore/core/App.java +++ b/src/mightypork/gamecore/core/App.java @@ -39,7 +39,8 @@ public class App extends BusNode { * * @param backend */ - public App(AppBackend backend) { + public App(AppBackend backend) + { if (App.instance != null) { throw new IllegalStateException("App already initialized"); } @@ -125,9 +126,9 @@ public class App extends BusNode { Log.i("=== Starting initialization sequence ==="); // sort initializers by order. - List orderedInitializers = InitTask.inOrder(initializers); + final List orderedInitializers = InitTask.inOrder(initializers); - for (InitTask initializer : orderedInitializers) { + for (final InitTask initializer : orderedInitializers) { Log.f1("Running init task \"" + initializer.getName() + "\"..."); initializer.bind(this); initializer.init(); diff --git a/src/mightypork/gamecore/core/InitTask.java b/src/mightypork/gamecore/core/InitTask.java index 7be6c86..ff0ec41 100644 --- a/src/mightypork/gamecore/core/InitTask.java +++ b/src/mightypork/gamecore/core/InitTask.java @@ -85,23 +85,23 @@ public abstract class InitTask { */ public static List inOrder(List tasks) { - List remaining = new ArrayList<>(tasks); + final List remaining = new ArrayList<>(tasks); - List ordered = new ArrayList<>(); - Set loaded = new HashSet<>(); + final List ordered = new ArrayList<>(); + final Set loaded = new HashSet<>(); // resolve task order int addedThisIteration = 0; do { - for (Iterator i = remaining.iterator(); i.hasNext();) { - InitTask task = i.next(); + for (final Iterator i = remaining.iterator(); i.hasNext();) { + final InitTask task = i.next(); String[] deps = task.getDependencies(); if (deps == null) deps = new String[] {}; int unmetDepsCount = deps.length; - for (String d : deps) { + for (final String d : deps) { if (loaded.contains(d)) unmetDepsCount--; } @@ -119,7 +119,7 @@ public abstract class InitTask { // build error message for each bad task int badInitializers = 0; - for (InitTask task : remaining) { + for (final InitTask task : remaining) { if (Reflect.hasAnnotation(task.getClass(), OptionalInitTask.class)) { continue; } @@ -128,7 +128,7 @@ public abstract class InitTask { String notSatisfied = ""; - for (String d : task.getDependencies()) { + for (final String d : task.getDependencies()) { if (!loaded.contains(d)) { if (!notSatisfied.isEmpty()) { diff --git a/src/mightypork/gamecore/core/OptionalInitTask.java b/src/mightypork/gamecore/core/OptionalInitTask.java index 39a47d0..c5e3748 100644 --- a/src/mightypork/gamecore/core/OptionalInitTask.java +++ b/src/mightypork/gamecore/core/OptionalInitTask.java @@ -1,7 +1,12 @@ package mightypork.gamecore.core; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** diff --git a/src/mightypork/gamecore/core/config/Config.java b/src/mightypork/gamecore/core/config/Config.java index d319847..8a6dad2 100644 --- a/src/mightypork/gamecore/core/config/Config.java +++ b/src/mightypork/gamecore/core/config/Config.java @@ -23,9 +23,9 @@ public class Config { protected static Map configs = new HashMap<>(); - private Map strokes = new HashMap<>(); + private final Map strokes = new HashMap<>(); - private PropertyManager propertyManager; + private final PropertyManager propertyManager; /** @@ -36,7 +36,7 @@ public class Config { */ public static Config forAlias(String alias) { - Config c = configs.get(alias); + final Config c = configs.get(alias); if (c == null) { throw new IllegalArgumentException("There is no config with alias \"" + alias + "\""); @@ -68,7 +68,8 @@ public class Config { * @param file config file, relative to workdir * @param headComment file comment */ - public Config(String file, String headComment) { + public Config(String file, String headComment) + { this(new PropertyFile(WorkDir.getFile(file), headComment)); } @@ -78,11 +79,8 @@ public class Config { * * @param store property store backing the property manager */ - public Config(PropertyStore store) { - if (propertyManager != null) { - throw new IllegalStateException("Config already initialized."); - } - + public Config(PropertyStore store) + { propertyManager = new PropertyManager(store); } diff --git a/src/mightypork/gamecore/core/config/KeyStrokeProperty.java b/src/mightypork/gamecore/core/config/KeyStrokeProperty.java index 03e98df..86c9cba 100644 --- a/src/mightypork/gamecore/core/config/KeyStrokeProperty.java +++ b/src/mightypork/gamecore/core/config/KeyStrokeProperty.java @@ -17,7 +17,8 @@ import mightypork.utils.config.propmgr.Property; */ public class KeyStrokeProperty extends Property { - public KeyStrokeProperty(String key, KeyStroke defaultValue, String comment) { + public KeyStrokeProperty(String key, KeyStroke defaultValue, String comment) + { super(key, defaultValue, comment); } diff --git a/src/mightypork/gamecore/core/events/MainLoopRequest.java b/src/mightypork/gamecore/core/events/MainLoopRequest.java index 7bcc546..520a967 100644 --- a/src/mightypork/gamecore/core/events/MainLoopRequest.java +++ b/src/mightypork/gamecore/core/events/MainLoopRequest.java @@ -21,7 +21,8 @@ public class MainLoopRequest extends BusEvent { /** * @param task task to run on main thread in rendering context */ - public MainLoopRequest(Runnable task) { + public MainLoopRequest(Runnable task) + { this(task, false); } @@ -30,7 +31,8 @@ public class MainLoopRequest extends BusEvent { * @param task task to run on main thread in rendering context * @param priority if true, skip other tasks in queue */ - public MainLoopRequest(Runnable task, boolean priority) { + public MainLoopRequest(Runnable task, boolean priority) + { this.task = task; this.priority = priority; } diff --git a/src/mightypork/gamecore/core/events/ShutdownEvent.java b/src/mightypork/gamecore/core/events/ShutdownEvent.java index 8defcce..f0b9cea 100644 --- a/src/mightypork/gamecore/core/events/ShutdownEvent.java +++ b/src/mightypork/gamecore/core/events/ShutdownEvent.java @@ -18,10 +18,11 @@ import mightypork.utils.logging.Log; */ public class ShutdownEvent extends BusEvent { - private Runnable shutdownTask; + private final Runnable shutdownTask; - public ShutdownEvent(Runnable doShutdown) { + public ShutdownEvent(Runnable doShutdown) + { this.shutdownTask = doShutdown; } diff --git a/src/mightypork/gamecore/core/init/InitTaskDisplay.java b/src/mightypork/gamecore/core/init/InitTaskDisplay.java index 20cf522..aefdf1b 100644 --- a/src/mightypork/gamecore/core/init/InitTaskDisplay.java +++ b/src/mightypork/gamecore/core/init/InitTaskDisplay.java @@ -77,7 +77,7 @@ public class InitTaskDisplay extends InitTask { @Override public void run() { - GraphicsModule gfx = app.getBackend().getGraphics(); + final GraphicsModule gfx = app.getBackend().getGraphics(); gfx.setSize(width, height); gfx.setResizable(resizable); diff --git a/src/mightypork/gamecore/core/init/InitTaskWorkdir.java b/src/mightypork/gamecore/core/init/InitTaskWorkdir.java index 6f986fa..46f1eaf 100644 --- a/src/mightypork/gamecore/core/init/InitTaskWorkdir.java +++ b/src/mightypork/gamecore/core/init/InitTaskWorkdir.java @@ -26,14 +26,15 @@ public class InitTaskWorkdir extends InitTask { private File workdirPath; private boolean doLock; private String lockFile = ".lock"; - private Map namedPaths = new HashMap<>(); + private final Map namedPaths = new HashMap<>(); /** * @param workdir path to the working directory * @param lock whether to lock the directory (single instance mode) */ - public InitTaskWorkdir(File workdir, boolean lock) { + public InitTaskWorkdir(File workdir, boolean lock) + { this.workdirPath = workdir; this.doLock = lock; } @@ -99,7 +100,7 @@ public class InitTaskWorkdir extends InitTask { } } - for (Entry e : namedPaths.entrySet()) { + for (final Entry e : namedPaths.entrySet()) { WorkDir.addPath(e.getKey(), e.getValue()); } } diff --git a/src/mightypork/gamecore/core/plugins/screenshot/InitTaskPluginScreenshot.java b/src/mightypork/gamecore/core/plugins/screenshot/InitTaskPluginScreenshot.java index 76363da..2abbf01 100644 --- a/src/mightypork/gamecore/core/plugins/screenshot/InitTaskPluginScreenshot.java +++ b/src/mightypork/gamecore/core/plugins/screenshot/InitTaskPluginScreenshot.java @@ -18,7 +18,8 @@ public class InitTaskPluginScreenshot extends InitTask { /** * Initialize to use the "screenshots" directory */ - public InitTaskPluginScreenshot() { + public InitTaskPluginScreenshot() + { this("screenshots"); } @@ -28,7 +29,8 @@ public class InitTaskPluginScreenshot extends InitTask { * * @param dir screenshot dir (relative to workdir) */ - public InitTaskPluginScreenshot(String dir) { + public InitTaskPluginScreenshot(String dir) + { this.screenshotDir = dir; } diff --git a/src/mightypork/gamecore/core/plugins/screenshot/ScreenshotPlugin.java b/src/mightypork/gamecore/core/plugins/screenshot/ScreenshotPlugin.java index fb4307f..4dd08b2 100644 --- a/src/mightypork/gamecore/core/plugins/screenshot/ScreenshotPlugin.java +++ b/src/mightypork/gamecore/core/plugins/screenshot/ScreenshotPlugin.java @@ -26,7 +26,7 @@ public class ScreenshotPlugin extends AppPlugin { @Override public void run() { - Runnable tts = new TaskTakeScreenshot(); + final Runnable tts = new TaskTakeScreenshot(); Support.runAsThread(tts); } })); diff --git a/src/mightypork/gamecore/core/plugins/screenshot/TaskTakeScreenshot.java b/src/mightypork/gamecore/core/plugins/screenshot/TaskTakeScreenshot.java index d1e095c..9ffda5f 100644 --- a/src/mightypork/gamecore/core/plugins/screenshot/TaskTakeScreenshot.java +++ b/src/mightypork/gamecore/core/plugins/screenshot/TaskTakeScreenshot.java @@ -26,7 +26,8 @@ public class TaskTakeScreenshot implements Runnable { /** * Take screenshot. Must be called in render thread. */ - public TaskTakeScreenshot() { + public TaskTakeScreenshot() + { scr = App.gfx().takeScreenshot(); } diff --git a/src/mightypork/gamecore/graphics/fonts/DeferredFont.java b/src/mightypork/gamecore/graphics/fonts/DeferredFont.java index 659ec50..9136bfc 100644 --- a/src/mightypork/gamecore/graphics/fonts/DeferredFont.java +++ b/src/mightypork/gamecore/graphics/fonts/DeferredFont.java @@ -25,7 +25,8 @@ public abstract class DeferredFont extends BaseDeferredResource implements IFont * @param style style index as in awt Font. Not using constants to be * independent on awt. */ - private FontStyle(int style) { + private FontStyle(int style) + { this.numval = style; } } @@ -39,7 +40,8 @@ public abstract class DeferredFont extends BaseDeferredResource implements IFont protected double discardBottom = 0; - public DeferredFont(String resource) { + public DeferredFont(String resource) + { super(resource); } diff --git a/src/mightypork/gamecore/graphics/fonts/FontRenderer.java b/src/mightypork/gamecore/graphics/fonts/FontRenderer.java index 4e3886b..e2d421b 100644 --- a/src/mightypork/gamecore/graphics/fonts/FontRenderer.java +++ b/src/mightypork/gamecore/graphics/fonts/FontRenderer.java @@ -24,7 +24,8 @@ public class FontRenderer { /** * @param font used font */ - public FontRenderer(IFont font) { + public FontRenderer(IFont font) + { this(font, RGB.WHITE); } @@ -33,7 +34,8 @@ public class FontRenderer { * @param font used font * @param color drawing color */ - public FontRenderer(IFont font, Color color) { + public FontRenderer(IFont font, Color color) + { this.font = font; this.color = color; } diff --git a/src/mightypork/gamecore/graphics/textures/DeferredTexture.java b/src/mightypork/gamecore/graphics/textures/DeferredTexture.java index 27bd0a7..5512efe 100644 --- a/src/mightypork/gamecore/graphics/textures/DeferredTexture.java +++ b/src/mightypork/gamecore/graphics/textures/DeferredTexture.java @@ -23,7 +23,8 @@ public abstract class DeferredTexture extends BaseDeferredResource implements IT /** * @param resourcePath resource path */ - public DeferredTexture(String resourcePath) { + public DeferredTexture(String resourcePath) + { super(resourcePath); } diff --git a/src/mightypork/gamecore/graphics/textures/QuadGrid.java b/src/mightypork/gamecore/graphics/textures/QuadGrid.java index e63eeec..4b69de1 100644 --- a/src/mightypork/gamecore/graphics/textures/QuadGrid.java +++ b/src/mightypork/gamecore/graphics/textures/QuadGrid.java @@ -18,7 +18,8 @@ public class QuadGrid { private final double tileH; - public QuadGrid(ITexture tx, int tilesX, int tilesY) { + public QuadGrid(ITexture tx, int tilesX, int tilesY) + { this.tx = tx; this.txWidth = tilesX; this.txHeight = tilesY; diff --git a/src/mightypork/gamecore/graphics/textures/TxQuad.java b/src/mightypork/gamecore/graphics/textures/TxQuad.java index bc3efd7..a2ac9ba 100644 --- a/src/mightypork/gamecore/graphics/textures/TxQuad.java +++ b/src/mightypork/gamecore/graphics/textures/TxQuad.java @@ -65,7 +65,8 @@ public class TxQuad { * @param x2 right bottom X (0-1) * @param y2 right bottom Y (0-1) */ - public TxQuad(ITexture tx, double x1, double y1, double x2, double y2) { + public TxQuad(ITexture tx, double x1, double y1, double x2, double y2) + { this(tx, Rect.make(x1, y1, x2, y2)); } @@ -74,7 +75,8 @@ public class TxQuad { * @param tx Texture * @param uvs Rect of texture UVs (0-1); will be frozen. */ - public TxQuad(ITexture tx, Rect uvs) { + public TxQuad(ITexture tx, Rect uvs) + { this.tx = tx; this.uvs = uvs.freeze(); } @@ -85,7 +87,8 @@ public class TxQuad { * * @param txQuad a copied quad */ - public TxQuad(TxQuad txQuad) { + public TxQuad(TxQuad txQuad) + { this.tx = txQuad.tx; this.uvs = txQuad.uvs; this.flipX = txQuad.flipX; diff --git a/src/mightypork/gamecore/graphics/textures/TxSheet.java b/src/mightypork/gamecore/graphics/textures/TxSheet.java index b29e873..d1be58e 100644 --- a/src/mightypork/gamecore/graphics/textures/TxSheet.java +++ b/src/mightypork/gamecore/graphics/textures/TxSheet.java @@ -22,7 +22,8 @@ public class TxSheet { private final int count; - public TxSheet(TxQuad tx, int width, int height) { + public TxSheet(TxQuad tx, int width, int height) + { this.original = tx; this.width = width; this.count = width * height; diff --git a/src/mightypork/gamecore/gui/components/BaseComponent.java b/src/mightypork/gamecore/gui/components/BaseComponent.java index be01481..81363c3 100644 --- a/src/mightypork/gamecore/gui/components/BaseComponent.java +++ b/src/mightypork/gamecore/gui/components/BaseComponent.java @@ -33,7 +33,8 @@ public abstract class BaseComponent extends AbstractRectCache implements Compone private Num alphaMul = Num.ONE; - public BaseComponent() { + public BaseComponent() + { enableCaching(false); } diff --git a/src/mightypork/gamecore/gui/components/LayoutComponent.java b/src/mightypork/gamecore/gui/components/LayoutComponent.java index 22aeef7..e90ab1d 100644 --- a/src/mightypork/gamecore/gui/components/LayoutComponent.java +++ b/src/mightypork/gamecore/gui/components/LayoutComponent.java @@ -15,14 +15,16 @@ public abstract class LayoutComponent extends BaseComponent implements ClientHub final LinkedList components = new LinkedList<>(); - public LayoutComponent(RectBound context) { + public LayoutComponent(RectBound context) + { this.clientList = new DelegatingList(); setRect(context); enableCaching(true); // layout is typically updated only when screen resizes. } - public LayoutComponent() { + public LayoutComponent() + { this(null); } diff --git a/src/mightypork/gamecore/gui/components/LinearComponent.java b/src/mightypork/gamecore/gui/components/LinearComponent.java index 665d545..893149c 100644 --- a/src/mightypork/gamecore/gui/components/LinearComponent.java +++ b/src/mightypork/gamecore/gui/components/LinearComponent.java @@ -52,7 +52,8 @@ public abstract class LinearComponent extends BaseComponent implements DynamicWi private Num height; - public LinearComponent() { + public LinearComponent() + { super.setRect(rect); } diff --git a/src/mightypork/gamecore/gui/components/input/ClickableWrapper.java b/src/mightypork/gamecore/gui/components/input/ClickableWrapper.java index ac6b8aa..45dc6b7 100644 --- a/src/mightypork/gamecore/gui/components/input/ClickableWrapper.java +++ b/src/mightypork/gamecore/gui/components/input/ClickableWrapper.java @@ -14,7 +14,8 @@ public class ClickableWrapper extends ClickableComponent implements DelegatingCl private final ClientList list; - public ClickableWrapper(Component wrapped) { + public ClickableWrapper(Component wrapped) + { this.wrapped = wrapped; wrapped.setRect(this); diff --git a/src/mightypork/gamecore/gui/components/input/TextButton.java b/src/mightypork/gamecore/gui/components/input/TextButton.java index 725c5bf..d630308 100644 --- a/src/mightypork/gamecore/gui/components/input/TextButton.java +++ b/src/mightypork/gamecore/gui/components/input/TextButton.java @@ -32,7 +32,8 @@ public class TextButton extends ClickableComponent implements DynamicWidthCompon private boolean hoverMove = true; - public TextButton(IFont font, String text, Color color) { + public TextButton(IFont font, String text, Color color) + { this.color = color; this.textPainter = new TextPainter(font, AlignX.CENTER, this.color, text); diff --git a/src/mightypork/gamecore/gui/components/layout/ColumnLayout.java b/src/mightypork/gamecore/gui/components/layout/ColumnLayout.java index 57e8849..9b3f317 100644 --- a/src/mightypork/gamecore/gui/components/layout/ColumnLayout.java +++ b/src/mightypork/gamecore/gui/components/layout/ColumnLayout.java @@ -10,12 +10,14 @@ public class ColumnLayout extends GridLayout { private int col = 0; - public ColumnLayout(int rows) { + public ColumnLayout(int rows) + { this(null, rows); } - public ColumnLayout(RectBound context, int cols) { + public ColumnLayout(RectBound context, int cols) + { super(context, 1, cols); } diff --git a/src/mightypork/gamecore/gui/components/layout/ConstraintLayout.java b/src/mightypork/gamecore/gui/components/layout/ConstraintLayout.java index b12c15b..6f4cc09 100644 --- a/src/mightypork/gamecore/gui/components/layout/ConstraintLayout.java +++ b/src/mightypork/gamecore/gui/components/layout/ConstraintLayout.java @@ -13,11 +13,13 @@ import mightypork.utils.math.constraints.rect.RectBound; */ public class ConstraintLayout extends LayoutComponent { - public ConstraintLayout() { + public ConstraintLayout() + { } - public ConstraintLayout(RectBound context) { + public ConstraintLayout(RectBound context) + { super(context); } diff --git a/src/mightypork/gamecore/gui/components/layout/FlowColumnLayout.java b/src/mightypork/gamecore/gui/components/layout/FlowColumnLayout.java index 2162170..bd6a315 100644 --- a/src/mightypork/gamecore/gui/components/layout/FlowColumnLayout.java +++ b/src/mightypork/gamecore/gui/components/layout/FlowColumnLayout.java @@ -26,7 +26,8 @@ public class FlowColumnLayout extends LayoutComponent { * @param elementWidth width of all elements * @param align component align. Legal values are LEFT and RIGHT. */ - public FlowColumnLayout(RectBound context, Num elementWidth, AlignX align) { + public FlowColumnLayout(RectBound context, Num elementWidth, AlignX align) + { super(context); this.elementWidth = elementWidth; this.align = align; @@ -44,7 +45,8 @@ public class FlowColumnLayout extends LayoutComponent { * @param elementWidth width of all elements * @param align component align. Legal values are LEFT and RIGHT. */ - public FlowColumnLayout(Num elementWidth, AlignX align) { + public FlowColumnLayout(Num elementWidth, AlignX align) + { this(null, elementWidth, align); } diff --git a/src/mightypork/gamecore/gui/components/layout/FlowRowLayout.java b/src/mightypork/gamecore/gui/components/layout/FlowRowLayout.java index 580ca69..aa3b119 100644 --- a/src/mightypork/gamecore/gui/components/layout/FlowRowLayout.java +++ b/src/mightypork/gamecore/gui/components/layout/FlowRowLayout.java @@ -26,7 +26,8 @@ public class FlowRowLayout extends LayoutComponent { * @param elementHeight height of all elements * @param align component align. Legal values are TOP and BOTTOM. */ - public FlowRowLayout(RectBound context, Num elementHeight, AlignY align) { + public FlowRowLayout(RectBound context, Num elementHeight, AlignY align) + { super(context); this.elementHeight = elementHeight; this.align = align; @@ -44,7 +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(Num elementHeight, AlignY align) { + public FlowRowLayout(Num elementHeight, AlignY align) + { this(null, elementHeight, align); } diff --git a/src/mightypork/gamecore/gui/components/layout/GridLayout.java b/src/mightypork/gamecore/gui/components/layout/GridLayout.java index 74cdc12..72e39b0 100644 --- a/src/mightypork/gamecore/gui/components/layout/GridLayout.java +++ b/src/mightypork/gamecore/gui/components/layout/GridLayout.java @@ -22,7 +22,8 @@ public class GridLayout extends LayoutComponent { * @param rows number of rows * @param cols number of columns */ - public GridLayout(RectBound context, int rows, int cols) { + public GridLayout(RectBound context, int rows, int cols) + { super(context); this.tiler = tiles(cols, rows); } @@ -35,7 +36,8 @@ public class GridLayout extends LayoutComponent { * @param rows number of rows * @param cols number of columns */ - public GridLayout(int rows, int cols) { + public GridLayout(int rows, int cols) + { this(null, rows, cols); } diff --git a/src/mightypork/gamecore/gui/components/layout/RowLayout.java b/src/mightypork/gamecore/gui/components/layout/RowLayout.java index 400c06f..aed15d1 100644 --- a/src/mightypork/gamecore/gui/components/layout/RowLayout.java +++ b/src/mightypork/gamecore/gui/components/layout/RowLayout.java @@ -10,12 +10,14 @@ public class RowLayout extends GridLayout { private int row = 0; - public RowLayout(int rows) { + public RowLayout(int rows) + { this(null, rows); } - public RowLayout(RectBound context, int rows) { + public RowLayout(RectBound context, int rows) + { super(context, rows, 1); } diff --git a/src/mightypork/gamecore/gui/components/layout/linear/AbstractLinearWrapper.java b/src/mightypork/gamecore/gui/components/layout/linear/AbstractLinearWrapper.java index f7ef0ed..d2142b5 100644 --- a/src/mightypork/gamecore/gui/components/layout/linear/AbstractLinearWrapper.java +++ b/src/mightypork/gamecore/gui/components/layout/linear/AbstractLinearWrapper.java @@ -23,7 +23,8 @@ public abstract class AbstractLinearWrapper extends LinearComponent implements D /** * @param wrapped wrapped component. Can be null. */ - public AbstractLinearWrapper(Component wrapped) { + public AbstractLinearWrapper(Component wrapped) + { this.wrapped = wrapped; if (wrapped != null) { if (wrapped instanceof LinearComponent) { diff --git a/src/mightypork/gamecore/gui/components/layout/linear/LinearGap.java b/src/mightypork/gamecore/gui/components/layout/linear/LinearGap.java index a5bf526..d5f6d25 100644 --- a/src/mightypork/gamecore/gui/components/layout/linear/LinearGap.java +++ b/src/mightypork/gamecore/gui/components/layout/linear/LinearGap.java @@ -12,12 +12,14 @@ import mightypork.utils.math.constraints.num.Num; */ public class LinearGap extends LinearRectangle { - public LinearGap(Num width) { + public LinearGap(Num width) + { super(new NullComponent(), width); } - public LinearGap(double heightPercent) { + public LinearGap(double heightPercent) + { this(Num.ZERO); setWidth(height().perc(heightPercent)); } diff --git a/src/mightypork/gamecore/gui/components/layout/linear/LinearLayout.java b/src/mightypork/gamecore/gui/components/layout/linear/LinearLayout.java index d97adb6..8a3502d 100644 --- a/src/mightypork/gamecore/gui/components/layout/linear/LinearLayout.java +++ b/src/mightypork/gamecore/gui/components/layout/linear/LinearLayout.java @@ -21,12 +21,14 @@ import mightypork.utils.math.constraints.vect.proxy.VectAdapter; */ public class LinearLayout extends LayoutComponent { - public LinearLayout(AlignX align) { + public LinearLayout(AlignX align) + { this.align = align; } - public LinearLayout(RectBound context, AlignX align) { + public LinearLayout(RectBound context, AlignX align) + { super(context); this.align = align; } diff --git a/src/mightypork/gamecore/gui/components/layout/linear/LinearRectangle.java b/src/mightypork/gamecore/gui/components/layout/linear/LinearRectangle.java index 9fa3fe8..78e3f9c 100644 --- a/src/mightypork/gamecore/gui/components/layout/linear/LinearRectangle.java +++ b/src/mightypork/gamecore/gui/components/layout/linear/LinearRectangle.java @@ -10,7 +10,8 @@ public class LinearRectangle extends AbstractLinearWrapper { private Num width; - public LinearRectangle(Component wrapped, Num width) { + public LinearRectangle(Component wrapped, Num width) + { super(wrapped); this.width = width; } diff --git a/src/mightypork/gamecore/gui/components/layout/linear/LinearSquare.java b/src/mightypork/gamecore/gui/components/layout/linear/LinearSquare.java index bb3a813..a3c37ee 100644 --- a/src/mightypork/gamecore/gui/components/layout/linear/LinearSquare.java +++ b/src/mightypork/gamecore/gui/components/layout/linear/LinearSquare.java @@ -6,7 +6,8 @@ import mightypork.gamecore.gui.components.Component; public class LinearSquare extends AbstractLinearWrapper { - public LinearSquare(Component wrapped) { + public LinearSquare(Component wrapped) + { super(wrapped); } diff --git a/src/mightypork/gamecore/gui/components/layout/linear/LinearWrapper.java b/src/mightypork/gamecore/gui/components/layout/linear/LinearWrapper.java index 0acd7d8..2fe8896 100644 --- a/src/mightypork/gamecore/gui/components/layout/linear/LinearWrapper.java +++ b/src/mightypork/gamecore/gui/components/layout/linear/LinearWrapper.java @@ -6,7 +6,8 @@ import mightypork.gamecore.gui.components.DynamicWidthComponent; public class LinearWrapper extends AbstractLinearWrapper { - public LinearWrapper(DynamicWidthComponent wrapped) { + public LinearWrapper(DynamicWidthComponent wrapped) + { super(wrapped); } diff --git a/src/mightypork/gamecore/gui/components/painters/ImagePainter.java b/src/mightypork/gamecore/gui/components/painters/ImagePainter.java index f51b639..70ad825 100644 --- a/src/mightypork/gamecore/gui/components/painters/ImagePainter.java +++ b/src/mightypork/gamecore/gui/components/painters/ImagePainter.java @@ -20,7 +20,8 @@ public class ImagePainter extends BaseComponent implements DynamicWidthComponent /** * @param txQuad drawn image */ - public ImagePainter(TxQuad txQuad) { + public ImagePainter(TxQuad txQuad) + { this.txQuad = txQuad; } diff --git a/src/mightypork/gamecore/gui/components/painters/QuadPainter.java b/src/mightypork/gamecore/gui/components/painters/QuadPainter.java index 57b9d13..7294668 100644 --- a/src/mightypork/gamecore/gui/components/painters/QuadPainter.java +++ b/src/mightypork/gamecore/gui/components/painters/QuadPainter.java @@ -36,7 +36,8 @@ public class QuadPainter extends BaseComponent { * * @param color */ - public QuadPainter(Color color) { + public QuadPainter(Color color) + { this.grad = new Grad(color, color, color, color); } @@ -49,7 +50,8 @@ public class QuadPainter extends BaseComponent { * @param leftBottom * @param rightBottom */ - public QuadPainter(Color leftTop, Color rightTop, Color leftBottom, Color rightBottom) { + public QuadPainter(Color leftTop, Color rightTop, Color leftBottom, Color rightBottom) + { this.grad = new Grad(leftTop, rightTop, rightBottom, leftBottom); } diff --git a/src/mightypork/gamecore/gui/components/painters/TextPainter.java b/src/mightypork/gamecore/gui/components/painters/TextPainter.java index 59b5c65..3c8d18f 100644 --- a/src/mightypork/gamecore/gui/components/painters/TextPainter.java +++ b/src/mightypork/gamecore/gui/components/painters/TextPainter.java @@ -39,32 +39,38 @@ public class TextPainter extends BaseComponent implements DynamicWidthComponent /** * @param font font to use */ - public TextPainter(IFont font) { + public TextPainter(IFont font) + { this(font, AlignX.LEFT, RGB.WHITE); } - public TextPainter(IFont font, Color color, String text) { + public TextPainter(IFont font, Color color, String text) + { this(font, AlignX.LEFT, color, new StringWrapper(text)); } - public TextPainter(IFont font, Color color, StringProvider text) { + public TextPainter(IFont font, Color color, StringProvider text) + { this(font, AlignX.LEFT, color, text); } - public TextPainter(IFont font, Color color) { + public TextPainter(IFont font, Color color) + { this(font, AlignX.LEFT, color, (StringProvider) null); } - public TextPainter(IFont font, AlignX align, Color color, String text) { + public TextPainter(IFont font, AlignX align, Color color, String text) + { this(font, align, color, new StringWrapper(text)); } - public TextPainter(IFont font, AlignX align, Color color, StringProvider text) { + public TextPainter(IFont font, AlignX align, Color color, StringProvider text) + { this.font = new FontRenderer(font); this.color = color; this.align = align; @@ -72,7 +78,8 @@ public class TextPainter extends BaseComponent implements DynamicWidthComponent } - public TextPainter(IFont font, AlignX align, Color color) { + public TextPainter(IFont font, AlignX align, Color color) + { this(font, align, color, (StringProvider) null); } diff --git a/src/mightypork/gamecore/gui/events/LayoutChangeEvent.java b/src/mightypork/gamecore/gui/events/LayoutChangeEvent.java index 0a9e378..99e66ec 100644 --- a/src/mightypork/gamecore/gui/events/LayoutChangeEvent.java +++ b/src/mightypork/gamecore/gui/events/LayoutChangeEvent.java @@ -18,7 +18,8 @@ import mightypork.utils.eventbus.events.flags.NonRejectableEvent; @NonRejectableEvent public class LayoutChangeEvent extends BusEvent { - public LayoutChangeEvent() { + public LayoutChangeEvent() + { } diff --git a/src/mightypork/gamecore/gui/events/ScreenRequest.java b/src/mightypork/gamecore/gui/events/ScreenRequest.java index c48fc8e..eaa7f4c 100644 --- a/src/mightypork/gamecore/gui/events/ScreenRequest.java +++ b/src/mightypork/gamecore/gui/events/ScreenRequest.java @@ -19,7 +19,8 @@ public class ScreenRequest extends BusEvent { /** * @param screenKey screen name */ - public ScreenRequest(String screenKey) { + public ScreenRequest(String screenKey) + { scrName = screenKey; } diff --git a/src/mightypork/gamecore/gui/events/ViewportChangeEvent.java b/src/mightypork/gamecore/gui/events/ViewportChangeEvent.java index b013926..b648cde 100644 --- a/src/mightypork/gamecore/gui/events/ViewportChangeEvent.java +++ b/src/mightypork/gamecore/gui/events/ViewportChangeEvent.java @@ -22,7 +22,8 @@ public class ViewportChangeEvent extends BusEvent { /** * @param size new screen size */ - public ViewportChangeEvent(Vect size) { + public ViewportChangeEvent(Vect size) + { this.screenSize = size; } diff --git a/src/mightypork/gamecore/gui/screens/LayeredScreen.java b/src/mightypork/gamecore/gui/screens/LayeredScreen.java index d9233a5..5e38ed2 100644 --- a/src/mightypork/gamecore/gui/screens/LayeredScreen.java +++ b/src/mightypork/gamecore/gui/screens/LayeredScreen.java @@ -46,7 +46,8 @@ public abstract class LayeredScreen extends Screen { private final LayersClient layersClient = new LayersClient(); - public LayeredScreen() { + public LayeredScreen() + { addChildClient(layersClient); } diff --git a/src/mightypork/gamecore/gui/screens/Overlay.java b/src/mightypork/gamecore/gui/screens/Overlay.java index c997972..a6fdc06 100644 --- a/src/mightypork/gamecore/gui/screens/Overlay.java +++ b/src/mightypork/gamecore/gui/screens/Overlay.java @@ -49,7 +49,8 @@ public abstract class Overlay extends BusNode implements Comparable, Up private Num alphaMul = Num.ONE; - public Overlay() { + public Overlay() + { this.mouse = App.input().getMousePos(); diff --git a/src/mightypork/gamecore/gui/screens/Screen.java b/src/mightypork/gamecore/gui/screens/Screen.java index 29d659a..f705302 100644 --- a/src/mightypork/gamecore/gui/screens/Screen.java +++ b/src/mightypork/gamecore/gui/screens/Screen.java @@ -28,7 +28,8 @@ public abstract class Screen extends BusNode implements Renderable, RectBound, K private volatile boolean needSetupViewport = false; - public Screen() { + public Screen() + { // disable events initially setListening(false); diff --git a/src/mightypork/gamecore/gui/screens/ScreenLayer.java b/src/mightypork/gamecore/gui/screens/ScreenLayer.java index 6a7c7af..09bab66 100644 --- a/src/mightypork/gamecore/gui/screens/ScreenLayer.java +++ b/src/mightypork/gamecore/gui/screens/ScreenLayer.java @@ -17,7 +17,8 @@ public abstract class ScreenLayer extends Overlay { /** * @param screen parent screen */ - public ScreenLayer(Screen screen) { + public ScreenLayer(Screen screen) + { this.screen = screen; } diff --git a/src/mightypork/gamecore/gui/screens/impl/CrossfadeOverlay.java b/src/mightypork/gamecore/gui/screens/impl/CrossfadeOverlay.java index b89179e..cf79a11 100644 --- a/src/mightypork/gamecore/gui/screens/impl/CrossfadeOverlay.java +++ b/src/mightypork/gamecore/gui/screens/impl/CrossfadeOverlay.java @@ -40,7 +40,8 @@ public class CrossfadeOverlay extends Overlay { }; - public CrossfadeOverlay() { + public CrossfadeOverlay() + { final QuadPainter qp = new QuadPainter(RGB.BLACK); // TODO allow custom colors qp.setRect(root); root.add(qp); diff --git a/src/mightypork/gamecore/gui/screens/impl/CrossfadeRequest.java b/src/mightypork/gamecore/gui/screens/impl/CrossfadeRequest.java index 29982e2..ec14232 100644 --- a/src/mightypork/gamecore/gui/screens/impl/CrossfadeRequest.java +++ b/src/mightypork/gamecore/gui/screens/impl/CrossfadeRequest.java @@ -19,7 +19,8 @@ public class CrossfadeRequest extends BusEvent { * @param screen screen key to show. Null = exit the app. * @param fromDark true to fade from full black (ie. start of the game) */ - public CrossfadeRequest(String screen, boolean fromDark) { + public CrossfadeRequest(String screen, boolean fromDark) + { super(); this.screen = screen; this.fromDark = fromDark; @@ -29,7 +30,8 @@ public class CrossfadeRequest extends BusEvent { /** * @param screen screen key to show. Null = exit the app. */ - public CrossfadeRequest(String screen) { + public CrossfadeRequest(String screen) + { super(); this.screen = screen; this.fromDark = false; diff --git a/src/mightypork/gamecore/gui/screens/impl/FadingLayer.java b/src/mightypork/gamecore/gui/screens/impl/FadingLayer.java index 82e87cc..b0b84d4 100644 --- a/src/mightypork/gamecore/gui/screens/impl/FadingLayer.java +++ b/src/mightypork/gamecore/gui/screens/impl/FadingLayer.java @@ -47,7 +47,8 @@ public abstract class FadingLayer extends ScreenLayer { * * @param screen */ - public FadingLayer(Screen screen) { + public FadingLayer(Screen screen) + { this(screen, new NumAnimated(1, Easing.QUADRATIC_OUT, 0.3)); } @@ -56,7 +57,8 @@ public abstract class FadingLayer extends ScreenLayer { * @param screen * @param easingAnim the animation num */ - public FadingLayer(Screen screen, NumAnimated easingAnim) { + public FadingLayer(Screen screen, NumAnimated easingAnim) + { super(screen); numa = easingAnim; diff --git a/src/mightypork/gamecore/gui/screens/impl/LayerColor.java b/src/mightypork/gamecore/gui/screens/impl/LayerColor.java index b1b67a2..b4f2451 100644 --- a/src/mightypork/gamecore/gui/screens/impl/LayerColor.java +++ b/src/mightypork/gamecore/gui/screens/impl/LayerColor.java @@ -12,7 +12,8 @@ public class LayerColor extends ScreenLayer { private final int zIndex; - public LayerColor(Screen screen, Color color, int zIndex) { + public LayerColor(Screen screen, Color color, int zIndex) + { super(screen); final QuadPainter qp = new QuadPainter(color); diff --git a/src/mightypork/gamecore/input/Key.java b/src/mightypork/gamecore/input/Key.java index 66b6695..b9f7dff 100644 --- a/src/mightypork/gamecore/input/Key.java +++ b/src/mightypork/gamecore/input/Key.java @@ -28,14 +28,15 @@ public class Key { * @param name key name (primary alias) * @param aliases extra aliases (used for matching) */ - public Key(String name, String... aliases) { + public Key(String name, String... aliases) + { // assign name and aliases, converting both to uppercase this.name = name; this.aliases.add(prepareForMatch(name)); - for (String al : aliases) { + for (final String al : aliases) { this.aliases.add(prepareForMatch(al)); } } diff --git a/src/mightypork/gamecore/input/KeyBinding.java b/src/mightypork/gamecore/input/KeyBinding.java index 0e5baec..2ae432f 100644 --- a/src/mightypork/gamecore/input/KeyBinding.java +++ b/src/mightypork/gamecore/input/KeyBinding.java @@ -23,7 +23,8 @@ public class KeyBinding implements KeyEventHandler { * @param stroke trigger keystroke * @param handler action */ - public KeyBinding(KeyStroke stroke, Trigger edge, Runnable handler) { + public KeyBinding(KeyStroke stroke, Trigger edge, Runnable handler) + { this.keystroke = stroke; this.handler = handler; this.edge = edge; diff --git a/src/mightypork/gamecore/input/KeyStroke.java b/src/mightypork/gamecore/input/KeyStroke.java index 0f0da13..26357e9 100644 --- a/src/mightypork/gamecore/input/KeyStroke.java +++ b/src/mightypork/gamecore/input/KeyStroke.java @@ -21,7 +21,8 @@ public class KeyStroke { * @param key key code * @param modmask modifiers */ - public KeyStroke(Key key, int modmask) { + public KeyStroke(Key key, int modmask) + { setTo(key, modmask); } @@ -46,7 +47,8 @@ public class KeyStroke { * * @param key key */ - public KeyStroke(Key key) { + public KeyStroke(Key key) + { this(key, Keys.MOD_NONE); } diff --git a/src/mightypork/gamecore/input/Keys.java b/src/mightypork/gamecore/input/Keys.java index 957c22f..f972c5f 100644 --- a/src/mightypork/gamecore/input/Keys.java +++ b/src/mightypork/gamecore/input/Keys.java @@ -163,16 +163,16 @@ public class Keys { NONE.setCode(0); // Use reflection to find keys - Field[] fields = Keys.class.getFields(); + final Field[] fields = Keys.class.getFields(); try { - for (Field field : fields) { - int modifiers = field.getModifiers(); + for (final Field field : fields) { + final int modifiers = field.getModifiers(); if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers) && Modifier.isFinal(modifiers) && field.getType().equals(Key.class)) { keyList.add((Key) field.get(null)); } } - } catch (Exception e) {} + } catch (final Exception e) {} } @@ -185,7 +185,7 @@ public class Keys { lookupByCode.put(NONE.getCode(), NONE); - for (Key k : keyList) { + for (final Key k : keyList) { if (!k.isDefined()) continue; if (!lookupByCode.containsKey(k.getCode())) { lookupByCode.put(k.getCode(), k); @@ -207,7 +207,7 @@ public class Keys { */ public static Key stringToKey(String keyStr) { - for (Key k : keyList) { + for (final Key k : keyList) { if (k.matches(keyStr)) return k; } @@ -350,7 +350,7 @@ public class Keys { { int mods = 0; - InputModule inp = App.input(); + final InputModule inp = App.input(); if (inp.isKeyDown(Keys.ALT_LEFT) || inp.isKeyDown(Keys.ALT_RIGHT)) { mods |= Keys.MOD_ALT; diff --git a/src/mightypork/gamecore/input/events/KeyEvent.java b/src/mightypork/gamecore/input/events/KeyEvent.java index 4c97912..0010477 100644 --- a/src/mightypork/gamecore/input/events/KeyEvent.java +++ b/src/mightypork/gamecore/input/events/KeyEvent.java @@ -1,14 +1,13 @@ package mightypork.gamecore.input.events; +import mightypork.gamecore.input.Keys; import mightypork.utils.eventbus.BusEvent; import mightypork.utils.eventbus.events.flags.NotLoggedEvent; -import org.lwjgl.input.Keyboard; - /** - * A keyboard event + * A keyboard event FIXME Should use Key class, not keycode. * * @author Ondřej Hruška (MightyPork) */ @@ -25,7 +24,8 @@ public class KeyEvent extends BusEvent { * @param c typed char (can be zero char) * @param down true = pressed, false = released. */ - public KeyEvent(int key, char c, boolean down) { + public KeyEvent(int key, char c, boolean down) + { this.key = key; this.c = c; this.down = down; @@ -33,7 +33,7 @@ public class KeyEvent extends BusEvent { /** - * @return key code (see {@link org.lwjgl.input.Keyboard}) + * @return key code */ public int getKey() { @@ -78,7 +78,8 @@ public class KeyEvent extends BusEvent { @Override public String toString() { - return Keyboard.getKeyName(key) + ":" + (down ? "DOWN" : "UP"); + // FIXME + return Keys.codeToKey(key).getName() + ":" + (down ? "DOWN" : "UP"); } } diff --git a/src/mightypork/gamecore/input/events/MouseButtonEvent.java b/src/mightypork/gamecore/input/events/MouseButtonEvent.java index 3696afe..e116804 100644 --- a/src/mightypork/gamecore/input/events/MouseButtonEvent.java +++ b/src/mightypork/gamecore/input/events/MouseButtonEvent.java @@ -34,7 +34,8 @@ public class MouseButtonEvent extends BusEvent { * @param down button pressed * @param wheeld wheel change */ - public MouseButtonEvent(Vect pos, int button, boolean down, int wheeld) { + public MouseButtonEvent(Vect pos, int button, boolean down, int wheeld) + { this.button = button; this.down = down; this.pos = pos.freeze(); diff --git a/src/mightypork/gamecore/input/events/MouseMotionEvent.java b/src/mightypork/gamecore/input/events/MouseMotionEvent.java index 5131644..06fda84 100644 --- a/src/mightypork/gamecore/input/events/MouseMotionEvent.java +++ b/src/mightypork/gamecore/input/events/MouseMotionEvent.java @@ -23,7 +23,8 @@ public class MouseMotionEvent extends BusEvent { * @param pos end pos * @param move move vector */ - public MouseMotionEvent(Vect pos, Vect move) { + public MouseMotionEvent(Vect pos, Vect move) + { this.move = move.freeze(); this.pos = pos.freeze(); } diff --git a/src/mightypork/gamecore/resources/BaseDeferredResource.java b/src/mightypork/gamecore/resources/BaseDeferredResource.java index e0ac880..716510c 100644 --- a/src/mightypork/gamecore/resources/BaseDeferredResource.java +++ b/src/mightypork/gamecore/resources/BaseDeferredResource.java @@ -27,7 +27,8 @@ public abstract class BaseDeferredResource implements DeferredResource, Destroya * @param resource resource path / name; this string is later used in * loadResource() */ - public BaseDeferredResource(String resource) { + public BaseDeferredResource(String resource) + { this.resource = resource; } diff --git a/src/mightypork/gamecore/resources/loading/AsyncResourceLoader.java b/src/mightypork/gamecore/resources/loading/AsyncResourceLoader.java index efd5410..8dd66e3 100644 --- a/src/mightypork/gamecore/resources/loading/AsyncResourceLoader.java +++ b/src/mightypork/gamecore/resources/loading/AsyncResourceLoader.java @@ -43,7 +43,8 @@ public class AsyncResourceLoader extends Thread implements ResourceLoader, Destr } - public AsyncResourceLoader() { + public AsyncResourceLoader() + { super("Deferred loader"); } diff --git a/src/mightypork/gamecore/resources/loading/MustLoadInRenderingContext.java b/src/mightypork/gamecore/resources/loading/MustLoadInRenderingContext.java index 64497a7..057f12b 100644 --- a/src/mightypork/gamecore/resources/loading/MustLoadInRenderingContext.java +++ b/src/mightypork/gamecore/resources/loading/MustLoadInRenderingContext.java @@ -1,7 +1,12 @@ package mightypork.gamecore.resources.loading; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** diff --git a/src/mightypork/gamecore/resources/loading/ResourceLoadRequest.java b/src/mightypork/gamecore/resources/loading/ResourceLoadRequest.java index a940adc..4dfe638 100644 --- a/src/mightypork/gamecore/resources/loading/ResourceLoadRequest.java +++ b/src/mightypork/gamecore/resources/loading/ResourceLoadRequest.java @@ -20,7 +20,8 @@ public class ResourceLoadRequest extends BusEvent { /** * @param resource resource to load */ - public ResourceLoadRequest(DeferredResource resource) { + public ResourceLoadRequest(DeferredResource resource) + { this.resource = resource; }