Not all fixed yet, but OMG that bounds system! Wow!
This commit is contained in:
@@ -109,7 +109,7 @@ public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable
|
||||
|
||||
fadeAnim.update(delta);
|
||||
|
||||
final double gain = getGain(fadeAnim.now());
|
||||
final double gain = getGain(fadeAnim.value());
|
||||
if (!paused && gain != lastUpdateGain) {
|
||||
AL10.alSourcef(sourceID, AL10.AL_GAIN, (float) gain);
|
||||
lastUpdateGain = gain;
|
||||
|
||||
@@ -3,6 +3,7 @@ package mightypork.gamecore.control.bus.events;
|
||||
|
||||
import mightypork.gamecore.control.bus.events.types.UnloggedEvent;
|
||||
import mightypork.utils.math.vect.Vect;
|
||||
import mightypork.utils.math.vect.VectVal;
|
||||
import mightypork.utils.math.vect.VectView;
|
||||
|
||||
|
||||
@@ -14,8 +15,8 @@ import mightypork.utils.math.vect.VectView;
|
||||
@UnloggedEvent
|
||||
public class MouseMotionEvent implements Event<MouseMotionEvent.Listener> {
|
||||
|
||||
private final VectView move;
|
||||
private final VectView pos;
|
||||
private final VectVal move;
|
||||
private final VectVal pos;
|
||||
|
||||
|
||||
/**
|
||||
@@ -31,7 +32,7 @@ public class MouseMotionEvent implements Event<MouseMotionEvent.Listener> {
|
||||
/**
|
||||
* @return movement since last {@link MouseMotionEvent}
|
||||
*/
|
||||
public VectView getMove()
|
||||
public VectVal getMove()
|
||||
{
|
||||
return move;
|
||||
}
|
||||
@@ -40,7 +41,7 @@ public class MouseMotionEvent implements Event<MouseMotionEvent.Listener> {
|
||||
/**
|
||||
* @return current mouse position
|
||||
*/
|
||||
public VectView getPos()
|
||||
public VectVal getPos()
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package mightypork.gamecore.gui.components;
|
||||
|
||||
|
||||
import mightypork.gamecore.control.AppAccess;
|
||||
import mightypork.gamecore.control.AppSubModule;
|
||||
import mightypork.gamecore.control.bus.BusAccess;
|
||||
import mightypork.gamecore.control.bus.clients.BusNode;
|
||||
import mightypork.utils.math.constraints.RectBound;
|
||||
import mightypork.utils.math.rect.RectView;
|
||||
|
||||
|
||||
public abstract class AbstractComponent extends AppSubModule implements PluggableRenderable {
|
||||
|
||||
private RectBound context;
|
||||
|
||||
public AbstractComponent(AppAccess app) {
|
||||
super(app);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContext(RectBound context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RectView getRect()
|
||||
{
|
||||
return context.getRect();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package mightypork.gamecore.gui.components;
|
||||
|
||||
|
||||
import mightypork.utils.math.constraints.PluggableRect;
|
||||
import mightypork.utils.math.constraints.PluggableRectBound;
|
||||
import mightypork.utils.math.constraints.RectBound;
|
||||
import mightypork.utils.math.rect.RectView;
|
||||
|
||||
@@ -11,7 +11,7 @@ import mightypork.utils.math.rect.RectView;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public interface PluggableRenderable extends Renderable, PluggableRect {
|
||||
public interface PluggableRenderable extends Renderable, PluggableRectBound {
|
||||
|
||||
@Override
|
||||
void render();
|
||||
|
||||
+16
-32
@@ -5,30 +5,28 @@ import java.util.LinkedList;
|
||||
|
||||
import mightypork.gamecore.control.AppAccess;
|
||||
import mightypork.gamecore.control.bus.EventBus;
|
||||
import mightypork.gamecore.control.bus.clients.BusNode;
|
||||
import mightypork.gamecore.gui.components.AbstractComponent;
|
||||
import mightypork.gamecore.gui.components.PluggableRenderable;
|
||||
import mightypork.gamecore.gui.components.PluggableRenderer;
|
||||
import mightypork.gamecore.gui.components.Renderable;
|
||||
import mightypork.gamecore.gui.components.painters.AbstractPainter;
|
||||
import mightypork.utils.math.constraints.RectBound;
|
||||
import mightypork.utils.math.rect.RectView;
|
||||
|
||||
|
||||
/**
|
||||
* Bag for {@link PluggableRenderer} elements with constraints.<br>
|
||||
* Bag for {@link AbstractPainter} elements with constraints.<br>
|
||||
* Elements are exposed to {@link EventBus}.
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public abstract class ElementHolder extends BusNode implements PluggableRenderable {
|
||||
public abstract class AbstractLayout extends AbstractComponent {
|
||||
|
||||
private final LinkedList<PluggableRenderable> elements = new LinkedList<>();
|
||||
private RectBound context;
|
||||
final LinkedList<PluggableRenderable> elements = new LinkedList<>();
|
||||
|
||||
|
||||
/**
|
||||
* @param app app access
|
||||
*/
|
||||
public ElementHolder(AppAccess app) {
|
||||
public AbstractLayout(AppAccess app) {
|
||||
super(app);
|
||||
}
|
||||
|
||||
@@ -37,35 +35,12 @@ public abstract class ElementHolder extends BusNode implements PluggableRenderab
|
||||
* @param app app access
|
||||
* @param context boudning context
|
||||
*/
|
||||
public ElementHolder(AppAccess app, RectBound context) {
|
||||
public AbstractLayout(AppAccess app, RectBound context) {
|
||||
super(app);
|
||||
setContext(context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setContext(RectBound context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void render()
|
||||
{
|
||||
for (final Renderable element : elements) {
|
||||
element.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RectView getRect()
|
||||
{
|
||||
return context.getRect();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add element to the holder, setting it's context.<br>
|
||||
* Element must then be attached using the <code>attach</code> method.
|
||||
@@ -88,4 +63,13 @@ public abstract class ElementHolder extends BusNode implements PluggableRenderab
|
||||
addChildClient(elem);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void render()
|
||||
{
|
||||
for (final Renderable element : elements) {
|
||||
element.render();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import mightypork.utils.math.constraints.RectBound;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class ColumnHolder extends ElementHolder {
|
||||
public class ColumnHolder extends AbstractLayout {
|
||||
|
||||
private final int cols;
|
||||
private int col = 0;
|
||||
|
||||
@@ -12,7 +12,7 @@ import mightypork.utils.math.constraints.RectBound;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class RowHolder extends ElementHolder {
|
||||
public class RowHolder extends AbstractLayout {
|
||||
|
||||
private final int rows;
|
||||
private int row = 0;
|
||||
|
||||
+5
-3
@@ -1,7 +1,9 @@
|
||||
package mightypork.gamecore.gui.components;
|
||||
package mightypork.gamecore.gui.components.painters;
|
||||
|
||||
|
||||
import mightypork.utils.math.constraints.ContextAdapter;
|
||||
import mightypork.gamecore.gui.components.PluggableRenderable;
|
||||
import mightypork.gamecore.gui.components.Renderable;
|
||||
import mightypork.utils.math.constraints.RectBoundAdapter;
|
||||
import mightypork.utils.math.constraints.RectBound;
|
||||
import mightypork.utils.math.rect.RectView;
|
||||
|
||||
@@ -11,7 +13,7 @@ import mightypork.utils.math.rect.RectView;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public abstract class PluggableRenderer extends ContextAdapter implements PluggableRenderable {
|
||||
public abstract class AbstractPainter extends RectBoundAdapter implements PluggableRenderable {
|
||||
|
||||
@Override
|
||||
public abstract void render();
|
||||
@@ -1,7 +1,6 @@
|
||||
package mightypork.gamecore.gui.components.painters;
|
||||
|
||||
|
||||
import mightypork.gamecore.gui.components.PluggableRenderer;
|
||||
import mightypork.gamecore.render.Render;
|
||||
import mightypork.gamecore.render.textures.TxQuad;
|
||||
|
||||
@@ -11,7 +10,7 @@ import mightypork.gamecore.render.textures.TxQuad;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class ImagePainter extends PluggableRenderer {
|
||||
public class ImagePainter extends AbstractPainter {
|
||||
|
||||
private TxQuad texture;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mightypork.gamecore.gui.components.painters;
|
||||
|
||||
|
||||
import mightypork.gamecore.gui.components.PluggableRenderer;
|
||||
import mightypork.gamecore.render.Render;
|
||||
import mightypork.utils.annotations.FactoryMethod;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
@@ -12,7 +11,7 @@ import mightypork.utils.math.color.RGB;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class QuadPainter extends PluggableRenderer {
|
||||
public class QuadPainter extends AbstractPainter {
|
||||
|
||||
private final RGB colorHMinVMin;
|
||||
private final RGB colorHMaxVMin;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mightypork.gamecore.gui.components.painters;
|
||||
|
||||
|
||||
import mightypork.gamecore.gui.components.PluggableRenderer;
|
||||
import mightypork.gamecore.render.fonts.FontRenderer;
|
||||
import mightypork.gamecore.render.fonts.FontRenderer.Align;
|
||||
import mightypork.gamecore.render.fonts.GLFont;
|
||||
@@ -20,7 +19,7 @@ import mightypork.utils.string.StringProvider.StringWrapper;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class TextPainter extends PluggableRenderer {
|
||||
public class TextPainter extends AbstractPainter {
|
||||
|
||||
private final FontRenderer font;
|
||||
private RGB color;
|
||||
|
||||
@@ -10,6 +10,7 @@ import mightypork.utils.files.FileUtils;
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.math.rect.Rect;
|
||||
import mightypork.utils.math.rect.RectView;
|
||||
import mightypork.utils.math.vect.Vect;
|
||||
import mightypork.utils.math.vect.VectVal;
|
||||
import mightypork.utils.math.vect.VectView;
|
||||
@@ -351,10 +352,12 @@ public class Render {
|
||||
*/
|
||||
public static void quad(Rect quad)
|
||||
{
|
||||
final double x1 = quad.left();
|
||||
final double y1 = quad.top();
|
||||
final double x2 = quad.right();
|
||||
final double y2 = quad.bottom();
|
||||
RectView rv = quad.view();
|
||||
|
||||
final double x1 = rv.left().value();
|
||||
final double y1 = rv.top().value();
|
||||
final double x2 = rv.right().value();
|
||||
final double y2 = rv.bottom().value();
|
||||
|
||||
// draw with color
|
||||
unbindTexture();
|
||||
|
||||
Reference in New Issue
Block a user