diff --git a/src/yugecin/opsudance/core/Demux.java b/src/yugecin/opsudance/core/Demux.java index cb248bca..c9f2972e 100644 --- a/src/yugecin/opsudance/core/Demux.java +++ b/src/yugecin/opsudance/core/Demux.java @@ -23,9 +23,11 @@ import org.newdawn.slick.Input; import org.newdawn.slick.KeyListener; import org.newdawn.slick.MouseListener; import yugecin.opsudance.core.state.transitions.*; +import yugecin.opsudance.errorhandling.ErrorDumpable; import yugecin.opsudance.kernel.InstanceContainer; import yugecin.opsudance.core.state.OpsuState; +import java.io.StringWriter; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; @@ -33,7 +35,7 @@ import java.lang.reflect.Proxy; /** * state demultiplexer, sends events to current state */ -public class Demux implements KeyListener, MouseListener { +public class Demux implements ErrorDumpable, KeyListener, MouseListener { private final InstanceContainer instanceContainer; @@ -98,6 +100,22 @@ public class Demux implements KeyListener, MouseListener { state.enter(); } + @Override + public void writeErrorDump(StringWriter dump) { + dump.append("> Demux dump\n"); + if (isTransitioning()) { + dump.append("doing a transition\n"); + dump.append("using out transition ").append(outTransitionState.getClass().getSimpleName()).append('\n'); + dump.append("using in transition ").append(inTransitionState.getClass().getSimpleName()).append('\n'); + if (state == inTransitionState) { + dump.append("currently doing the in transition\n"); + } else { + dump.append("currently doing the out transition\n"); + } + } + state.writeErrorDump(dump); + } + /* * demux stuff below */ diff --git a/src/yugecin/opsudance/core/DisplayContainer.java b/src/yugecin/opsudance/core/DisplayContainer.java index 93d3bc1b..7a49b91d 100644 --- a/src/yugecin/opsudance/core/DisplayContainer.java +++ b/src/yugecin/opsudance/core/DisplayContainer.java @@ -204,8 +204,9 @@ public class DisplayContainer implements ErrorDumpable { @Override public void writeErrorDump(StringWriter dump) { - dump.append("> DisplayContainer dump").append('\n'); - dump.append("OpenGL version: ").append(glVersion).append( "(").append(glVendor).append(")").append('\n'); + dump.append("> DisplayContainer dump\n"); + dump.append("OpenGL version: ").append(glVersion).append( "(").append(glVendor).append(")\n"); + demux.writeErrorDump(dump); } } diff --git a/src/yugecin/opsudance/core/state/BaseOpsuState.java b/src/yugecin/opsudance/core/state/BaseOpsuState.java index 07a7f173..2d6e7755 100644 --- a/src/yugecin/opsudance/core/state/BaseOpsuState.java +++ b/src/yugecin/opsudance/core/state/BaseOpsuState.java @@ -20,6 +20,8 @@ package yugecin.opsudance.core.state; import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.ResolutionChangeListener; +import java.io.StringWriter; + public abstract class BaseOpsuState implements OpsuState, ResolutionChangeListener { protected final DisplayContainer displayContainer; @@ -91,4 +93,10 @@ public abstract class BaseOpsuState implements OpsuState, ResolutionChangeListen return false; } + @Override + public void writeErrorDump(StringWriter dump) { + dump.append("> BaseOpsuState dump\n"); + dump.append("isDirty: ").append(String.valueOf(isDirty)).append('\n'); + } + } diff --git a/src/yugecin/opsudance/core/state/OpsuState.java b/src/yugecin/opsudance/core/state/OpsuState.java index 22611efa..36d2e581 100644 --- a/src/yugecin/opsudance/core/state/OpsuState.java +++ b/src/yugecin/opsudance/core/state/OpsuState.java @@ -18,8 +18,9 @@ package yugecin.opsudance.core.state; import org.newdawn.slick.Graphics; +import yugecin.opsudance.errorhandling.ErrorDumpable; -public interface OpsuState { +public interface OpsuState extends ErrorDumpable { void update(int delta); void preRenderUpdate(int delta); diff --git a/src/yugecin/opsudance/core/state/transitions/TransitionState.java b/src/yugecin/opsudance/core/state/transitions/TransitionState.java index 5956da7d..11bcad13 100644 --- a/src/yugecin/opsudance/core/state/transitions/TransitionState.java +++ b/src/yugecin/opsudance/core/state/transitions/TransitionState.java @@ -22,6 +22,8 @@ import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.state.BaseOpsuState; import yugecin.opsudance.core.state.OpsuState; +import java.io.StringWriter; + public abstract class TransitionState extends BaseOpsuState { protected OpsuState applicableState; @@ -79,4 +81,17 @@ public abstract class TransitionState extends BaseOpsuState { return false; } + @Override + public void writeErrorDump(StringWriter dump) { + dump.append("> TransitionState dump\n"); + dump.append("progress: ").append(String.valueOf(transitionTime)).append("/").append(String.valueOf(transitionTargetTime)).append('\n'); + dump.append("applicable state: "); + if (applicableState == null) { + dump.append("IS NULL"); + return; + } + dump.append(applicableState.getClass().getSimpleName()).append('\n'); + applicableState.writeErrorDump(dump); + } + } diff --git a/src/yugecin/opsudance/states/EmptyRedState.java b/src/yugecin/opsudance/states/EmptyRedState.java index 2e8cbc16..5f98b8f3 100644 --- a/src/yugecin/opsudance/states/EmptyRedState.java +++ b/src/yugecin/opsudance/states/EmptyRedState.java @@ -23,6 +23,8 @@ import org.newdawn.slick.Graphics; import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.state.OpsuState; +import java.io.StringWriter; + public class EmptyRedState implements OpsuState { private int counter; @@ -96,4 +98,10 @@ public class EmptyRedState implements OpsuState { return false; } + @Override + public void writeErrorDump(StringWriter dump) { + dump.append("> EmptyRedState dump\n"); + dump.append("its red\n"); + } + } diff --git a/src/yugecin/opsudance/states/EmptyState.java b/src/yugecin/opsudance/states/EmptyState.java index 2f0d6013..faf95e5c 100644 --- a/src/yugecin/opsudance/states/EmptyState.java +++ b/src/yugecin/opsudance/states/EmptyState.java @@ -23,6 +23,8 @@ import org.newdawn.slick.Graphics; import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.state.OpsuState; +import java.io.StringWriter; + public class EmptyState implements OpsuState { private int counter; @@ -92,4 +94,10 @@ public class EmptyState implements OpsuState { return false; } + @Override + public void writeErrorDump(StringWriter dump) { + dump.append("> EmptyState dump\n"); + dump.append("its green\n"); + } + }