v5stable
Ondřej Hruška 11 years ago
parent 7d61de7c61
commit f81c349d20
  1. 9
      src/mightypork/gamecore/audio/DeferredAudio.java
  2. 3
      src/mightypork/gamecore/audio/NullAudio.java
  3. 8
      src/mightypork/gamecore/audio/SoundBank.java
  4. 45
      src/mightypork/gamecore/audio/SoundSystem.java
  5. 8
      src/mightypork/gamecore/audio/Volume.java
  6. 40
      src/mightypork/gamecore/audio/players/BaseAudioPlayer.java
  7. 36
      src/mightypork/gamecore/audio/players/EffectPlayer.java
  8. 37
      src/mightypork/gamecore/audio/players/LoopPlayer.java
  9. 5
      src/mightypork/gamecore/control/AppAdapter.java
  10. 7
      src/mightypork/gamecore/control/AppModule.java
  11. 11
      src/mightypork/gamecore/control/AppSubModule.java
  12. 64
      src/mightypork/gamecore/control/BaseApp.java
  13. 9
      src/mightypork/gamecore/control/GameLoop.java
  14. 3
      src/mightypork/gamecore/control/SlickLogRedirector.java
  15. 19
      src/mightypork/gamecore/control/bus/BufferedHashSet.java
  16. 7
      src/mightypork/gamecore/control/bus/EventBus.java
  17. 3
      src/mightypork/gamecore/control/bus/clients/BusNode.java
  18. 3
      src/mightypork/gamecore/control/bus/clients/RootBusNode.java
  19. 10
      src/mightypork/gamecore/control/bus/events/KeyEvent.java
  20. 8
      src/mightypork/gamecore/control/bus/events/MainLoopTaskRequest.java
  21. 5
      src/mightypork/gamecore/control/bus/events/MouseButtonEvent.java
  22. 9
      src/mightypork/gamecore/control/bus/events/MouseMotionEvent.java
  23. 10
      src/mightypork/gamecore/control/bus/events/ResourceLoadRequest.java
  24. 24
      src/mightypork/gamecore/control/bus/events/ScreenChangeEvent.java
  25. 11
      src/mightypork/gamecore/control/bus/events/ScreenRequestEvent.java
  26. 6
      src/mightypork/gamecore/control/interf/NoImpl.java
  27. 5
      src/mightypork/gamecore/control/timing/Pauseable.java
  28. 5
      src/mightypork/gamecore/gui/ActionTrigger.java
  29. 17
      src/mightypork/gamecore/gui/renderers/ColumnHolder.java
  30. 7
      src/mightypork/gamecore/gui/renderers/ElementHolder.java
  31. 11
      src/mightypork/gamecore/gui/renderers/ImagePainter.java
  32. 5
      src/mightypork/gamecore/gui/renderers/PluggableRenderable.java
  33. 17
      src/mightypork/gamecore/gui/renderers/RowHolder.java
  34. 77
      src/mightypork/gamecore/gui/renderers/TextPainter.java
  35. 8
      src/mightypork/gamecore/gui/screens/LayeredScreen.java
  36. 3
      src/mightypork/gamecore/gui/screens/Screen.java
  37. 6
      src/mightypork/gamecore/gui/screens/ScreenLayer.java
  38. 3
      src/mightypork/gamecore/gui/screens/ScreenRegistry.java
  39. 8
      src/mightypork/gamecore/input/InputSystem.java
  40. 10
      src/mightypork/gamecore/input/KeyBinder.java
  41. 10
      src/mightypork/gamecore/loading/AsyncResourceLoader.java
  42. 4
      src/mightypork/gamecore/loading/BaseDeferredResource.java
  43. 34
      src/mightypork/gamecore/render/DisplaySystem.java
  44. 14
      src/mightypork/gamecore/render/Render.java
  45. 19
      src/mightypork/gamecore/render/Screenshot.java
  46. 3
      src/mightypork/gamecore/render/fonts/FontBank.java
  47. 5
      src/mightypork/gamecore/render/fonts/GLFont.java
  48. 5
      src/mightypork/gamecore/render/fonts/SlickFont.java
  49. 17
      src/mightypork/gamecore/render/textures/DeferredTexture.java
  50. 5
      src/mightypork/gamecore/render/textures/FilterMode.java
  51. 5
      src/mightypork/gamecore/render/textures/FilteredTexture.java
  52. 3
      src/mightypork/gamecore/render/textures/TextureBank.java
  53. 10
      src/mightypork/gamecore/render/textures/TxQuad.java
  54. 5
      src/mightypork/gamecore/render/textures/WrapMode.java
  55. 6
      src/mightypork/rogue/App.java
  56. 7
      src/mightypork/utils/math/animation/AnimDouble.java
  57. 7
      src/mightypork/utils/math/constraints/ContextAdapter.java
  58. 8
      src/mightypork/utils/math/constraints/NumberConstraint.java
  59. 8
      src/mightypork/utils/math/constraints/PluggableContext.java

