Fixed some issues & cleanup

master
Ondřej Hruška 11 years ago
parent e56148559c
commit 6208a0c2eb
  1. 4
      src/junk/BaseApp.java
  2. 3
      src/mightypork/gamecore/audio/DeferredAudio.java
  3. 3
      src/mightypork/gamecore/audio/JointVolume.java
  4. 3
      src/mightypork/gamecore/audio/Volume.java
  5. 3
      src/mightypork/gamecore/audio/players/BaseAudioPlayer.java
  6. 3
      src/mightypork/gamecore/audio/players/EffectPlayer.java
  7. 5
      src/mightypork/gamecore/audio/players/LoopPlayer.java
  8. 7
      src/mightypork/gamecore/core/App.java
  9. 16
      src/mightypork/gamecore/core/InitTask.java
  10. 7
      src/mightypork/gamecore/core/OptionalInitTask.java
  11. 16
      src/mightypork/gamecore/core/config/Config.java
  12. 3
      src/mightypork/gamecore/core/config/KeyStrokeProperty.java
  13. 6
      src/mightypork/gamecore/core/events/MainLoopRequest.java
  14. 5
      src/mightypork/gamecore/core/events/ShutdownEvent.java
  15. 2
      src/mightypork/gamecore/core/init/InitTaskDisplay.java
  16. 7
      src/mightypork/gamecore/core/init/InitTaskWorkdir.java
  17. 6
      src/mightypork/gamecore/core/plugins/screenshot/InitTaskPluginScreenshot.java
  18. 2
      src/mightypork/gamecore/core/plugins/screenshot/ScreenshotPlugin.java
  19. 3
      src/mightypork/gamecore/core/plugins/screenshot/TaskTakeScreenshot.java
  20. 6
      src/mightypork/gamecore/graphics/fonts/DeferredFont.java
  21. 6
      src/mightypork/gamecore/graphics/fonts/FontRenderer.java
  22. 3
      src/mightypork/gamecore/graphics/textures/DeferredTexture.java
  23. 3
      src/mightypork/gamecore/graphics/textures/QuadGrid.java
  24. 9
      src/mightypork/gamecore/graphics/textures/TxQuad.java
  25. 3
      src/mightypork/gamecore/graphics/textures/TxSheet.java
  26. 3
      src/mightypork/gamecore/gui/components/BaseComponent.java
  27. 6
      src/mightypork/gamecore/gui/components/LayoutComponent.java
  28. 3
      src/mightypork/gamecore/gui/components/LinearComponent.java
  29. 3
      src/mightypork/gamecore/gui/components/input/ClickableWrapper.java
  30. 3
      src/mightypork/gamecore/gui/components/input/TextButton.java
  31. 6
      src/mightypork/gamecore/gui/components/layout/ColumnLayout.java
  32. 6
      src/mightypork/gamecore/gui/components/layout/ConstraintLayout.java
  33. 6
      src/mightypork/gamecore/gui/components/layout/FlowColumnLayout.java
  34. 6
      src/mightypork/gamecore/gui/components/layout/FlowRowLayout.java
  35. 6
      src/mightypork/gamecore/gui/components/layout/GridLayout.java
  36. 6
      src/mightypork/gamecore/gui/components/layout/RowLayout.java
  37. 3
      src/mightypork/gamecore/gui/components/layout/linear/AbstractLinearWrapper.java
  38. 6
      src/mightypork/gamecore/gui/components/layout/linear/LinearGap.java
  39. 6
      src/mightypork/gamecore/gui/components/layout/linear/LinearLayout.java
  40. 3
      src/mightypork/gamecore/gui/components/layout/linear/LinearRectangle.java
  41. 3
      src/mightypork/gamecore/gui/components/layout/linear/LinearSquare.java
  42. 3
      src/mightypork/gamecore/gui/components/layout/linear/LinearWrapper.java
  43. 3
      src/mightypork/gamecore/gui/components/painters/ImagePainter.java
  44. 6
      src/mightypork/gamecore/gui/components/painters/QuadPainter.java
  45. 21
      src/mightypork/gamecore/gui/components/painters/TextPainter.java
  46. 3
      src/mightypork/gamecore/gui/events/LayoutChangeEvent.java
  47. 3
      src/mightypork/gamecore/gui/events/ScreenRequest.java
  48. 3
      src/mightypork/gamecore/gui/events/ViewportChangeEvent.java
  49. 3
      src/mightypork/gamecore/gui/screens/LayeredScreen.java
  50. 3
      src/mightypork/gamecore/gui/screens/Overlay.java
  51. 3
      src/mightypork/gamecore/gui/screens/Screen.java
  52. 3
      src/mightypork/gamecore/gui/screens/ScreenLayer.java
  53. 3
      src/mightypork/gamecore/gui/screens/impl/CrossfadeOverlay.java
  54. 6
      src/mightypork/gamecore/gui/screens/impl/CrossfadeRequest.java
  55. 6
      src/mightypork/gamecore/gui/screens/impl/FadingLayer.java
  56. 3
      src/mightypork/gamecore/gui/screens/impl/LayerColor.java
  57. 5
      src/mightypork/gamecore/input/Key.java
  58. 3
      src/mightypork/gamecore/input/KeyBinding.java
  59. 6
      src/mightypork/gamecore/input/KeyStroke.java
  60. 14
      src/mightypork/gamecore/input/Keys.java
  61. 13
      src/mightypork/gamecore/input/events/KeyEvent.java
  62. 3
      src/mightypork/gamecore/input/events/MouseButtonEvent.java
  63. 3
      src/mightypork/gamecore/input/events/MouseMotionEvent.java
  64. 3
      src/mightypork/gamecore/resources/BaseDeferredResource.java
  65. 3
      src/mightypork/gamecore/resources/loading/AsyncResourceLoader.java
  66. 7
      src/mightypork/gamecore/resources/loading/MustLoadInRenderingContext.java
  67. 3
      src/mightypork/gamecore/resources/loading/ResourceLoadRequest.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);
}

