Moved some classes. Added LayoutChangeEvent class.

v5stable
Ondřej Hruška 11 years ago
parent e7225d1ee0
commit eb981454c0
  1. 4
      src/mightypork/gamecore/audio/players/LoopPlayer.java
  2. 31
      src/mightypork/gamecore/control/bus/EventBus.java
  3. 4
      src/mightypork/gamecore/control/bus/clients/DelegatingClient.java
  4. 26
      src/mightypork/gamecore/control/bus/events/LayoutChangeEvent.java
  5. 2
      src/mightypork/gamecore/control/bus/events/MouseButtonEvent.java
  6. 2
      src/mightypork/gamecore/gui/components/BusEnabledPainter.java
  7. 2
      src/mightypork/gamecore/gui/components/Component.java
  8. 4
      src/mightypork/gamecore/gui/components/PluggableRenderable.java
  9. 2
      src/mightypork/gamecore/gui/components/SimplePainter.java
  10. 2
      src/mightypork/gamecore/gui/components/layout/AbstractLayout.java
  11. 2
      src/mightypork/gamecore/gui/components/layout/ColumnHolder.java
  12. 2
      src/mightypork/gamecore/gui/components/layout/RowHolder.java
  13. 2
      src/mightypork/gamecore/gui/screens/Screen.java
  14. 2
      src/mightypork/gamecore/gui/screens/ScreenLayer.java
  15. 2
      src/mightypork/gamecore/render/DisplaySystem.java
  16. 2
      src/mightypork/rogue/screens/LayerFps.java
  17. 6
      src/mightypork/rogue/screens/test_bouncyboxes/BouncyBox.java
  18. 6
      src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java
  19. 2
      src/mightypork/rogue/screens/test_render/LayerTestGradient.java
  20. 1
      src/mightypork/utils/math/Calc.java
  21. 2
      src/mightypork/utils/math/Easing.java
  22. 8
      src/mightypork/utils/math/Polar.java
  23. 18
      src/mightypork/utils/math/constraints/num/NumAnimated.java
  24. 11
      src/mightypork/utils/math/constraints/num/NumAnimatedDeg.java
  25. 11
      src/mightypork/utils/math/constraints/num/NumAnimatedRad.java
  26. 1
      src/mightypork/utils/math/constraints/num/NumBound.java
  27. 1
      src/mightypork/utils/math/constraints/num/NumBoundAdapter.java
  28. 3
      src/mightypork/utils/math/constraints/num/PluggableNumBound.java
  29. 2
      src/mightypork/utils/math/constraints/rect/PluggableRectBound.java
  30. 1
      src/mightypork/utils/math/constraints/rect/Rect.java
  31. 3
      src/mightypork/utils/math/constraints/rect/RectBound.java
  32. 2
      src/mightypork/utils/math/constraints/rect/RectBoundAdapter.java
  33. 2
      src/mightypork/utils/math/constraints/vect/PluggableVectBound.java
  34. 1
      src/mightypork/utils/math/constraints/vect/Vect.java
  35. 16
      src/mightypork/utils/math/constraints/vect/VectAnimated.java
  36. 3
      src/mightypork/utils/math/constraints/vect/VectBound.java
  37. 2
      src/mightypork/utils/math/constraints/vect/VectBoundAdapter.java

@ -5,7 +5,7 @@ import mightypork.gamecore.audio.DeferredAudio;
import mightypork.gamecore.audio.Volume;
import mightypork.gamecore.control.timing.Pauseable;
import mightypork.gamecore.control.timing.Updateable;
import mightypork.utils.math.animation.AnimDouble;
import mightypork.utils.math.constraints.num.NumAnimated;
import org.lwjgl.openal.AL10;
@ -20,7 +20,7 @@ public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable
private int sourceID = -1;
/** animator for fade in and fade out */
private final AnimDouble fadeAnim = new AnimDouble(0);
private final NumAnimated fadeAnim = new NumAnimated(0);
private double lastUpdateGain = 0;

