getting rid of delegation methods

This commit is contained in:
yugecin 2017-01-13 16:28:36 +01:00
parent 1f89c6fcce
commit a1e5c3d30f
5 changed files with 8 additions and 19 deletions

View File

@ -63,7 +63,7 @@ public class OpsuDance {
initUpdater(args);
sout("database & updater initialized");
container.switchStateNow(EmptyState.class);
container.demux.switchStateNow(EmptyState.class);
while (rungame());

View File

@ -93,6 +93,10 @@ public class Demux implements KeyListener, MouseListener {
switchState(newState, FadeOutTransitionState.class, 200, FadeInTransitionState.class, 300);
}
public void switchStateNow(Class<? extends OpsuState> newState) {
switchState(newState, EmptyTransitionState.class, 0, EmptyTransitionState.class, 0);
}
public void switchState(Class<? extends OpsuState> newState, Class<? extends TransitionState> outTransition, int outTime, Class<? extends TransitionState> inTransition, int inTime) {
if (isTransitioning()) {
return;

View File

@ -30,9 +30,6 @@ import org.newdawn.slick.opengl.InternalTextureLoader;
import org.newdawn.slick.opengl.renderer.Renderer;
import org.newdawn.slick.opengl.renderer.SGL;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.state.OpsuState;
import yugecin.opsudance.core.state.transitions.EmptyTransitionState;
import yugecin.opsudance.core.state.transitions.TransitionState;
import yugecin.opsudance.errorhandling.ErrorDumpable;
import yugecin.opsudance.utils.GLHelper;
@ -49,7 +46,7 @@ public class DisplayContainer implements ErrorDumpable {
private static SGL GL = Renderer.get();
private final Demux demux;
public final Demux demux;
private final DisplayMode nativeDisplayMode;
private final List<ResolutionChangeListener> resolutionChangeListeners;
@ -86,18 +83,6 @@ public class DisplayContainer implements ErrorDumpable {
resolutionChangeListeners.add(listener);
}
public void switchState(Class<? extends OpsuState> newState) {
demux.switchState(newState);
}
public void switchStateNow(Class<? extends OpsuState> newState) {
demux.switchState(newState, EmptyTransitionState.class, 0, EmptyTransitionState.class, 0);
}
public void switchState(Class<? extends OpsuState> newState, Class<? extends TransitionState> outTransition, int outTime, Class<? extends TransitionState> inTransition, int inTime) {
demux.switchState(newState, outTransition, outTime, inTransition, inTime);
}
public void run() throws LWJGLException {
while(!(Display.isCloseRequested() && demux.onCloseRequest())) {
delta = getDelta();

View File

@ -41,7 +41,7 @@ public class EmptyRedState implements OpsuState {
if (counter < 0) {
counter = 10000; // to prevent more calls to switch, as this will keep rendering until state transitioned
System.out.println(System.currentTimeMillis() - start);
displayContainer.switchState(EmptyState.class);
displayContainer.demux.switchState(EmptyState.class);
}
}

View File

@ -39,7 +39,7 @@ public class EmptyState implements OpsuState {
counter -= delta;
if (counter < 0) {
counter = 10000; // to prevent more calls to switch, as this will keep rending until state transitioned
displayContainer.switchState(EmptyRedState.class);
displayContainer.demux.switchState(EmptyRedState.class);
}
}