Attempt to separate framework from game impl.

v5stable
Ondřej Hruška 11 years ago
parent 8e8e15355e
commit 251475557f
  1. 17
      src/mightypork/gamecore/AppAccess.java
  2. 10
      src/mightypork/gamecore/AppAdapter.java
  3. 14
      src/mightypork/gamecore/BusAccess.java
  4. 66
      src/mightypork/gamecore/GameLoop.java
  5. 2
      src/mightypork/gamecore/SlickLogRedirector.java
  6. 48
      src/mightypork/gamecore/control/ChildClient.java
  7. 55
      src/mightypork/gamecore/control/Subsystem.java
  8. 2
      src/mightypork/gamecore/control/bus/BufferedHashSet.java
  9. 14
      src/mightypork/gamecore/control/bus/EventBus.java
  10. 10
      src/mightypork/gamecore/control/bus/EventChannel.java
  11. 2
      src/mightypork/gamecore/control/bus/clients/DelegatingClient.java
  12. 2
      src/mightypork/gamecore/control/bus/clients/ToggleableClient.java
  13. 7
      src/mightypork/gamecore/control/bus/events/DestroyEvent.java
  14. 8
      src/mightypork/gamecore/control/bus/events/Event.java
  15. 4
      src/mightypork/gamecore/control/bus/events/KeyboardEvent.java
  16. 5
      src/mightypork/gamecore/control/bus/events/MainLoopTaskRequest.java
  17. 16
      src/mightypork/gamecore/control/bus/events/MouseButtonEvent.java
  18. 5
      src/mightypork/gamecore/control/bus/events/MouseMotionEvent.java
  19. 7
      src/mightypork/gamecore/control/bus/events/ResourceLoadRequest.java
  20. 3
      src/mightypork/gamecore/control/bus/events/ScreenChangeEvent.java
  21. 5
      src/mightypork/gamecore/control/bus/events/ScreenRequestEvent.java
  22. 9
      src/mightypork/gamecore/control/bus/events/UpdateEvent.java
  23. 2
      src/mightypork/gamecore/control/bus/events/types/DelayedEvent.java
  24. 2
      src/mightypork/gamecore/control/bus/events/types/ImmediateEvent.java
  25. 2
      src/mightypork/gamecore/control/bus/events/types/SingleReceiverEvent.java
  26. 2
      src/mightypork/gamecore/control/bus/events/types/UnloggedEvent.java
  27. 2
      src/mightypork/gamecore/control/interf/Destroyable.java
  28. 2
      src/mightypork/gamecore/control/interf/Updateable.java
  29. 2
      src/mightypork/gamecore/control/timing/FpsMeter.java
  30. 2
      src/mightypork/gamecore/control/timing/Pauseable.java
  31. 2
      src/mightypork/gamecore/control/timing/TimerDelta.java
  32. 2
      src/mightypork/gamecore/control/timing/TimerFps.java
  33. 8
      src/mightypork/gamecore/gui/renderers/ColumnHolder.java
  34. 25
      src/mightypork/gamecore/gui/renderers/ElementHolder.java
  35. 6
      src/mightypork/gamecore/gui/renderers/ImageRenderer.java
  36. 8
      src/mightypork/gamecore/gui/renderers/PluggableRenderable.java
  37. 8
      src/mightypork/gamecore/gui/renderers/PluggableRenderer.java
  38. 8
      src/mightypork/gamecore/gui/renderers/RowHolder.java
  39. 6
      src/mightypork/gamecore/gui/renderers/TextRenderer.java
  40. 4
      src/mightypork/gamecore/gui/screens/LayeredScreen.java
  41. 24
      src/mightypork/gamecore/gui/screens/Screen.java
  42. 23
      src/mightypork/gamecore/gui/screens/ScreenLayer.java
  43. 10
      src/mightypork/gamecore/gui/screens/ScreenRegistry.java
  44. 37
      src/mightypork/gamecore/input/Action.java
  45. 7
      src/mightypork/gamecore/input/ActionTrigger.java
  46. 32
      src/mightypork/gamecore/input/InputSystem.java
  47. 2
      src/mightypork/gamecore/input/KeyBinder.java
  48. 4
      src/mightypork/gamecore/input/KeyBinding.java
  49. 4
      src/mightypork/gamecore/input/KeyBindingPool.java
  50. 2
      src/mightypork/gamecore/input/KeyStroke.java
  51. 2
      src/mightypork/gamecore/input/Keys.java
  52. 16
      src/mightypork/gamecore/loading/AsyncResourceLoader.java
  53. 4
      src/mightypork/gamecore/loading/BaseDeferredResource.java
  54. 2
      src/mightypork/gamecore/loading/DeferredResource.java
  55. 2
      src/mightypork/gamecore/loading/MustLoadInMainThread.java
  56. 2
      src/mightypork/gamecore/loading/NullResource.java
  57. 53
      src/mightypork/gamecore/render/DisplaySystem.java
  58. 4
      src/mightypork/gamecore/render/Render.java
  59. 2
      src/mightypork/gamecore/render/Renderable.java
  60. 6
      src/mightypork/gamecore/resources/fonts/DeferredFont.java
  61. 2
      src/mightypork/gamecore/resources/fonts/DeferredFontNative.java
  62. 8
      src/mightypork/gamecore/resources/fonts/FontBank.java
  63. 4
      src/mightypork/gamecore/resources/fonts/FontRenderer.java
  64. 2
      src/mightypork/gamecore/resources/fonts/GLFont.java
  65. 2
      src/mightypork/gamecore/resources/fonts/Glyphs.java
  66. 2
      src/mightypork/gamecore/resources/fonts/NullFont.java
  67. 4
      src/mightypork/gamecore/resources/fonts/SlickFont.java
  68. 4
      src/mightypork/gamecore/resources/sounds/DeferredAudio.java
  69. 2
      src/mightypork/gamecore/resources/sounds/JointVolume.java
  70. 4
      src/mightypork/gamecore/resources/sounds/NullAudio.java
  71. 10
      src/mightypork/gamecore/resources/sounds/SoundBank.java
  72. 14
      src/mightypork/gamecore/resources/sounds/SoundSystem.java
  73. 6
      src/mightypork/gamecore/resources/sounds/players/BaseAudioPlayer.java
  74. 4
      src/mightypork/gamecore/resources/sounds/players/EffectPlayer.java
  75. 8
      src/mightypork/gamecore/resources/sounds/players/LoopPlayer.java
  76. 8
      src/mightypork/gamecore/resources/textures/DeferredTexture.java
  77. 2
      src/mightypork/gamecore/resources/textures/FilteredTexture.java
  78. 12
      src/mightypork/gamecore/resources/textures/TextureBank.java
  79. 2
      src/mightypork/gamecore/resources/textures/TxQuad.java
  80. 35
      src/mightypork/rogue/App.java
  81. 69
      src/mightypork/rogue/MainLoop.java
  82. 25
      src/mightypork/rogue/Res.java
  83. 28
      src/mightypork/rogue/TaskTakeScreenshot.java
  84. 38
      src/mightypork/rogue/bus/Subsystem.java
  85. 6
      src/mightypork/rogue/events/ActionRequest.java
  86. 22
      src/mightypork/rogue/screens/test_bouncyboxes/BouncyBox.java
  87. 20
      src/mightypork/rogue/screens/test_bouncyboxes/LayerBouncyBoxes.java
  88. 12
      src/mightypork/rogue/screens/test_bouncyboxes/ScreenTestBouncy.java
  89. 24
      src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java
  90. 16
      src/mightypork/rogue/screens/test_cat_sound/ScreenTestCat.java
  91. 8
      src/mightypork/rogue/screens/test_font/ScreenTestFont.java
  92. 4
      src/mightypork/utils/math/animation/AnimDouble.java
  93. 120
      src/mightypork/utils/math/constraints/ConstraintFactory.java
  94. 4
      src/mightypork/utils/math/constraints/ContextAdapter.java
  95. 2
      src/mightypork/utils/math/constraints/NumberConstraint.java
  96. 4
      src/mightypork/utils/math/constraints/PluggableContext.java
  97. 18
      src/mightypork/utils/math/constraints/RectConstraint.java
  98. 10
      src/mightypork/utils/math/constraints/RectEvaluable.java
  99. 6
      src/mightypork/utils/math/coord/Coord.java
  100. 2
      src/mightypork/utils/math/coord/CoordAnimated.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,10 +1,9 @@
