progressed on pre game screen

This commit is contained in:
Harrison Deng 2017-05-24 14:45:00 -05:00
parent bb40cd230d
commit e949deffe7
9 changed files with 95 additions and 26 deletions

View File

@ -2,6 +2,7 @@ package zero1hd.polyjet.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.math.Vector3;
@ -36,7 +37,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
targetPosition = new Vector3(stage.getCamera().position);
}
public void postTransition() {
public Screen postTransition() {
stage.clear();
mainPage = new MainPage(core, targetPosition);
@ -84,6 +85,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
});
Gdx.app.debug("Post Transition", "Beginning screen setup for Main menu.");
return this;
}
@Override

View File

@ -1,12 +1,19 @@
package zero1hd.polyjet.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.audio.Audio;
import zero1hd.polyjet.ui.pages.AnalyzePage;
import zero1hd.polyjet.ui.pages.MusicSelectionPage;
import zero1hd.polyjet.util.MiniEvents;
import zero1hd.polyjet.util.MiniListener;
import zero1hd.polyjet.util.TransitionAdapter;
@ -15,34 +22,94 @@ import zero1hd.polyjet.util.TransitionAdapter;
public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, MiniListener {
Stage stage;
Vector3 cameraPos;
MusicSelectionPage ms;
AnalyzePage ap;
public PreGameScreen(Skin skin, AssetManager assets) {
stage = new Stage();
cameraPos = new Vector3();
private Vector3 cameraPos;
private Polyjet core;
public PreGameScreen(Polyjet core) {
stage = new Stage(new ScreenViewport());
cameraPos = new Vector3(stage.getCamera().position);
this.core = core;
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.getViewport().apply();
stage.act();
stage.draw();
if (stage.getCamera().position.x != cameraPos.x) {
stage.getCamera().position.lerp(cameraPos, 0.25f);
}
super.render(delta);
}
@Override
public void resize(int width, int height) {
stage.getViewport().update(width, height);
super.resize(width, height);
}
@Override
public void handle(MiniEvents ID) {
// TODO Auto-generated method stub
switch (ID) {
case MUSIC_SELECTED:
cameraPos.x = 1.5f*Gdx.graphics.getWidth();
ap.setSong(Audio.getAudioData(ms.getSelectedMusic()), ms.getSelectedMusicInfo());
break;
case SPECTRAL_FLUX_DONE:
break;
case MUSIC_DATA_CLEANED:
break;
case BACK:
if (cameraPos.x == 1.5f*Gdx.graphics.getWidth()) {
cameraPos.x = 0.5f*Gdx.graphics.getWidth();
} else {
core.setScreen(new MainMenu(core).postTransition());
}
break;
}
}
@Override
public void postTransition() {
// TODO Auto-generated method stub
public Screen postTransition() {
Image circle1 = new Image(core.getAssetManager().get("cybercircle1.png", Texture.class));
circle1.setOrigin(circle1.getWidth()/2f, circle1.getHeight()/2f);
circle1.setPosition(Gdx.graphics.getWidth(), circle1.getHeight()/3);
stage.addActor(circle1);
ms = new MusicSelectionPage(core);
ms.miniSender.addListener(this);
ms.beginMusicSearch();
stage.addActor(ms);
ap = new AnalyzePage(core.getDefaultSkin(), core.getAssetManager());
ap.getAudioAnalyzer().sender.addListener(this);
ap.setPosition(Gdx.graphics.getWidth(), ap.getY());
stage.addActor(ap);
return this;
}
public void setPhase(int phase) {
cameraPos.x = Gdx.graphics.getWidth()*(phase + 0.5f);
}
@Override
public void show() {
Gdx.input.setInputProcessor(stage);
super.show();
}
@Override
public void dispose() {
stage.dispose();
super.dispose();
}
}

View File

@ -2,7 +2,6 @@ package zero1hd.polyjet.ui.pages;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
@ -16,13 +15,12 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.polyjet.audio.AudioAnalyzer;
import zero1hd.polyjet.audio.AudioData;
import zero1hd.polyjet.audio.AudioInfo;
import zero1hd.polyjet.util.MiniEvents;
public class AnalyzePage extends Page {
AudioAnalyzer audioAnalyzer;
AudioData music;
Vector3 cameraPos;
Table songInfo;
Slider difficultyModifier;
Label difficultyModifierPercentage;
@ -32,10 +30,9 @@ public class AnalyzePage extends Page {
private Image loadingCircle;
private Label status;
public AnalyzePage(Skin skin, Vector3 camPos, AssetManager assets) {
public AnalyzePage(Skin skin, AssetManager assets) {
super("Results", skin);
this.skin = skin;
cameraPos = camPos;
audioAnalyzer = new AudioAnalyzer();
songInfo = new Table(skin);
@ -51,8 +48,7 @@ public class AnalyzePage extends Page {
back.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
clearAudioData();
cameraPos.x = 0.5f*getWidth();
miniSender.send(MiniEvents.BACK);
}
});
songInfo.setSize(getWidth(), getHeightBelowTitle());
@ -65,7 +61,6 @@ public class AnalyzePage extends Page {
public void setSong(AudioData music, AudioInfo audioInfo) {
songInfo.clear();
cameraPos.x = 1.5f*getWidth();
this.music = music;
audioAnalyzer.startAnalyticalThread(music);
songInfo.add(new Label(audioInfo.getSongName(), skin, "large-font", skin.getColor("default")));

View File

@ -99,7 +99,7 @@ public class MainPage extends Page {
Actions.run(new Runnable() {
@Override
public void run() {
core.setScreen(new PreGameScreen(core.getDefaultSkin(), core.getAssetManager()));
core.setScreen(new PreGameScreen(core).postTransition());
}
}), Actions.parallel(Actions.scaleTo(1, 1), Actions.alpha(0.6f))));
}

View File

@ -17,7 +17,6 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.audio.AudioInfo;
import zero1hd.polyjet.screens.MainMenu;
import zero1hd.polyjet.ui.builders.MusicSelectable;
import zero1hd.polyjet.ui.windows.LoadingWindow;
import zero1hd.polyjet.ui.windows.NoticeWindow;
@ -36,7 +35,7 @@ public class MusicSelectionPage extends Page {
private FileHandle selectedMusic;
private AudioInfo selectedMusicInfo;
public MusicSelectionPage(final Polyjet core, final MainMenu mainMenu) {
public MusicSelectionPage(final Polyjet core) {
super("Select music", core.getDefaultSkin());
this.core = core;
@ -47,7 +46,7 @@ public class MusicSelectionPage extends Page {
back.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
core.setScreen(mainMenu);
miniSender.send(MiniEvents.BACK);
cancel = true;
}
});
@ -70,8 +69,8 @@ public class MusicSelectionPage extends Page {
addActor(musicChoiceScroller);
loadingWindow.toFront();
back.toFront();
back.toFront();
}
@Override

View File

@ -20,6 +20,7 @@ public class Page extends Group {
}
public Page(String titleText, Skin skin) {
miniSender = new MiniSender();
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
setTouchable(Touchable.childrenOnly);
pageTitle = new Label(titleText, skin, "large-font", skin.getColor("default"));

View File

@ -199,6 +199,9 @@ public class CreativeStage extends Stage implements MiniListener {
@Override
public void handle(MiniEvents ID) {
switch (ID) {
case BACK:
break;
case MUSIC_SELECTED:
beatViewer.setMusic(null);
volumeWindow.setMusic(null);

View File

@ -1,5 +1,5 @@
package zero1hd.polyjet.util;
public enum MiniEvents {
SPECTRAL_FLUX_DONE, MUSIC_DATA_CLEANED, MUSIC_SELECTED;
SPECTRAL_FLUX_DONE, MUSIC_DATA_CLEANED, MUSIC_SELECTED, BACK;
}

View File

@ -1,5 +1,7 @@
package zero1hd.polyjet.util;
import com.badlogic.gdx.Screen;
public interface TransitionAdapter {
public void postTransition();
public Screen postTransition();
}