diff --git a/src/yugecin/opsudance/OpsuDance.java b/src/yugecin/opsudance/OpsuDance.java index 0a96abe7..c3eda1c8 100644 --- a/src/yugecin/opsudance/OpsuDance.java +++ b/src/yugecin/opsudance/OpsuDance.java @@ -63,7 +63,7 @@ public class OpsuDance { initUpdater(args); sout("database & updater initialized"); - container.demux.switchStateNow(EmptyState.class); + container.demux.init(EmptyState.class); } catch (Exception e) { errorAndExit("startup failure", e); } diff --git a/src/yugecin/opsudance/core/Demux.java b/src/yugecin/opsudance/core/Demux.java index c9f2972e..8ed07ba2 100644 --- a/src/yugecin/opsudance/core/Demux.java +++ b/src/yugecin/opsudance/core/Demux.java @@ -28,9 +28,6 @@ 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; /** * state demultiplexer, sends events to current state @@ -51,13 +48,6 @@ public class Demux implements ErrorDumpable, KeyListener, MouseListener { public Demux(final InstanceContainer instanceContainer) { this.instanceContainer = instanceContainer; - state = (OpsuState) Proxy.newProxyInstance(OpsuState.class.getClassLoader(), new Class[]{OpsuState.class}, new InvocationHandler() { - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - return false; - } - }); - outTransitionListener = new TransitionFinishedListener() { @Override public void onFinish() { @@ -78,6 +68,11 @@ public class Demux implements ErrorDumpable, KeyListener, MouseListener { }; } + public void init(Class startingState) { + state = instanceContainer.provide(startingState); + state.enter(); + } + public boolean isTransitioning() { return state instanceof TransitionState; }