@ -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);
}

@ -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;
}

@ -15,7 +15,8 @@ public class Volume extends Mutable<Double> {
/**
* @param d initial value
*/
public Volume(Double d) {
public Volume(Double d)
{
super(d);
}

@ -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;

@ -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);
}

@ -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;

@ -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<InitTask> orderedInitializers = InitTask.inOrder(initializers);
final List<InitTask> 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();

@ -85,23 +85,23 @@ public abstract class InitTask {
*/
public static List<InitTask> inOrder(List<InitTask> tasks)
{
List<InitTask> remaining = new ArrayList<>(tasks);
final List<InitTask> remaining = new ArrayList<>(tasks);
List<InitTask> ordered = new ArrayList<>();
Set<String> loaded = new HashSet<>();
final List<InitTask> ordered = new ArrayList<>();
final Set<String> loaded = new HashSet<>();
// resolve task order
int addedThisIteration = 0;
do {
for (Iterator<InitTask> i = remaining.iterator(); i.hasNext();) {
InitTask task = i.next();
for (final Iterator<InitTask> 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()) {

@ -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;
/**

@ -23,9 +23,9 @@ public class Config {
protected static Map<String, Config> configs = new HashMap<>();
private Map<String, KeyStrokeProperty> strokes = new HashMap<>();
private final Map<String, KeyStrokeProperty> 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);
}

@ -17,7 +17,8 @@ import mightypork.utils.config.propmgr.Property;
*/
public class KeyStrokeProperty extends Property<KeyStroke> {
public KeyStrokeProperty(String key, KeyStroke defaultValue, String comment) {
public KeyStrokeProperty(String key, KeyStroke defaultValue, String comment)
{
super(key, defaultValue, comment);
}

@ -21,7 +21,8 @@ public class MainLoopRequest extends BusEvent<MainLoop> {
/**
* @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<MainLoop> {
* @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;
}

@ -18,10 +18,11 @@ import mightypork.utils.logging.Log;
*/
public class ShutdownEvent extends BusEvent<ShutdownListener> {
private Runnable shutdownTask;
private final Runnable shutdownTask;
public ShutdownEvent(Runnable doShutdown) {
public ShutdownEvent(Runnable doShutdown)
{
this.shutdownTask = doShutdown;
}

@ -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);

@ -26,14 +26,15 @@ public class InitTaskWorkdir extends InitTask {
private File workdirPath;
private boolean doLock;
private String lockFile = ".lock";
private Map<String, String> namedPaths = new HashMap<>();
private final Map<String, String> 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<String, String> e : namedPaths.entrySet()) {
for (final Entry<String, String> e : namedPaths.entrySet()) {
WorkDir.addPath(e.getKey(), e.getValue());
}
}

@ -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;
}

@ -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);
}
}));

@ -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();
}

@ -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);
}

