make more stuff ErrorDumpable
This commit is contained in:
parent
c467e9b34e
commit
24c6c7da77
|
@ -23,9 +23,11 @@ import org.newdawn.slick.Input;
|
||||||
import org.newdawn.slick.KeyListener;
|
import org.newdawn.slick.KeyListener;
|
||||||
import org.newdawn.slick.MouseListener;
|
import org.newdawn.slick.MouseListener;
|
||||||
import yugecin.opsudance.core.state.transitions.*;
|
import yugecin.opsudance.core.state.transitions.*;
|
||||||
|
import yugecin.opsudance.errorhandling.ErrorDumpable;
|
||||||
import yugecin.opsudance.kernel.InstanceContainer;
|
import yugecin.opsudance.kernel.InstanceContainer;
|
||||||
import yugecin.opsudance.core.state.OpsuState;
|
import yugecin.opsudance.core.state.OpsuState;
|
||||||
|
|
||||||
|
import java.io.StringWriter;
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
|
@ -33,7 +35,7 @@ import java.lang.reflect.Proxy;
|
||||||
/**
|
/**
|
||||||
* state demultiplexer, sends events to current state
|
* state demultiplexer, sends events to current state
|
||||||
*/
|
*/
|
||||||
public class Demux implements KeyListener, MouseListener {
|
public class Demux implements ErrorDumpable, KeyListener, MouseListener {
|
||||||
|
|
||||||
private final InstanceContainer instanceContainer;
|
private final InstanceContainer instanceContainer;
|
||||||
|
|
||||||
|
@ -98,6 +100,22 @@ public class Demux implements KeyListener, MouseListener {
|
||||||
state.enter();
|
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
|
* demux stuff below
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -204,8 +204,9 @@ public class DisplayContainer implements ErrorDumpable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeErrorDump(StringWriter dump) {
|
public void writeErrorDump(StringWriter dump) {
|
||||||
dump.append("> DisplayContainer dump").append('\n');
|
dump.append("> DisplayContainer dump\n");
|
||||||
dump.append("OpenGL version: ").append(glVersion).append( "(").append(glVendor).append(")").append('\n');
|
dump.append("OpenGL version: ").append(glVersion).append( "(").append(glVendor).append(")\n");
|
||||||
|
demux.writeErrorDump(dump);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ package yugecin.opsudance.core.state;
|
||||||
import yugecin.opsudance.core.DisplayContainer;
|
import yugecin.opsudance.core.DisplayContainer;
|
||||||
import yugecin.opsudance.core.ResolutionChangeListener;
|
import yugecin.opsudance.core.ResolutionChangeListener;
|
||||||
|
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
public abstract class BaseOpsuState implements OpsuState, ResolutionChangeListener {
|
public abstract class BaseOpsuState implements OpsuState, ResolutionChangeListener {
|
||||||
|
|
||||||
protected final DisplayContainer displayContainer;
|
protected final DisplayContainer displayContainer;
|
||||||
|
@ -91,4 +93,10 @@ public abstract class BaseOpsuState implements OpsuState, ResolutionChangeListen
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeErrorDump(StringWriter dump) {
|
||||||
|
dump.append("> BaseOpsuState dump\n");
|
||||||
|
dump.append("isDirty: ").append(String.valueOf(isDirty)).append('\n');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
package yugecin.opsudance.core.state;
|
package yugecin.opsudance.core.state;
|
||||||
|
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
|
import yugecin.opsudance.errorhandling.ErrorDumpable;
|
||||||
|
|
||||||
public interface OpsuState {
|
public interface OpsuState extends ErrorDumpable {
|
||||||
|
|
||||||
void update(int delta);
|
void update(int delta);
|
||||||
void preRenderUpdate(int delta);
|
void preRenderUpdate(int delta);
|
||||||
|
|
|
@ -22,6 +22,8 @@ import yugecin.opsudance.core.DisplayContainer;
|
||||||
import yugecin.opsudance.core.state.BaseOpsuState;
|
import yugecin.opsudance.core.state.BaseOpsuState;
|
||||||
import yugecin.opsudance.core.state.OpsuState;
|
import yugecin.opsudance.core.state.OpsuState;
|
||||||
|
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
public abstract class TransitionState extends BaseOpsuState {
|
public abstract class TransitionState extends BaseOpsuState {
|
||||||
|
|
||||||
protected OpsuState applicableState;
|
protected OpsuState applicableState;
|
||||||
|
@ -79,4 +81,17 @@ public abstract class TransitionState extends BaseOpsuState {
|
||||||
return false;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.newdawn.slick.Graphics;
|
||||||
import yugecin.opsudance.core.DisplayContainer;
|
import yugecin.opsudance.core.DisplayContainer;
|
||||||
import yugecin.opsudance.core.state.OpsuState;
|
import yugecin.opsudance.core.state.OpsuState;
|
||||||
|
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
public class EmptyRedState implements OpsuState {
|
public class EmptyRedState implements OpsuState {
|
||||||
|
|
||||||
private int counter;
|
private int counter;
|
||||||
|
@ -96,4 +98,10 @@ public class EmptyRedState implements OpsuState {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeErrorDump(StringWriter dump) {
|
||||||
|
dump.append("> EmptyRedState dump\n");
|
||||||
|
dump.append("its red\n");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.newdawn.slick.Graphics;
|
||||||
import yugecin.opsudance.core.DisplayContainer;
|
import yugecin.opsudance.core.DisplayContainer;
|
||||||
import yugecin.opsudance.core.state.OpsuState;
|
import yugecin.opsudance.core.state.OpsuState;
|
||||||
|
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
public class EmptyState implements OpsuState {
|
public class EmptyState implements OpsuState {
|
||||||
|
|
||||||
private int counter;
|
private int counter;
|
||||||
|
@ -92,4 +94,10 @@ public class EmptyState implements OpsuState {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeErrorDump(StringWriter dump) {
|
||||||
|
dump.append("> EmptyState dump\n");
|
||||||
|
dump.append("its green\n");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user