package mightypork.rogue; package mightypork.gamecore;
import mightypork.rogue.input.InputSystem; import mightypork.gamecore.input.InputSystem;
import mightypork.rogue.render.DisplaySystem; import mightypork.gamecore.render.DisplaySystem;
import mightypork.rogue.sounds.SoundSystem; import mightypork.gamecore.resources.sounds.SoundSystem;
import mightypork.utils.control.bus.EventBus;
/** /**
@ -12,7 +11,7 @@ import mightypork.utils.control.bus.EventBus;
* *
* @author MightyPork * @author MightyPork
*/ */
public interface AppAccess { public interface AppAccess extends BusAccess {
/** /**
* @return sound system * @return sound system
@ -32,12 +31,6 @@ public interface AppAccess {
abstract DisplaySystem disp(); abstract DisplaySystem disp();
/**
* @return event bus
*/
abstract EventBus bus();
/** /**
* Quit to OS<br> * Quit to OS<br>
* Destroy app & exit VM * Destroy app & exit VM

@ -1,10 +1,10 @@
package mightypork.rogue; package mightypork.gamecore;
import mightypork.rogue.input.InputSystem; import mightypork.gamecore.control.bus.EventBus;
import mightypork.rogue.render.DisplaySystem; import mightypork.gamecore.input.InputSystem;
import mightypork.rogue.sounds.SoundSystem; import mightypork.gamecore.render.DisplaySystem;
import mightypork.utils.control.bus.EventBus; import mightypork.gamecore.resources.sounds.SoundSystem;
/** /**

@ -0,0 +1,14 @@
package mightypork.gamecore;
import mightypork.gamecore.control.bus.EventBus;
public interface BusAccess {
/**
* @return event bus
*/
public abstract EventBus bus();
}

@ -0,0 +1,66 @@
package mightypork.gamecore;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import mightypork.gamecore.control.Subsystem;
import mightypork.gamecore.control.bus.events.MainLoopTaskRequest;
import mightypork.gamecore.control.bus.events.UpdateEvent;
import mightypork.gamecore.control.timing.TimerDelta;
public abstract class GameLoop extends Subsystem implements MainLoopTaskRequest.Listener {
private final Queue<Runnable> taskQueue = new ConcurrentLinkedQueue<Runnable>();
/** timer */
private TimerDelta timer;
private boolean running = true;
public GameLoop(AppAccess app) {
super(app);
}
public void start()
{
timer = new TimerDelta();
while (running) {
disp().beginFrame();
bus().send(new UpdateEvent(timer.getDelta()));
Runnable r;
while ((r = taskQueue.poll()) != null) {
r.run();
}
tick();
disp().endFrame();
}
}
/**
* Called each frame, in rendering context.
*/
protected abstract void tick();
@Override
protected final void deinit()
{
running = false;
}
@Override
public final synchronized void queueTask(Runnable request)
{
taskQueue.add(request);
}
}

@ -1,4 +1,4 @@
package mightypork.rogue.util; package mightypork.gamecore;
import mightypork.utils.logging.LogInstance; import mightypork.utils.logging.LogInstance;

@ -1,15 +1,15 @@
package mightypork.rogue.bus; package mightypork.gamecore.control;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import mightypork.rogue.AppAccess; import mightypork.gamecore.BusAccess;
import mightypork.rogue.AppAdapter; import mightypork.gamecore.control.bus.EventBus;
import mightypork.utils.control.bus.EventBus; import mightypork.gamecore.control.bus.clients.DelegatingClient;
import mightypork.utils.control.bus.clients.DelegatingClient; import mightypork.gamecore.control.bus.clients.ToggleableClient;
import mightypork.utils.control.bus.clients.ToggleableClient; import mightypork.gamecore.control.interf.Destroyable;
/** /**
@ -18,17 +18,38 @@ import mightypork.utils.control.bus.clients.ToggleableClient;
* *
* @author MightyPork * @author MightyPork
*/ */
public class ChildClient extends AppAdapter implements DelegatingClient, ToggleableClient { public abstract class ChildClient implements BusAccess, DelegatingClient, ToggleableClient, Destroyable {
public ChildClient(AppAccess app) { private BusAccess busAccess;
super(app);
}
private final Set<Object> clients = new LinkedHashSet<Object>(); private final Set<Object> clients = new LinkedHashSet<Object>();
private boolean listening = true; private boolean listening = true;
private boolean delegating = true; private boolean delegating = true;
public ChildClient(BusAccess busAccess) {
this.busAccess = busAccess;
bus().subscribe(this);
}
@Override
public final void destroy()
{
deinit();
bus().unsubscribe(this);
}
/**
* Deinitialize the subsystem<br>
* (called during destruction)
*/
protected abstract void deinit();
@Override @Override
public final Collection<Object> getChildClients() public final Collection<Object> getChildClients()
{ {
@ -97,4 +118,11 @@ public class ChildClient extends AppAdapter implements DelegatingClient, Togglea
this.delegating = delegating; this.delegating = delegating;
} }
@Override
public EventBus bus()
{
return busAccess.bus();
}
} }

@ -0,0 +1,55 @@
package mightypork.gamecore.control;
import mightypork.gamecore.AppAccess;
import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.render.DisplaySystem;
import mightypork.gamecore.resources.sounds.SoundSystem;
/**
* App event bus client, to be used for subsystems, screens and anything that
* needs access to the eventbus
*
* @author MightyPork
*/
public abstract class Subsystem extends ChildClient implements AppAccess {
private final AppAccess app;
public Subsystem(AppAccess app) {
super(app);
this.app = app;
}
@Override
public final SoundSystem snd()
{
return app.snd();
}
@Override
public final InputSystem input()
{
return app.input();
}
@Override
public final DisplaySystem disp()
{
return app.disp();
}
@Override
public void shutdown()
{
app.shutdown();
}
}

@ -1,4 +1,4 @@
package mightypork.utils.control.bus; package mightypork.gamecore.control.bus;
import java.util.Collection; import java.util.Collection;

@ -1,16 +1,16 @@
package mightypork.utils.control.bus; package mightypork.gamecore.control.bus;
import java.util.concurrent.DelayQueue; import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed; import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import mightypork.utils.control.bus.events.Event; import mightypork.gamecore.control.bus.events.Event;
import mightypork.utils.control.bus.events.types.DelayedEvent; import mightypork.gamecore.control.bus.events.types.DelayedEvent;
import mightypork.utils.control.bus.events.types.ImmediateEvent; import mightypork.gamecore.control.bus.events.types.ImmediateEvent;
import mightypork.utils.control.bus.events.types.SingleReceiverEvent; import mightypork.gamecore.control.bus.events.types.SingleReceiverEvent;
import mightypork.utils.control.bus.events.types.UnloggedEvent; import mightypork.gamecore.control.bus.events.types.UnloggedEvent;
import mightypork.utils.control.interf.Destroyable; import mightypork.gamecore.control.interf.Destroyable;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;

@ -1,13 +1,13 @@
package mightypork.utils.control.bus; package mightypork.gamecore.control.bus;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import mightypork.utils.control.bus.clients.DelegatingClient; import mightypork.gamecore.control.bus.clients.DelegatingClient;
import mightypork.utils.control.bus.clients.ToggleableClient; import mightypork.gamecore.control.bus.clients.ToggleableClient;
import mightypork.utils.control.bus.events.Event; import mightypork.gamecore.control.bus.events.Event;
import mightypork.utils.control.bus.events.types.SingleReceiverEvent; import mightypork.gamecore.control.bus.events.types.SingleReceiverEvent;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;

@ -1,4 +1,4 @@
package mightypork.utils.control.bus.clients; package mightypork.gamecore.control.bus.clients;
import java.util.Collection; import java.util.Collection;

@ -1,4 +1,4 @@
package mightypork.utils.control.bus.clients; package mightypork.gamecore.control.bus.clients;
/** /**

@ -1,9 +1,8 @@
package mightypork.rogue.bus.events; package mightypork.gamecore.control.bus.events;
import mightypork.utils.control.bus.events.Event; import mightypork.gamecore.control.bus.events.types.ImmediateEvent;
import mightypork.utils.control.bus.events.types.ImmediateEvent; import mightypork.gamecore.control.interf.Destroyable;
import mightypork.utils.control.interf.Destroyable;
/** /**

@ -1,9 +1,9 @@
package mightypork.utils.control.bus.events; package mightypork.gamecore.control.bus.events;
import mightypork.utils.control.bus.events.types.DelayedEvent; import mightypork.gamecore.control.bus.events.types.DelayedEvent;
import mightypork.utils.control.bus.events.types.ImmediateEvent; import mightypork.gamecore.control.bus.events.types.ImmediateEvent;
import mightypork.utils.control.bus.events.types.SingleReceiverEvent; import mightypork.gamecore.control.bus.events.types.SingleReceiverEvent;
/** /**

@ -1,8 +1,6 @@
package mightypork.rogue.bus.events; package mightypork.gamecore.control.bus.events;
import mightypork.utils.control.bus.events.Event;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;

@ -1,8 +1,7 @@
package mightypork.rogue.bus.events; package mightypork.gamecore.control.bus.events;
import mightypork.utils.control.bus.events.Event; import mightypork.gamecore.control.bus.events.types.SingleReceiverEvent;
import mightypork.utils.control.bus.events.types.SingleReceiverEvent;
/** /**

@ -1,7 +1,7 @@
package mightypork.rogue.bus.events; package mightypork.gamecore.control.bus.events;
import mightypork.utils.control.bus.events.Event; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
@ -101,6 +101,18 @@ public class MouseButtonEvent implements Event<MouseButtonEvent.Listener> {
} }
/**
* Get if event happened over a rect
*
* @param rect rect region
* @return was over
*/
public boolean isOver(RectConstraint rect)
{
return pos.isInRect(rect.getRect());
}
@Override @Override
public void handleBy(Listener handler) public void handleBy(Listener handler)
{ {

@ -1,8 +1,7 @@
package mightypork.rogue.bus.events; package mightypork.gamecore.control.bus.events;
import mightypork.utils.control.bus.events.Event; import mightypork.gamecore.control.bus.events.types.UnloggedEvent;
import mightypork.utils.control.bus.events.types.UnloggedEvent;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;

@ -1,9 +1,8 @@
package mightypork.rogue.bus.events; package mightypork.gamecore.control.bus.events;
import mightypork.rogue.loading.DeferredResource; import mightypork.gamecore.control.bus.events.types.SingleReceiverEvent;
import mightypork.utils.control.bus.events.Event; import mightypork.gamecore.loading.DeferredResource;
import mightypork.utils.control.bus.events.types.SingleReceiverEvent;
/** /**

@ -1,7 +1,6 @@
package mightypork.rogue.bus.events; package mightypork.gamecore.control.bus.events;
import mightypork.utils.control.bus.events.Event;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;

@ -1,8 +1,7 @@
package mightypork.rogue.bus.events; package mightypork.gamecore.control.bus.events;
import mightypork.utils.control.bus.events.Event; import mightypork.gamecore.control.bus.events.types.SingleReceiverEvent;
import mightypork.utils.control.bus.events.types.SingleReceiverEvent;
/** /**

@ -1,10 +1,9 @@
package mightypork.rogue.bus.events; package mightypork.gamecore.control.bus.events;
import mightypork.utils.control.bus.events.Event; import mightypork.gamecore.control.bus.events.types.ImmediateEvent;
import mightypork.utils.control.bus.events.types.ImmediateEvent; import mightypork.gamecore.control.bus.events.types.UnloggedEvent;
import mightypork.utils.control.bus.events.types.UnloggedEvent; import mightypork.gamecore.control.interf.Updateable;
import mightypork.utils.control.interf.Updateable;
/** /**

@ -1,4 +1,4 @@
package mightypork.utils.control.bus.events.types; package mightypork.gamecore.control.bus.events.types;
import java.lang.annotation.*; import java.lang.annotation.*;

@ -1,4 +1,4 @@
package mightypork.utils.control.bus.events.types; package mightypork.gamecore.control.bus.events.types;
import java.lang.annotation.*; import java.lang.annotation.*;

@ -1,4 +1,4 @@
package mightypork.utils.control.bus.events.types; package mightypork.gamecore.control.bus.events.types;
import java.lang.annotation.*; import java.lang.annotation.*;

@ -1,4 +1,4 @@
package mightypork.utils.control.bus.events.types; package mightypork.gamecore.control.bus.events.types;
import java.lang.annotation.*; import java.lang.annotation.*;

@ -1,4 +1,4 @@
package mightypork.utils.control.interf; package mightypork.gamecore.control.interf;
/** /**

@ -1,4 +1,4 @@
package mightypork.utils.control.interf; package mightypork.gamecore.control.interf;
/** /**

@ -1,4 +1,4 @@
package mightypork.utils.control.timing; package mightypork.gamecore.control.timing;
/** /**

@ -1,4 +1,4 @@
package mightypork.utils.control.timing; package mightypork.gamecore.control.timing;
public interface Pauseable { public interface Pauseable {

@ -1,4 +1,4 @@
package mightypork.utils.control.timing; package mightypork.gamecore.control.timing;
/** /**

@ -1,4 +1,4 @@
package mightypork.utils.control.timing; package mightypork.gamecore.control.timing;
/** /**

@ -1,9 +1,9 @@
package mightypork.rogue.gui.renderers; package mightypork.gamecore.gui.renderers;
import static mightypork.utils.math.constraints.ConstraintFactory.*; import static mightypork.utils.math.constraints.ConstraintFactory.*;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.utils.math.constraints.RectEvaluable; import mightypork.utils.math.constraints.RectConstraint;
public class ColumnHolder extends ElementHolder { public class ColumnHolder extends ElementHolder {
@ -12,7 +12,7 @@ public class ColumnHolder extends ElementHolder {
private int col = 0; private int col = 0;
public ColumnHolder(AppAccess app, RectEvaluable context, int rows) { public ColumnHolder(AppAccess app, RectConstraint context, int rows) {
super(app, context); super(app, context);
this.cols = rows; this.cols = rows;
} }

@ -1,13 +1,13 @@
package mightypork.rogue.gui.renderers; package mightypork.gamecore.gui.renderers;
import java.util.LinkedList; import java.util.LinkedList;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.rogue.bus.ChildClient; import mightypork.gamecore.control.ChildClient;
import mightypork.rogue.render.Renderable; import mightypork.gamecore.control.bus.EventBus;
import mightypork.utils.control.bus.EventBus; import mightypork.gamecore.render.Renderable;
import mightypork.utils.math.constraints.RectEvaluable; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
@ -20,7 +20,7 @@ import mightypork.utils.math.coord.Rect;
public abstract class ElementHolder extends ChildClient implements PluggableRenderable { public abstract class ElementHolder extends ChildClient implements PluggableRenderable {
private final LinkedList<PluggableRenderable> elements = new LinkedList<PluggableRenderable>(); private final LinkedList<PluggableRenderable> elements = new LinkedList<PluggableRenderable>();
private RectEvaluable context; private RectConstraint context;
public ElementHolder(AppAccess app) { public ElementHolder(AppAccess app) {
@ -28,14 +28,14 @@ public abstract class ElementHolder extends ChildClient implements PluggableRend
} }
public ElementHolder(AppAccess app, RectEvaluable context) { public ElementHolder(AppAccess app, RectConstraint context) {
super(app); super(app);
setContext(context); setContext(context);
} }
@Override @Override
public final void setContext(RectEvaluable context) public final void setContext(RectConstraint context)
{ {
this.context = context; this.context = context;
} }
@ -79,4 +79,11 @@ public abstract class ElementHolder extends ChildClient implements PluggableRend
addChildClient(elem); addChildClient(elem);
} }
@Override
protected void deinit()
{
// no impl
}
} }

@ -1,8 +1,8 @@
package mightypork.rogue.gui.renderers; package mightypork.gamecore.gui.renderers;
import mightypork.rogue.render.Render; import mightypork.gamecore.render.Render;
import mightypork.rogue.textures.TxQuad; import mightypork.gamecore.resources.textures.TxQuad;
public class ImageRenderer extends PluggableRenderer { public class ImageRenderer extends PluggableRenderer {

@ -1,9 +1,9 @@
package mightypork.rogue.gui.renderers; package mightypork.gamecore.gui.renderers;
import mightypork.rogue.render.Renderable; import mightypork.gamecore.render.Renderable;
import mightypork.utils.math.constraints.PluggableContext; import mightypork.utils.math.constraints.PluggableContext;
import mightypork.utils.math.constraints.RectEvaluable; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
@ -18,6 +18,6 @@ public interface PluggableRenderable extends Renderable, PluggableContext {
@Override @Override
void setContext(RectEvaluable rect); void setContext(RectConstraint rect);
} }

@ -1,9 +1,9 @@
package mightypork.rogue.gui.renderers; package mightypork.gamecore.gui.renderers;
import mightypork.rogue.render.Renderable; import mightypork.gamecore.render.Renderable;
import mightypork.utils.math.constraints.ContextAdapter; import mightypork.utils.math.constraints.ContextAdapter;
import mightypork.utils.math.constraints.RectEvaluable; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
@ -26,7 +26,7 @@ public abstract class PluggableRenderer extends ContextAdapter implements Plugga
@Override @Override
public void setContext(RectEvaluable rect) public void setContext(RectConstraint rect)
{ {
super.setContext(rect); super.setContext(rect);
} }

@ -1,9 +1,9 @@
package mightypork.rogue.gui.renderers; package mightypork.gamecore.gui.renderers;
import static mightypork.utils.math.constraints.ConstraintFactory.*; import static mightypork.utils.math.constraints.ConstraintFactory.*;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.utils.math.constraints.RectEvaluable; import mightypork.utils.math.constraints.RectConstraint;
public class RowHolder extends ElementHolder { public class RowHolder extends ElementHolder {
@ -12,7 +12,7 @@ public class RowHolder extends ElementHolder {
private int row = 0; private int row = 0;
public RowHolder(AppAccess app, RectEvaluable context, int rows) { public RowHolder(AppAccess app, RectConstraint context, int rows) {
super(app, context); super(app, context);
this.rows = rows; this.rows = rows;
} }

@ -1,8 +1,8 @@
package mightypork.rogue.gui.renderers; package mightypork.gamecore.gui.renderers;
import mightypork.rogue.fonts.FontRenderer; import mightypork.gamecore.resources.fonts.FontRenderer;
import mightypork.rogue.fonts.GLFont; import mightypork.gamecore.resources.fonts.GLFont;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;

@ -1,10 +1,10 @@
package mightypork.rogue.gui.screens; package mightypork.gamecore.gui.screens;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
public abstract class LayeredScreen extends Screen { public abstract class LayeredScreen extends Screen {

@ -1,16 +1,16 @@
package mightypork.rogue.gui.screens; package mightypork.gamecore.gui.screens;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.rogue.bus.ChildClient; import mightypork.gamecore.control.Subsystem;
import mightypork.rogue.bus.events.ScreenChangeEvent; import mightypork.gamecore.control.bus.events.ScreenChangeEvent;
import mightypork.rogue.input.KeyBinder; import mightypork.gamecore.control.interf.Destroyable;
import mightypork.rogue.input.KeyBindingPool; import mightypork.gamecore.input.KeyBinder;
import mightypork.rogue.input.KeyStroke; import mightypork.gamecore.input.KeyBindingPool;
import mightypork.rogue.render.Renderable; import mightypork.gamecore.input.KeyStroke;
import mightypork.utils.control.interf.Destroyable; import mightypork.gamecore.render.Renderable;
import mightypork.utils.math.constraints.RectEvaluable; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
@ -20,7 +20,7 @@ import mightypork.utils.math.coord.Rect;
* *
* @author MightyPork * @author MightyPork
*/ */
public abstract class Screen extends ChildClient implements Renderable, Destroyable, KeyBinder, RectEvaluable, ScreenChangeEvent.Listener { public abstract class Screen extends Subsystem implements Renderable, Destroyable, KeyBinder, RectConstraint, ScreenChangeEvent.Listener {
private final KeyBindingPool keybindings = new KeyBindingPool(); private final KeyBindingPool keybindings = new KeyBindingPool();
@ -53,7 +53,7 @@ public abstract class Screen extends ChildClient implements Renderable, Destroya
@Override @Override
public final void destroy() public final void deinit()
{ {
deinitScreen(); deinitScreen();
} }

@ -1,12 +1,12 @@
package mightypork.rogue.gui.screens; package mightypork.gamecore.gui.screens;
import mightypork.rogue.bus.ChildClient; import mightypork.gamecore.control.Subsystem;
import mightypork.rogue.input.KeyBinder; import mightypork.gamecore.input.KeyBinder;
import mightypork.rogue.input.KeyBindingPool; import mightypork.gamecore.input.KeyBindingPool;
import mightypork.rogue.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
import mightypork.rogue.render.Renderable; import mightypork.gamecore.render.Renderable;
import mightypork.utils.math.constraints.RectEvaluable; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
@ -15,7 +15,7 @@ import mightypork.utils.math.coord.Rect;
* *
* @author MightyPork * @author MightyPork
*/ */
public abstract class ScreenLayer extends ChildClient implements Renderable, RectEvaluable, KeyBinder { public abstract class ScreenLayer extends Subsystem implements Renderable, RectConstraint, KeyBinder {
private final Screen screen; private final Screen screen;
@ -56,4 +56,11 @@ public abstract class ScreenLayer extends ChildClient implements Renderable, Rec
return screen.getRect(); return screen.getRect();
} }
@Override
protected void deinit()
{
// noimpl
}
} }

@ -1,12 +1,12 @@
package mightypork.rogue.gui.screens; package mightypork.gamecore.gui.screens;
import java.util.HashMap; import java.util.HashMap;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.rogue.bus.Subsystem; import mightypork.gamecore.control.Subsystem;
import mightypork.rogue.bus.events.ScreenRequestEvent; import mightypork.gamecore.control.bus.events.ScreenRequestEvent;
import mightypork.rogue.render.Renderable; import mightypork.gamecore.render.Renderable;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;

@ -0,0 +1,37 @@
package mightypork.gamecore.input;
/**
* Triggered action
*
* @author MightyPork
*/
public abstract class Action implements Runnable {
private boolean enabled = true;
/**
* Enable the action
*
* @param enable true to enable
*/
public final void enable(boolean enable)
{
this.enabled = enable;
}
@Override
public final void run()
{
if (enabled) execute();
}
/**
* Do the work.
*/
public abstract void execute();
}

@ -0,0 +1,7 @@
package mightypork.gamecore.input;
public interface ActionTrigger {
void setAction(Action action);
}

@ -1,15 +1,15 @@
package mightypork.rogue.input; package mightypork.gamecore.input;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.rogue.bus.Subsystem; import mightypork.gamecore.control.Subsystem;
import mightypork.rogue.bus.events.ActionRequest; import mightypork.gamecore.control.bus.events.KeyboardEvent;
import mightypork.rogue.bus.events.ActionRequest.RequestType; import mightypork.gamecore.control.bus.events.MouseButtonEvent;
import mightypork.rogue.bus.events.KeyboardEvent; import mightypork.gamecore.control.bus.events.MouseMotionEvent;
import mightypork.rogue.bus.events.MouseButtonEvent; import mightypork.gamecore.control.interf.Updateable;
import mightypork.rogue.bus.events.MouseMotionEvent; import mightypork.rogue.events.ActionRequest;
import mightypork.utils.control.interf.Updateable; import mightypork.rogue.events.ActionRequest.RequestType;
import mightypork.utils.math.constraints.NumEvaluable; import mightypork.utils.math.constraints.NumberConstraint;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
@ -175,7 +175,7 @@ public class InputSystem extends Subsystem implements Updateable, KeyBinder {
Mouse.setGrabbed(grab); Mouse.setGrabbed(grab);
} }
private final NumEvaluable cmousex = new NumEvaluable() { private final NumberConstraint cmousex = new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -184,7 +184,7 @@ public class InputSystem extends Subsystem implements Updateable, KeyBinder {
} }
}; };
private final NumEvaluable cmousey = new NumEvaluable() { private final NumberConstraint cmousey = new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -194,13 +194,13 @@ public class InputSystem extends Subsystem implements Updateable, KeyBinder {
}; };
public NumEvaluable c_mouse_x() public NumberConstraint c_mouse_x()
{ {
return cmousex; return cmousex;
} }
public NumEvaluable c_mouse_y() public NumberConstraint c_mouse_y()
{ {
return cmousey; return cmousey;
} }