@ -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;
}

@ -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);
}

@ -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;

@ -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;

@ -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;

@ -33,7 +33,8 @@ public abstract class BaseComponent extends AbstractRectCache implements Compone
private Num alphaMul = Num.ONE;
public BaseComponent() {
public BaseComponent()
{
enableCaching(false);
}

@ -15,14 +15,16 @@ public abstract class LayoutComponent extends BaseComponent implements ClientHub
final LinkedList<Component> 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);
}

@ -52,7 +52,8 @@ public abstract class LinearComponent extends BaseComponent implements DynamicWi
private Num height;
public LinearComponent() {
public LinearComponent()
{
super.setRect(rect);
}

@ -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);

@ -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);

@ -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);
}

@ -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);
}

@ -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);
}

@ -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);
}

@ -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);
}

@ -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);
}

@ -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) {

@ -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));
}

@ -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;
}

@ -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;
}

@ -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);
}

@ -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);
}

@ -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;
}

@ -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);
}

@ -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);
}

@ -18,7 +18,8 @@ import mightypork.utils.eventbus.events.flags.NonRejectableEvent;
@NonRejectableEvent
public class LayoutChangeEvent extends BusEvent<LayoutChangeListener> {
public LayoutChangeEvent() {
public LayoutChangeEvent()
{
}

@ -19,7 +19,8 @@ public class ScreenRequest extends BusEvent<ScreenRequestListener> {
/**
* @param screenKey screen name
*/
public ScreenRequest(String screenKey) {
public ScreenRequest(String screenKey)
{
scrName = screenKey;
}

@ -22,7 +22,8 @@ public class ViewportChangeEvent extends BusEvent<ViewportChangeListener> {
/**
* @param size new screen size
*/
public ViewportChangeEvent(Vect size) {
public ViewportChangeEvent(Vect size)
{
this.screenSize = size;
}

@ -46,7 +46,8 @@ public abstract class LayeredScreen extends Screen {
private final LayersClient layersClient = new LayersClient();
public LayeredScreen() {
public LayeredScreen()
{
addChildClient(layersClient);
}

@ -49,7 +49,8 @@ public abstract class Overlay extends BusNode implements Comparable<Overlay>, Up
private Num alphaMul = Num.ONE;
public Overlay() {
public Overlay()
{
this.mouse = App.input().getMousePos();

@ -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);

@ -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;
}

@ -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);

@ -19,7 +19,8 @@ public class CrossfadeRequest extends BusEvent<CrossfadeOverlay> {
* @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<CrossfadeOverlay> {
/**
* @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;

@ -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;

@ -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);

@ -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));
}
}

@ -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;

@ -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);
}

@ -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;

@ -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<KeyEventHandler> {
* @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<KeyEventHandler> {
/**
* @return key code (see {@link org.lwjgl.input.Keyboard})
* @return key code
*/
public int getKey()
{
@ -78,7 +78,8 @@ public class KeyEvent extends BusEvent<KeyEventHandler> {
@Override
public String toString()
{
return Keyboard.getKeyName(key) + ":" + (down ? "DOWN" : "UP");
// FIXME
return Keys.codeToKey(key).getName() + ":" + (down ? "DOWN" : "UP");
}
}

@ -34,7 +34,8 @@ public class MouseButtonEvent extends BusEvent<MouseButtonHandler> {
* @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();

@ -23,7 +23,8 @@ public class MouseMotionEvent extends BusEvent<MouseMotionHandler> {
* @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();
}

@ -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;
}

@ -43,7 +43,8 @@ public class AsyncResourceLoader extends Thread implements ResourceLoader, Destr
}
public AsyncResourceLoader() {
public AsyncResourceLoader()
{
super("Deferred loader");
}

@ -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;
/**

@ -20,7 +20,8 @@ public class ResourceLoadRequest extends BusEvent<ResourceLoader> {
/**
* @param resource resource to load
*/
public ResourceLoadRequest(DeferredResource resource) {
public ResourceLoadRequest(DeferredResource resource)
{
this.resource = resource;
}

Loading…
Cancel
Save