restruct, cleaner hierarchy; much nicer code

v5stable
Ondřej Hruška 11 years ago
parent 5e79c3ac03
commit 5e35bfe958
  1. 4
      src/mightypork/gamecore/audio/SoundSystem.java
  2. 4
      src/mightypork/gamecore/control/AppModule.java
  3. 54
      src/mightypork/gamecore/control/AppSubModule.java
  4. 27
      src/mightypork/gamecore/control/BusNode.java
  5. 2
      src/mightypork/gamecore/control/GameLoop.java
  6. 35
      src/mightypork/gamecore/control/RootBusNode.java
  7. 8
      src/mightypork/gamecore/control/bus/EventBus.java
  8. 12
      src/mightypork/gamecore/gui/renderers/ElementHolder.java
  9. 1
      src/mightypork/gamecore/gui/renderers/PluggableRenderable.java
  10. 1
      src/mightypork/gamecore/gui/renderers/PluggableRenderer.java
  11. 2
      src/mightypork/gamecore/gui/renderers/Renderable.java
  12. 31
      src/mightypork/gamecore/gui/screens/Screen.java
  13. 13
      src/mightypork/gamecore/gui/screens/ScreenLayer.java
  14. 6
      src/mightypork/gamecore/gui/screens/ScreenRegistry.java
  15. 47
      src/mightypork/gamecore/input/InputSystem.java
  16. 30
      src/mightypork/gamecore/render/DisplaySystem.java
  17. 2
      src/mightypork/rogue/App.java
  18. 4
      src/mightypork/rogue/MainLoop.java
  19. 6
      src/mightypork/rogue/Res.java
  20. 4
      src/mightypork/rogue/TaskTakeScreenshot.java
  21. 14
      src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java

