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,9 +21,10 @@ import com.google.inject.Inject;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import yugecin.opsudance.core.Demux;
import yugecin.opsudance.core.state.OpsuState;
import yugecin.opsudance.kernel.InstanceContainer;
public class EmptyRedState implements GameState {
public class EmptyRedState implements OpsuState {
private int counter;

View File

@@ -21,9 +21,10 @@ import com.google.inject.Inject;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import yugecin.opsudance.core.Demux;
import yugecin.opsudance.core.state.OpsuState;
import yugecin.opsudance.kernel.InstanceContainer;
public class EmptyState implements GameState {
public class EmptyState implements OpsuState {
private int counter;

View File

@@ -1,29 +0,0 @@
/*
* 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.states;
import org.newdawn.slick.Graphics;
public interface GameState {
void update(int delta);
void render(Graphics g);
void enter();
void leave();
}

View File

@@ -1,50 +0,0 @@
/*
* 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.states.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

@@ -1,48 +0,0 @@
/*
* 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.states.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

@@ -1,74 +0,0 @@
/*
* 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.states.transitions;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.states.GameState;
public abstract class FadeTransitionState extends TransitionState {
protected GameState 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(GameState 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

@@ -1,62 +0,0 @@
/*
* 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.states.transitions;
import org.newdawn.slick.Graphics;
import yugecin.opsudance.states.GameState;
public abstract class TransitionState implements GameState {
protected GameState applicableState;
protected final int transitionTargetTime;
protected int transitionTime;
public TransitionState(int transitionTargetTime) {
this.transitionTargetTime = transitionTargetTime;
}
public void setApplicableState(GameState 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();
}