@ -1,4 +1,4 @@
package mightypork.rogue.input; package mightypork.gamecore.input;
public interface KeyBinder { public interface KeyBinder {

@ -1,7 +1,7 @@
package mightypork.rogue.input; package mightypork.gamecore.input;
import mightypork.rogue.bus.events.KeyboardEvent; import mightypork.gamecore.control.bus.events.KeyboardEvent;
/** /**

@ -1,11 +1,11 @@
package mightypork.rogue.input; package mightypork.gamecore.input;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import mightypork.rogue.bus.events.KeyboardEvent; import mightypork.gamecore.control.bus.events.KeyboardEvent;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;

@ -1,4 +1,4 @@
package mightypork.rogue.input; package mightypork.gamecore.input;
import java.util.Iterator; import java.util.Iterator;

@ -1,4 +1,4 @@
package mightypork.rogue.input; package mightypork.gamecore.input;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;

@ -1,14 +1,14 @@
package mightypork.rogue.loading; package mightypork.gamecore.loading;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import mightypork.rogue.AppAccess; import mightypork.gamecore.BusAccess;
import mightypork.rogue.bus.events.MainLoopTaskRequest; import mightypork.gamecore.control.bus.events.MainLoopTaskRequest;
import mightypork.rogue.bus.events.ResourceLoadRequest; import mightypork.gamecore.control.bus.events.ResourceLoadRequest;
import mightypork.utils.control.interf.Destroyable; import mightypork.gamecore.control.interf.Destroyable;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
@ -19,7 +19,7 @@ import mightypork.utils.logging.Log;
*/ */
public class AsyncResourceLoader extends Thread implements ResourceLoadRequest.Listener, Destroyable { public class AsyncResourceLoader extends Thread implements ResourceLoadRequest.Listener, Destroyable {
public static void launch(AppAccess app) public static void launch(BusAccess app)
{ {
(new AsyncResourceLoader(app)).start(); (new AsyncResourceLoader(app)).start();
} }
@ -28,10 +28,10 @@ public class AsyncResourceLoader extends Thread implements ResourceLoadRequest.L
private final LinkedBlockingQueue<DeferredResource> toLoad = new LinkedBlockingQueue<DeferredResource>(); private final LinkedBlockingQueue<DeferredResource> toLoad = new LinkedBlockingQueue<DeferredResource>();
private boolean stopped; private boolean stopped;
private final AppAccess app; private final BusAccess app;
public AsyncResourceLoader(AppAccess app) { public AsyncResourceLoader(BusAccess app) {
super("Deferred loader"); super("Deferred loader");
this.app = app; this.app = app;
app.bus().subscribe(this); app.bus().subscribe(this);

@ -1,7 +1,7 @@
package mightypork.rogue.loading; package mightypork.gamecore.loading;
import mightypork.utils.control.interf.Destroyable; import mightypork.gamecore.control.interf.Destroyable;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
import mightypork.utils.logging.LoggedName; import mightypork.utils.logging.LoggedName;

@ -1,4 +1,4 @@
package mightypork.rogue.loading; package mightypork.gamecore.loading;
/** /**

@ -1,4 +1,4 @@
package mightypork.rogue.loading; package mightypork.gamecore.loading;
import java.lang.annotation.*; import java.lang.annotation.*;

@ -1,4 +1,4 @@
package mightypork.rogue.loading; package mightypork.gamecore.loading;
/** /**

@ -1,15 +1,20 @@
package mightypork.rogue.render; package mightypork.gamecore.render;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import mightypork.rogue.AppAccess; import javax.imageio.ImageIO;
import mightypork.rogue.bus.Subsystem;
import mightypork.rogue.bus.events.ScreenChangeEvent; import mightypork.gamecore.AppAccess;
import mightypork.gamecore.control.Subsystem;
import mightypork.gamecore.control.bus.events.ScreenChangeEvent;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
import mightypork.utils.math.constraints.RectEvaluable; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
@ -19,7 +24,7 @@ import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.DisplayMode;
public class DisplaySystem extends Subsystem implements RectEvaluable { public class DisplaySystem extends Subsystem implements RectConstraint {
private DisplayMode windowDisplayMode; private DisplayMode windowDisplayMode;
private int targetFps; private int targetFps;
@ -192,10 +197,11 @@ public class DisplaySystem extends Subsystem implements RectEvaluable {
public static class Screenshot { public static class Screenshot {
public int width; private int width;
public int height; private int height;
public int bpp; private int bpp;
public ByteBuffer bytes; private ByteBuffer bytes;
private BufferedImage image;
public Screenshot(int width, int height, int bpp, ByteBuffer buffer) { public Screenshot(int width, int height, int bpp, ByteBuffer buffer) {
@ -204,5 +210,32 @@ public class DisplaySystem extends Subsystem implements RectEvaluable {
this.bpp = bpp; this.bpp = bpp;
this.bytes = buffer; this.bytes = buffer;
} }
public BufferedImage getImage()
{
if (image != null) return image;
image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_RGB);
// convert to a buffered image
for (int x = 0; x < this.width; x++) {
for (int y = 0; y < this.height; y++) {
final int i = (x + (this.width * y)) * this.bpp;
final int r = this.bytes.get(i) & 0xFF;
final int g = this.bytes.get(i + 1) & 0xFF;
final int b = this.bytes.get(i + 2) & 0xFF;
image.setRGB(x, this.height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b);
}
}
return image;
}
public void save(File file) throws IOException
{
ImageIO.write(getImage(), "PNG", file);
}
} }
} }

@ -1,11 +1,11 @@
package mightypork.rogue.render; package mightypork.gamecore.render;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import java.io.IOException; import java.io.IOException;
import mightypork.rogue.textures.TxQuad; import mightypork.gamecore.resources.textures.TxQuad;
import mightypork.utils.files.FileUtils; import mightypork.utils.files.FileUtils;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;

@ -1,4 +1,4 @@
package mightypork.rogue.render; package mightypork.gamecore.render;
/** /**

@ -1,4 +1,4 @@
package mightypork.rogue.fonts; package mightypork.gamecore.resources.fonts;
import java.awt.Font; import java.awt.Font;
@ -6,8 +6,8 @@ import java.awt.FontFormatException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import mightypork.rogue.loading.BaseDeferredResource; import mightypork.gamecore.loading.BaseDeferredResource;
import mightypork.rogue.loading.MustLoadInMainThread; import mightypork.gamecore.loading.MustLoadInMainThread;
import mightypork.utils.files.FileUtils; import mightypork.utils.files.FileUtils;
import mightypork.utils.logging.LoggedName; import mightypork.utils.logging.LoggedName;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;

@ -1,4 +1,4 @@
package mightypork.rogue.fonts; package mightypork.gamecore.resources.fonts;
import java.awt.Font; import java.awt.Font;

@ -1,11 +1,11 @@
package mightypork.rogue.fonts; package mightypork.gamecore.resources.fonts;
import java.util.HashMap; import java.util.HashMap;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.rogue.AppAdapter; import mightypork.gamecore.AppAdapter;
import mightypork.rogue.bus.events.ResourceLoadRequest; import mightypork.gamecore.control.bus.events.ResourceLoadRequest;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
import org.newdawn.slick.opengl.Texture; import org.newdawn.slick.opengl.Texture;

@ -1,7 +1,7 @@
package mightypork.rogue.fonts; package mightypork.gamecore.resources.fonts;
import mightypork.rogue.render.Render; import mightypork.gamecore.render.Render;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;

@ -1,4 +1,4 @@
package mightypork.rogue.fonts; package mightypork.gamecore.resources.fonts;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;

@ -1,4 +1,4 @@
package mightypork.rogue.fonts; package mightypork.gamecore.resources.fonts;
/** /**

@ -1,4 +1,4 @@
package mightypork.rogue.fonts; package mightypork.gamecore.resources.fonts;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;

@ -1,11 +1,11 @@
package mightypork.rogue.fonts; package mightypork.gamecore.resources.fonts;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import java.awt.Font; import java.awt.Font;
import mightypork.rogue.render.Render; import mightypork.gamecore.render.Render;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;

@ -1,9 +1,9 @@
package mightypork.rogue.sounds; package mightypork.gamecore.resources.sounds;
import java.io.IOException; import java.io.IOException;
import mightypork.rogue.loading.BaseDeferredResource; import mightypork.gamecore.loading.BaseDeferredResource;
import mightypork.utils.files.FileUtils; import mightypork.utils.files.FileUtils;
import mightypork.utils.logging.LoggedName; import mightypork.utils.logging.LoggedName;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;

@ -1,4 +1,4 @@
package mightypork.rogue.sounds; package mightypork.gamecore.resources.sounds;
import mightypork.utils.math.Calc; import mightypork.utils.math.Calc;

@ -1,7 +1,7 @@
package mightypork.rogue.sounds; package mightypork.gamecore.resources.sounds;
import mightypork.rogue.loading.NullResource; import mightypork.gamecore.loading.NullResource;
import mightypork.utils.logging.LoggedName; import mightypork.utils.logging.LoggedName;

@ -1,13 +1,13 @@
package mightypork.rogue.sounds; package mightypork.gamecore.resources.sounds;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.rogue.AppAdapter; import mightypork.gamecore.AppAdapter;
import mightypork.rogue.sounds.players.EffectPlayer; import mightypork.gamecore.resources.sounds.players.EffectPlayer;
import mightypork.rogue.sounds.players.LoopPlayer; import mightypork.gamecore.resources.sounds.players.LoopPlayer;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;

@ -1,16 +1,16 @@
package mightypork.rogue.sounds; package mightypork.gamecore.resources.sounds;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.rogue.bus.Subsystem; import mightypork.gamecore.control.Subsystem;
import mightypork.rogue.bus.events.ResourceLoadRequest; import mightypork.gamecore.control.bus.events.ResourceLoadRequest;
import mightypork.rogue.sounds.players.EffectPlayer; import mightypork.gamecore.control.interf.Updateable;
import mightypork.rogue.sounds.players.LoopPlayer; import mightypork.gamecore.resources.sounds.players.EffectPlayer;
import mightypork.utils.control.interf.Updateable; import mightypork.gamecore.resources.sounds.players.LoopPlayer;
import mightypork.utils.math.Calc.Buffers; import mightypork.utils.math.Calc.Buffers;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import mightypork.utils.objects.Mutable; import mightypork.utils.objects.Mutable;

@ -1,8 +1,8 @@
package mightypork.rogue.sounds.players; package mightypork.gamecore.resources.sounds.players;
import mightypork.rogue.sounds.DeferredAudio; import mightypork.gamecore.control.interf.Destroyable;
import mightypork.utils.control.interf.Destroyable; import mightypork.gamecore.resources.sounds.DeferredAudio;
import mightypork.utils.objects.Mutable; import mightypork.utils.objects.Mutable;

@ -1,7 +1,7 @@
package mightypork.rogue.sounds.players; package mightypork.gamecore.resources.sounds.players;
import mightypork.rogue.sounds.DeferredAudio; import mightypork.gamecore.resources.sounds.DeferredAudio;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import mightypork.utils.objects.Mutable; import mightypork.utils.objects.Mutable;

@ -1,9 +1,9 @@
package mightypork.rogue.sounds.players; package mightypork.gamecore.resources.sounds.players;
import mightypork.rogue.sounds.DeferredAudio; import mightypork.gamecore.control.interf.Updateable;
import mightypork.utils.control.interf.Updateable; import mightypork.gamecore.control.timing.Pauseable;
import mightypork.utils.control.timing.Pauseable; import mightypork.gamecore.resources.sounds.DeferredAudio;
import mightypork.utils.math.animation.AnimDouble; import mightypork.utils.math.animation.AnimDouble;
import mightypork.utils.objects.Mutable; import mightypork.utils.objects.Mutable;

@ -1,9 +1,9 @@
package mightypork.rogue.textures; package mightypork.gamecore.resources.textures;
import mightypork.rogue.loading.BaseDeferredResource; import mightypork.gamecore.loading.BaseDeferredResource;
import mightypork.rogue.loading.MustLoadInMainThread; import mightypork.gamecore.loading.MustLoadInMainThread;
import mightypork.rogue.render.Render; import mightypork.gamecore.render.Render;
import mightypork.utils.logging.LoggedName; import mightypork.utils.logging.LoggedName;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;

@ -1,4 +1,4 @@
package mightypork.rogue.textures; package mightypork.gamecore.resources.textures;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;

@ -1,13 +1,13 @@
package mightypork.rogue.textures; package mightypork.gamecore.resources.textures;
import java.util.HashMap; import java.util.HashMap;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.rogue.AppAdapter; import mightypork.gamecore.AppAdapter;
import mightypork.rogue.bus.events.ResourceLoadRequest; import mightypork.gamecore.control.bus.events.ResourceLoadRequest;
import mightypork.rogue.textures.FilteredTexture.Filter; import mightypork.gamecore.resources.textures.FilteredTexture.Filter;
import mightypork.rogue.textures.FilteredTexture.Wrap; import mightypork.gamecore.resources.textures.FilteredTexture.Wrap;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
import org.newdawn.slick.opengl.Texture; import org.newdawn.slick.opengl.Texture;

@ -1,4 +1,4 @@
package mightypork.rogue.textures; package mightypork.gamecore.resources.textures;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;

@ -9,21 +9,24 @@ import java.util.logging.Level;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import mightypork.rogue.bus.events.*; import mightypork.gamecore.AppAccess;
import mightypork.rogue.bus.events.ActionRequest.RequestType; import mightypork.gamecore.GameLoop;
import mightypork.rogue.gui.screens.ScreenRegistry; import mightypork.gamecore.SlickLogRedirector;
import mightypork.rogue.gui.screens.test_bouncyboxes.ScreenTestBouncy; import mightypork.gamecore.control.bus.EventBus;
import mightypork.rogue.gui.screens.test_cat_sound.ScreenTestCat; import mightypork.gamecore.control.bus.events.*;
import mightypork.rogue.gui.screens.test_font.ScreenTestFont; import mightypork.gamecore.control.interf.Destroyable;
import mightypork.rogue.input.InputSystem; import mightypork.gamecore.control.interf.Updateable;
import mightypork.rogue.input.KeyStroke; import mightypork.gamecore.gui.screens.ScreenRegistry;
import mightypork.rogue.input.Keys; import mightypork.gamecore.input.InputSystem;
import mightypork.rogue.render.DisplaySystem; import mightypork.gamecore.input.KeyStroke;
import mightypork.rogue.sounds.SoundSystem; import mightypork.gamecore.input.Keys;
import mightypork.rogue.util.SlickLogRedirector; import mightypork.gamecore.render.DisplaySystem;
import mightypork.utils.control.bus.EventBus; import mightypork.gamecore.resources.sounds.SoundSystem;
import mightypork.utils.control.interf.Destroyable; import mightypork.rogue.events.ActionRequest;
import mightypork.utils.control.interf.Updateable; import mightypork.rogue.events.ActionRequest.RequestType;
import mightypork.rogue.screens.test_bouncyboxes.ScreenTestBouncy;
import mightypork.rogue.screens.test_cat_sound.ScreenTestCat;
import mightypork.rogue.screens.test_font.ScreenTestFont;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
import mightypork.utils.logging.LogInstance; import mightypork.utils.logging.LogInstance;
@ -43,7 +46,7 @@ public class App implements AppAccess {
private DisplaySystem displaySystem; private DisplaySystem displaySystem;
private static SoundSystem soundSystem; private static SoundSystem soundSystem;
private EventBus eventBus; private EventBus eventBus;
private MainLoop mainLoop; private GameLoop mainLoop;
private ScreenRegistry screens; private ScreenRegistry screens;

@ -1,24 +1,17 @@
package mightypork.rogue; package mightypork.rogue;
import java.util.Queue; import mightypork.gamecore.GameLoop;
import java.util.concurrent.ConcurrentLinkedQueue; import mightypork.gamecore.input.Action;
import mightypork.gamecore.render.Renderable;
import mightypork.rogue.bus.Subsystem; import mightypork.rogue.events.ActionRequest;
import mightypork.rogue.bus.events.ActionRequest; import mightypork.rogue.events.ActionRequest.RequestType;
import mightypork.rogue.bus.events.ActionRequest.RequestType;
import mightypork.rogue.bus.events.MainLoopTaskRequest;
import mightypork.rogue.bus.events.UpdateEvent;
import mightypork.rogue.render.Renderable;
import mightypork.rogue.tasks.TaskTakeScreenshot;
import mightypork.rogue.util.Utils; import mightypork.rogue.util.Utils;
import mightypork.utils.control.timing.TimerDelta;
public class MainLoop extends Subsystem implements ActionRequest.Listener, MainLoopTaskRequest.Listener { public class MainLoop extends GameLoop implements ActionRequest.Listener {
private final Queue<Runnable> taskQueue = new ConcurrentLinkedQueue<Runnable>(); final Renderable renderable;
private final Renderable renderable;
public MainLoop(App app, Renderable masterRenderable) { public MainLoop(App app, Renderable masterRenderable) {
@ -31,36 +24,11 @@ public class MainLoop extends Subsystem implements ActionRequest.Listener, MainL
this.renderable = masterRenderable; this.renderable = masterRenderable;
} }
/** timer */
private TimerDelta timer;
private boolean running = true;
public void start()
{
timer = new TimerDelta();
while (running) {
disp().beginFrame();
bus().send(new UpdateEvent(timer.getDelta()));
Runnable r;
while ((r = taskQueue.poll()) != null) {
r.run();
}
renderable.render();
disp().endFrame();
}
}
@Override @Override
protected void deinit() protected void tick()
{ {
running = false; renderable.render();
} }
@ -82,10 +50,10 @@ public class MainLoop extends Subsystem implements ActionRequest.Listener, MainL
} }
/** Take a screenshot */ /** Take a screenshot */
private final Runnable taskScreenshot = new Runnable() { private final Action taskScreenshot = new Action() {
@Override @Override
public void run() public void execute()
{ {
Res.getEffect("gui.shutter").play(1); Res.getEffect("gui.shutter").play(1);
Utils.runAsThread(new TaskTakeScreenshot(disp())); Utils.runAsThread(new TaskTakeScreenshot(disp()));
@ -93,29 +61,22 @@ public class MainLoop extends Subsystem implements ActionRequest.Listener, MainL
}; };
/** Shutdown the application */ /** Shutdown the application */
private final Runnable taskShutdown = new Runnable() { private final Action taskShutdown = new Action() {
@Override @Override
public void run() public void execute()
{ {
shutdown(); shutdown();
} }
}; };
/** Toggle fullscreen */ /** Toggle fullscreen */
private final Runnable taskFullscreen = new Runnable() { private final Action taskFullscreen = new Action() {
@Override @Override
public void run() public void execute()
{ {
disp().switchFullscreen(); disp().switchFullscreen();
} }
}; };
@Override
public synchronized void queueTask(Runnable request)
{
taskQueue.add(request);
}
} }

@ -1,18 +1,19 @@
package mightypork.rogue; package mightypork.rogue;
import mightypork.rogue.fonts.DeferredFont; import mightypork.gamecore.AppAccess;
import mightypork.rogue.fonts.DeferredFont.FontStyle; import mightypork.gamecore.loading.AsyncResourceLoader;
import mightypork.rogue.fonts.FontBank; import mightypork.gamecore.resources.fonts.DeferredFont;
import mightypork.rogue.fonts.GLFont; import mightypork.gamecore.resources.fonts.DeferredFont.FontStyle;
import mightypork.rogue.loading.AsyncResourceLoader; import mightypork.gamecore.resources.fonts.FontBank;
import mightypork.rogue.sounds.SoundBank; import mightypork.gamecore.resources.fonts.GLFont;
import mightypork.rogue.sounds.players.EffectPlayer; import mightypork.gamecore.resources.sounds.SoundBank;
import mightypork.rogue.sounds.players.LoopPlayer; import mightypork.gamecore.resources.sounds.players.EffectPlayer;
import mightypork.rogue.textures.FilteredTexture.Filter; import mightypork.gamecore.resources.sounds.players.LoopPlayer;
import mightypork.rogue.textures.FilteredTexture.Wrap; import mightypork.gamecore.resources.textures.FilteredTexture.Filter;
import mightypork.rogue.textures.TextureBank; import mightypork.gamecore.resources.textures.FilteredTexture.Wrap;
import mightypork.rogue.textures.TxQuad; import mightypork.gamecore.resources.textures.TextureBank;
import mightypork.gamecore.resources.textures.TxQuad;
import org.newdawn.slick.opengl.Texture; import org.newdawn.slick.opengl.Texture;

@ -1,18 +1,14 @@
package mightypork.rogue.tasks; package mightypork.rogue;
import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import javax.imageio.ImageIO; import mightypork.gamecore.render.DisplaySystem;
import mightypork.gamecore.render.DisplaySystem.Screenshot;
import mightypork.rogue.Paths;
import mightypork.rogue.render.DisplaySystem;
import mightypork.rogue.render.DisplaySystem.Screenshot;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
@ -29,20 +25,6 @@ public class TaskTakeScreenshot implements Runnable {
@Override @Override
public void run() public void run()
{ {
final BufferedImage image = new BufferedImage(scr.width, scr.height, BufferedImage.TYPE_INT_RGB);
// convert to a buffered image
for (int x = 0; x < scr.width; x++) {
for (int y = 0; y < scr.height; y++) {
final int i = (x + (scr.width * y)) * scr.bpp;
final int r = scr.bytes.get(i) & 0xFF;
final int g = scr.bytes.get(i + 1) & 0xFF;
final int b = scr.bytes.get(i + 2) & 0xFF;
image.setRGB(x, scr.height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b);
}
}
final String fname = getUniqueScreenshotName(); final String fname = getUniqueScreenshotName();
// generate unique filename // generate unique filename
@ -56,11 +38,9 @@ public class TaskTakeScreenshot implements Runnable {
Log.f3("Saving screenshot to file: " + file); Log.f3("Saving screenshot to file: " + file);
final String format = "PNG";
// save to disk // save to disk
try { try {
ImageIO.write(image, format, file); scr.save(file);
} catch (final IOException e) { } catch (final IOException e) {
Log.e("Failed to save screenshot.", e); Log.e("Failed to save screenshot.", e);
} }

@ -1,38 +0,0 @@
package mightypork.rogue.bus;
import mightypork.rogue.AppAccess;
import mightypork.utils.control.interf.Destroyable;
/**
* App event bus client, to be used for subsystems, screens and anything that
* needs access to the eventbus
*
* @author MightyPork
*/
public abstract class Subsystem extends ChildClient implements Destroyable {
public Subsystem(AppAccess app) {
super(app);
bus().subscribe(this);
}
@Override
public final void destroy()
{
deinit();
bus().unsubscribe(this);
}
/**
* Deinitialize the subsystem<br>
* (called during destruction)
*/
protected abstract void deinit();
}

@ -1,8 +1,8 @@
package mightypork.rogue.bus.events; package mightypork.rogue.events;
import mightypork.utils.control.bus.events.Event; import mightypork.gamecore.control.bus.events.Event;
import mightypork.utils.control.bus.events.types.SingleReceiverEvent; import mightypork.gamecore.control.bus.events.types.SingleReceiverEvent;
/** /**

@ -1,37 +1,37 @@
package mightypork.rogue.gui.screens.test_bouncyboxes; package mightypork.rogue.screens.test_bouncyboxes;
import static mightypork.utils.math.constraints.ConstraintFactory.*; import static mightypork.utils.math.constraints.ConstraintFactory.*;
import java.util.Random; import java.util.Random;
import mightypork.rogue.gui.renderers.PluggableRenderer; import mightypork.gamecore.control.interf.Updateable;
import mightypork.rogue.render.Render; import mightypork.gamecore.gui.renderers.PluggableRenderer;
import mightypork.utils.control.interf.Updateable; import mightypork.gamecore.render.Render;
import mightypork.utils.math.animation.AnimDouble; import mightypork.utils.math.animation.AnimDouble;
import mightypork.utils.math.animation.Easing; import mightypork.utils.math.animation.Easing;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.NumEvaluable; import mightypork.utils.math.constraints.NumberConstraint;
import mightypork.utils.math.constraints.RectEvaluable; import mightypork.utils.math.constraints.RectConstraint;
public class BouncyBox extends PluggableRenderer implements Updateable { public class BouncyBox extends PluggableRenderer implements Updateable {
private final Random rand = new Random(); private final Random rand = new Random();
private final RectEvaluable box; private final RectConstraint box;
private final AnimDouble pos = new AnimDouble(0, Easing.BOUNCE_OUT); private final AnimDouble pos = new AnimDouble(0, Easing.BOUNCE_OUT);
public BouncyBox() { public BouncyBox() {
// create box // create box
final NumEvaluable side = c_height(this); final NumberConstraint side = c_height(this);
RectEvaluable abox = c_box(this, side, side); RectConstraint abox = c_box(this, side, side);
// move // move
final NumEvaluable move_length = c_sub(c_width(this), side); final NumberConstraint move_length = c_sub(c_width(this), side);
final NumEvaluable offset = c_mul(move_length, c_n(pos)); final NumberConstraint offset = c_mul(move_length, c_n(pos));
abox = c_move(abox, offset, c_n(0)); abox = c_move(abox, offset, c_n(0));
// add padding // add padding

@ -1,4 +1,4 @@
package mightypork.rogue.gui.screens.test_bouncyboxes; package mightypork.rogue.screens.test_bouncyboxes;
import static mightypork.utils.math.constraints.ConstraintFactory.*; import static mightypork.utils.math.constraints.ConstraintFactory.*;
@ -6,16 +6,16 @@ import static mightypork.utils.math.constraints.ConstraintFactory.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import mightypork.gamecore.gui.renderers.RowHolder;
import mightypork.gamecore.gui.renderers.TextRenderer;
import mightypork.gamecore.gui.renderers.TextRenderer.Align;
import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys;
import mightypork.rogue.Res; import mightypork.rogue.Res;
import mightypork.rogue.gui.renderers.RowHolder;
import mightypork.rogue.gui.renderers.TextRenderer;
import mightypork.rogue.gui.renderers.TextRenderer.Align;
import mightypork.rogue.gui.screens.Screen;
import mightypork.rogue.gui.screens.ScreenLayer;
import mightypork.rogue.input.KeyStroke;
import mightypork.rogue.input.Keys;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.RectEvaluable; import mightypork.utils.math.constraints.RectConstraint;
public class LayerBouncyBoxes extends ScreenLayer { public class LayerBouncyBoxes extends ScreenLayer {
@ -46,7 +46,7 @@ public class LayerBouncyBoxes extends ScreenLayer {
}); });
// shrink screen rect by 8% on all sides // shrink screen rect by 8% on all sides
final RectEvaluable holder_rect = c_shrink(this, c_percent(c_height(this), c_n(8))); final RectConstraint holder_rect = c_shrink(this, c_percent(c_height(this), c_n(8)));
addChildClient(layout = new RowHolder(screen, holder_rect, 8)); addChildClient(layout = new RowHolder(screen, holder_rect, 8));

@ -1,11 +1,11 @@
package mightypork.rogue.gui.screens.test_bouncyboxes; package mightypork.rogue.screens.test_bouncyboxes;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.rogue.bus.events.ScreenRequestEvent; import mightypork.gamecore.control.bus.events.ScreenRequestEvent;
import mightypork.rogue.gui.screens.LayeredScreen; import mightypork.gamecore.gui.screens.LayeredScreen;
import mightypork.rogue.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
import mightypork.rogue.input.Keys; import mightypork.gamecore.input.Keys;
public class ScreenTestBouncy extends LayeredScreen { public class ScreenTestBouncy extends LayeredScreen {

@ -1,24 +1,24 @@
package mightypork.rogue.gui.screens.test_cat_sound; package mightypork.rogue.screens.test_cat_sound;
import static mightypork.utils.math.constraints.ConstraintFactory.*; import static mightypork.utils.math.constraints.ConstraintFactory.*;
import java.util.Random; import java.util.Random;
import mightypork.gamecore.control.bus.events.MouseButtonEvent;
import mightypork.gamecore.control.interf.Updateable;
import mightypork.gamecore.gui.renderers.ImageRenderer;
import mightypork.gamecore.gui.renderers.TextRenderer;
import mightypork.gamecore.gui.renderers.TextRenderer.Align;
import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys;
import mightypork.rogue.Res; import mightypork.rogue.Res;
import mightypork.rogue.bus.events.MouseButtonEvent;
import mightypork.rogue.gui.renderers.ImageRenderer;
import mightypork.rogue.gui.renderers.TextRenderer;
import mightypork.rogue.gui.renderers.TextRenderer.Align;
import mightypork.rogue.gui.screens.Screen;
import mightypork.rogue.gui.screens.ScreenLayer;
import mightypork.rogue.input.KeyStroke;
import mightypork.rogue.input.Keys;
import mightypork.utils.control.interf.Updateable;
import mightypork.utils.math.animation.AnimDouble; import mightypork.utils.math.animation.AnimDouble;
import mightypork.utils.math.animation.Easing; import mightypork.utils.math.animation.Easing;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.RectEvaluable; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
@ -44,7 +44,7 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
cat.setContext(c_centered(c_box(this, c_n(size), c_n(size)), c_n(xPos), c_n(yPos))); cat.setContext(c_centered(c_box(this, c_n(size), c_n(size)), c_n(xPos), c_n(yPos)));
//@formatter:off //@formatter:off
final RectEvaluable flyingFontBox = c_centered( final RectConstraint flyingFontBox = c_centered(
c_box(this, c_n(0), c_n(64)), c_box(this, c_n(0), c_n(64)),
input().c_mouse_x(), input().c_mouse_x(),
input().c_mouse_y() input().c_mouse_y()

@ -1,14 +1,14 @@
package mightypork.rogue.gui.screens.test_cat_sound; package mightypork.rogue.screens.test_cat_sound;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.gamecore.control.bus.events.ScreenRequestEvent;
import mightypork.gamecore.gui.screens.LayeredScreen;
import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys;
import mightypork.rogue.Res; import mightypork.rogue.Res;
import mightypork.rogue.bus.events.ActionRequest; import mightypork.rogue.events.ActionRequest;
import mightypork.rogue.bus.events.ActionRequest.RequestType; import mightypork.rogue.events.ActionRequest.RequestType;
import mightypork.rogue.bus.events.ScreenRequestEvent;
import mightypork.rogue.gui.screens.LayeredScreen;
import mightypork.rogue.input.KeyStroke;
import mightypork.rogue.input.Keys;
public class ScreenTestCat extends LayeredScreen { public class ScreenTestCat extends LayeredScreen {

@ -1,10 +1,10 @@
package mightypork.rogue.gui.screens.test_font; package mightypork.rogue.screens.test_font;
import mightypork.rogue.AppAccess; import mightypork.gamecore.AppAccess;
import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.resources.fonts.FontRenderer;
import mightypork.rogue.Res; import mightypork.rogue.Res;
import mightypork.rogue.fonts.FontRenderer;
import mightypork.rogue.gui.screens.Screen;
import mightypork.utils.math.color.RGB; import mightypork.utils.math.color.RGB;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;

@ -1,8 +1,8 @@
package mightypork.utils.math.animation; package mightypork.utils.math.animation;
import mightypork.utils.control.interf.Updateable; import mightypork.gamecore.control.interf.Updateable;
import mightypork.utils.control.timing.Pauseable; import mightypork.gamecore.control.timing.Pauseable;
import mightypork.utils.math.Calc; import mightypork.utils.math.Calc;

@ -14,9 +14,9 @@ import mightypork.utils.math.coord.Rect;
*/ */
public class ConstraintFactory { public class ConstraintFactory {
public static NumEvaluable c_min(final NumEvaluable a, final NumEvaluable b) public static NumberConstraint c_min(final NumberConstraint a, final NumberConstraint b)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -27,9 +27,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_max(final NumEvaluable a, final NumEvaluable b) public static NumberConstraint c_max(final NumberConstraint a, final NumberConstraint b)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -40,9 +40,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_abs(final NumEvaluable a) public static NumberConstraint c_abs(final NumberConstraint a)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -53,9 +53,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_round(final NumEvaluable a) public static NumberConstraint c_round(final NumberConstraint a)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -66,9 +66,9 @@ public class ConstraintFactory {
} }
public static RectEvaluable c_round(final RectEvaluable r) public static RectConstraint c_round(final RectConstraint r)
{ {
return new RectEvaluable() { return new RectConstraint() {
@Override @Override
public Rect getRect() public Rect getRect()
@ -79,9 +79,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_ceil(final NumEvaluable a) public static NumberConstraint c_ceil(final NumberConstraint a)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -92,9 +92,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_floor(final NumEvaluable a) public static NumberConstraint c_floor(final NumberConstraint a)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -105,9 +105,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_neg(final NumEvaluable a) public static NumberConstraint c_neg(final NumberConstraint a)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -118,9 +118,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_add(final NumEvaluable a, final NumEvaluable b) public static NumberConstraint c_add(final NumberConstraint a, final NumberConstraint b)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -131,9 +131,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_sub(final NumEvaluable a, final NumEvaluable b) public static NumberConstraint c_sub(final NumberConstraint a, final NumberConstraint b)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -144,9 +144,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_mul(final NumEvaluable a, final NumEvaluable b) public static NumberConstraint c_mul(final NumberConstraint a, final NumberConstraint b)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -157,9 +157,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_div(final NumEvaluable a, final NumEvaluable b) public static NumberConstraint c_div(final NumberConstraint a, final NumberConstraint b)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -170,9 +170,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_percent(final NumEvaluable whole, final NumEvaluable percent) public static NumberConstraint c_percent(final NumberConstraint whole, final NumberConstraint percent)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -183,9 +183,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_n(final double a) public static NumberConstraint c_n(final double a)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -196,9 +196,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_n(final AnimDouble a) public static NumberConstraint c_n(final AnimDouble a)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -209,9 +209,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_width(final RectEvaluable r) public static NumberConstraint c_width(final RectConstraint r)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -222,9 +222,9 @@ public class ConstraintFactory {
} }
public static NumEvaluable c_height(final RectEvaluable r) public static NumberConstraint c_height(final RectConstraint r)
{ {
return new NumEvaluable() { return new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -235,9 +235,9 @@ public class ConstraintFactory {
} }
public static RectEvaluable c_row(final RectEvaluable r, final int rows, final int index) public static RectConstraint c_row(final RectConstraint r, final int rows, final int index)
{ {
return new RectEvaluable() { return new RectConstraint() {
@Override @Override
public Rect getRect() public Rect getRect()
@ -254,9 +254,9 @@ public class ConstraintFactory {
} }
public static RectEvaluable c_column(final RectEvaluable r, final int columns, final int index) public static RectConstraint c_column(final RectConstraint r, final int columns, final int index)
{ {
return new RectEvaluable() { return new RectConstraint() {
@Override @Override
public Rect getRect() public Rect getRect()
@ -273,21 +273,21 @@ public class ConstraintFactory {
} }
public static RectEvaluable c_shrink(RectEvaluable r, NumEvaluable shrink) public static RectConstraint c_shrink(RectConstraint r, NumberConstraint shrink)
{ {
return c_shrink(r, shrink, shrink, shrink, shrink); return c_shrink(r, shrink, shrink, shrink, shrink);
} }
public static RectEvaluable c_shrink(RectEvaluable context, NumEvaluable horiz, NumEvaluable vert) public static RectConstraint c_shrink(RectConstraint context, NumberConstraint horiz, NumberConstraint vert)
{ {
return c_shrink(context, horiz, vert, horiz, vert); return c_shrink(context, horiz, vert, horiz, vert);
} }
public static RectEvaluable c_shrink(final RectEvaluable r, final NumEvaluable x1, final NumEvaluable y1, final NumEvaluable x2, final NumEvaluable y2) public static RectConstraint c_shrink(final RectConstraint r, final NumberConstraint x1, final NumberConstraint y1, final NumberConstraint x2, final NumberConstraint y2)
{ {
return new RectEvaluable() { return new RectConstraint() {
@Override @Override
public Rect getRect() public Rect getRect()
@ -298,9 +298,9 @@ public class ConstraintFactory {
} }
public static RectEvaluable c_center(final RectEvaluable r) public static RectConstraint c_center(final RectConstraint r)
{ {
return new RectEvaluable() { return new RectConstraint() {
@Override @Override
public Rect getRect() public Rect getRect()
@ -311,21 +311,21 @@ public class ConstraintFactory {
} }
public static RectEvaluable c_grow(RectEvaluable r, NumEvaluable grow) public static RectConstraint c_grow(RectConstraint r, NumberConstraint grow)
{ {
return c_grow(r, grow, grow, grow, grow); return c_grow(r, grow, grow, grow, grow);
} }
public static RectEvaluable c_grow(RectEvaluable r, NumEvaluable horiz, NumEvaluable vert) public static RectConstraint c_grow(RectConstraint r, NumberConstraint horiz, NumberConstraint vert)
{ {
return c_grow(r, horiz, vert, horiz, vert); return c_grow(r, horiz, vert, horiz, vert);
} }
public static RectEvaluable c_grow(final RectEvaluable r, final NumEvaluable x1, final NumEvaluable y1, final NumEvaluable x2, final NumEvaluable y2) public static RectConstraint c_grow(final RectConstraint r, final NumberConstraint x1, final NumberConstraint y1, final NumberConstraint x2, final NumberConstraint y2)
{ {
return new RectEvaluable() { return new RectConstraint() {
@Override @Override
public Rect getRect() public Rect getRect()
@ -336,9 +336,9 @@ public class ConstraintFactory {
} }
public static RectEvaluable c_tile(final RectEvaluable r, final int rows, final int cols, final int left, final int top) public static RectConstraint c_tile(final RectConstraint r, final int rows, final int cols, final int left, final int top)
{ {
return new RectEvaluable() { return new RectConstraint() {
@Override @Override
public Rect getRect() public Rect getRect()
@ -356,9 +356,9 @@ public class ConstraintFactory {
} }
public static RectEvaluable c_box(final RectEvaluable r, final NumEvaluable width, final NumEvaluable height) public static RectConstraint c_box(final RectConstraint r, final NumberConstraint width, final NumberConstraint height)
{ {
return new RectEvaluable() { return new RectConstraint() {
@Override @Override
public Rect getRect() public Rect getRect()
@ -378,9 +378,9 @@ public class ConstraintFactory {
} }
public static RectEvaluable c_box(final RectEvaluable r, final NumEvaluable x, final NumEvaluable y, final NumEvaluable width, final NumEvaluable height) public static RectConstraint c_box(final RectConstraint r, final NumberConstraint x, final NumberConstraint y, final NumberConstraint width, final NumberConstraint height)
{ {
return new RectEvaluable() { return new RectConstraint() {
@Override @Override
public Rect getRect() public Rect getRect()
@ -400,9 +400,9 @@ public class ConstraintFactory {
} }
public static RectEvaluable c_centered(final RectEvaluable r, final NumEvaluable x, final NumEvaluable y) public static RectConstraint c_centered(final RectConstraint r, final NumberConstraint x, final NumberConstraint y)
{ {
return new RectEvaluable() { return new RectConstraint() {
@Override @Override
public Rect getRect() public Rect getRect()
@ -415,9 +415,9 @@ public class ConstraintFactory {
} }
public static RectEvaluable c_box_abs(final RectEvaluable r, final NumEvaluable x1, final NumEvaluable y1, final NumEvaluable x2, final NumEvaluable y2) public static RectConstraint c_box_abs(final RectConstraint r, final NumberConstraint x1, final NumberConstraint y1, final NumberConstraint x2, final NumberConstraint y2)
{ {
return new RectEvaluable() { return new RectConstraint() {
@Override @Override
public Rect getRect() public Rect getRect()
@ -432,9 +432,9 @@ public class ConstraintFactory {
} }
public static RectEvaluable c_move(final RectEvaluable r, final NumEvaluable x, final NumEvaluable y) public static RectConstraint c_move(final RectConstraint r, final NumberConstraint x, final NumberConstraint y)
{ {
return new RectEvaluable() { return new RectConstraint() {
@Override @Override
public Rect getRect() public Rect getRect()

@ -6,11 +6,11 @@ import mightypork.utils.math.coord.Rect;
public class ContextAdapter implements PluggableContext { public class ContextAdapter implements PluggableContext {
private RectEvaluable backing = null; private RectConstraint backing = null;
@Override @Override
public void setContext(RectEvaluable rect) public void setContext(RectConstraint rect)
{ {
this.backing = rect; this.backing = rect;
} }

@ -1,7 +1,7 @@
package mightypork.utils.math.constraints; package mightypork.utils.math.constraints;
public interface NumEvaluable { public interface NumberConstraint {
double getValue(); double getValue();

@ -4,9 +4,9 @@ package mightypork.utils.math.constraints;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
public interface PluggableContext extends RectEvaluable { public interface PluggableContext extends RectConstraint {
abstract void setContext(RectEvaluable rect); abstract void setContext(RectConstraint rect);
@Override @Override

@ -0,0 +1,18 @@
package mightypork.utils.math.constraints;
import mightypork.utils.math.coord.Rect;
/**
* Rect constraint (ie. region)
*
* @author MightyPork
*/
public interface RectConstraint {
/**
* @return rect region
*/
Rect getRect();
}

@ -1,10 +0,0 @@
package mightypork.utils.math.constraints;
import mightypork.utils.math.coord.Rect;
public interface RectEvaluable {
Rect getRect();
}

@ -4,6 +4,7 @@ package mightypork.utils.math.coord;
import java.util.Random; import java.util.Random;
import mightypork.utils.math.Calc; import mightypork.utils.math.Calc;
import mightypork.utils.math.constraints.RectConstraint;
/** /**
@ -200,9 +201,10 @@ public class Coord {
* @param rect checked rect. * @param rect checked rect.
* @return is inside * @return is inside
*/ */
public boolean isInRect(Rect rect) public boolean isInRect(RectConstraint rect)
{ {
return isInRect(rect.getMin(), rect.getMax()); Rect r = rect.getRect();
return isInRect(r.getMin(), r.getMax());
} }

@ -1,7 +1,7 @@
package mightypork.utils.math.coord; package mightypork.utils.math.coord;
import mightypork.utils.control.interf.Updateable; import mightypork.gamecore.control.interf.Updateable;
import mightypork.utils.math.Calc; import mightypork.utils.math.Calc;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save