almost fixed constraints and rects; about time to go sleep now, lol
This commit is contained in:
@@ -32,7 +32,7 @@ public class SoundSystem extends RootBusNode implements Updateable {
|
||||
private static final Vec INITIAL_LISTENER_POS = Vec.ZERO;
|
||||
private static final int MAX_SOURCES = 256;
|
||||
|
||||
private static VecMutable listener = new MutableCoord(0,0,0);
|
||||
private static VecMutable listener = new MutableCoord(0, 0, 0);
|
||||
|
||||
private static boolean inited;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package mightypork.gamecore.gui.components;
|
||||
|
||||
import mightypork.utils.math.constraints.PluggableContext;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
import mightypork.utils.math.rect.Rect;
|
||||
import mightypork.utils.math.rect.RectView;
|
||||
|
||||
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ public interface PluggableRenderable extends Renderable, PluggableContext {
|
||||
|
||||
|
||||
@Override
|
||||
Rect getRect();
|
||||
RectView getRect();
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,7 @@ package mightypork.gamecore.gui.components;
|
||||
|
||||
import mightypork.utils.math.constraints.ContextAdapter;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
import mightypork.utils.math.rect.Rect;
|
||||
import mightypork.utils.math.rect.RectView;
|
||||
|
||||
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ public abstract class PluggableRenderer extends ContextAdapter implements Plugga
|
||||
|
||||
|
||||
@Override
|
||||
public Rect getRect()
|
||||
public RectView getRect()
|
||||
{
|
||||
return super.getRect();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import mightypork.gamecore.gui.components.PluggableRenderable;
|
||||
import mightypork.gamecore.gui.components.PluggableRenderer;
|
||||
import mightypork.gamecore.gui.components.Renderable;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
import mightypork.utils.math.rect.Rect;
|
||||
import mightypork.utils.math.rect.RectView;
|
||||
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ public abstract class ElementHolder extends BusNode implements PluggableRenderab
|
||||
|
||||
|
||||
@Override
|
||||
public Rect getRect()
|
||||
public RectView getRect()
|
||||
{
|
||||
return context.getRect();
|
||||
}
|
||||
|
||||
@@ -6,11 +6,10 @@ import mightypork.gamecore.render.fonts.FontRenderer;
|
||||
import mightypork.gamecore.render.fonts.FontRenderer.Align;
|
||||
import mightypork.gamecore.render.fonts.GLFont;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.math.coord.CoordValue;
|
||||
import mightypork.utils.math.coord.MutableCoord;
|
||||
import mightypork.utils.math.coord.Vec;
|
||||
import mightypork.utils.math.coord.VecMutable;
|
||||
import mightypork.utils.math.rect.Rect;
|
||||
import mightypork.utils.math.rect.RectView;
|
||||
import mightypork.utils.string.StringProvider;
|
||||
import mightypork.utils.string.StringProvider.StringWrapper;
|
||||
|
||||
@@ -31,7 +30,7 @@ public class TextPainter extends PluggableRenderer {
|
||||
private boolean shadow;
|
||||
|
||||
private RGB shadowColor = RGB.BLACK;
|
||||
private VecMutable shadowOffset = new MutableCoord(1, 1);
|
||||
private final VecMutable shadowOffset = new MutableCoord(1, 1);
|
||||
|
||||
|
||||
/**
|
||||
@@ -87,7 +86,7 @@ public class TextPainter extends PluggableRenderer {
|
||||
if (text == null) return;
|
||||
|
||||
final String str = text.getString();
|
||||
final Rect rect = getRect();
|
||||
final RectView rect = getRect();
|
||||
|
||||
if (shadow) {
|
||||
font.draw(str, rect.move(shadowOffset), align, shadowColor);
|
||||
|
||||
@@ -12,7 +12,7 @@ import mightypork.gamecore.input.KeyStroke;
|
||||
import mightypork.gamecore.render.Render;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
import mightypork.utils.math.coord.Vec;
|
||||
import mightypork.utils.math.rect.Rect;
|
||||
import mightypork.utils.math.rect.RectView;
|
||||
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ public abstract class Screen extends AppSubModule implements Renderable, KeyBind
|
||||
|
||||
|
||||
@Override
|
||||
public Rect getRect()
|
||||
public RectView getRect()
|
||||
{
|
||||
return getDisplay().getRect();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mightypork.gamecore.gui.screens;
|
||||
|
||||
|
||||
import mightypork.gamecore.control.AppAccess;
|
||||
import mightypork.gamecore.control.AppSubModule;
|
||||
import mightypork.gamecore.control.interf.DefaultImpl;
|
||||
import mightypork.gamecore.gui.components.Renderable;
|
||||
@@ -10,7 +9,7 @@ import mightypork.gamecore.input.KeyBindingPool;
|
||||
import mightypork.gamecore.input.KeyStroke;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
import mightypork.utils.math.coord.Vec;
|
||||
import mightypork.utils.math.rect.Rect;
|
||||
import mightypork.utils.math.rect.RectView;
|
||||
|
||||
|
||||
/**
|
||||
@@ -60,7 +59,7 @@ public abstract class ScreenLayer extends AppSubModule implements Comparable<Scr
|
||||
|
||||
|
||||
@Override
|
||||
public Rect getRect()
|
||||
public RectView getRect()
|
||||
{
|
||||
return screen.getRect();
|
||||
}
|
||||
@@ -110,6 +109,4 @@ public abstract class ScreenLayer extends AppSubModule implements Comparable<Scr
|
||||
*/
|
||||
public abstract int getPriority();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,14 +10,11 @@ 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.Constraints;
|
||||
import mightypork.utils.math.constraints.NumberConstraint;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
import mightypork.utils.math.coord.ConstraintCoord;
|
||||
import mightypork.utils.math.coord.SynthCoord2D;
|
||||
import mightypork.utils.math.coord.Vec;
|
||||
import mightypork.utils.math.coord.FixedCoord;
|
||||
import mightypork.utils.math.coord.VecView;
|
||||
import mightypork.utils.math.rect.Rect;
|
||||
import mightypork.utils.math.rect.FixedRect;
|
||||
import mightypork.utils.math.rect.RectView;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
@@ -180,7 +177,7 @@ public class DisplaySystem extends AppModule implements RectConstraint {
|
||||
*/
|
||||
public static VecView getSize()
|
||||
{
|
||||
return size;
|
||||
return new FixedCoord(getWidth(), getHeight());
|
||||
}
|
||||
|
||||
|
||||
@@ -229,9 +226,9 @@ public class DisplaySystem extends AppModule implements RectConstraint {
|
||||
|
||||
|
||||
@Override
|
||||
public Rect getRect()
|
||||
public RectView getRect()
|
||||
{
|
||||
return new Rect(Vec.ZERO, getSize());
|
||||
return new FixedRect(getSize());
|
||||
}
|
||||
|
||||
|
||||
@@ -242,49 +239,49 @@ public class DisplaySystem extends AppModule implements RectConstraint {
|
||||
{
|
||||
return fpsMeter.getFPS();
|
||||
}
|
||||
|
||||
public Vec getCenter()
|
||||
|
||||
|
||||
public VecView getCenter()
|
||||
{
|
||||
return center;
|
||||
return getSize().half();
|
||||
}
|
||||
|
||||
private static final VecView size = new SynthCoord2D() {
|
||||
|
||||
@Override
|
||||
public double y()
|
||||
{
|
||||
return getHeight();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double x()
|
||||
{
|
||||
return getWidth();
|
||||
}
|
||||
};
|
||||
|
||||
/** Screen width constraint */
|
||||
private static final NumberConstraint width = size.xc();
|
||||
|
||||
/** Screen height constaint */
|
||||
private static final NumberConstraint height = size.yc();
|
||||
|
||||
|
||||
private static final VecView center = new SynthCoord2D() {
|
||||
|
||||
@Override
|
||||
public double y()
|
||||
{
|
||||
return size.half().x();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double x()
|
||||
{
|
||||
return size.half().y();
|
||||
}
|
||||
};
|
||||
// private static final VecView size = new SynthCoord2D() {
|
||||
//
|
||||
// @Override
|
||||
// public double y()
|
||||
// {
|
||||
// return getHeight();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public double x()
|
||||
// {
|
||||
// return getWidth();
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// /** Screen width constraint */
|
||||
// private static final NumberConstraint width = size.xc();
|
||||
//
|
||||
// /** Screen height constaint */
|
||||
// private static final NumberConstraint height = size.yc();
|
||||
//
|
||||
// private static final VecView center = new SynthCoord2D() {
|
||||
//
|
||||
// @Override
|
||||
// public double y()
|
||||
// {
|
||||
// return size.half().x();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public double x()
|
||||
// {
|
||||
// return size.half().y();
|
||||
// }
|
||||
// };
|
||||
|
||||
}
|
||||
|
||||
@@ -9,10 +9,8 @@ import mightypork.gamecore.render.textures.TxQuad;
|
||||
import mightypork.utils.files.FileUtils;
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.math.coord.CoordValue;
|
||||
import mightypork.utils.math.coord.FixedCoord;
|
||||
import mightypork.utils.math.coord.Vec;
|
||||
import mightypork.utils.math.coord.VecView;
|
||||
import mightypork.utils.math.rect.Rect;
|
||||
import mightypork.utils.math.rect.Rect;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -29,9 +27,9 @@ import org.newdawn.slick.util.ResourceLoader;
|
||||
*/
|
||||
public class Render {
|
||||
|
||||
public static final Vec AXIS_X = new CoordValue(1, 0, 0);
|
||||
public static final Vec AXIS_Y = new CoordValue(0, 1, 0);
|
||||
public static final Vec AXIS_Z = new CoordValue(0, 0, 1);
|
||||
public static final Vec AXIS_X = new FixedCoord(1, 0, 0);
|
||||
public static final Vec AXIS_Y = new FixedCoord(0, 1, 0);
|
||||
public static final Vec AXIS_Z = new FixedCoord(0, 0, 1);
|
||||
|
||||
|
||||
/**
|
||||
@@ -437,7 +435,7 @@ public class Render {
|
||||
* @param colorHMinVMax
|
||||
*/
|
||||
public static void quadColor(Rect quad, RGB colorHMinVMin, RGB colorHMaxVMin, RGB colorHMaxVMax, RGB colorHMinVMax)
|
||||
{
|
||||
{
|
||||
final double x1 = quad.xMin();
|
||||
final double y1 = quad.yMin();
|
||||
final double x2 = quad.xMax();
|
||||
@@ -511,7 +509,7 @@ public class Render {
|
||||
*/
|
||||
public static void quadTextured(Rect quad, Texture texture)
|
||||
{
|
||||
quadTextured(quad, new Rect(0,0,1,1), texture, RGB.WHITE);
|
||||
quadTextured(quad, Rect.ONE, texture, RGB.WHITE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package mightypork.gamecore.render.fonts;
|
||||
|
||||
|
||||
import mightypork.gamecore.render.Render;
|
||||
import static mightypork.utils.math.constraints.Constraints.*;
|
||||
import mightypork.gamecore.render.Render;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.math.coord.Vec;
|
||||
import mightypork.utils.math.coord.VecView;
|
||||
@@ -173,7 +173,7 @@ public class FontRenderer {
|
||||
* @param height drawing height
|
||||
* @param align horizontal alignment
|
||||
*/
|
||||
public void draw(String text, VecView pos, double height, Align align)
|
||||
public void draw(String text, Vec pos, double height, Align align)
|
||||
{
|
||||
draw(text, pos, height, align, this.color);
|
||||
}
|
||||
@@ -188,25 +188,25 @@ public class FontRenderer {
|
||||
* @param align horizontal alignment
|
||||
* @param color drawing color
|
||||
*/
|
||||
public void draw(String text, VecView pos, double height, Align align, RGB color)
|
||||
public void draw(String text, Vec pos, double height, Align align, RGB color)
|
||||
{
|
||||
|
||||
final double w = getWidth(text, height);
|
||||
|
||||
final VecView start;
|
||||
final Vec start;
|
||||
|
||||
switch (align) {
|
||||
case LEFT:
|
||||
start = pos;
|
||||
start = pos.view();
|
||||
break;
|
||||
|
||||
case CENTER:
|
||||
start = pos.sub(w / 2D, 0);
|
||||
start = pos.view().sub(w / 2D, 0);
|
||||
break;
|
||||
|
||||
case RIGHT:
|
||||
default:
|
||||
start = pos.sub(w, 0);
|
||||
start = pos.view().sub(w, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import mightypork.gamecore.render.fonts.GLFont;
|
||||
import mightypork.gamecore.render.textures.FilterMode;
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.math.coord.CoordValue;
|
||||
import mightypork.utils.math.coord.FixedCoord;
|
||||
import mightypork.utils.math.coord.VecView;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
@@ -425,7 +425,7 @@ public class CachedFont implements GLFont {
|
||||
@Override
|
||||
public VecView getNeededSpace(String text)
|
||||
{
|
||||
return new CoordValue(getWidth(text), getHeight());
|
||||
return new FixedCoord(getWidth(text), getHeight());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public class DeferredFont extends DeferredResource implements GLFont {
|
||||
*/
|
||||
protected Font getAwtFont(String resource, float size, int style) throws FontFormatException, IOException
|
||||
{
|
||||
try (InputStream in = FileUtils.getResource(resource)) {
|
||||
try(InputStream in = FileUtils.getResource(resource)) {
|
||||
|
||||
Font awtFont = Font.createFont(Font.TRUETYPE_FONT, in);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mightypork.gamecore.render.textures;
|
||||
|
||||
|
||||
import mightypork.utils.math.rect.FixedRect;
|
||||
import mightypork.utils.math.rect.Rect;
|
||||
|
||||
import org.newdawn.slick.opengl.Texture;
|
||||
@@ -64,7 +65,7 @@ public class TxQuad {
|
||||
* @param y2 right bottom Y (0-1)
|
||||
*/
|
||||
public TxQuad(Texture tx, double x1, double y1, double x2, double y2) {
|
||||
this(tx, new Rect(x1, y1, x2, y2));
|
||||
this(tx, new FixedRect(x1, y1, x2, y2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user