@ -108,6 +108,9 @@ public class DeferredAudio extends BaseDeferredResource {
} }
/**
* Stop playing
*/
public void stop() public void stop()
{ {
if (!isLoaded()) return; if (!isLoaded()) return;
@ -117,6 +120,9 @@ public class DeferredAudio extends BaseDeferredResource {
} }
/**
* @return true if the audio is playing
*/
public boolean isPlaying() public boolean isPlaying()
{ {
if (!isLoaded()) return false; if (!isLoaded()) return false;
@ -125,6 +131,9 @@ public class DeferredAudio extends BaseDeferredResource {
} }
/**
* @return trie if the audio is paused
*/
public boolean isPaused() public boolean isPaused()
{ {
if (!isLoaded()) return false; if (!isLoaded()) return false;

@ -14,6 +14,9 @@ import mightypork.utils.logging.LoggedName;
@LoggedName(name = "NullAudio") @LoggedName(name = "NullAudio")
public class NullAudio extends DeferredAudio implements NullResource { public class NullAudio extends DeferredAudio implements NullResource {
/**
* new null audio
*/
public NullAudio() { public NullAudio() {
super(null); super(null);
} }

@ -11,6 +11,11 @@ import mightypork.gamecore.control.AppAdapter;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
/**
* Audio resource storage
*
* @author MightyPork
*/
public class SoundBank extends AppAdapter { public class SoundBank extends AppAdapter {
private static final DeferredAudio NO_SOUND = new NullAudio(); private static final DeferredAudio NO_SOUND = new NullAudio();
@ -21,6 +26,9 @@ public class SoundBank extends AppAdapter {
private final Map<String, LoopPlayer> loops = new HashMap<>(); private final Map<String, LoopPlayer> loops = new HashMap<>();
/**
* @param app app access
*/
public SoundBank(AppAccess app) { public SoundBank(AppAccess app) {
super(app); super(app);
if (getSoundSystem() == null) throw new NullPointerException("SoundSystem cannot be null."); if (getSoundSystem() == null) throw new NullPointerException("SoundSystem cannot be null.");

@ -63,6 +63,9 @@ public class SoundSystem extends RootBusNode implements Updateable {
} }
/**
* @return listener coordinate
*/
public static Coord getListener() public static Coord getListener()
{ {
return listener; return listener;
@ -70,14 +73,17 @@ public class SoundSystem extends RootBusNode implements Updateable {
// -- instance -- // -- instance --
public final Volume masterVolume = new Volume(1D); private final Volume masterVolume = new Volume(1D);
public final Volume effectsVolume = new JointVolume(masterVolume); private final Volume effectsVolume = new JointVolume(masterVolume);
public final Volume loopsVolume = new JointVolume(masterVolume); private final Volume loopsVolume = new JointVolume(masterVolume);
private final Set<LoopPlayer> loopPlayers = new HashSet<>(); private final Set<LoopPlayer> loopPlayers = new HashSet<>();
private final Set<DeferredAudio> resources = new HashSet<>(); private final Set<DeferredAudio> resources = new HashSet<>();
/**
* @param app app access
*/
public SoundSystem(AppAccess app) { public SoundSystem(AppAccess app) {
super(app); super(app);
} }
@ -208,4 +214,37 @@ public class SoundSystem extends RootBusNode implements Updateable {
{ {
loopsVolume.set(d); loopsVolume.set(d);
} }
/**
* Get level of master volume
*
* @return level
*/
public double getMasterVolume()
{
return masterVolume.get();
}
/**
* Get level of effects volume
*
* @return level
*/
public double getEffectsVolume()
{
return effectsVolume.get();
}
/**
* Get level of music volume
*
* @return level
*/
public double getMusicVolume()
{
return loopsVolume.get();
}
} }

@ -5,8 +5,16 @@ import mightypork.utils.math.Calc;
import mightypork.utils.objects.Mutable; import mightypork.utils.objects.Mutable;
/**
* Mutable volume 0-1
*
* @author MightyPork
*/
public class Volume extends Mutable<Double> { public class Volume extends Mutable<Double> {
/**
* @param d initial value
*/
public Volume(Double d) { public Volume(Double d) {
super(d); super(d);
} }

@ -6,6 +6,11 @@ import mightypork.gamecore.audio.Volume;
import mightypork.gamecore.control.interf.Destroyable; import mightypork.gamecore.control.interf.Destroyable;
/**
* Basic abstract player
*
* @author MightyPork
*/
public abstract class BaseAudioPlayer implements Destroyable { public abstract class BaseAudioPlayer implements Destroyable {
/** the track */ /** the track */
@ -21,20 +26,21 @@ public abstract class BaseAudioPlayer implements Destroyable {
private final Volume gainMultiplier; private final Volume gainMultiplier;
public BaseAudioPlayer(DeferredAudio track, double baseGain, Volume gainMultiplier) { /**
this(track, 1, baseGain, gainMultiplier); * @param track audio resource
} * @param basePitch base pitch (pitch multiplier)
* @param baseGain base gain (volume multiplier)
* @param volume colume control
public BaseAudioPlayer(DeferredAudio track, double basePitch, double baseGain, Volume gainMultiplier) { */
public BaseAudioPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume) {
this.audio = track; this.audio = track;
this.baseGain = baseGain; this.baseGain = baseGain;
this.basePitch = basePitch; this.basePitch = basePitch;
if (gainMultiplier == null) gainMultiplier = new Volume(1D); if (volume == null) volume = new Volume(1D);
this.gainMultiplier = gainMultiplier; this.gainMultiplier = volume;
} }
@ -45,18 +51,33 @@ public abstract class BaseAudioPlayer implements Destroyable {
} }
/**
* @return audio resource
*/
protected DeferredAudio getAudio() protected DeferredAudio getAudio()
{ {
return audio; return audio;
} }
/**
* Get play gain, computed based on volume and given multiplier
*
* @param multiplier extra volume adjustment
* @return computed gain
*/
protected double getGain(double multiplier) protected double getGain(double multiplier)
{ {
return baseGain * gainMultiplier.get() * multiplier; return baseGain * gainMultiplier.get() * multiplier;
} }
/**
* Get pitch
*
* @param multiplier pitch adjustment
* @return computed pitch
*/
protected double getPitch(double multiplier) protected double getPitch(double multiplier)
{ {
return basePitch * multiplier; return basePitch * multiplier;
@ -74,6 +95,9 @@ public abstract class BaseAudioPlayer implements Destroyable {
} }
/**
* force load the resource
*/
public void load() public void load()
{ {
if (hasAudio()) audio.load(); if (hasAudio()) audio.load();

@ -6,13 +6,31 @@ import mightypork.gamecore.audio.Volume;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
/**
* Player for one-off effects
*
* @author MightyPork
*/
public class EffectPlayer extends BaseAudioPlayer { public class EffectPlayer extends BaseAudioPlayer {
public EffectPlayer(DeferredAudio track, double basePitch, double baseGain, Volume gainMultiplier) { /**
super(track, (float) basePitch, (float) baseGain, gainMultiplier); * @param track audio resource
* @param basePitch base pitch (pitch multiplier)
* @param baseGain base gain (volume multiplier)
* @param volume volume control
*/
public EffectPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume) {
super(track, (float) basePitch, (float) baseGain, volume);
} }
/**
* Play at listener
*
* @param pitch play pitch
* @param gain play gain
* @return source id
*/
public int play(double pitch, double gain) public int play(double pitch, double gain)
{ {
if (!hasAudio()) return -1; if (!hasAudio()) return -1;
@ -21,12 +39,26 @@ public class EffectPlayer extends BaseAudioPlayer {
} }
/**
* Play at listener
*
* @param gain play gain
* @return source id
*/
public int play(double gain) public int play(double gain)
{ {
return play(1, gain); return play(1, gain);
} }
/**
* Play at given position
*
* @param pitch play pitch
* @param gain play gain
* @param pos play position
* @return source id
*/
public int play(double pitch, double gain, Coord pos) public int play(double pitch, double gain, Coord pos)
{ {
if (!hasAudio()) return -1; if (!hasAudio()) return -1;

@ -10,6 +10,11 @@ import mightypork.utils.math.animation.AnimDouble;
import org.lwjgl.openal.AL10; import org.lwjgl.openal.AL10;
/**
* Audio loop player (with fading, good for music)
*
* @author MightyPork
*/
public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable { public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable {
private int sourceID = -1; private int sourceID = -1;
@ -29,13 +34,25 @@ public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable
private double outTime = 1; private double outTime = 1;
public LoopPlayer(DeferredAudio track, double pitch, double baseGain, Volume gainMultiplier) { /**
super(track, (float) pitch, (float) baseGain, gainMultiplier); * @param track audio resource
* @param basePitch base pitch (pitch multiplier)
* @param baseGain base gain (volume multiplier)
* @param volume volume control
*/
public LoopPlayer(DeferredAudio track, double basePitch, double baseGain, Volume volume) {
super(track, (float) basePitch, (float) baseGain, volume);
paused = true; paused = true;
} }
/**
* Set fading duration (seconds)
*
* @param in duration of fade-in
* @param out duration of fade-out
*/
public void setFadeTimes(double in, double out) public void setFadeTimes(double in, double out)
{ {
inTime = in; inTime = in;
@ -102,6 +119,11 @@ public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable
} }
/**
* Resume if paused, and fade in (pick up from current volume).
*
* @param secs
*/
public void fadeIn(double secs) public void fadeIn(double secs)
{ {
if (!hasAudio()) return; if (!hasAudio()) return;
@ -111,6 +133,11 @@ public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable
} }
/**
* Fade out and pause when reached zero volume
*
* @param secs fade duration
*/
public void fadeOut(double secs) public void fadeOut(double secs)
{ {
if (!hasAudio()) return; if (!hasAudio()) return;
@ -119,12 +146,18 @@ public class LoopPlayer extends BaseAudioPlayer implements Updateable, Pauseable
} }
/**
* Fade in with default duration
*/
public void fadeIn() public void fadeIn()
{ {
fadeIn(inTime); fadeIn(inTime);
} }
/**
* Fade out with default duration
*/
public void fadeOut() public void fadeOut()
{ {
fadeOut(outTime); fadeOut(outTime);

@ -8,7 +8,7 @@ import mightypork.gamecore.render.DisplaySystem;
/** /**
* App access adapter * App access adapter (defualt {@link AppAccess} implementation)
* *
* @author MightyPork * @author MightyPork
*/ */
@ -17,6 +17,9 @@ public class AppAdapter implements AppAccess {
private final AppAccess app; private final AppAccess app;
/**
* @param app app access
*/
public AppAdapter(AppAccess app) { public AppAdapter(AppAccess app) {
if (app == null) throw new NullPointerException("AppAccess instance cannot be null."); if (app == null) throw new NullPointerException("AppAccess instance cannot be null.");

@ -9,7 +9,7 @@ import mightypork.gamecore.render.DisplaySystem;
/** /**
* App event bus client, to be used for subsystems, screens and anything that * App event bus client, to be used for subsystems, screens and anything that
* needs access to the eventbus * needs access to the eventbus and other systems; Attached directly to bus.
* *
* @author MightyPork * @author MightyPork
*/ */
@ -18,6 +18,11 @@ public abstract class AppModule extends RootBusNode implements AppAccess {
private final AppAccess app; private final AppAccess app;
/**
* Create a module
*
* @param app access to app systems
*/
public AppModule(AppAccess app) { public AppModule(AppAccess app) {
super(app); super(app);

@ -3,13 +3,15 @@ package mightypork.gamecore.control;
import mightypork.gamecore.audio.SoundSystem; import mightypork.gamecore.audio.SoundSystem;
import mightypork.gamecore.control.bus.clients.BusNode; import mightypork.gamecore.control.bus.clients.BusNode;
import mightypork.gamecore.control.bus.clients.DelegatingClient;
import mightypork.gamecore.control.bus.clients.RootBusNode;
import mightypork.gamecore.input.InputSystem; import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.render.DisplaySystem; import mightypork.gamecore.render.DisplaySystem;
/** /**
* App event bus client, to be used for subsystems, screens and anything that * Delegating bus client, to be attached to any {@link DelegatingClient}, such
* needs access to the eventbus * as a {@link RootBusNode}.
* *
* @author MightyPork * @author MightyPork
*/ */
@ -18,6 +20,11 @@ public abstract class AppSubModule extends BusNode implements AppAccess {
private final AppAccess app; private final AppAccess app;
/**
* Create submodule
*
* @param app access to app systems
*/
public AppSubModule(AppAccess app) { public AppSubModule(AppAccess app) {
super(app); super(app);

@ -52,15 +52,20 @@ public abstract class BaseApp implements AppAccess {
} }
/**
* Init the app
*/
protected void initialize() protected void initialize()
{ {
preInit();
/* /*
* Lock working directory * Lock working directory
*/ */
initLock(); initLock();
// hook
preInit();
/* /*
* Setup logging * Setup logging
*/ */
@ -77,7 +82,7 @@ public abstract class BaseApp implements AppAccess {
eventBus = new EventBus(); eventBus = new EventBus();
Log.f3("Registering channels..."); Log.f3("Registering channels...");
initChannels(eventBus); initBus(eventBus);
/* /*
* Display * Display
@ -98,7 +103,7 @@ public abstract class BaseApp implements AppAccess {
*/ */
Log.f2("Initializing Input System..."); Log.f2("Initializing Input System...");
inputSystem = new InputSystem(this); inputSystem = new InputSystem(this);
initKeystrokes(inputSystem); initInputSystem(inputSystem);
/* /*
* Prepare main loop * Prepare main loop
@ -130,40 +135,87 @@ public abstract class BaseApp implements AppAccess {
} }
/**
* Called at the beginning of the initialization sequence, right after lock
* was obtained.
*/
@NoImpl @NoImpl
protected void preInit() protected void preInit()
{ {
} }
/**
*
*/
@NoImpl @NoImpl
protected void postInit() protected void postInit()
{ {
} }
/**
* Create and configure a log (using {@link Log})
*
* @return new log instance
*/
protected abstract LogInstance createLog(); protected abstract LogInstance createLog();
/**
* Create window and configure display system
*
* @param display
*/
protected abstract void initDisplay(DisplaySystem display); protected abstract void initDisplay(DisplaySystem display);
/**
* Configure sound system (ie. adjust volume)
*
* @param audio
*/
protected abstract void initSoundSystem(SoundSystem audio); protected abstract void initSoundSystem(SoundSystem audio);
protected abstract void initKeystrokes(InputSystem input); /**
* Configure input system (ie. define global keystrokes)
*
* @param input
*/
protected abstract void initInputSystem(InputSystem input);
/**
* Initialize resource banks; {@link AsyncResourceLoader} is already
* started.
*/
protected abstract void initResources(); protected abstract void initResources();
/**
* Register game screens to the registry.
*
* @param screens
*/
protected abstract void initScreens(ScreenRegistry screens); protected abstract void initScreens(ScreenRegistry screens);
/**
* Create game loop instance
*
* @return the game loop.
*/
protected abstract GameLoop createLoop(); protected abstract GameLoop createLoop();
protected void initChannels(EventBus bus) /**
* Initialize event bus (ie. add custom channels)<br>
* When overriding, must call super!
*
* @param bus
*/
protected void initBus(EventBus bus)
{ {
// framework events // framework events
bus.addChannel(DestroyEvent.class, Destroyable.class); bus.addChannel(DestroyEvent.class, Destroyable.class);
@ -182,7 +234,7 @@ public abstract class BaseApp implements AppAccess {
} }
/** /*
* Try to obtain lock. * Try to obtain lock.
*/ */
private void initLock() private void initLock()

@ -45,6 +45,9 @@ public abstract class GameLoop extends AppModule implements MainLoopTaskRequest.
} }
/**
* Start the loop
*/
public void start() public void start()
{ {
timer = new TimerDelta(); timer = new TimerDelta();
@ -70,6 +73,9 @@ public abstract class GameLoop extends AppModule implements MainLoopTaskRequest.
} }
/**
* Called before render
*/
@NoImpl @NoImpl
protected void beforeRender() protected void beforeRender()
{ {
@ -77,6 +83,9 @@ public abstract class GameLoop extends AppModule implements MainLoopTaskRequest.
} }
/**
* Called after render
*/
@NoImpl @NoImpl
protected void afterRender() protected void afterRender()
{ {

@ -16,6 +16,9 @@ public class SlickLogRedirector implements LogSystem {
LogInstance l; LogInstance l;
/**
* @param log log to redirect into
*/
public SlickLogRedirector(LogInstance log) { public SlickLogRedirector(LogInstance log) {
this.l = log; this.l = log;
} }

@ -21,21 +21,40 @@ public class BufferedHashSet<E> extends HashSet<E> {
private boolean buffering = false; private boolean buffering = false;
/**
* make empty
*/
public BufferedHashSet() { public BufferedHashSet() {
super(); super();
} }
/**
* make from elements of a collection
*
* @param c
*/
public BufferedHashSet(Collection<? extends E> c) { public BufferedHashSet(Collection<? extends E> c) {
super(c); super(c);
} }
/**
* make new
*
* @param initialCapacity
* @param loadFactor
*/
public BufferedHashSet(int initialCapacity, float loadFactor) { public BufferedHashSet(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor); super(initialCapacity, loadFactor);
} }
/**
* make new
*
* @param initialCapacity
*/
public BufferedHashSet(int initialCapacity) { public BufferedHashSet(int initialCapacity) {
super(initialCapacity); super(initialCapacity);
} }

@ -36,6 +36,7 @@ final public class EventBus implements Destroyable {
/** Whether the bus was destroyed */ /** Whether the bus was destroyed */
private boolean dead = false; private boolean dead = false;
/** Log detailed messages (debug) */
public boolean detailedLogging = false; public boolean detailedLogging = false;
@ -255,6 +256,12 @@ final public class EventBus implements Destroyable {
} }
/**
* Check if client can be accepted by any channel
*
* @param client tested client
* @return would be accepted
*/
public boolean isClientValid(Object client) public boolean isClientValid(Object client)
{ {
assertLive(); assertLive();

@ -24,6 +24,9 @@ public abstract class BusNode implements BusAccess, DelegatingClient, Toggleable
private boolean delegating = true; private boolean delegating = true;
/**
* @param busAccess access to bus
*/
public BusNode(BusAccess busAccess) { public BusNode(BusAccess busAccess) {
this.busAccess = busAccess; this.busAccess = busAccess;
} }

@ -12,6 +12,9 @@ import mightypork.gamecore.control.interf.Destroyable;
*/ */
public abstract class RootBusNode extends BusNode implements Destroyable { public abstract class RootBusNode extends BusNode implements Destroyable {
/**
* @param busAccess access to bus
*/
public RootBusNode(BusAccess busAccess) { public RootBusNode(BusAccess busAccess) {
super(busAccess); super(busAccess);

@ -16,6 +16,11 @@ public class KeyEvent implements Event<KeyEvent.Listener> {
private final char c; private final char c;
/**
* @param key key that triggered the event. Can be KEY_NONE.
* @param c typed char (can be zero char)
* @param down true = pressed, false = released.
*/
public KeyEvent(int key, char c, boolean down) { public KeyEvent(int key, char c, boolean down) {
this.key = key; this.key = key;
this.c = c; this.c = c;
@ -65,6 +70,11 @@ public class KeyEvent implements Event<KeyEvent.Listener> {
keh.receive(this); keh.receive(this);
} }
/**
* {@link KeyEvent} listener
*
* @author MightyPork
*/
public interface Listener { public interface Listener {
/** /**

@ -15,6 +15,9 @@ public class MainLoopTaskRequest implements Event<MainLoopTaskRequest.Listener>
private final Runnable task; private final Runnable task;
/**
* @param task task to run on main thread in rendering context
*/
public MainLoopTaskRequest(Runnable task) { public MainLoopTaskRequest(Runnable task) {
this.task = task; this.task = task;
} }
@ -26,6 +29,11 @@ public class MainLoopTaskRequest implements Event<MainLoopTaskRequest.Listener>
handler.queueTask(task); handler.queueTask(task);
} }
/**
* {@link MainLoopTaskRequest} listener
*
* @author MightyPork
*/
public interface Listener { public interface Listener {
/** /**

@ -119,6 +119,11 @@ public class MouseButtonEvent implements Event<MouseButtonEvent.Listener> {
handler.receive(this); handler.receive(this);
} }
/**
* {@link MouseButtonEvent} listener
*
* @author MightyPork
*/
public interface Listener { public interface Listener {
/** /**

@ -17,6 +17,10 @@ public class MouseMotionEvent implements Event<MouseMotionEvent.Listener> {
private final Coord pos; private final Coord pos;
/**
* @param pos end pos
* @param move move vector
*/
public MouseMotionEvent(Coord pos, Coord move) { public MouseMotionEvent(Coord pos, Coord move) {
this.move = move; this.move = move;
this.pos = pos; this.pos = pos;
@ -47,6 +51,11 @@ public class MouseMotionEvent implements Event<MouseMotionEvent.Listener> {
keh.receive(this); keh.receive(this);
} }
/**
* {@link MouseMotionEvent} listener
*
* @author MightyPork
*/
public interface Listener { public interface Listener {
/** /**

@ -6,7 +6,7 @@ import mightypork.gamecore.loading.DeferredResource;
/** /**
* Request to schedule loading a deferred resource. * Request to load a deferred resource.
* *
* @author MightyPork * @author MightyPork
*/ */
@ -16,6 +16,9 @@ public class ResourceLoadRequest implements Event<ResourceLoadRequest.Listener>
private final DeferredResource resource; private final DeferredResource resource;
/**
* @param resource resource to load
*/
public ResourceLoadRequest(DeferredResource resource) { public ResourceLoadRequest(DeferredResource resource) {
this.resource = resource; this.resource = resource;
} }
@ -27,6 +30,11 @@ public class ResourceLoadRequest implements Event<ResourceLoadRequest.Listener>
handler.loadResource(resource); handler.loadResource(resource);
} }
/**
* {@link ResourceLoadRequest} listener
*
* @author MightyPork
*/
public interface Listener { public interface Listener {
/** /**

@ -16,6 +16,11 @@ public class ScreenChangeEvent implements Event<ScreenChangeEvent.Listener> {
private final boolean fsChanged; private final boolean fsChanged;
/**
* @param fsChanged fullscreen change triggered the event
* @param fullscreen is now fullscreen
* @param size new screen size
*/
public ScreenChangeEvent(boolean fsChanged, boolean fullscreen, Coord size) { public ScreenChangeEvent(boolean fsChanged, boolean fullscreen, Coord size) {
this.fullscreen = fullscreen; this.fullscreen = fullscreen;
this.screenSize = size; this.screenSize = size;
@ -23,18 +28,27 @@ public class ScreenChangeEvent implements Event<ScreenChangeEvent.Listener> {
} }
/**
* @return true if screen is now fullscreen
*/
public boolean isFullscreen() public boolean isFullscreen()
{ {
return fullscreen; return fullscreen;
} }
/**
* @return true if event was triggered by fullscreen toggle
*/
public boolean fullscreenChanged() public boolean fullscreenChanged()
{ {
return fsChanged; return fsChanged;
} }
/**
* @return new screen size
*/
public Coord getScreenSize() public Coord getScreenSize()
{ {
return screenSize; return screenSize;
@ -47,8 +61,18 @@ public class ScreenChangeEvent implements Event<ScreenChangeEvent.Listener> {
handler.receive(this); handler.receive(this);
} }
/**
* {@link ScreenChangeEvent} listener
*
* @author MightyPork
*/
public interface Listener { public interface Listener {
/**
* Handle event
*
* @param event
*/
void receive(ScreenChangeEvent event); void receive(ScreenChangeEvent event);
} }
} }

@ -15,6 +15,9 @@ public class ScreenRequestEvent implements Event<ScreenRequestEvent.Listener> {
private final String scrName; private final String scrName;
/**
* @param screenKey screen name
*/
public ScreenRequestEvent(String screenKey) { public ScreenRequestEvent(String screenKey) {
scrName = screenKey; scrName = screenKey;
} }
@ -26,8 +29,16 @@ public class ScreenRequestEvent implements Event<ScreenRequestEvent.Listener> {
handler.showScreen(scrName); handler.showScreen(scrName);
} }
/**
* {@link ScreenRequestEvent} listener
*
* @author MightyPork
*/
public interface Listener { public interface Listener {
/**
* @param key screen to show
*/
void showScreen(String key); void showScreen(String key);
} }

@ -8,6 +8,12 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
/**
* Indicates that the marked method is not implemented and can be safely
* overriden.
*
* @author MightyPork
*/
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target(value = { ElementType.METHOD }) @Target(value = { ElementType.METHOD })

@ -1,6 +1,11 @@
package mightypork.gamecore.control.timing; package mightypork.gamecore.control.timing;
/**
* Can be paused & resumed
*
* @author MightyPork
*/
public interface Pauseable { public interface Pauseable {
/** /**

@ -8,5 +8,10 @@ package mightypork.gamecore.gui;
*/ */
public interface ActionTrigger { public interface ActionTrigger {
/**
* Assign an action
*
* @param action action
*/
void setAction(Action action); void setAction(Action action);
} }

@ -6,18 +6,35 @@ import mightypork.gamecore.control.AppAccess;
import mightypork.utils.math.constraints.RectConstraint; import mightypork.utils.math.constraints.RectConstraint;
/**
* Holder with evenly spaced columns
*
* @author MightyPork
*/
public class ColumnHolder extends ElementHolder { public class ColumnHolder extends ElementHolder {
private final int cols; private final int cols;
private int col = 0; private int col = 0;
/**
* @param app app access
* @param context context
* @param rows number of rows
*/
public ColumnHolder(AppAccess app, RectConstraint context, int rows) { public ColumnHolder(AppAccess app, RectConstraint context, int rows) {
super(app, context); super(app, context);
this.cols = rows; this.cols = rows;
} }
/**
* make a new holder.<br>
* Context must be assigned before rendering.
*
* @param app app access
* @param rows number of rows
*/
public ColumnHolder(AppAccess app, int rows) { public ColumnHolder(AppAccess app, int rows) {
super(app); super(app);
this.cols = rows; this.cols = rows;

@ -22,11 +22,18 @@ public abstract class ElementHolder extends BusNode implements PluggableRenderab
private RectConstraint context; private RectConstraint context;
/**
* @param app app access
*/
public ElementHolder(AppAccess app) { public ElementHolder(AppAccess app) {
super(app); super(app);
} }
/**
* @param app app access
* @param context boudning context
*/
public ElementHolder(AppAccess app, RectConstraint context) { public ElementHolder(AppAccess app, RectConstraint context) {
super(app); super(app);
setContext(context); setContext(context);

@ -5,16 +5,27 @@ import mightypork.gamecore.render.Render;
import mightypork.gamecore.render.textures.TxQuad; import mightypork.gamecore.render.textures.TxQuad;
/**
* Draws image in given rect
*
* @author MightyPork
*/
public class ImagePainter extends PluggableRenderer { public class ImagePainter extends PluggableRenderer {
private TxQuad texture; private TxQuad texture;
/**
* @param texture drawn image
*/
public ImagePainter(TxQuad texture) { public ImagePainter(TxQuad texture) {
this.texture = texture; this.texture = texture;
} }
/**
* @param texture texture to use
*/
public void setTexture(TxQuad texture) public void setTexture(TxQuad texture)
{ {
this.texture = texture; this.texture = texture;

@ -6,6 +6,11 @@ import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
/**
* Renderable that can be assigned different context
*
* @author MightyPork
*/
public interface PluggableRenderable extends Renderable, PluggableContext { public interface PluggableRenderable extends Renderable, PluggableContext {
@Override @Override

@ -6,18 +6,35 @@ import mightypork.gamecore.control.AppAccess;
import mightypork.utils.math.constraints.RectConstraint; import mightypork.utils.math.constraints.RectConstraint;
/**
* Holder with evenly spaced rows
*
* @author MightyPork
*/
public class RowHolder extends ElementHolder { public class RowHolder extends ElementHolder {
private final int rows; private final int rows;
private int row = 0; private int row = 0;
/**
* @param app app access
* @param context bounding context
* @param rows number of rows
*/
public RowHolder(AppAccess app, RectConstraint context, int rows) { public RowHolder(AppAccess app, RectConstraint context, int rows) {
super(app, context); super(app, context);
this.rows = rows; this.rows = rows;
} }
/**
* Make a row holder.<br>
* Context must be assigned before rendering.
*
* @param app app access
* @param rows number of rows
*/
public RowHolder(AppAccess app, int rows) { public RowHolder(AppAccess app, int rows) {
super(app); super(app);
this.rows = rows; this.rows = rows;

@ -9,6 +9,11 @@ import mightypork.utils.string.StringProvider;
import mightypork.utils.string.StringProvider.StringWrapper; import mightypork.utils.string.StringProvider.StringWrapper;
/**
* Text painting component
*
* @author MightyPork
*/
public class TextPainter extends PluggableRenderer { public class TextPainter extends PluggableRenderer {
private final FontRenderer font; private final FontRenderer font;
@ -17,16 +22,35 @@ public class TextPainter extends PluggableRenderer {
private StringProvider text; private StringProvider text;
/**
* @param font font to use
*/
public TextPainter(GLFont font) { public TextPainter(GLFont font) {
this(font, Align.LEFT, RGB.WHITE); this(font, Align.LEFT, RGB.WHITE);
} }
/**
* Constructor for fixed text
*
* @param font font to use
* @param align text align
* @param color default color
* @param text drawn text
*/
public TextPainter(GLFont font, Align align, RGB color, String text) { public TextPainter(GLFont font, Align align, RGB color, String text) {
this(font, align, color, new StringWrapper(text)); this(font, align, color, new StringWrapper(text));
} }
/**
* COnstructor for changeable text.
*
* @param font font to use
* @param align text align
* @param color default color
* @param text text provider
*/
public TextPainter(GLFont font, Align align, RGB color, StringProvider text) { public TextPainter(GLFont font, Align align, RGB color, StringProvider text) {
this.font = new FontRenderer(font); this.font = new FontRenderer(font);
this.color = color; this.color = color;
@ -35,6 +59,11 @@ public class TextPainter extends PluggableRenderer {
} }
/**
* @param font font to use
* @param align text align
* @param color default color
*/
public TextPainter(GLFont font, Align align, RGB color) { public TextPainter(GLFont font, Align align, RGB color) {
this(font, align, color, (StringProvider) null); this(font, align, color, (StringProvider) null);
} }
@ -63,43 +92,85 @@ public class TextPainter extends PluggableRenderer {
} }
/**
* Assign paint color
*
* @param color paint color
*/
public void setColor(RGB color) public void setColor(RGB color)
{ {
this.color = color; this.color = color;
} }
/**
* Set text align
*
* @param align text align
*/
public void setAlign(Align align) public void setAlign(Align align)
{ {
this.align = align; this.align = align;
} }
/**
* Set drawn text
*
* @param text text
*/
public void setText(String text) public void setText(String text)
{ {
this.text = new StringWrapper(text); this.text = new StringWrapper(text);
} }
/**
* Set drawn text provider
*
* @param text text provider
*/
public void setText(StringProvider text) public void setText(StringProvider text)
{ {
this.text = text; this.text = text;
} }
protected RGB getColor() /**
* Get draw color.<br>
* <i>This getter is used for getting drawing color; so if it's overriden,
* the draw color can be adjusted in real time.</i>
*
* @return drawing color
*/
public RGB getColor()
{ {
return color; return color;
} }
protected Align getAlign() /**
* Get text align.<br>
* <i>This getter is used for getting align; so if it's overidden, the align
* can be adjusted in real time.</i>
*
* @return text align
*/
public Align getAlign()
{ {
return align; return align;
} }
protected String getText() /**
* Get text to draw.<br>
* <i>This getter is used for getting text to draw; so if it's overidden,
* the text can be adjusted in real time. (alternative to using
* StringProvider)</i>
*
* @return text align
*/
public String getText()
{ {
return text.getString(); return text.getString();
} }

@ -8,11 +8,19 @@ import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.render.Render; import mightypork.gamecore.render.Render;
/**
* Screen with multiple instances of {@link ScreenLayer}
*
* @author MightyPork
*/
public abstract class LayeredScreen extends Screen { public abstract class LayeredScreen extends Screen {
private final Collection<ScreenLayer> layers = new TreeSet<>(); private final Collection<ScreenLayer> layers = new TreeSet<>();
/**
* @param app app access
*/
public LayeredScreen(AppAccess app) { public LayeredScreen(AppAccess app) {
super(app); super(app);
} }

@ -28,6 +28,9 @@ public abstract class Screen extends AppSubModule implements Renderable, KeyBind
private volatile boolean needSetupViewport = false; private volatile boolean needSetupViewport = false;
/**
* @param app app access
*/
public Screen(AppAccess app) { public Screen(AppAccess app) {
super(app); super(app);

@ -22,6 +22,9 @@ public abstract class ScreenLayer extends AppSubModule implements Comparable<Scr
private final KeyBindingPool keybindings = new KeyBindingPool(); private final KeyBindingPool keybindings = new KeyBindingPool();
/**
* @param screen parent screen
*/
public ScreenLayer(Screen screen) { public ScreenLayer(Screen screen) {
super(screen); // screen as AppAccess super(screen); // screen as AppAccess
@ -44,6 +47,9 @@ public abstract class ScreenLayer extends AppSubModule implements Comparable<Scr
} }
/**
* @return parent screen instance
*/
protected final Screen getScreen() protected final Screen getScreen()
{ {
return screen; return screen;

@ -22,6 +22,9 @@ public class ScreenRegistry extends AppModule implements ScreenRequestEvent.List
private volatile Screen active = null; private volatile Screen active = null;
/**
* @param app app access
*/
public ScreenRegistry(AppAccess app) { public ScreenRegistry(AppAccess app) {
super(app); super(app);
} }

@ -19,6 +19,11 @@ import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
/**
* Input system
*
* @author MightyPork
*/
public class InputSystem extends RootBusNode implements Updateable, KeyBinder { public class InputSystem extends RootBusNode implements Updateable, KeyBinder {
// listeners // listeners
@ -27,6 +32,9 @@ public class InputSystem extends RootBusNode implements Updateable, KeyBinder {
private static boolean inited = false; private static boolean inited = false;
/**
* @param app app access
*/
public InputSystem(AppAccess app) { public InputSystem(AppAccess app) {
super(app); super(app);

@ -1,13 +1,21 @@
package mightypork.gamecore.input; package mightypork.gamecore.input;
import mightypork.gamecore.gui.Action;
/**
* Can bind events to keys.
*
* @author MightyPork
*/
public interface KeyBinder { public interface KeyBinder {
/** /**
* Bind handler to a keystroke, replace current handler if any * Bind handler to a keystroke, replace current handler if any
* *
* @param stroke trigger keystroke * @param stroke trigger keystroke
* @param task handler * @param task handler; can be {@link Runnable} or {@link Action}
*/ */
void bindKeyStroke(KeyStroke stroke, Runnable task); void bindKeyStroke(KeyStroke stroke, Runnable task);

@ -19,9 +19,14 @@ import mightypork.utils.logging.Log;
*/ */
public class AsyncResourceLoader extends Thread implements ResourceLoadRequest.Listener, Destroyable { public class AsyncResourceLoader extends Thread implements ResourceLoadRequest.Listener, Destroyable {
/**
* Start a new loader thread.
*
* @param app app access
*/
public static void launch(BusAccess app) public static void launch(BusAccess app)
{ {
Thread loader = new AsyncResourceLoader(app); final Thread loader = new AsyncResourceLoader(app);
loader.setDaemon(true); loader.setDaemon(true);
loader.start(); loader.start();
} }
@ -33,6 +38,9 @@ public class AsyncResourceLoader extends Thread implements ResourceLoadRequest.L
private final BusAccess app; private final BusAccess app;
/**
* @param app app acceess
*/
public AsyncResourceLoader(BusAccess app) { public AsyncResourceLoader(BusAccess app) {
super("Deferred loader"); super("Deferred loader");
this.app = app; this.app = app;

@ -21,6 +21,10 @@ public abstract class BaseDeferredResource implements DeferredResource, Destroya
private volatile boolean loadAttempted = false; private volatile boolean loadAttempted = false;
/**
* @param resource resource path / name; this string is later used in
* loadResource()
*/
public BaseDeferredResource(String resource) { public BaseDeferredResource(String resource) {
this.resource = resource; this.resource = resource;
} }

@ -7,8 +7,6 @@ import java.nio.ByteBuffer;
import mightypork.gamecore.control.AppAccess; import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.control.AppModule; import mightypork.gamecore.control.AppModule;
import mightypork.gamecore.control.bus.clients.RootBusNode;
import mightypork.gamecore.control.bus.events.DestroyEvent;
import mightypork.gamecore.control.bus.events.ScreenChangeEvent; import mightypork.gamecore.control.bus.events.ScreenChangeEvent;
import mightypork.gamecore.control.timing.FpsMeter; import mightypork.gamecore.control.timing.FpsMeter;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
@ -23,14 +21,23 @@ import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.DisplayMode;
/**
* Display system
*
* @author MightyPork
*/
public class DisplaySystem extends AppModule implements RectConstraint { public class DisplaySystem extends AppModule implements RectConstraint {
private DisplayMode windowDisplayMode; private DisplayMode windowDisplayMode;
private int targetFps; private int targetFps;
/** Y axis goes down (not up); Used also to adjust inputs. */
public static boolean yAxisDown = true; public static boolean yAxisDown = true;
private FpsMeter fpsMeter; private FpsMeter fpsMeter;
/**
* @param app app access
*/
public DisplaySystem(AppAccess app) { public DisplaySystem(AppAccess app) {
super(app); super(app);
} }
@ -43,12 +50,27 @@ public class DisplaySystem extends AppModule implements RectConstraint {
} }
/**
* Set target fps (for syncing in endFrame() call).<br>
* With vsync enabled, the target fps may not be met.
*
* @param fps requested fps
*/
public void setTargetFps(int fps) public void setTargetFps(int fps)
{ {
this.targetFps = fps; this.targetFps = fps;
} }
/**
* Create a main window
*
* @param width requested width
* @param height requested height
* @param resizable is resizable by the user
* @param fullscreen is in fullscreen
* @param title window title
*/
public void createMainWindow(int width, int height, boolean resizable, boolean fullscreen, String title) public void createMainWindow(int width, int height, boolean resizable, boolean fullscreen, String title)
{ {
try { try {
@ -158,12 +180,18 @@ public class DisplaySystem extends AppModule implements RectConstraint {
} }
/**
* @return screen width
*/
public static int getWidth() public static int getWidth()
{ {
return Display.getWidth(); return Display.getWidth();
} }
/**
* @return screen height
*/
public static int getHeight() public static int getHeight()
{ {
return Display.getHeight(); return Display.getHeight();
@ -211,6 +239,7 @@ public class DisplaySystem extends AppModule implements RectConstraint {
return fpsMeter.getFPS(); return fpsMeter.getFPS();
} }
/** Screen width constraint */
public static final NumberConstraint width = new NumberConstraint() { public static final NumberConstraint width = new NumberConstraint() {
@Override @Override
@ -220,6 +249,7 @@ public class DisplaySystem extends AppModule implements RectConstraint {
} }
}; };
/** Screen height constaint */
public static final NumberConstraint height = new NumberConstraint() { public static final NumberConstraint height = new NumberConstraint() {
@Override @Override

@ -353,6 +353,13 @@ public class Render {
} }
/**
* Draw quad with horizontal gradient
*
* @param quad drawn quad bounds
* @param colorLeft left color
* @param colorRight right color
*/
public static void quadGradH(Rect quad, RGB colorLeft, RGB colorRight) public static void quadGradH(Rect quad, RGB colorLeft, RGB colorRight)
{ {
final double left = quad.x1(); final double left = quad.x1();
@ -377,6 +384,13 @@ public class Render {
} }
/**
* Draw quad with vertical gradient
*
* @param quad drawn quad bounds
* @param colorTop top color
* @param colorBottom bottom color
*/
public static void quadGradV(Rect quad, RGB colorTop, RGB colorBottom) public static void quadGradV(Rect quad, RGB colorTop, RGB colorBottom)
{ {
final double left = quad.x1(); final double left = quad.x1();

@ -24,6 +24,12 @@ public class Screenshot {
private BufferedImage image; private BufferedImage image;
/**
* @param width image width
* @param height image height
* @param bpp bits per pixel (typically 4)
* @param buffer
*/
public Screenshot(int width, int height, int bpp, ByteBuffer buffer) { public Screenshot(int width, int height, int bpp, ByteBuffer buffer) {
this.width = width; this.width = width;
this.height = height; this.height = height;
@ -32,6 +38,12 @@ public class Screenshot {
} }
/**
* Extract to an image.<br>
* Subsequent calls will use a cached value.
*
* @return image
*/
public BufferedImage getImage() public BufferedImage getImage()
{ {
if (image != null) return image; if (image != null) return image;
@ -53,6 +65,13 @@ public class Screenshot {
} }
/**
* Save to a file.<br>
* Cached value is used if any.
*
* @param file target file
* @throws IOException on error writing to file
*/
public void save(File file) throws IOException public void save(File file) throws IOException
{ {
ImageIO.write(getImage(), "PNG", file); ImageIO.write(getImage(), "PNG", file);

@ -21,6 +21,9 @@ public class FontBank extends AppAdapter {
private static final GLFont NULL_FONT = new NullFont(); private static final GLFont NULL_FONT = new NullFont();
/**
* @param app app access
*/
public FontBank(AppAccess app) { public FontBank(AppAccess app) {
super(app); super(app);
} }

@ -5,6 +5,11 @@ import mightypork.utils.math.color.RGB;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
/**
* Interface bor drawable font.
*
* @author MightyPork
*/
public interface GLFont { public interface GLFont {
/** /**

@ -41,6 +41,11 @@ public class SlickFont implements GLFont {
} }
/**
* Set used filtering
*
* @param filter font filtering mode
*/
public void setFiltering(FilterMode filter) public void setFiltering(FilterMode filter)
{ {
this.filter = filter; this.filter = filter;

@ -26,11 +26,20 @@ public class DeferredTexture extends BaseDeferredResource implements FilteredTex
private WrapMode wrap = WrapMode.CLAMP; private WrapMode wrap = WrapMode.CLAMP;
/**
* @param resourcePath resource path
*/
public DeferredTexture(String resourcePath) { public DeferredTexture(String resourcePath) {
super(resourcePath); super(resourcePath);
} }
/**
* Get a quad from this texture of given position/size
*
* @param rect quad rect
* @return the quad
*/
public TxQuad getQuad(Rect rect) public TxQuad getQuad(Rect rect)
{ {
return new TxQuad(this, rect); return new TxQuad(this, rect);
@ -53,6 +62,9 @@ public class DeferredTexture extends BaseDeferredResource implements FilteredTex
} }
/**
* Bind without adjusting parameters
*/
public void bindRaw() public void bindRaw()
{ {
if (!ensureLoaded()) return; if (!ensureLoaded()) return;
@ -61,12 +73,15 @@ public class DeferredTexture extends BaseDeferredResource implements FilteredTex
} }
/**
* Bind and adjust parameters (filter, wrap)
*/
@Override @Override
public void bind() public void bind()
{ {
if (!ensureLoaded()) return; if (!ensureLoaded()) return;
backingTexture.bind(); bindRaw();
GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

@ -4,6 +4,11 @@ package mightypork.gamecore.render.textures;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
/**
* Texture filtering mode
*
* @author MightyPork
*/
public enum FilterMode public enum FilterMode
{ {
LINEAR(GL11.GL_LINEAR), NEAREST(GL11.GL_NEAREST); LINEAR(GL11.GL_LINEAR), NEAREST(GL11.GL_NEAREST);

@ -4,6 +4,11 @@ package mightypork.gamecore.render.textures;
import org.newdawn.slick.opengl.Texture; import org.newdawn.slick.opengl.Texture;
/**
* Texture with filter and wrap mode
*
* @author MightyPork
*/
public interface FilteredTexture extends Texture { public interface FilteredTexture extends Texture {
/** /**

@ -18,6 +18,9 @@ import org.newdawn.slick.opengl.Texture;
*/ */
public class TextureBank extends AppAdapter { public class TextureBank extends AppAdapter {
/**
* @param app app access
*/
public TextureBank(AppAccess app) { public TextureBank(AppAccess app) {
super(app); super(app);
} }

@ -78,12 +78,22 @@ public class TxQuad {
} }
/**
* Clone another
*
* @param txQuad a copied quad
*/
public TxQuad(TxQuad txQuad) { public TxQuad(TxQuad txQuad) {
this.tx = txQuad.tx; this.tx = txQuad.tx;
this.uvs = txQuad.uvs.copy(); this.uvs = txQuad.uvs.copy();
} }
/**
* Get copy
*
* @return copy of this
*/
public TxQuad copy() public TxQuad copy()
{ {
return new TxQuad(this); return new TxQuad(this);

@ -4,6 +4,11 @@ package mightypork.gamecore.render.textures;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
/**
* Texture wrap mode
*
* @author MightyPork
*/
public enum WrapMode public enum WrapMode
{ {
CLAMP(GL11.GL_CLAMP), REPEAT(GL11.GL_REPEAT); CLAMP(GL11.GL_CLAMP), REPEAT(GL11.GL_REPEAT);

@ -110,7 +110,7 @@ public class App extends BaseApp {
@Override @Override
protected void initKeystrokes(InputSystem input) protected void initInputSystem(InputSystem input)
{ {
// Go fullscreen // Go fullscreen
getInput().bindKeyStroke(new KeyStroke(Keys.KEY_F11), new Runnable() { getInput().bindKeyStroke(new KeyStroke(Keys.KEY_F11), new Runnable() {
@ -177,9 +177,9 @@ public class App extends BaseApp {
@Override @Override
protected void initChannels(EventBus bus) protected void initBus(EventBus bus)
{ {
super.initChannels(bus); super.initBus(bus);
// custom channels // custom channels
bus.addChannel(ActionRequest.class, ActionRequest.Listener.class); bus.addChannel(ActionRequest.class, ActionRequest.Listener.class);

@ -206,6 +206,13 @@ public class AnimDouble implements Updateable, Pauseable, NumberConstraint {
} }
/**
* Get progress already elapsed based on current value.<br>
* Used to resume animation from current point in fading etc.
*
* @param value current value
* @return progress ratio 0-1
*/
protected double getProgressFromValue(double value) protected double getProgressFromValue(double value)
{ {
double p = 0; double p = 0;

@ -4,7 +4,12 @@ package mightypork.utils.math.constraints;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
public class ContextAdapter implements PluggableContext { /**
* Basic pluggable context implementation
*
* @author MightyPork
*/
public abstract class ContextAdapter implements PluggableContext {
private RectConstraint backing = null; private RectConstraint backing = null;

@ -1,8 +1,16 @@
package mightypork.utils.math.constraints; package mightypork.utils.math.constraints;
/**
* Numeric constraint
*
* @author MightyPork
*/
public interface NumberConstraint { public interface NumberConstraint {
/**
* @return current value
*/
double getValue(); double getValue();
} }

@ -4,8 +4,16 @@ package mightypork.utils.math.constraints;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
/**
* Interface for constraints that can be assigned context
*
* @author MightyPork
*/
public interface PluggableContext extends RectConstraint { public interface PluggableContext extends RectConstraint {
/**
* @param rect context to set
*/
abstract void setContext(RectConstraint rect); abstract void setContext(RectConstraint rect);

Loading…
Cancel
Save