@ -1,10 +1,12 @@
package mightypork.gamecore.control.bus;
import java.util.Collection;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
import mightypork.gamecore.control.bus.clients.DelegatingClient;
import mightypork.gamecore.control.bus.events.Event;
import mightypork.gamecore.control.bus.events.types.DelayedEvent;
import mightypork.gamecore.control.bus.events.types.ImmediateEvent;
@ -116,7 +118,7 @@ final public class EventBus implements Destroyable {
/**
* Send based on annotation.
* Send based on annotation.clients
*
* @param event event
*/
@ -187,6 +189,16 @@ final public class EventBus implements Destroyable {
}
public void sendDirectToChildren(DelegatingClient delegatingClient, Event<?> event)
{
assertLive();
if (shallLog(event)) Log.f3("<bus> Di sub " + Log.str(event));
doDispatch(delegatingClient.getChildClients(), event);
}
/**
* Send immediately.<br>
* Should be used for real-time events that require immediate response, such
@ -201,6 +213,21 @@ final public class EventBus implements Destroyable {
channels.setBuffering(true);
clients.setBuffering(true);
doDispatch(clients, event);
channels.setBuffering(false);
clients.setBuffering(false);
}
/**
* Send to a set of clients
*
* @param clients clients
* @param event event
*/
private void doDispatch(Collection<Object> clients, Event<?> event)
{
boolean sent = false;
boolean accepted = false;
@ -218,8 +245,6 @@ final public class EventBus implements Destroyable {
if (!accepted) Log.e("<bus> Not accepted by any channel: " + Log.str(event));
if (!sent && shallLog(event)) Log.w("<bus> Not delivered: " + Log.str(event));
channels.setBuffering(false);
clients.setBuffering(false);
}

@ -5,7 +5,9 @@ import java.util.Collection;
/**
* Client containing child clients
* Client containing child clients. According to the contract, if the collection
* of clients is ordered, the clients will be served in that order. In any case,
* the {@link DelegatingClient} itself will be served beforehand.
*
* @author MightyPork
*/

@ -0,0 +1,26 @@
package mightypork.gamecore.control.bus.events;
import mightypork.gamecore.control.bus.events.types.ImmediateEvent;
import mightypork.gamecore.control.timing.Pollable;
/**
* Intended use is to notify UI component sub-clients that they should poll
* their cached constraints.
*
* @author MightyPork
*/
@ImmediateEvent
public class LayoutChangeEvent implements Event<Pollable> {
public LayoutChangeEvent() {
}
@Override
public void handleBy(Pollable handler)
{
handler.poll();
}
}

@ -1,7 +1,7 @@
package mightypork.gamecore.control.bus.events;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.RectBound;
import mightypork.utils.math.constraints.vect.Vect;

@ -10,8 +10,8 @@ import mightypork.gamecore.control.bus.EventBus;
import mightypork.gamecore.control.bus.clients.ClientHub;
import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.render.DisplaySystem;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.RectBound;
public abstract class BusEnabledPainter extends SimplePainter implements ClientHub, Component, AppAccess {

@ -4,8 +4,8 @@ package mightypork.gamecore.gui.components;
import mightypork.gamecore.control.bus.clients.ToggleableClient;
import mightypork.gamecore.control.interf.Enableable;
import mightypork.gamecore.gui.Hideable;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.RectBound;
/**

@ -1,9 +1,9 @@
package mightypork.gamecore.gui.components;
import mightypork.utils.math.constraints.PluggableRectBound;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.PluggableRectBound;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.RectBound;
/**

@ -1,8 +1,8 @@
package mightypork.gamecore.gui.components;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.RectBound;
import mightypork.utils.math.constraints.rect.RectBoundAdapter;

@ -9,7 +9,7 @@ import mightypork.gamecore.gui.components.BusEnabledPainter;
import mightypork.gamecore.gui.components.PluggableRenderable;
import mightypork.gamecore.gui.components.Renderable;
import mightypork.gamecore.gui.components.SimplePainter;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.RectBound;
/**

@ -3,7 +3,7 @@ package mightypork.gamecore.gui.components.layout;
import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.gui.components.PluggableRenderable;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.RectBound;
import mightypork.utils.math.constraints.rect.TiledRect;

@ -3,7 +3,7 @@ package mightypork.gamecore.gui.components.layout;
import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.gui.components.PluggableRenderable;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.RectBound;
import mightypork.utils.math.constraints.rect.TiledRect;

@ -10,8 +10,8 @@ import mightypork.gamecore.input.KeyBindingPool;
import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.render.Render;
import mightypork.utils.annotations.DefaultImpl;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.RectBound;
import mightypork.utils.math.constraints.vect.Vect;

@ -8,8 +8,8 @@ import mightypork.gamecore.input.KeyBinder;
import mightypork.gamecore.input.KeyBindingPool;
import mightypork.gamecore.input.KeyStroke;
import mightypork.utils.annotations.DefaultImpl;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.RectBound;
import mightypork.utils.math.constraints.vect.Vect;

@ -10,8 +10,8 @@ import mightypork.gamecore.control.AppModule;
import mightypork.gamecore.control.bus.events.ScreenChangeEvent;
import mightypork.gamecore.control.timing.FpsMeter;
import mightypork.utils.logging.Log;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.RectBound;
import mightypork.utils.math.constraints.vect.Vect;
import org.lwjgl.BufferUtils;

@ -11,7 +11,7 @@ import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.gamecore.render.fonts.GLFont;
import mightypork.rogue.Res;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.RectBound;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.string.StringProvider;

@ -7,9 +7,9 @@ import mightypork.gamecore.control.bus.events.ScreenChangeEvent;
import mightypork.gamecore.control.timing.Updateable;
import mightypork.gamecore.gui.components.SimplePainter;
import mightypork.gamecore.render.Render;
import mightypork.utils.math.animation.AnimDouble;
import mightypork.utils.math.animation.Easing;
import mightypork.utils.math.Easing;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.num.NumAnimated;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.rect.Rect;
@ -20,7 +20,7 @@ public class BouncyBox extends SimplePainter implements Updateable, ScreenChange
private final Rect box;
private final AnimDouble pos = new AnimDouble(0, Easing.BOUNCE_OUT);
private final NumAnimated pos = new NumAnimated(0, Easing.BOUNCE_OUT);
public BouncyBox() {

@ -14,9 +14,9 @@ import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys;
import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.rogue.Res;
import mightypork.utils.math.animation.AnimDouble;
import mightypork.utils.math.animation.Easing;
import mightypork.utils.math.Easing;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.num.NumAnimated;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.vect.Vect;
@ -25,7 +25,7 @@ import mightypork.utils.math.constraints.vect.VectAnimated;
public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButtonEvent.Listener {
private final AnimDouble size = new AnimDouble(400, Easing.SINE_BOTH);
private final NumAnimated size = new NumAnimated(400, Easing.SINE_BOTH);
private final VectAnimated pos = VectAnimated.makeVar(Easing.ELASTIC_OUT);
private final Random rand = new Random();

@ -5,7 +5,7 @@ import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.render.Render;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.rect.RectBound;
public class LayerTestGradient extends ScreenLayer {

@ -6,7 +6,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import mightypork.utils.math.animation.Easing;
import mightypork.utils.math.constraints.vect.Vect;
import org.lwjgl.BufferUtils;

@ -1,4 +1,4 @@
package mightypork.utils.math.animation;
package mightypork.utils.math;
import mightypork.utils.annotations.FactoryMethod;

@ -1,8 +1,6 @@
package mightypork.utils.math;
import mightypork.utils.math.Calc.Deg;
import mightypork.utils.math.Calc.Rad;
import mightypork.utils.math.constraints.vect.Vect;
@ -42,7 +40,7 @@ public class Polar {
*/
public Polar(double angle, boolean deg, double distance) {
this.radius = distance;
this.angle = deg ? Deg.toRad(angle) : angle;
this.angle = deg ? Math.toRadians(angle) : angle;
}
@ -60,7 +58,7 @@ public class Polar {
*/
public double getAngleDeg()
{
return Rad.toDeg(angle);
return Math.toDegrees(angle);
}
@ -78,7 +76,7 @@ public class Polar {
*/
public void setAngleDeg(double angle)
{
this.angle = Deg.toRad(angle);
this.angle = Math.toRadians(angle);
}

@ -1,10 +1,10 @@
package mightypork.utils.math.animation;
package mightypork.utils.math.constraints.num;
import mightypork.gamecore.control.timing.Pauseable;
import mightypork.gamecore.control.timing.Updateable;
import mightypork.utils.math.Calc;
import mightypork.utils.math.constraints.num.NumMutable;
import mightypork.utils.math.Easing;
/**
@ -12,7 +12,7 @@ import mightypork.utils.math.constraints.num.NumMutable;
*
* @author MightyPork
*/
public class AnimDouble extends NumMutable implements Updateable, Pauseable {
public class NumAnimated extends NumMutable implements Updateable, Pauseable {
/** target double */
protected double to = 0;
@ -41,7 +41,7 @@ public class AnimDouble extends NumMutable implements Updateable, Pauseable {
*
* @param value initial value
*/
public AnimDouble(double value) {
public NumAnimated(double value) {
setTo(value);
}
@ -52,7 +52,7 @@ public class AnimDouble extends NumMutable implements Updateable, Pauseable {
* @param value initial value
* @param easing easing function
*/
public AnimDouble(double value, Easing easing) {
public NumAnimated(double value, Easing easing) {
this(value);
setEasing(easing);
}
@ -63,7 +63,7 @@ public class AnimDouble extends NumMutable implements Updateable, Pauseable {
*
* @param other other animator
*/
public AnimDouble(AnimDouble other) {
public NumAnimated(NumAnimated other) {
setTo(other);
}
@ -213,7 +213,7 @@ public class AnimDouble extends NumMutable implements Updateable, Pauseable {
*
* @param other
*/
public void setTo(AnimDouble other)
public void setTo(NumAnimated other)
{
this.from = other.from;
this.to = other.to;
@ -314,9 +314,9 @@ public class AnimDouble extends NumMutable implements Updateable, Pauseable {
* @return copy
*/
@Override
public AnimDouble clone()
public NumAnimated clone()
{
return new AnimDouble(this);
return new NumAnimated(this);
}

@ -1,7 +1,8 @@
package mightypork.utils.math.animation;
package mightypork.utils.math.constraints.num;
import mightypork.utils.math.Calc;
import mightypork.utils.math.Easing;
import mightypork.utils.math.Calc.Deg;
@ -10,19 +11,19 @@ import mightypork.utils.math.Calc.Deg;
*
* @author MightyPork
*/
public class AnimDoubleDeg extends AnimDouble {
public class NumAnimatedDeg extends NumAnimated {
public AnimDoubleDeg(AnimDouble other) {
public NumAnimatedDeg(NumAnimated other) {
super(other);
}
public AnimDoubleDeg(double value) {
public NumAnimatedDeg(double value) {
super(value);
}
public AnimDoubleDeg(double value, Easing easing) {
public NumAnimatedDeg(double value, Easing easing) {
super(value, easing);
}

@ -1,7 +1,8 @@
package mightypork.utils.math.animation;
package mightypork.utils.math.constraints.num;
import mightypork.utils.math.Calc;
import mightypork.utils.math.Easing;
import mightypork.utils.math.Calc.Rad;
@ -10,19 +11,19 @@ import mightypork.utils.math.Calc.Rad;
*
* @author MightyPork
*/
public class AnimDoubleRad extends AnimDouble {
public class NumAnimatedRad extends NumAnimated {
public AnimDoubleRad(AnimDouble other) {
public NumAnimatedRad(NumAnimated other) {
super(other);
}
public AnimDoubleRad(double value) {
public NumAnimatedRad(double value) {
super(value);
}
public AnimDoubleRad(double value, Easing easing) {
public NumAnimatedRad(double value, Easing easing) {
super(value, easing);
}

@ -1,6 +1,7 @@
package mightypork.utils.math.constraints.num;
/**
* Numeric constraint
*

@ -1,7 +1,6 @@
package mightypork.utils.math.constraints.num;
import mightypork.utils.math.constraints.PluggableNumBound;
public class NumBoundAdapter extends NumAdapter implements PluggableNumBound {

@ -1,7 +1,6 @@
package mightypork.utils.math.constraints;
package mightypork.utils.math.constraints.num;
import mightypork.utils.math.constraints.num.NumBound;
/**

@ -1,4 +1,4 @@
package mightypork.utils.math.constraints;
package mightypork.utils.math.constraints.rect;
/**

@ -3,7 +3,6 @@ package mightypork.utils.math.constraints.rect;
import mightypork.utils.annotations.FactoryMethod;
import mightypork.utils.math.constraints.Digestable;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.num.NumConst;
import mightypork.utils.math.constraints.vect.Vect;

@ -1,7 +1,6 @@
package mightypork.utils.math.constraints;
package mightypork.utils.math.constraints.rect;
import mightypork.utils.math.constraints.rect.Rect;
/**

@ -1,8 +1,6 @@
package mightypork.utils.math.constraints.rect;
import mightypork.utils.math.constraints.PluggableRectBound;
import mightypork.utils.math.constraints.RectBound;
/**

@ -1,4 +1,4 @@
package mightypork.utils.math.constraints;
package mightypork.utils.math.constraints.vect;
/**

@ -4,7 +4,6 @@ package mightypork.utils.math.constraints.vect;
import mightypork.utils.annotations.DefaultImpl;
import mightypork.utils.annotations.FactoryMethod;
import mightypork.utils.math.constraints.Digestable;
import mightypork.utils.math.constraints.VectBound;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.num.NumConst;
import mightypork.utils.math.constraints.rect.Rect;

@ -4,8 +4,8 @@ package mightypork.utils.math.constraints.vect;
import mightypork.gamecore.control.timing.Pauseable;
import mightypork.gamecore.control.timing.Updateable;
import mightypork.utils.annotations.FactoryMethod;
import mightypork.utils.math.animation.AnimDouble;
import mightypork.utils.math.animation.Easing;
import mightypork.utils.math.Easing;
import mightypork.utils.math.constraints.num.NumAnimated;
/**
@ -15,7 +15,7 @@ import mightypork.utils.math.animation.Easing;
*/
public class VectAnimated extends VectMutable implements Pauseable, Updateable {
private final AnimDouble x, y, z;
private final NumAnimated x, y, z;
private double defaultDuration = 0;
@ -27,7 +27,7 @@ public class VectAnimated extends VectMutable implements Pauseable, Updateable {
* @param y y animator
* @param z z animator
*/
public VectAnimated(AnimDouble x, AnimDouble y, AnimDouble z) {
public VectAnimated(NumAnimated x, NumAnimated y, NumAnimated z) {
this.x = x;
this.y = y;
this.z = z;
@ -41,9 +41,9 @@ public class VectAnimated extends VectMutable implements Pauseable, Updateable {
* @param easing animation easing
*/
public VectAnimated(Vect start, Easing easing) {
x = new AnimDouble(start.x(), easing);
y = new AnimDouble(start.y(), easing);
z = new AnimDouble(start.z(), easing);
x = new NumAnimated(start.x(), easing);
y = new NumAnimated(start.y(), easing);
z = new NumAnimated(start.z(), easing);
}
@ -255,7 +255,7 @@ public class VectAnimated extends VectMutable implements Pauseable, Updateable {
* @return animated mutable vector
*/
@FactoryMethod
public static VectAnimated makeVar(AnimDouble x, AnimDouble y, AnimDouble z)
public static VectAnimated makeVar(NumAnimated x, NumAnimated y, NumAnimated z)
{
return new VectAnimated(x, y, z);
}

@ -1,7 +1,6 @@
package mightypork.utils.math.constraints;
package mightypork.utils.math.constraints.vect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -1,8 +1,6 @@
package mightypork.utils.math.constraints.vect;
import mightypork.utils.math.constraints.PluggableVectBound;
import mightypork.utils.math.constraints.VectBound;
public class VectBoundAdapter extends VectAdapter implements PluggableVectBound {

Loading…
Cancel
Save