Converted to Java 7, factored InstanceLock to own file.
This commit is contained in:
@@ -10,7 +10,7 @@ import mightypork.utils.objects.Mutable;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public class JointVolume extends Mutable<Double> {
|
||||
public class JointVolume extends Volume {
|
||||
|
||||
private final Mutable<Double>[] volumes;
|
||||
|
||||
@@ -20,7 +20,8 @@ public class JointVolume extends Mutable<Double> {
|
||||
*
|
||||
* @param volumes individual volumes to join
|
||||
*/
|
||||
public JointVolume(Mutable<Double>... volumes) {
|
||||
@SafeVarargs
|
||||
public JointVolume(Volume... volumes) {
|
||||
super(1D);
|
||||
this.volumes = volumes;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ public class SoundBank extends AppAdapter {
|
||||
private static final LoopPlayer NULL_LOOP = new LoopPlayer(NO_SOUND, 0, 0, null);
|
||||
private static final EffectPlayer NULL_EFFECT = new EffectPlayer(NO_SOUND, 0, 0, null);
|
||||
|
||||
private final Map<String, EffectPlayer> effects = new HashMap<String, EffectPlayer>();
|
||||
private final Map<String, LoopPlayer> loops = new HashMap<String, LoopPlayer>();
|
||||
private final Map<String, EffectPlayer> effects = new HashMap<>();
|
||||
private final Map<String, LoopPlayer> loops = new HashMap<>();
|
||||
|
||||
|
||||
public SoundBank(AppAccess app) {
|
||||
|
||||
@@ -13,7 +13,6 @@ import mightypork.gamecore.control.bus.events.ResourceLoadRequest;
|
||||
import mightypork.gamecore.control.interf.Updateable;
|
||||
import mightypork.utils.math.Calc.Buffers;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.objects.Mutable;
|
||||
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.AL10;
|
||||
@@ -25,7 +24,6 @@ import org.newdawn.slick.openal.SoundStore;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class SoundSystem extends RootBusNode implements Updateable {
|
||||
|
||||
private static final Coord INITIAL_LISTENER_POS = new Coord(0, 0, 0);
|
||||
@@ -72,12 +70,12 @@ public class SoundSystem extends RootBusNode implements Updateable {
|
||||
|
||||
// -- instance --
|
||||
|
||||
public final Mutable<Double> masterVolume = new Mutable<Double>(1D);
|
||||
public final Mutable<Double> effectsVolume = new JointVolume(masterVolume);
|
||||
public final Mutable<Double> loopsVolume = new JointVolume(masterVolume);
|
||||
public final Volume masterVolume = new Volume(1D);
|
||||
public final Volume effectsVolume = new JointVolume(masterVolume);
|
||||
public final Volume loopsVolume = new JointVolume(masterVolume);
|
||||
|
||||
private final Set<LoopPlayer> loopPlayers = new HashSet<LoopPlayer>();
|
||||
private final Set<DeferredAudio> resources = new HashSet<DeferredAudio>();
|
||||
private final Set<LoopPlayer> loopPlayers = new HashSet<>();
|
||||
private final Set<DeferredAudio> resources = new HashSet<>();
|
||||
|
||||
|
||||
public SoundSystem(AppAccess app) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package mightypork.gamecore.audio;
|
||||
|
||||
|
||||
import mightypork.utils.math.Calc;
|
||||
import mightypork.utils.objects.Mutable;
|
||||
|
||||
|
||||
public class Volume extends Mutable<Double> {
|
||||
|
||||
public Volume(Double d) {
|
||||
super(d);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void set(Double d)
|
||||
{
|
||||
super.set(Calc.clampd(d, 0, 1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,8 +2,8 @@ package mightypork.gamecore.audio.players;
|
||||
|
||||
|
||||
import mightypork.gamecore.audio.DeferredAudio;
|
||||
import mightypork.gamecore.audio.Volume;
|
||||
import mightypork.gamecore.control.interf.Destroyable;
|
||||
import mightypork.utils.objects.Mutable;
|
||||
|
||||
|
||||
public abstract class BaseAudioPlayer implements Destroyable {
|
||||
@@ -18,21 +18,21 @@ public abstract class BaseAudioPlayer implements Destroyable {
|
||||
private final double basePitch;
|
||||
|
||||
/** dedicated volume control */
|
||||
private final Mutable<Double> gainMultiplier;
|
||||
private final Volume gainMultiplier;
|
||||
|
||||
|
||||
public BaseAudioPlayer(DeferredAudio track, double baseGain, Mutable<Double> gainMultiplier) {
|
||||
public BaseAudioPlayer(DeferredAudio track, double baseGain, Volume gainMultiplier) {
|
||||
this(track, 1, baseGain, gainMultiplier);
|
||||
}
|
||||
|
||||
|
||||
public BaseAudioPlayer(DeferredAudio track, double basePitch, double baseGain, Mutable<Double> gainMultiplier) {
|
||||
public BaseAudioPlayer(DeferredAudio track, double basePitch, double baseGain, Volume gainMultiplier) {
|
||||
this.audio = track;
|
||||
|
||||
this.baseGain = baseGain;
|
||||
this.basePitch = basePitch;
|
||||
|
||||
if (gainMultiplier == null) gainMultiplier = new Mutable<Double>(1D);
|
||||
if (gainMultiplier == null) gainMultiplier = new Volume(1D);
|
||||
|
||||
this.gainMultiplier = gainMultiplier;
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ package mightypork.gamecore.audio.players;
|
||||
|
||||
|
||||
import mightypork.gamecore.audio.DeferredAudio;
|
||||
import mightypork.gamecore.audio.Volume;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.objects.Mutable;
|
||||
|
||||
|
||||
public class EffectPlayer extends BaseAudioPlayer {
|
||||
|
||||
public EffectPlayer(DeferredAudio track, double basePitch, double baseGain, Mutable<Double> gainMultiplier) {
|
||||
public EffectPlayer(DeferredAudio track, double basePitch, double baseGain, Volume gainMultiplier) {
|
||||
super(track, (float) basePitch, (float) baseGain, gainMultiplier);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ package mightypork.gamecore.audio.players;
|
||||
|
||||
|
||||
import mightypork.gamecore.audio.DeferredAudio;
|
||||
import mightypork.gamecore.audio.Volume;
|
||||
import mightypork.gamecore.control.interf.Updateable;
|
||||
import mightypork.gamecore.control.timing.Pauseable;
|
||||
import mightypork.utils.math.animation.AnimDouble;
|
||||
import mightypork.utils.objects.Mutable;
|
||||
|
||||
import org.lwjgl.openal.AL10;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable
|
||||
private double outTime = 1;
|
||||
|
||||
|
||||
public LoopPlayer(DeferredAudio track, double pitch, double baseGain, Mutable<Double> gainMultiplier) {
|
||||
public LoopPlayer(DeferredAudio track, double pitch, double baseGain, Volume gainMultiplier) {
|
||||
super(track, (float) pitch, (float) baseGain, gainMultiplier);
|
||||
|
||||
paused = true;
|
||||
|
||||
@@ -19,9 +19,9 @@ import mightypork.gamecore.gui.screens.ScreenRegistry;
|
||||
*/
|
||||
public abstract class GameLoop extends AppModule implements MainLoopTaskRequest.Listener {
|
||||
|
||||
private final Queue<Runnable> taskQueue = new ConcurrentLinkedQueue<Runnable>();
|
||||
private final Queue<Runnable> taskQueue = new ConcurrentLinkedQueue<>();
|
||||
private TimerDelta timer;
|
||||
private Renderable mainRenderable;
|
||||
private final Renderable mainRenderable;
|
||||
private boolean running = true;
|
||||
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ import java.util.List;
|
||||
*/
|
||||
public class BufferedHashSet<E> extends HashSet<E> {
|
||||
|
||||
private final List<E> toAdd = new LinkedList<E>();
|
||||
private final List<Object> toRemove = new LinkedList<Object>();
|
||||
private final List<E> toAdd = new LinkedList<>();
|
||||
private final List<Object> toRemove = new LinkedList<>();
|
||||
private boolean buffering = false;
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package mightypork.gamecore.control.bus;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Access to an {@link EventBus} instance
|
||||
*
|
||||
|
||||
@@ -22,13 +22,13 @@ import mightypork.utils.logging.Log;
|
||||
final public class EventBus implements Destroyable {
|
||||
|
||||
/** Message channels */
|
||||
private final BufferedHashSet<EventChannel<?, ?>> channels = new BufferedHashSet<EventChannel<?, ?>>();
|
||||
private final BufferedHashSet<EventChannel<?, ?>> channels = new BufferedHashSet<>();
|
||||
|
||||
/** Registered clients */
|
||||
private final BufferedHashSet<Object> clients = new BufferedHashSet<Object>();
|
||||
private final BufferedHashSet<Object> clients = new BufferedHashSet<>();
|
||||
|
||||
/** Messages queued for delivery */
|
||||
private final DelayQueue<DelayQueueEntry> sendQueue = new DelayQueue<DelayQueueEntry>();
|
||||
private final DelayQueue<DelayQueueEntry> sendQueue = new DelayQueue<>();
|
||||
|
||||
/** Queue polling thread */
|
||||
private final QueuePollingThread busThread;
|
||||
@@ -235,7 +235,7 @@ final public class EventBus implements Destroyable {
|
||||
|
||||
clients.add(client);
|
||||
|
||||
if(detailedLogging) Log.f3("<bus> Client joined: "+Log.str(client));
|
||||
if (detailedLogging) Log.f3("<bus> Client joined: " + Log.str(client));
|
||||
}
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ final public class EventBus implements Destroyable {
|
||||
|
||||
clients.remove(client);
|
||||
|
||||
if(detailedLogging) Log.f3("<bus> Client left: "+Log.str(client));
|
||||
if (detailedLogging) Log.f3("<bus> Client left: " + Log.str(client));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ final public class EventChannel<EVENT extends Event<CLIENT>, CLIENT> {
|
||||
{
|
||||
if (!canBroadcast(event)) return false;
|
||||
|
||||
return doBroadcast(eventClass.cast(event), clients, new HashSet<Object>());
|
||||
return doBroadcast(eventClass.cast(event), clients, new HashSet<>());
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ final public class EventChannel<EVENT extends Event<CLIENT>, CLIENT> {
|
||||
*/
|
||||
public static <F_EVENT extends Event<F_CLIENT>, F_CLIENT> EventChannel<F_EVENT, F_CLIENT> create(Class<F_EVENT> eventClass, Class<F_CLIENT> clientClass)
|
||||
{
|
||||
return new EventChannel<F_EVENT, F_CLIENT>(eventClass, clientClass);
|
||||
return new EventChannel<>(eventClass, clientClass);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public abstract class BusNode implements BusAccess, DelegatingClient, Toggleable
|
||||
|
||||
private final BusAccess busAccess;
|
||||
|
||||
private final Set<Object> clients = new LinkedHashSet<Object>();
|
||||
private final Set<Object> clients = new LinkedHashSet<>();
|
||||
private boolean listening = true;
|
||||
private boolean delegating = true;
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class BusNode implements BusAccess, DelegatingClient, Toggleable
|
||||
*/
|
||||
public final void addChildClient(Object client)
|
||||
{
|
||||
if(client instanceof RootBusNode) {
|
||||
if (client instanceof RootBusNode) {
|
||||
throw new IllegalArgumentException("Cannot nest RootBusNode.");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mightypork.gamecore.control.bus.clients;
|
||||
|
||||
|
||||
import mightypork.gamecore.control.bus.BusAccess;
|
||||
import mightypork.gamecore.control.interf.Destroyable;
|
||||
|
||||
@@ -10,10 +11,10 @@ import mightypork.gamecore.control.interf.Destroyable;
|
||||
* @author MightyPork
|
||||
*/
|
||||
public abstract class RootBusNode extends BusNode implements Destroyable {
|
||||
|
||||
|
||||
public RootBusNode(BusAccess busAccess) {
|
||||
super(busAccess);
|
||||
|
||||
|
||||
getEventBus().subscribe(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(value={ElementType.METHOD})
|
||||
@Target(value = { ElementType.METHOD })
|
||||
public @interface NoImpl {
|
||||
//
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class FpsMeter {
|
||||
if (System.currentTimeMillis() - lastTimeMillis > 1000) {
|
||||
lastSecFPS = frames;
|
||||
frames = 0;
|
||||
long over = System.currentTimeMillis() - lastTimeMillis - 1000;
|
||||
final long over = System.currentTimeMillis() - lastTimeMillis - 1000;
|
||||
lastTimeMillis = System.currentTimeMillis() - over;
|
||||
}
|
||||
frames++;
|
||||
|
||||
@@ -18,7 +18,7 @@ import mightypork.utils.math.coord.Rect;
|
||||
*/
|
||||
public abstract class ElementHolder extends BusNode implements PluggableRenderable {
|
||||
|
||||
private final LinkedList<PluggableRenderable> elements = new LinkedList<PluggableRenderable>();
|
||||
private final LinkedList<PluggableRenderable> elements = new LinkedList<>();
|
||||
private RectConstraint context;
|
||||
|
||||
|
||||
|
||||
@@ -2,15 +2,13 @@ package mightypork.gamecore.gui.renderers;
|
||||
|
||||
|
||||
import mightypork.gamecore.render.fonts.FontRenderer;
|
||||
import mightypork.gamecore.render.fonts.GLFont;
|
||||
import mightypork.gamecore.render.fonts.FontRenderer.Align;
|
||||
import mightypork.gamecore.render.fonts.GLFont;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.string.StringProvider;
|
||||
import mightypork.utils.string.StringProvider.StringWrapper;
|
||||
|
||||
|
||||
|
||||
|
||||
public class TextPainter extends PluggableRenderer {
|
||||
|
||||
private final FontRenderer font;
|
||||
@@ -41,6 +39,7 @@ public class TextPainter extends PluggableRenderer {
|
||||
this(font, align, color, (StringProvider) null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Use size specified during font init instead of size provided by
|
||||
* {@link GLFont} instance (measured from tile heights.<br>
|
||||
@@ -49,7 +48,8 @@ public class TextPainter extends PluggableRenderer {
|
||||
*
|
||||
* @param enable use it
|
||||
*/
|
||||
public void usePtSize(boolean enable) {
|
||||
public void usePtSize(boolean enable)
|
||||
{
|
||||
font.usePtSize(enable);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import mightypork.gamecore.render.Render;
|
||||
|
||||
public abstract class LayeredScreen extends Screen {
|
||||
|
||||
private final Collection<ScreenLayer> layers = new TreeSet<ScreenLayer>();
|
||||
private final Collection<ScreenLayer> layers = new TreeSet<>();
|
||||
|
||||
|
||||
public LayeredScreen(AppAccess app) {
|
||||
|
||||
@@ -56,15 +56,17 @@ public abstract class ScreenLayer extends AppSubModule implements Comparable<Scr
|
||||
return screen.getRect();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final int compareTo(ScreenLayer o)
|
||||
{
|
||||
return getPriority() - o.getPriority();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return higher = on top.
|
||||
*/
|
||||
public abstract int getPriority();
|
||||
|
||||
@Override
|
||||
public final int compareTo(ScreenLayer o)
|
||||
{
|
||||
return Integer.compare(getPriority(), o.getPriority());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import mightypork.utils.logging.Log;
|
||||
|
||||
public class ScreenRegistry extends AppModule implements ScreenRequestEvent.Listener, Renderable {
|
||||
|
||||
private final HashMap<String, Screen> screens = new HashMap<String, Screen>();
|
||||
private final HashMap<String, Screen> screens = new HashMap<>();
|
||||
private Screen active = null;
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ public class InputSystem extends RootBusNode implements Updateable, KeyBinder {
|
||||
private final KeyBindingPool keybindings;
|
||||
|
||||
private static boolean inited = false;
|
||||
|
||||
|
||||
public InputSystem(AppAccess app) {
|
||||
super(app);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import mightypork.utils.logging.Log;
|
||||
*/
|
||||
public class KeyBindingPool implements KeyBinder, KeyEvent.Listener {
|
||||
|
||||
private final Set<KeyBinding> bindings = new HashSet<KeyBinding>();
|
||||
private final Set<KeyBinding> bindings = new HashSet<>();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.lwjgl.input.Keyboard;
|
||||
*/
|
||||
public class KeyStroke {
|
||||
|
||||
private final Set<Integer> keys = new LinkedHashSet<Integer>();
|
||||
private final Set<Integer> keys = new LinkedHashSet<>();
|
||||
private final boolean fallingEdge;
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class AsyncResourceLoader extends Thread implements ResourceLoadRequest.L
|
||||
|
||||
private final ExecutorService exs = Executors.newCachedThreadPool();
|
||||
|
||||
private final LinkedBlockingQueue<DeferredResource> toLoad = new LinkedBlockingQueue<DeferredResource>();
|
||||
private final LinkedBlockingQueue<DeferredResource> toLoad = new LinkedBlockingQueue<>();
|
||||
private boolean stopped;
|
||||
private final BusAccess app;
|
||||
|
||||
|
||||
@@ -200,6 +200,7 @@ public class DisplaySystem extends RootBusNode implements RectConstraint {
|
||||
return new Rect(getSize());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return current FPS
|
||||
*/
|
||||
@@ -208,7 +209,6 @@ public class DisplaySystem extends RootBusNode implements RectConstraint {
|
||||
return fpsMeter.getFPS();
|
||||
}
|
||||
|
||||
|
||||
public static final NumberConstraint width = new NumberConstraint() {
|
||||
|
||||
@Override
|
||||
@@ -218,7 +218,6 @@ public class DisplaySystem extends RootBusNode implements RectConstraint {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public static final NumberConstraint height = new NumberConstraint() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,7 @@ public class Render {
|
||||
private static final Coord AXIS_Y = new Coord(0, 1, 0);
|
||||
private static final Coord AXIS_Z = new Coord(0, 0, 1);
|
||||
|
||||
|
||||
/**
|
||||
* Bind GL color
|
||||
*
|
||||
@@ -464,8 +465,8 @@ public class Render {
|
||||
{
|
||||
quadTextured(quad, txquad.uvs, txquad.tx, tint);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Setup Ortho projection for 2D graphics
|
||||
*/
|
||||
@@ -480,7 +481,7 @@ public class Render {
|
||||
|
||||
// back to modelview
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
|
||||
glLoadIdentity();
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
@@ -17,10 +17,10 @@ import javax.imageio.ImageIO;
|
||||
*/
|
||||
public class Screenshot {
|
||||
|
||||
private int width;
|
||||
private int height;
|
||||
private int bpp;
|
||||
private ByteBuffer bytes;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final int bpp;
|
||||
private final ByteBuffer bytes;
|
||||
private BufferedImage image;
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DeferredFont extends BaseDeferredResource implements GLFont {
|
||||
private final double size;
|
||||
private final FontStyle style;
|
||||
private final String extraChars;
|
||||
private FilterMode filter;
|
||||
private final FilterMode filter;
|
||||
|
||||
|
||||
/**
|
||||
@@ -107,11 +107,8 @@ public class DeferredFont extends BaseDeferredResource implements GLFont {
|
||||
*/
|
||||
protected Font getAwtFont(String resource, float size, int style) throws FontFormatException, IOException
|
||||
{
|
||||
InputStream in = null;
|
||||
|
||||
try {
|
||||
|
||||
in = FileUtils.getResource(resource);
|
||||
try (InputStream in = FileUtils.getResource(resource)) {
|
||||
|
||||
Font awtFont = Font.createFont(Font.TRUETYPE_FONT, in);
|
||||
|
||||
@@ -119,14 +116,8 @@ public class DeferredFont extends BaseDeferredResource implements GLFont {
|
||||
awtFont = awtFont.deriveFont(style);
|
||||
|
||||
return awtFont;
|
||||
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) in.close();
|
||||
} catch (final IOException e) {
|
||||
//pass
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -171,6 +162,7 @@ public class DeferredFont extends BaseDeferredResource implements GLFont {
|
||||
return font.getGlyphHeight();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSize()
|
||||
{
|
||||
|
||||
@@ -6,8 +6,6 @@ import java.util.HashMap;
|
||||
import mightypork.gamecore.control.AppAccess;
|
||||
import mightypork.gamecore.control.AppAdapter;
|
||||
import mightypork.gamecore.control.bus.events.ResourceLoadRequest;
|
||||
import mightypork.gamecore.render.fonts.DeferredFont.FontStyle;
|
||||
import mightypork.gamecore.render.textures.FilterMode;
|
||||
import mightypork.utils.logging.Log;
|
||||
|
||||
import org.newdawn.slick.opengl.Texture;
|
||||
@@ -21,12 +19,13 @@ import org.newdawn.slick.opengl.Texture;
|
||||
public class FontBank extends AppAdapter {
|
||||
|
||||
private static final GLFont NULL_FONT = new NullFont();
|
||||
|
||||
|
||||
|
||||
public FontBank(AppAccess app) {
|
||||
super(app);
|
||||
}
|
||||
|
||||
private final HashMap<String, GLFont> fonts = new HashMap<String, GLFont>();
|
||||
private final HashMap<String, GLFont> fonts = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@ public class FontRenderer {
|
||||
* @param font used font
|
||||
* @param color drawing color
|
||||
*/
|
||||
public FontRenderer(GLFont font, RGB color) {
|
||||
public FontRenderer(GLFont font, RGB color) {
|
||||
this.font = font;
|
||||
this.color = color;
|
||||
}
|
||||
@@ -131,12 +131,13 @@ public class FontRenderer {
|
||||
Render.popState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Draw on screen
|
||||
*
|
||||
* @param text text to draw
|
||||
* @param bounds drawing bounds (height for font height, horizontal bounds for align)
|
||||
* @param bounds drawing bounds (height for font height, horizontal bounds
|
||||
* for align)
|
||||
* @param align horizontal alignment (with respect to bounds)
|
||||
*/
|
||||
public void draw(String text, Rect bounds, Align align)
|
||||
@@ -144,13 +145,13 @@ public class FontRenderer {
|
||||
this.draw(text, bounds, align, this.color);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Draw on screen
|
||||
*
|
||||
* @param text text to draw
|
||||
* @param bounds drawing bounds (height for font height, horizontal bounds for align)
|
||||
* @param bounds drawing bounds (height for font height, horizontal bounds
|
||||
* for align)
|
||||
* @param align horizontal alignment (with respect to bounds)
|
||||
* @param color drawing color
|
||||
*/
|
||||
@@ -190,7 +191,7 @@ public class FontRenderer {
|
||||
draw(text, pos, height, align, this.color);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Draw on screen
|
||||
*
|
||||
|
||||
@@ -36,8 +36,8 @@ public interface GLFont {
|
||||
* @return space needed
|
||||
*/
|
||||
int getWidth(String text);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return specified font size
|
||||
*/
|
||||
|
||||
@@ -38,8 +38,8 @@ public class NullFont implements GLFont {
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getSize()
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@ package mightypork.gamecore.render.fonts;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import mightypork.gamecore.render.Render;
|
||||
import mightypork.gamecore.render.textures.FilterMode;
|
||||
@@ -24,7 +23,7 @@ public class SlickFont implements GLFont {
|
||||
|
||||
private final TrueTypeFont ttf;
|
||||
private FilterMode filter;
|
||||
private int fsize;
|
||||
private final int fsize;
|
||||
|
||||
|
||||
/**
|
||||
@@ -63,7 +62,7 @@ public class SlickFont implements GLFont {
|
||||
|
||||
|
||||
private void prepareForRender()
|
||||
{
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter.num);
|
||||
@@ -114,8 +113,8 @@ public class SlickFont implements GLFont {
|
||||
{
|
||||
return ttf.getWidth(text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getSize()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package mightypork.gamecore.render.textures;
|
||||
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
||||
public enum FilterMode
|
||||
{
|
||||
LINEAR(GL11.GL_LINEAR), NEAREST(GL11.GL_NEAREST);
|
||||
@@ -12,4 +14,4 @@ public enum FilterMode
|
||||
private FilterMode(int gl) {
|
||||
this.num = gl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ public class TextureBank extends AppAdapter {
|
||||
super(app);
|
||||
}
|
||||
|
||||
private final HashMap<String, DeferredTexture> textures = new HashMap<String, DeferredTexture>();
|
||||
private final HashMap<String, DeferredTexture> textures = new HashMap<>();
|
||||
|
||||
private final HashMap<String, TxQuad> quads = new HashMap<String, TxQuad>();
|
||||
private final HashMap<String, TxQuad> quads = new HashMap<>();
|
||||
|
||||
private DeferredTexture lastTx;
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package mightypork.gamecore.render.textures;
|
||||
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
||||
public enum WrapMode
|
||||
{
|
||||
CLAMP(GL11.GL_CLAMP), REPEAT(GL11.GL_REPEAT);
|
||||
@@ -12,4 +14,4 @@ public enum WrapMode
|
||||
private WrapMode(int gl) {
|
||||
this.num = gl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user