moving stuff around again

This commit is contained in:
yugecin
2017-01-10 12:07:24 +01:00
parent 0ceff03bdd
commit e05b675285
11 changed files with 26 additions and 27 deletions

View File

@@ -21,10 +21,10 @@ import com.google.inject.Inject;
import org.newdawn.slick.Graphics;
import yugecin.opsudance.kernel.InstanceContainer;
import yugecin.opsudance.states.EmptyState;
import yugecin.opsudance.states.GameState;
import yugecin.opsudance.states.transitions.FadeInTransitionState;
import yugecin.opsudance.states.transitions.FadeOutTransitionState;
import yugecin.opsudance.states.transitions.TransitionState;
import yugecin.opsudance.core.state.OpsuState;
import yugecin.opsudance.core.state.transitions.FadeInTransitionState;
import yugecin.opsudance.core.state.transitions.FadeOutTransitionState;
import yugecin.opsudance.core.state.transitions.TransitionState;
/**
* state demultiplexer, sends events to current state
@@ -36,7 +36,7 @@ public class Demux {
private TransitionState fadeOutTransitionState;
private TransitionState fadeInTransitionState;
private GameState state;
private OpsuState state;
@Inject
public Demux(InstanceContainer instanceContainer) {
@@ -66,7 +66,7 @@ public class Demux {
return state == fadeInTransitionState || state == fadeOutTransitionState;
}
public void switchState(GameState newState) {
public void switchState(OpsuState newState) {
if (isTransitioning()) {
return;
}
@@ -76,7 +76,7 @@ public class Demux {
state.enter();
}
public void switchStateNow(GameState newState) {
public void switchStateNow(OpsuState newState) {
if (!isTransitioning()) {
return;
}

View File

@@ -143,8 +143,6 @@ public class DisplayContainer {
if (displayMode.getBitsPerPixel() == 16) {
InternalTextureLoader.get().set16BitMode();
}
getDelta();
}
private void initGL() {

View File

@@ -0,0 +1,29 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu!dance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.core.state;
import org.newdawn.slick.Graphics;
public interface OpsuState {
void update(int delta);
void render(Graphics g);
void enter();
void leave();
}

View File

@@ -0,0 +1,50 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu!dance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.core.state.transitions;
import com.google.inject.Inject;
import yugecin.opsudance.core.Demux;
import yugecin.opsudance.core.DisplayContainer;
public class FadeInTransitionState extends FadeTransitionState {
private final Demux demux;
@Inject
public FadeInTransitionState(DisplayContainer container, Demux demux) {
super(container, 300);
this.demux = demux;
}
@Override
protected float getMaskAlphaLevel(float fadeProgress) {
return 1f - fadeProgress;
}
@Override
public void enter() {
super.enter();
applicableState.enter();
}
@Override
protected void onTransitionFinished() {
demux.switchStateNow(applicableState);
}
}

View File

@@ -0,0 +1,48 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu!dance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.core.state.transitions;
import com.google.inject.Inject;
import yugecin.opsudance.core.Demux;
import yugecin.opsudance.core.DisplayContainer;
public class FadeOutTransitionState extends FadeTransitionState {
private final Demux demux;
private final FadeInTransitionState fadeInTransitionState;
@Inject
public FadeOutTransitionState(DisplayContainer container, Demux demux, FadeInTransitionState fadeInTransitionState) {
super(container, 200);
this.demux = demux;
this.fadeInTransitionState = fadeInTransitionState;
}
@Override
protected float getMaskAlphaLevel(float fadeProgress) {
return fadeProgress;
}
@Override
protected void onTransitionFinished() {
applicableState.leave();
demux.switchStateNow(fadeInTransitionState);
fadeInTransitionState.enter();
}
}

View File

@@ -0,0 +1,74 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu!dance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.core.state.transitions;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.state.OpsuState;
public abstract class FadeTransitionState extends TransitionState {
protected OpsuState applicableState;
private final DisplayContainer container;
protected final int fadeTargetTime;
protected int fadeTime;
private final Color black;
public FadeTransitionState(DisplayContainer container, int fadeTargetTime) {
super(fadeTargetTime);
this.container = container;
this.fadeTargetTime = fadeTargetTime;
black = new Color(Color.black);
}
public void setApplicableState(OpsuState applicableState) {
this.applicableState = applicableState;
}
@Override
public void update(int delta) {
applicableState.update(delta);
fadeTime += delta;
if (fadeTime >= fadeTargetTime) {
onTransitionFinished();
}
}
@Override
public void render(Graphics g) {
applicableState.render(g);
black.a = getMaskAlphaLevel((float) fadeTime / fadeTargetTime);
g.setColor(black);
g.fillRect(0, 0, container.width, container.height);
}
@Override
public void enter() {
fadeTime = 0;
}
@Override
public void leave() { }
protected abstract float getMaskAlphaLevel(float fadeProgress);
}

View File

@@ -0,0 +1,62 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu!dance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.core.state.transitions;
import org.newdawn.slick.Graphics;
import yugecin.opsudance.core.state.OpsuState;
public abstract class TransitionState implements OpsuState {
protected OpsuState applicableState;
protected final int transitionTargetTime;
protected int transitionTime;
public TransitionState(int transitionTargetTime) {
this.transitionTargetTime = transitionTargetTime;
}
public void setApplicableState(OpsuState applicableState) {
this.applicableState = applicableState;
}
@Override
public void update(int delta) {
applicableState.update(delta);
transitionTime += delta;
if (transitionTime >= transitionTargetTime) {
onTransitionFinished();
}
}
@Override
public void render(Graphics g) {
applicableState.render(g);
}
@Override
public void enter() {
transitionTime = 0;
}
@Override
public void leave() { }
protected abstract void onTransitionFinished();
}