restruct, cleaner hierarchy; much nicer code
This commit is contained in:
@@ -8,7 +8,7 @@ import java.util.Set;
|
||||
import mightypork.gamecore.audio.players.EffectPlayer;
|
||||
import mightypork.gamecore.audio.players.LoopPlayer;
|
||||
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.interf.Updateable;
|
||||
import mightypork.utils.math.Calc.Buffers;
|
||||
@@ -26,7 +26,7 @@ import org.newdawn.slick.openal.SoundStore;
|
||||
* @author MightyPork
|
||||
*/
|
||||
@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 int MAX_SOURCES = 256;
|
||||
|
||||
+2
-2
@@ -12,12 +12,12 @@ import mightypork.gamecore.render.DisplaySystem;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public abstract class Subsystem extends ChildClient implements AppAccess {
|
||||
public abstract class AppModule extends RootBusNode implements AppAccess {
|
||||
|
||||
private final AppAccess app;
|
||||
|
||||
|
||||
public Subsystem(AppAccess app) {
|
||||
public AppModule(AppAccess app) {
|
||||
super(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();
|
||||
}
|
||||
|
||||
}
|
||||
+6
-21
@@ -8,7 +8,6 @@ import java.util.Set;
|
||||
import mightypork.gamecore.control.bus.EventBus;
|
||||
import mightypork.gamecore.control.bus.clients.DelegatingClient;
|
||||
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
|
||||
*/
|
||||
public abstract class ChildClient implements BusAccess, DelegatingClient, ToggleableClient, Destroyable {
|
||||
public abstract class BusNode implements BusAccess, DelegatingClient, ToggleableClient {
|
||||
|
||||
private BusAccess busAccess;
|
||||
|
||||
@@ -26,29 +25,11 @@ public abstract class ChildClient implements BusAccess, DelegatingClient, Toggle
|
||||
private boolean delegating = true;
|
||||
|
||||
|
||||
public ChildClient(BusAccess busAccess) {
|
||||
public BusNode(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
|
||||
public final Collection<Object> getChildClients()
|
||||
{
|
||||
@@ -77,6 +58,10 @@ public abstract class ChildClient implements BusAccess, DelegatingClient, Toggle
|
||||
*/
|
||||
public final void addChildClient(Object client)
|
||||
{
|
||||
if(client instanceof RootBusNode) {
|
||||
throw new IllegalArgumentException("Cannot nest RootBusNode.");
|
||||
}
|
||||
|
||||
if (bus().isClientValid(client)) {
|
||||
clients.add(client);
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import mightypork.gamecore.control.bus.events.UpdateEvent;
|
||||
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>();
|
||||
/** 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 */
|
||||
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)
|
||||
{
|
||||
if (!logSending) return false;
|
||||
if (!detailedLogging) return false;
|
||||
if (event.getClass().isAnnotationPresent(UnloggedEvent.class)) return false;
|
||||
|
||||
return true;
|
||||
@@ -234,6 +234,8 @@ final public class EventBus implements Destroyable {
|
||||
if (client == null) return;
|
||||
|
||||
clients.add(client);
|
||||
|
||||
if(detailedLogging) Log.f3("<bus> Client joined: "+Log.str(client));
|
||||
}
|
||||
|
||||
|
||||
@@ -247,6 +249,8 @@ final public class EventBus implements Destroyable {
|
||||
assertLive();
|
||||
|
||||
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 mightypork.gamecore.control.AppAccess;
|
||||
import mightypork.gamecore.control.ChildClient;
|
||||
import mightypork.gamecore.control.BusNode;
|
||||
import mightypork.gamecore.control.bus.EventBus;
|
||||
import mightypork.gamecore.render.Renderable;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
import mightypork.utils.math.coord.Rect;
|
||||
|
||||
@@ -17,7 +16,7 @@ import mightypork.utils.math.coord.Rect;
|
||||
*
|
||||
* @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 RectConstraint context;
|
||||
@@ -79,11 +78,4 @@ public abstract class ElementHolder extends ChildClient implements PluggableRend
|
||||
addChildClient(elem);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void deinit()
|
||||
{
|
||||
// no impl
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mightypork.gamecore.gui.renderers;
|
||||
|
||||
|
||||
import mightypork.gamecore.render.Renderable;
|
||||
import mightypork.utils.math.constraints.PluggableContext;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
import mightypork.utils.math.coord.Rect;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mightypork.gamecore.gui.renderers;
|
||||
|
||||
|
||||
import mightypork.gamecore.render.Renderable;
|
||||
import mightypork.utils.math.constraints.ContextAdapter;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
import mightypork.utils.math.coord.Rect;
|
||||
|
||||
+1
-1
@@ -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 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.interf.Destroyable;
|
||||
import mightypork.gamecore.gui.renderers.Renderable;
|
||||
import mightypork.gamecore.input.KeyBinder;
|
||||
import mightypork.gamecore.input.KeyBindingPool;
|
||||
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.coord.Coord;
|
||||
import mightypork.utils.math.coord.Rect;
|
||||
@@ -20,7 +20,7 @@ import mightypork.utils.math.coord.Rect;
|
||||
*
|
||||
* @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();
|
||||
|
||||
@@ -52,13 +52,6 @@ public abstract class Screen extends Subsystem implements Renderable, Destroyabl
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void deinit()
|
||||
{
|
||||
deinitScreen();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare for being shown
|
||||
*
|
||||
@@ -155,26 +148,12 @@ public abstract class Screen extends Subsystem implements Renderable, Destroyabl
|
||||
if (!isActive()) return;
|
||||
|
||||
if (needSetupViewport) {
|
||||
setupViewport();
|
||||
DisplaySystem.setupOrtho();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
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.KeyBindingPool;
|
||||
import mightypork.gamecore.input.KeyStroke;
|
||||
import mightypork.gamecore.render.Renderable;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
import mightypork.utils.math.coord.Rect;
|
||||
|
||||
@@ -15,7 +15,7 @@ import mightypork.utils.math.coord.Rect;
|
||||
*
|
||||
* @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;
|
||||
|
||||
@@ -56,11 +56,4 @@ public abstract class ScreenLayer extends Subsystem implements Renderable, RectC
|
||||
return screen.getRect();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void deinit()
|
||||
{
|
||||
// noimpl
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ package mightypork.gamecore.gui.screens;
|
||||
import java.util.HashMap;
|
||||
|
||||
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.render.Renderable;
|
||||
import mightypork.gamecore.gui.renderers.Renderable;
|
||||
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 Screen active = null;
|
||||
|
||||
@@ -2,11 +2,12 @@ package mightypork.gamecore.input;
|
||||
|
||||
|
||||
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.MouseButtonEvent;
|
||||
import mightypork.gamecore.control.bus.events.MouseMotionEvent;
|
||||
import mightypork.gamecore.control.interf.Updateable;
|
||||
import mightypork.gamecore.render.DisplaySystem;
|
||||
import mightypork.rogue.events.ActionRequest;
|
||||
import mightypork.rogue.events.ActionRequest.RequestType;
|
||||
import mightypork.utils.math.constraints.NumberConstraint;
|
||||
@@ -18,14 +19,12 @@ import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.Display;
|
||||
|
||||
|
||||
public class InputSystem extends Subsystem implements Updateable, KeyBinder {
|
||||
public class InputSystem extends RootBusNode implements Updateable, KeyBinder {
|
||||
|
||||
// listeners
|
||||
private final KeyBindingPool keybindings;
|
||||
private boolean yAxisDown = true;
|
||||
|
||||
private static boolean inited = false;
|
||||
|
||||
|
||||
public InputSystem(AppAccess 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 int wheeld = Mouse.getEventDWheel();
|
||||
|
||||
if (yAxisDown) {
|
||||
if (DisplaySystem.yAxisDown) {
|
||||
flipScrY(pos);
|
||||
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) {
|
||||
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;
|
||||
if (DisplaySystem.yAxisDown) c.setY_ip(DisplaySystem.getSize().y - c.y);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +147,7 @@ public class InputSystem extends Subsystem implements Updateable, KeyBinder {
|
||||
*
|
||||
* @return mouse position
|
||||
*/
|
||||
public Coord getMousePos()
|
||||
public static Coord getMousePos()
|
||||
{
|
||||
final Coord pos = new Coord(Mouse.getX(), Mouse.getY());
|
||||
flipScrY(pos);
|
||||
@@ -175,7 +160,7 @@ public class InputSystem extends Subsystem implements Updateable, KeyBinder {
|
||||
Mouse.setGrabbed(grab);
|
||||
}
|
||||
|
||||
private final NumberConstraint cmousex = new NumberConstraint() {
|
||||
public static final NumberConstraint mouseX = new NumberConstraint() {
|
||||
|
||||
@Override
|
||||
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
|
||||
public double getValue()
|
||||
@@ -192,16 +177,4 @@ public class InputSystem extends Subsystem implements Updateable, KeyBinder {
|
||||
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 mightypork.gamecore.control.AppAccess;
|
||||
import mightypork.gamecore.control.Subsystem;
|
||||
import mightypork.gamecore.control.RootBusNode;
|
||||
import mightypork.gamecore.control.bus.events.ScreenChangeEvent;
|
||||
import mightypork.utils.logging.Log;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
@@ -24,10 +24,11 @@ import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.DisplayMode;
|
||||
|
||||
|
||||
public class DisplaySystem extends Subsystem implements RectConstraint {
|
||||
public class DisplaySystem extends RootBusNode implements RectConstraint {
|
||||
|
||||
private DisplayMode windowDisplayMode;
|
||||
private int targetFps;
|
||||
public static boolean yAxisDown = true;
|
||||
|
||||
|
||||
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);
|
||||
final int width = Display.getDisplayMode().getWidth();
|
||||
@@ -135,7 +136,7 @@ public class DisplaySystem extends Subsystem implements RectConstraint {
|
||||
*
|
||||
* @return is fullscreen
|
||||
*/
|
||||
public boolean isFullscreen()
|
||||
public static boolean isFullscreen()
|
||||
{
|
||||
return Display.isFullscreen();
|
||||
}
|
||||
@@ -146,19 +147,19 @@ public class DisplaySystem extends Subsystem implements RectConstraint {
|
||||
*
|
||||
* @return size
|
||||
*/
|
||||
public Coord getSize()
|
||||
public static Coord getSize()
|
||||
{
|
||||
return new Coord(getWidth(), getHeight());
|
||||
}
|
||||
|
||||
|
||||
public int getWidth()
|
||||
public static int getWidth()
|
||||
{
|
||||
return Display.getWidth();
|
||||
}
|
||||
|
||||
|
||||
public int getHeight()
|
||||
public static int getHeight()
|
||||
{
|
||||
return Display.getHeight();
|
||||
}
|
||||
@@ -238,4 +239,19 @@ public class DisplaySystem extends Subsystem implements RectConstraint {
|
||||
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...");
|
||||
eventBus = new EventBus();
|
||||
eventBus.logSending = true;
|
||||
eventBus.detailedLogging = true;
|
||||
initChannels();
|
||||
|
||||
/*
|
||||
|
||||
@@ -2,8 +2,8 @@ package mightypork.rogue;
|
||||
|
||||
|
||||
import mightypork.gamecore.control.GameLoop;
|
||||
import mightypork.gamecore.gui.renderers.Renderable;
|
||||
import mightypork.gamecore.input.Action;
|
||||
import mightypork.gamecore.render.Renderable;
|
||||
import mightypork.rogue.events.ActionRequest;
|
||||
import mightypork.rogue.events.ActionRequest.RequestType;
|
||||
import mightypork.rogue.util.Utils;
|
||||
@@ -56,7 +56,7 @@ public class MainLoop extends GameLoop implements ActionRequest.Listener {
|
||||
public void execute()
|
||||
{
|
||||
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.loading.AsyncResourceLoader;
|
||||
import mightypork.gamecore.render.fonts.DeferredFont;
|
||||
import mightypork.gamecore.render.fonts.DeferredFont.FontStyle;
|
||||
import mightypork.gamecore.render.fonts.FontBank;
|
||||
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.Wrap;
|
||||
import mightypork.gamecore.render.textures.TextureBank;
|
||||
import mightypork.gamecore.render.textures.TxQuad;
|
||||
|
||||
import org.newdawn.slick.opengl.Texture;
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ public class TaskTakeScreenshot implements Runnable {
|
||||
private final Screenshot scr;
|
||||
|
||||
|
||||
public TaskTakeScreenshot(DisplaySystem disp) {
|
||||
scr = disp.takeScreenshot();
|
||||
public TaskTakeScreenshot() {
|
||||
scr = DisplaySystem.takeScreenshot();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,8 +12,10 @@ import mightypork.gamecore.gui.renderers.TextRenderer;
|
||||
import mightypork.gamecore.gui.renderers.TextRenderer.Align;
|
||||
import mightypork.gamecore.gui.screens.Screen;
|
||||
import mightypork.gamecore.gui.screens.ScreenLayer;
|
||||
import mightypork.gamecore.input.InputSystem;
|
||||
import mightypork.gamecore.input.KeyStroke;
|
||||
import mightypork.gamecore.input.Keys;
|
||||
import mightypork.gamecore.render.DisplaySystem;
|
||||
import mightypork.rogue.Res;
|
||||
import mightypork.utils.math.animation.AnimDouble;
|
||||
import mightypork.utils.math.animation.Easing;
|
||||
@@ -37,8 +39,8 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
|
||||
public LayerFlyingCat(Screen screen) {
|
||||
super(screen);
|
||||
|
||||
xPos.setTo(disp().getWidth() / 2);
|
||||
yPos.setTo(disp().getHeight() / 2);
|
||||
xPos.setTo(DisplaySystem.getWidth() / 2);
|
||||
yPos.setTo(DisplaySystem.getHeight() / 2);
|
||||
|
||||
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)));
|
||||
@@ -46,8 +48,8 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
|
||||
//@formatter:off
|
||||
final RectConstraint flyingFontBox = c_centered(
|
||||
c_box(this, c_n(0), c_n(64)),
|
||||
input().c_mouse_x(),
|
||||
input().c_mouse_y()
|
||||
InputSystem.mouseX,
|
||||
InputSystem.mouseY
|
||||
);
|
||||
//@formatter:on
|
||||
|
||||
@@ -59,8 +61,8 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
xPos.fadeTo(disp().getWidth() / 2, 2);
|
||||
yPos.fadeTo(disp().getHeight() / 2, 2);
|
||||
xPos.fadeTo(DisplaySystem.getWidth() / 2, 2);
|
||||
yPos.fadeTo(DisplaySystem.getHeight() / 2, 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user