began clean version of pre-game screen
This commit is contained in:
parent
1e5a743739
commit
52cd737c3a
@ -241,7 +241,6 @@ public class Polyjet extends Game {
|
|||||||
super.resize(width, height);
|
super.resize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int fontScale(float fontSize) {
|
public int fontScale(float fontSize) {
|
||||||
Gdx.app.debug("Font pixel size", MathUtils.round(Gdx.graphics.getDensity()*(fontSize*Gdx.graphics.getHeight())) + "px");
|
Gdx.app.debug("Font pixel size", MathUtils.round(Gdx.graphics.getDensity()*(fontSize*Gdx.graphics.getHeight())) + "px");
|
||||||
return MathUtils.round(Gdx.graphics.getDensity()*(fontSize*Gdx.graphics.getHeight()));
|
return MathUtils.round(Gdx.graphics.getDensity()*(fontSize*Gdx.graphics.getHeight()));
|
||||||
|
@ -2,116 +2,45 @@ package zero1hd.polyjet.screens;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.ScreenAdapter;
|
import com.badlogic.gdx.ScreenAdapter;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
|
||||||
|
|
||||||
import zero1hd.polyjet.Polyjet;
|
|
||||||
import zero1hd.polyjet.audio.Audio;
|
|
||||||
import zero1hd.polyjet.audio.WavAudioData;
|
|
||||||
import zero1hd.polyjet.ui.pages.AnalyzePage;
|
|
||||||
import zero1hd.polyjet.ui.pages.MusicSelectionPage;
|
|
||||||
import zero1hd.polyjet.util.MiniEvents;
|
import zero1hd.polyjet.util.MiniEvents;
|
||||||
import zero1hd.polyjet.util.MiniListener;
|
import zero1hd.polyjet.util.MiniListener;
|
||||||
import zero1hd.polyjet.util.TransitionAdapter;
|
import zero1hd.polyjet.util.TransitionAdapter;
|
||||||
|
|
||||||
|
|
||||||
public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, MiniListener {
|
public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, MiniListener {
|
||||||
Polyjet core;
|
|
||||||
Stage stage;
|
Stage stage;
|
||||||
Label statusText;
|
|
||||||
|
|
||||||
WavAudioData audiofile;
|
Vector3 cameraPos;
|
||||||
Vector3 cameraTarget;
|
|
||||||
|
|
||||||
Label lastStatement;
|
|
||||||
|
|
||||||
private MainMenu mainMenu;
|
|
||||||
private MusicSelectionPage musicSelection;
|
|
||||||
private AnalyzePage analyzePage;
|
|
||||||
public PreGameScreen(final Polyjet core, MainMenu mainMenu) {
|
|
||||||
this.core = core;
|
|
||||||
|
|
||||||
this.mainMenu = mainMenu;
|
|
||||||
|
|
||||||
|
public PreGameScreen() {
|
||||||
stage = new Stage();
|
stage = new Stage();
|
||||||
|
cameraPos = new Vector3();
|
||||||
cameraTarget = new Vector3(stage.getCamera().position);
|
|
||||||
postTransition();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postTransition() {
|
|
||||||
stage.clear();
|
|
||||||
|
|
||||||
Image cyberCircle1 = new Image(core.getAssetManager().get("cybercircle3B.png", Texture.class));
|
|
||||||
cyberCircle1.setScale(0.8f);
|
|
||||||
cyberCircle1.setOrigin(cyberCircle1.getWidth()/2, cyberCircle1.getHeight()/2);
|
|
||||||
cyberCircle1.setColor(0.8f,0.8f,0.8f,0.7f);
|
|
||||||
cyberCircle1.addAction(Actions.forever(Actions.rotateBy(360f, 10f)));
|
|
||||||
cyberCircle1.setPosition(Gdx.graphics.getWidth()-cyberCircle1.getWidth()/2-10, -cyberCircle1.getHeight()*2/4f);
|
|
||||||
stage.addActor(cyberCircle1);
|
|
||||||
|
|
||||||
analyzePage = new AnalyzePage(core.getDefaultSkin(), cameraTarget, core.getAssetManager());
|
|
||||||
analyzePage.setPosition(1f*Gdx.graphics.getWidth(), 0);
|
|
||||||
stage.addActor(analyzePage);
|
|
||||||
|
|
||||||
//draw music selector
|
|
||||||
musicSelection = new MusicSelectionPage(core, mainMenu);
|
|
||||||
musicSelection.addListener(this);
|
|
||||||
stage.addActor(musicSelection);
|
|
||||||
musicSelection.beginMusicSearch();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
|
if (stage.getCamera().position.x != cameraPos.x) {
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
stage.getCamera().position.lerp(cameraPos, 0.25f);
|
||||||
stage.getViewport().apply();
|
|
||||||
stage.act();
|
|
||||||
stage.draw();
|
|
||||||
|
|
||||||
if (stage.getCamera().position.x != cameraTarget.x) {
|
|
||||||
stage.getCamera().position.lerp(cameraTarget, 0.25f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cameraTarget.x != 1.5f*Gdx.graphics.getWidth() && analyzePage.hasAudioData()) {
|
|
||||||
cameraTarget.x = 1.5f*Gdx.graphics.getWidth();
|
|
||||||
}
|
}
|
||||||
super.render(delta);
|
super.render(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show() {
|
|
||||||
Gdx.input.setInputProcessor(stage);
|
|
||||||
super.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resize(int width, int height) {
|
|
||||||
stage.getViewport().update(width, height);
|
|
||||||
super.resize(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
stage.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(MiniEvents ID) {
|
public void handle(MiniEvents ID) {
|
||||||
switch (ID) {
|
// TODO Auto-generated method stub
|
||||||
case MUSIC_SELECTED:
|
|
||||||
analyzePage.setSong(Audio.getAudioData(musicSelection.getSelectedMusic()), musicSelection.getSelectedMusicInfo());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postTransition() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhase(int phase) {
|
||||||
|
cameraPos.x = Gdx.graphics.getWidth()*(phase + 0.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,8 @@ public class MusicSelectionPage extends Page {
|
|||||||
});
|
});
|
||||||
addActor(back);
|
addActor(back);
|
||||||
|
|
||||||
|
loadingWindow = new LoadingWindow(core.getDefaultSkin(), "tinted", true, core.getAssetManager(), core.prefs.getFloat("fx vol"));
|
||||||
|
|
||||||
loadingWindow.setPosition((getWidth()-loadingWindow.getWidth())/2f, (getHeight()-loadingWindow.getHeight())/2f);
|
loadingWindow.setPosition((getWidth()-loadingWindow.getWidth())/2f, (getHeight()-loadingWindow.getHeight())/2f);
|
||||||
addActor(loadingWindow);
|
addActor(loadingWindow);
|
||||||
loadingWindow.playOpenSound();
|
loadingWindow.playOpenSound();
|
||||||
@ -112,7 +114,7 @@ public class MusicSelectionPage extends Page {
|
|||||||
if (!selectable.isMusicInvalid()) {
|
if (!selectable.isMusicInvalid()) {
|
||||||
selectedMusic = selectable.getMusicFile();
|
selectedMusic = selectable.getMusicFile();
|
||||||
selectedMusicInfo = selectable.getAudioInfo();
|
selectedMusicInfo = selectable.getAudioInfo();
|
||||||
send(MiniEvents.MUSIC_SELECTED);
|
miniSender.send(MiniEvents.MUSIC_SELECTED);
|
||||||
} else {
|
} else {
|
||||||
//Play "no" sound
|
//Play "no" sound
|
||||||
}
|
}
|
||||||
|
@ -5,19 +5,17 @@ import com.badlogic.gdx.scenes.scene2d.Group;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
|
|
||||||
import zero1hd.polyjet.util.MiniEvents;
|
import zero1hd.polyjet.util.MiniSender;
|
||||||
import zero1hd.polyjet.util.MiniListener;
|
|
||||||
|
|
||||||
public class Page extends Group {
|
public class Page extends Group {
|
||||||
private Label pageTitle;
|
private Label pageTitle;
|
||||||
|
|
||||||
private Array<MiniListener> listeners;
|
public MiniSender miniSender;
|
||||||
|
|
||||||
public Page() {
|
public Page() {
|
||||||
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
listeners = new Array<>();
|
miniSender = new MiniSender();
|
||||||
setTouchable(Touchable.childrenOnly);
|
setTouchable(Touchable.childrenOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,17 +30,4 @@ public class Page extends Group {
|
|||||||
public float getHeightBelowTitle() {
|
public float getHeightBelowTitle() {
|
||||||
return pageTitle.getY();
|
return pageTitle.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(MiniEvents ID) {
|
|
||||||
while (listeners.iterator().hasNext()) {
|
|
||||||
listeners.iterator().next().handle(ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addListener(MiniListener handler) {
|
|
||||||
if (listeners == null) {
|
|
||||||
Gdx.app.log("Test", "URS STEWPID");
|
|
||||||
}
|
|
||||||
listeners.add(handler);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user