use explicit init with state in demux and remove the mocked state
This commit is contained in:
parent
54b1b3bb1c
commit
7b1d052de7
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<? extends OpsuState> startingState) {
|
||||
state = instanceContainer.provide(startingState);
|
||||
state.enter();
|
||||
}
|
||||
|
||||
public boolean isTransitioning() {
|
||||
return state instanceof TransitionState;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user