@ -8,7 +8,7 @@ import java.util.Set;
import mightypork.gamecore.audio.players.EffectPlayer; import mightypork.gamecore.audio.players.EffectPlayer;
import mightypork.gamecore.audio.players.LoopPlayer; import mightypork.gamecore.audio.players.LoopPlayer;
import mightypork.gamecore.control.AppAccess; import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.control.Subsystem; import mightypork.gamecore.control.RootBusNode;
import mightypork.gamecore.control.bus.events.ResourceLoadRequest; import mightypork.gamecore.control.bus.events.ResourceLoadRequest;
import mightypork.gamecore.control.interf.Updateable; import mightypork.gamecore.control.interf.Updateable;
import mightypork.utils.math.Calc.Buffers; import mightypork.utils.math.Calc.Buffers;
@ -26,7 +26,7 @@ import org.newdawn.slick.openal.SoundStore;
* @author MightyPork * @author MightyPork
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class SoundSystem extends Subsystem implements Updateable { public class SoundSystem extends RootBusNode implements Updateable {
private static final Coord INITIAL_LISTENER_POS = new Coord(0, 0, 0); private static final Coord INITIAL_LISTENER_POS = new Coord(0, 0, 0);
private static final int MAX_SOURCES = 256; private static final int MAX_SOURCES = 256;

@ -12,12 +12,12 @@ import mightypork.gamecore.render.DisplaySystem;
* *
* @author MightyPork * @author MightyPork
*/ */
public abstract class Subsystem extends ChildClient implements AppAccess { public abstract class AppModule extends RootBusNode implements AppAccess {
private final AppAccess app; private final AppAccess app;
public Subsystem(AppAccess app) { public AppModule(AppAccess app) {
super(app); super(app);
this.app = app; this.app = app;

@ -0,0 +1,54 @@
package mightypork.gamecore.control;
import mightypork.gamecore.audio.SoundSystem;
import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.render.DisplaySystem;
/**
* App event bus client, to be used for subsystems, screens and anything that
* needs access to the eventbus
*
* @author MightyPork
*/
public abstract class AppSubModule extends BusNode implements AppAccess {
private final AppAccess app;
public AppSubModule(AppAccess app) {
super(app);
this.app = app;
}
@Override
public final SoundSystem snd()
{
return app.snd();
}
@Override
public final InputSystem input()
{
return app.input();
}
@Override
public final DisplaySystem disp()
{
return app.disp();
}
@Override
public void shutdown()
{
app.shutdown();
}
}

@ -8,7 +8,6 @@ import java.util.Set;
import mightypork.gamecore.control.bus.EventBus; import mightypork.gamecore.control.bus.EventBus;
import mightypork.gamecore.control.bus.clients.DelegatingClient; import mightypork.gamecore.control.bus.clients.DelegatingClient;
import mightypork.gamecore.control.bus.clients.ToggleableClient; import mightypork.gamecore.control.bus.clients.ToggleableClient;
import mightypork.gamecore.control.interf.Destroyable;
/** /**
@ -17,7 +16,7 @@ import mightypork.gamecore.control.interf.Destroyable;
* *
* @author MightyPork * @author MightyPork
*/ */
public abstract class ChildClient implements BusAccess, DelegatingClient, ToggleableClient, Destroyable { public abstract class BusNode implements BusAccess, DelegatingClient, ToggleableClient {
private BusAccess busAccess; private BusAccess busAccess;
@ -26,29 +25,11 @@ public abstract class ChildClient implements BusAccess, DelegatingClient, Toggle
private boolean delegating = true; private boolean delegating = true;
public ChildClient(BusAccess busAccess) { public BusNode(BusAccess busAccess) {
this.busAccess = busAccess; this.busAccess = busAccess;
bus().subscribe(this);
} }
@Override
public final void destroy()
{
deinit();
bus().unsubscribe(this);
}
/**
* Deinitialize the subsystem<br>
* (called during destruction)
*/
protected abstract void deinit();
@Override @Override
public final Collection<Object> getChildClients() public final Collection<Object> getChildClients()
{ {
@ -77,6 +58,10 @@ public abstract class ChildClient implements BusAccess, DelegatingClient, Toggle
*/ */
public final void addChildClient(Object client) public final void addChildClient(Object client)
{ {
if(client instanceof RootBusNode) {
throw new IllegalArgumentException("Cannot nest RootBusNode.");
}
if (bus().isClientValid(client)) { if (bus().isClientValid(client)) {
clients.add(client); clients.add(client);
} }

@ -9,7 +9,7 @@ import mightypork.gamecore.control.bus.events.UpdateEvent;
import mightypork.gamecore.control.timing.TimerDelta; import mightypork.gamecore.control.timing.TimerDelta;
public abstract class GameLoop extends Subsystem implements MainLoopTaskRequest.Listener { public abstract class GameLoop extends AppModule implements MainLoopTaskRequest.Listener {
private final Queue<Runnable> taskQueue = new ConcurrentLinkedQueue<Runnable>(); private final Queue<Runnable> taskQueue = new ConcurrentLinkedQueue<Runnable>();
/** timer */ /** timer */

@ -0,0 +1,35 @@
package mightypork.gamecore.control;
import mightypork.gamecore.control.interf.Destroyable;
/**
* Bus node that should be directly attached to the bus.
*
* @author MightyPork
*/
public abstract class RootBusNode extends BusNode implements Destroyable {
public RootBusNode(BusAccess busAccess) {
super(busAccess);
bus().subscribe(this);
}
@Override
public final void destroy()
{
deinit();
bus().unsubscribe(this);
}
/**
* Deinitialize the subsystem<br>
* (called during destruction)
*/
protected abstract void deinit();
}

@ -36,7 +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;
public boolean logSending = false; public boolean detailedLogging = false;
/** /**
@ -50,7 +50,7 @@ final public class EventBus implements Destroyable {
private boolean shallLog(Event<?> event) private boolean shallLog(Event<?> event)
{ {
if (!logSending) return false; if (!detailedLogging) return false;
if (event.getClass().isAnnotationPresent(UnloggedEvent.class)) return false; if (event.getClass().isAnnotationPresent(UnloggedEvent.class)) return false;
return true; return true;
@ -234,6 +234,8 @@ final public class EventBus implements Destroyable {
if (client == null) return; if (client == null) return;
clients.add(client); clients.add(client);
if(detailedLogging) Log.f3("<bus> Client joined: "+Log.str(client));
} }
@ -247,6 +249,8 @@ final public class EventBus implements Destroyable {
assertLive(); assertLive();
clients.remove(client); clients.remove(client);
if(detailedLogging) Log.f3("<bus> Client left: "+Log.str(client));
} }

@ -4,9 +4,8 @@ package mightypork.gamecore.gui.renderers;
import java.util.LinkedList; import java.util.LinkedList;
import mightypork.gamecore.control.AppAccess; import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.control.ChildClient; import mightypork.gamecore.control.BusNode;
import mightypork.gamecore.control.bus.EventBus; import mightypork.gamecore.control.bus.EventBus;
import mightypork.gamecore.render.Renderable;
import mightypork.utils.math.constraints.RectConstraint; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
@ -17,7 +16,7 @@ import mightypork.utils.math.coord.Rect;
* *
* @author MightyPork * @author MightyPork
*/ */
public abstract class ElementHolder extends ChildClient implements PluggableRenderable { public abstract class ElementHolder extends BusNode implements PluggableRenderable {
private final LinkedList<PluggableRenderable> elements = new LinkedList<PluggableRenderable>(); private final LinkedList<PluggableRenderable> elements = new LinkedList<PluggableRenderable>();
private RectConstraint context; private RectConstraint context;
@ -79,11 +78,4 @@ public abstract class ElementHolder extends ChildClient implements PluggableRend
addChildClient(elem); addChildClient(elem);
} }
@Override
protected void deinit()
{
// no impl
}
} }

@ -1,7 +1,6 @@
package mightypork.gamecore.gui.renderers; package mightypork.gamecore.gui.renderers;
import mightypork.gamecore.render.Renderable;
import mightypork.utils.math.constraints.PluggableContext; import mightypork.utils.math.constraints.PluggableContext;
import mightypork.utils.math.constraints.RectConstraint; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;

@ -1,7 +1,6 @@
package mightypork.gamecore.gui.renderers; package mightypork.gamecore.gui.renderers;
import mightypork.gamecore.render.Renderable;
import mightypork.utils.math.constraints.ContextAdapter; import mightypork.utils.math.constraints.ContextAdapter;
import mightypork.utils.math.constraints.RectConstraint; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;

@ -1,4 +1,4 @@
package mightypork.gamecore.render; package mightypork.gamecore.gui.renderers;
/** /**

@ -3,13 +3,13 @@ package mightypork.gamecore.gui.screens;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import mightypork.gamecore.control.AppAccess; import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.control.Subsystem; import mightypork.gamecore.control.AppSubModule;
import mightypork.gamecore.control.bus.events.ScreenChangeEvent; import mightypork.gamecore.control.bus.events.ScreenChangeEvent;
import mightypork.gamecore.control.interf.Destroyable; import mightypork.gamecore.gui.renderers.Renderable;
import mightypork.gamecore.input.KeyBinder; import mightypork.gamecore.input.KeyBinder;
import mightypork.gamecore.input.KeyBindingPool; import mightypork.gamecore.input.KeyBindingPool;
import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.render.Renderable; import mightypork.gamecore.render.DisplaySystem;
import mightypork.utils.math.constraints.RectConstraint; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
@ -20,7 +20,7 @@ import mightypork.utils.math.coord.Rect;
* *
* @author MightyPork * @author MightyPork
*/ */
public abstract class Screen extends Subsystem implements Renderable, Destroyable, KeyBinder, RectConstraint, ScreenChangeEvent.Listener { public abstract class Screen extends AppSubModule implements Renderable, KeyBinder, RectConstraint, ScreenChangeEvent.Listener {
private final KeyBindingPool keybindings = new KeyBindingPool(); private final KeyBindingPool keybindings = new KeyBindingPool();
@ -52,13 +52,6 @@ public abstract class Screen extends Subsystem implements Renderable, Destroyabl
} }
@Override
public final void deinit()
{
deinitScreen();
}
/** /**
* Prepare for being shown * Prepare for being shown
* *
@ -155,26 +148,12 @@ public abstract class Screen extends Subsystem implements Renderable, Destroyabl
if (!isActive()) return; if (!isActive()) return;
if (needSetupViewport) { if (needSetupViewport) {
setupViewport(); DisplaySystem.setupOrtho();
} }
renderScreen(); renderScreen();
} }
protected void setupViewport()
{
// fix projection for changed size
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
final Coord s = disp().getSize();
glViewport(0, 0, s.xi(), s.yi());
glOrtho(0, s.x, s.y, 0, -1000, 1000);
// back to modelview
glMatrixMode(GL_MODELVIEW);
}
public abstract String getId(); public abstract String getId();
} }

@ -1,11 +1,11 @@
package mightypork.gamecore.gui.screens; package mightypork.gamecore.gui.screens;
import mightypork.gamecore.control.Subsystem; import mightypork.gamecore.control.AppSubModule;
import mightypork.gamecore.gui.renderers.Renderable;
import mightypork.gamecore.input.KeyBinder; import mightypork.gamecore.input.KeyBinder;
import mightypork.gamecore.input.KeyBindingPool; import mightypork.gamecore.input.KeyBindingPool;
import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.render.Renderable;
import mightypork.utils.math.constraints.RectConstraint; import mightypork.utils.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Rect; import mightypork.utils.math.coord.Rect;
@ -15,7 +15,7 @@ import mightypork.utils.math.coord.Rect;
* *
* @author MightyPork * @author MightyPork
*/ */
public abstract class ScreenLayer extends Subsystem implements Renderable, RectConstraint, KeyBinder { public abstract class ScreenLayer extends AppSubModule implements Renderable, RectConstraint, KeyBinder {
private final Screen screen; private final Screen screen;
@ -56,11 +56,4 @@ public abstract class ScreenLayer extends Subsystem implements Renderable, RectC
return screen.getRect(); return screen.getRect();
} }
@Override
protected void deinit()
{
// noimpl
}
} }

@ -4,13 +4,13 @@ package mightypork.gamecore.gui.screens;
import java.util.HashMap; import java.util.HashMap;
import mightypork.gamecore.control.AppAccess; import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.control.Subsystem; import mightypork.gamecore.control.AppModule;
import mightypork.gamecore.control.bus.events.ScreenRequestEvent; import mightypork.gamecore.control.bus.events.ScreenRequestEvent;
import mightypork.gamecore.render.Renderable; import mightypork.gamecore.gui.renderers.Renderable;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
public class ScreenRegistry extends Subsystem implements ScreenRequestEvent.Listener, Renderable { 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<String, Screen>();
private Screen active = null; private Screen active = null;

@ -2,11 +2,12 @@ package mightypork.gamecore.input;
import mightypork.gamecore.control.AppAccess; import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.control.Subsystem; import mightypork.gamecore.control.RootBusNode;
import mightypork.gamecore.control.bus.events.KeyboardEvent; import mightypork.gamecore.control.bus.events.KeyboardEvent;
import mightypork.gamecore.control.bus.events.MouseButtonEvent; import mightypork.gamecore.control.bus.events.MouseButtonEvent;
import mightypork.gamecore.control.bus.events.MouseMotionEvent; import mightypork.gamecore.control.bus.events.MouseMotionEvent;
import mightypork.gamecore.control.interf.Updateable; import mightypork.gamecore.control.interf.Updateable;
import mightypork.gamecore.render.DisplaySystem;
import mightypork.rogue.events.ActionRequest; import mightypork.rogue.events.ActionRequest;
import mightypork.rogue.events.ActionRequest.RequestType; import mightypork.rogue.events.ActionRequest.RequestType;
import mightypork.utils.math.constraints.NumberConstraint; import mightypork.utils.math.constraints.NumberConstraint;
@ -18,14 +19,12 @@ import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
public class InputSystem extends Subsystem implements Updateable, KeyBinder { public class InputSystem extends RootBusNode implements Updateable, KeyBinder {
// listeners // listeners
private final KeyBindingPool keybindings; private final KeyBindingPool keybindings;
private boolean yAxisDown = true;
private static boolean inited = false;
private static boolean inited = false;
public InputSystem(AppAccess app) { public InputSystem(AppAccess app) {
super(app); super(app);
@ -113,7 +112,7 @@ public class InputSystem extends Subsystem implements Updateable, KeyBinder {
final Coord move = new Coord(Mouse.getEventDX(), Mouse.getEventDY()); final Coord move = new Coord(Mouse.getEventDX(), Mouse.getEventDY());
final int wheeld = Mouse.getEventDWheel(); final int wheeld = Mouse.getEventDWheel();
if (yAxisDown) { if (DisplaySystem.yAxisDown) {
flipScrY(pos); flipScrY(pos);
move.mul_ip(1, -1, 1); move.mul_ip(1, -1, 1);
} }
@ -137,23 +136,9 @@ public class InputSystem extends Subsystem implements Updateable, KeyBinder {
} }
private void flipScrY(Coord c) private static void flipScrY(Coord c)
{ {
if (disp() != null) { if (DisplaySystem.yAxisDown) c.setY_ip(DisplaySystem.getSize().y - c.y);
c.setY_ip(disp().getSize().y - c.y);
}
}
/**
* Set whether Y axis should go top-down instead of LWJGL default bottom-up.<br>
* Default = true.
*
* @param yAxisDown
*/
public void setYDown(boolean yAxisDown)
{
this.yAxisDown = yAxisDown;
} }
@ -162,7 +147,7 @@ public class InputSystem extends Subsystem implements Updateable, KeyBinder {
* *
* @return mouse position * @return mouse position
*/ */
public Coord getMousePos() public static Coord getMousePos()
{ {
final Coord pos = new Coord(Mouse.getX(), Mouse.getY()); final Coord pos = new Coord(Mouse.getX(), Mouse.getY());
flipScrY(pos); flipScrY(pos);
@ -175,7 +160,7 @@ public class InputSystem extends Subsystem implements Updateable, KeyBinder {
Mouse.setGrabbed(grab); Mouse.setGrabbed(grab);
} }
private final NumberConstraint cmousex = new NumberConstraint() { public static final NumberConstraint mouseX = new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -184,7 +169,7 @@ public class InputSystem extends Subsystem implements Updateable, KeyBinder {
} }
}; };
private final NumberConstraint cmousey = new NumberConstraint() { public static final NumberConstraint mouseY = new NumberConstraint() {
@Override @Override
public double getValue() public double getValue()
@ -192,16 +177,4 @@ public class InputSystem extends Subsystem implements Updateable, KeyBinder {
return getMousePos().y; return getMousePos().y;
} }
}; };
public NumberConstraint c_mouse_x()
{
return cmousex;
}
public NumberConstraint c_mouse_y()
{
return cmousey;
}
} }

@ -11,7 +11,7 @@ import java.nio.ByteBuffer;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import mightypork.gamecore.control.AppAccess; import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.control.Subsystem; import mightypork.gamecore.control.RootBusNode;
import mightypork.gamecore.control.bus.events.ScreenChangeEvent; import mightypork.gamecore.control.bus.events.ScreenChangeEvent;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
import mightypork.utils.math.constraints.RectConstraint; import mightypork.utils.math.constraints.RectConstraint;
@ -24,10 +24,11 @@ import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.DisplayMode;
public class DisplaySystem extends Subsystem implements RectConstraint { public class DisplaySystem extends RootBusNode implements RectConstraint {
private DisplayMode windowDisplayMode; private DisplayMode windowDisplayMode;
private int targetFps; private int targetFps;
public static boolean yAxisDown = true;
public DisplaySystem(AppAccess app) { public DisplaySystem(AppAccess app) {
@ -105,7 +106,7 @@ public class DisplaySystem extends Subsystem implements RectConstraint {
} }
public Screenshot takeScreenshot() public static Screenshot takeScreenshot()
{ {
glReadBuffer(GL_FRONT); glReadBuffer(GL_FRONT);
final int width = Display.getDisplayMode().getWidth(); final int width = Display.getDisplayMode().getWidth();
@ -135,7 +136,7 @@ public class DisplaySystem extends Subsystem implements RectConstraint {
* *
* @return is fullscreen * @return is fullscreen
*/ */
public boolean isFullscreen() public static boolean isFullscreen()
{ {
return Display.isFullscreen(); return Display.isFullscreen();
} }
@ -146,19 +147,19 @@ public class DisplaySystem extends Subsystem implements RectConstraint {
* *
* @return size * @return size
*/ */
public Coord getSize() public static Coord getSize()
{ {
return new Coord(getWidth(), getHeight()); return new Coord(getWidth(), getHeight());
} }
public int getWidth() public static int getWidth()
{ {
return Display.getWidth(); return Display.getWidth();
} }
public int getHeight() public static int getHeight()
{ {
return Display.getHeight(); return Display.getHeight();
} }
@ -238,4 +239,19 @@ public class DisplaySystem extends Subsystem implements RectConstraint {
ImageIO.write(getImage(), "PNG", file); ImageIO.write(getImage(), "PNG", file);
} }
} }
public static void setupOrtho()
{
// fix projection for changed size
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
final Coord s = getSize();
glViewport(0, 0, s.xi(), s.yi());
glOrtho(0, s.x, (yAxisDown ? 1 : -1) * s.y, 0, -1000, 1000);
// back to modelview
glMatrixMode(GL_MODELVIEW);
}
} }

@ -144,7 +144,7 @@ public class App implements AppAccess {
*/ */
Log.f2("Initializing Event Bus..."); Log.f2("Initializing Event Bus...");
eventBus = new EventBus(); eventBus = new EventBus();
eventBus.logSending = true; eventBus.detailedLogging = true;
initChannels(); initChannels();
/* /*

@ -2,8 +2,8 @@ package mightypork.rogue;
import mightypork.gamecore.control.GameLoop; import mightypork.gamecore.control.GameLoop;
import mightypork.gamecore.gui.renderers.Renderable;
import mightypork.gamecore.input.Action; import mightypork.gamecore.input.Action;
import mightypork.gamecore.render.Renderable;
import mightypork.rogue.events.ActionRequest; import mightypork.rogue.events.ActionRequest;
import mightypork.rogue.events.ActionRequest.RequestType; import mightypork.rogue.events.ActionRequest.RequestType;
import mightypork.rogue.util.Utils; import mightypork.rogue.util.Utils;
@ -56,7 +56,7 @@ public class MainLoop extends GameLoop implements ActionRequest.Listener {
public void execute() public void execute()
{ {
Res.getEffect("gui.shutter").play(1); Res.getEffect("gui.shutter").play(1);
Utils.runAsThread(new TaskTakeScreenshot(disp())); Utils.runAsThread(new TaskTakeScreenshot());
} }
}; };

@ -7,13 +7,13 @@ import mightypork.gamecore.audio.players.LoopPlayer;
import mightypork.gamecore.control.AppAccess; import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.loading.AsyncResourceLoader; import mightypork.gamecore.loading.AsyncResourceLoader;
import mightypork.gamecore.render.fonts.DeferredFont; import mightypork.gamecore.render.fonts.DeferredFont;
import mightypork.gamecore.render.fonts.DeferredFont.FontStyle;
import mightypork.gamecore.render.fonts.FontBank; import mightypork.gamecore.render.fonts.FontBank;
import mightypork.gamecore.render.fonts.GLFont; import mightypork.gamecore.render.fonts.GLFont;
import mightypork.gamecore.render.fonts.DeferredFont.FontStyle;
import mightypork.gamecore.render.textures.TextureBank;
import mightypork.gamecore.render.textures.TxQuad;
import mightypork.gamecore.render.textures.FilteredTexture.Filter; import mightypork.gamecore.render.textures.FilteredTexture.Filter;
import mightypork.gamecore.render.textures.FilteredTexture.Wrap; import mightypork.gamecore.render.textures.FilteredTexture.Wrap;
import mightypork.gamecore.render.textures.TextureBank;
import mightypork.gamecore.render.textures.TxQuad;
import org.newdawn.slick.opengl.Texture; import org.newdawn.slick.opengl.Texture;

@ -17,8 +17,8 @@ public class TaskTakeScreenshot implements Runnable {
private final Screenshot scr; private final Screenshot scr;
public TaskTakeScreenshot(DisplaySystem disp) { public TaskTakeScreenshot() {
scr = disp.takeScreenshot(); scr = DisplaySystem.takeScreenshot();
} }

@ -12,8 +12,10 @@ import mightypork.gamecore.gui.renderers.TextRenderer;
import mightypork.gamecore.gui.renderers.TextRenderer.Align; import mightypork.gamecore.gui.renderers.TextRenderer.Align;
import mightypork.gamecore.gui.screens.Screen; import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer; import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.input.KeyStroke; import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.input.Keys; import mightypork.gamecore.input.Keys;
import mightypork.gamecore.render.DisplaySystem;
import mightypork.rogue.Res; import mightypork.rogue.Res;
import mightypork.utils.math.animation.AnimDouble; import mightypork.utils.math.animation.AnimDouble;
import mightypork.utils.math.animation.Easing; import mightypork.utils.math.animation.Easing;
@ -37,8 +39,8 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
public LayerFlyingCat(Screen screen) { public LayerFlyingCat(Screen screen) {
super(screen); super(screen);
xPos.setTo(disp().getWidth() / 2); xPos.setTo(DisplaySystem.getWidth() / 2);
yPos.setTo(disp().getHeight() / 2); yPos.setTo(DisplaySystem.getHeight() / 2);
cat = new ImageRenderer(Res.getTxQuad("test.kitten")); cat = new ImageRenderer(Res.getTxQuad("test.kitten"));
cat.setContext(c_centered(c_box(this, c_n(size), c_n(size)), c_n(xPos), c_n(yPos))); cat.setContext(c_centered(c_box(this, c_n(size), c_n(size)), c_n(xPos), c_n(yPos)));
@ -46,8 +48,8 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
//@formatter:off //@formatter:off
final RectConstraint flyingFontBox = c_centered( final RectConstraint flyingFontBox = c_centered(
c_box(this, c_n(0), c_n(64)), c_box(this, c_n(0), c_n(64)),
input().c_mouse_x(), InputSystem.mouseX,
input().c_mouse_y() InputSystem.mouseY
); );
//@formatter:on //@formatter:on
@ -59,8 +61,8 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
@Override @Override
public void run() public void run()
{ {
xPos.fadeTo(disp().getWidth() / 2, 2); xPos.fadeTo(DisplaySystem.getWidth() / 2, 2);
yPos.fadeTo(disp().getHeight() / 2, 2); yPos.fadeTo(DisplaySystem.getHeight() / 2, 2);
} }
}); });
} }

Loading…
Cancel
Save