cleaned up naming, changed way of memory management, continued work on music selection ui
This commit is contained in:
parent
fece547e94
commit
877d0e2274
@ -258,7 +258,7 @@ arrow
|
|||||||
orig: 44, 44
|
orig: 44, 44
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
three-quart-circle
|
loading
|
||||||
rotate: false;
|
rotate: false;
|
||||||
xy: 136, 50
|
xy: 136, 50
|
||||||
size: 44, 44
|
size: 44, 44
|
||||||
|
@ -24,16 +24,13 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.List.ListStyle;
|
import com.badlogic.gdx.scenes.scene2d.ui.List.ListStyle;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle;
|
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox.SelectBoxStyle;
|
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox.SelectBoxStyle;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider.SliderStyle;
|
import com.badlogic.gdx.scenes.scene2d.ui.Slider.SliderStyle;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldStyle;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldStyle;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Window.WindowStyle;
|
import com.badlogic.gdx.scenes.scene2d.ui.Window.WindowStyle;
|
||||||
|
|
||||||
import zero1hd.polyjet.screens.GameScreen;
|
|
||||||
import zero1hd.polyjet.screens.MainMenu;
|
import zero1hd.polyjet.screens.MainMenu;
|
||||||
import zero1hd.polyjet.screens.PreGameScreen;
|
|
||||||
import zero1hd.polyjet.screens.LoadingScreen;
|
import zero1hd.polyjet.screens.LoadingScreen;
|
||||||
|
|
||||||
public class Polyjet extends Game {
|
public class Polyjet extends Game {
|
||||||
@ -51,12 +48,6 @@ public class Polyjet extends Game {
|
|||||||
TextureAtlas skinAtlas;
|
TextureAtlas skinAtlas;
|
||||||
public Preferences prefs;
|
public Preferences prefs;
|
||||||
|
|
||||||
//screens
|
|
||||||
public MainMenu mainMenuScreen;
|
|
||||||
public PreGameScreen preGameScreen;
|
|
||||||
public GameScreen gameScreen;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
@ -73,7 +64,7 @@ public class Polyjet extends Game {
|
|||||||
+ Gdx.graphics.getWidth() + "x" + Gdx.graphics.getHeight() +"\n"
|
+ Gdx.graphics.getWidth() + "x" + Gdx.graphics.getHeight() +"\n"
|
||||||
+ "Pixel density (PPI): " + Gdx.graphics.getDensity());
|
+ "Pixel density (PPI): " + Gdx.graphics.getDensity());
|
||||||
|
|
||||||
setScreen(mainMenuScreen = new MainMenu(this));
|
setScreen(new MainMenu(this));
|
||||||
|
|
||||||
Resolution[] resolution = {
|
Resolution[] resolution = {
|
||||||
new Resolution(800, 480, "800x480"),
|
new Resolution(800, 480, "800x480"),
|
||||||
@ -223,7 +214,6 @@ public class Polyjet extends Game {
|
|||||||
public void resize(int width, int height) {
|
public void resize(int width, int height) {
|
||||||
if (initComplete) {
|
if (initComplete) {
|
||||||
defaultSkin.dispose();
|
defaultSkin.dispose();
|
||||||
gameScreen = null;
|
|
||||||
assetManager.clear();
|
assetManager.clear();
|
||||||
prefs.putInteger("screen-width", width);
|
prefs.putInteger("screen-width", width);
|
||||||
prefs.putInteger("screen-height", height);
|
prefs.putInteger("screen-height", height);
|
||||||
|
@ -17,6 +17,7 @@ import zero1hd.polyjet.TransitionAdapter;
|
|||||||
import zero1hd.polyjet.audio.AudioAnalyzer;
|
import zero1hd.polyjet.audio.AudioAnalyzer;
|
||||||
import zero1hd.polyjet.audio.WavAudioData;
|
import zero1hd.polyjet.audio.WavAudioData;
|
||||||
import zero1hd.polyjet.maps.RhythmMap;
|
import zero1hd.polyjet.maps.RhythmMap;
|
||||||
|
import zero1hd.polyjet.ui.MusicSelectionPage;
|
||||||
|
|
||||||
|
|
||||||
public class PreGameScreen extends ScreenAdapter implements TransitionAdapter {
|
public class PreGameScreen extends ScreenAdapter implements TransitionAdapter {
|
||||||
@ -32,6 +33,8 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter {
|
|||||||
|
|
||||||
Label lastStatement;
|
Label lastStatement;
|
||||||
|
|
||||||
|
MusicSelectionPage musicSelection;
|
||||||
|
|
||||||
public PreGameScreen(final Polyjet core) {
|
public PreGameScreen(final Polyjet core) {
|
||||||
this.core = core;
|
this.core = core;
|
||||||
analyzer = new AudioAnalyzer();
|
analyzer = new AudioAnalyzer();
|
||||||
@ -42,13 +45,7 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter {
|
|||||||
stage.addListener(new ClickListener() {
|
stage.addListener(new ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
if (phase == 4) {
|
core.setScreen(new GameScreen(core));
|
||||||
if (core.gameScreen != null) {
|
|
||||||
core.setScreen(core.gameScreen);
|
|
||||||
} else {
|
|
||||||
core.setScreen((core.gameScreen = new GameScreen(core)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.clicked(event, x, y);
|
super.clicked(event, x, y);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -61,6 +58,8 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter {
|
|||||||
public void postTransition() {
|
public void postTransition() {
|
||||||
stage.clear();
|
stage.clear();
|
||||||
//draw music selector
|
//draw music selector
|
||||||
|
musicSelection = new MusicSelectionPage(core, core.defaultSkin);
|
||||||
|
stage.addActor(musicSelection);
|
||||||
|
|
||||||
statusText = new Label(null, core.defaultSkin);
|
statusText = new Label(null, core.defaultSkin);
|
||||||
statusText.setPosition(1.6f*Gdx.graphics.getWidth(), (Gdx.graphics.getHeight()-statusText.getHeight())/2);
|
statusText.setPosition(1.6f*Gdx.graphics.getWidth(), (Gdx.graphics.getHeight()-statusText.getHeight())/2);
|
||||||
@ -88,9 +87,6 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter {
|
|||||||
stage.act();
|
stage.act();
|
||||||
stage.draw();
|
stage.draw();
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case 0:
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
if (stage.getCamera().position.x != cameraTarget.x) {
|
if (stage.getCamera().position.x != cameraTarget.x) {
|
||||||
stage.getCamera().position.lerp(cameraTarget, 0.25f);
|
stage.getCamera().position.lerp(cameraTarget, 0.25f);
|
||||||
|
@ -99,12 +99,7 @@ public class MainPage extends Page {
|
|||||||
Actions.run(new Runnable() {
|
Actions.run(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
core.setScreen(new PreGameScreen(core));
|
||||||
if (core.preGameScreen != null) {
|
|
||||||
core.setScreen(core.preGameScreen);
|
|
||||||
} else {
|
|
||||||
core.setScreen(core.preGameScreen = new PreGameScreen(core));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}), Actions.parallel(Actions.scaleTo(1, 1), Actions.alpha(0.6f))));
|
}), Actions.parallel(Actions.scaleTo(1, 1), Actions.alpha(0.6f))));
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,21 @@
|
|||||||
package zero1hd.polyjet.ui;
|
package zero1hd.polyjet.ui;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
|
|
||||||
|
import zero1hd.polyjet.Polyjet;
|
||||||
|
|
||||||
public class MusicSelectionPage extends Page {
|
public class MusicSelectionPage extends Page {
|
||||||
public MusicSelectionPage() {
|
Image loading;
|
||||||
|
|
||||||
|
public MusicSelectionPage(Polyjet core, Skin skin) {
|
||||||
|
super("Select music", skin);
|
||||||
|
|
||||||
|
loading = new Image(skin, "loading");
|
||||||
|
loading.setPosition((getWidth()-loading.getWidth())/2, (getHeight()-loading.getHeight())/2);
|
||||||
|
loading.setOrigin(loading.getWidth()/2, loading.getHeight()/2);
|
||||||
|
loading.addAction(Actions.forever(Actions.rotateBy(-360f, 2f)));
|
||||||
|
addActor(loading);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,22 @@ package zero1hd.polyjet.ui;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
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.Skin;
|
||||||
|
|
||||||
public class Page extends Group {
|
public class Page extends Group {
|
||||||
|
private Label pageTitle;
|
||||||
|
|
||||||
public Page() {
|
public Page() {
|
||||||
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
setTouchable(Touchable.childrenOnly);
|
setTouchable(Touchable.childrenOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Page(String titleText, Skin skin) {
|
||||||
|
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
|
setTouchable(Touchable.childrenOnly);
|
||||||
|
pageTitle = new Label(titleText, skin, "large-font", skin.getColor("default"));
|
||||||
|
pageTitle.setPosition(18f, getHeight()-pageTitle.getHeight()-15f);
|
||||||
|
addActor(pageTitle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,12 @@ import com.badlogic.gdx.Preferences;
|
|||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
|
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent;
|
||||||
import com.mpatric.mp3agic.ID3v2;
|
import com.mpatric.mp3agic.ID3v2;
|
||||||
import com.mpatric.mp3agic.InvalidDataException;
|
import com.mpatric.mp3agic.InvalidDataException;
|
||||||
import com.mpatric.mp3agic.Mp3File;
|
import com.mpatric.mp3agic.Mp3File;
|
||||||
@ -16,7 +20,7 @@ import com.mpatric.mp3agic.UnsupportedTagException;
|
|||||||
|
|
||||||
import zero1hd.wavedecoder.WavInfo;
|
import zero1hd.wavedecoder.WavInfo;
|
||||||
|
|
||||||
public class MusicSelectable extends WidgetGroup {
|
public class MusicSelectable extends ImageButton {
|
||||||
Image imageIcon;
|
Image imageIcon;
|
||||||
FileHandle musicFile;
|
FileHandle musicFile;
|
||||||
boolean invalidMusic;
|
boolean invalidMusic;
|
||||||
@ -25,7 +29,9 @@ public class MusicSelectable extends WidgetGroup {
|
|||||||
|
|
||||||
WavInfo wavinfo;
|
WavInfo wavinfo;
|
||||||
|
|
||||||
public MusicSelectable(FileHandle musicFile, Preferences musicData) {
|
public MusicSelectable(FileHandle musicFile, Preferences musicData, Skin skin) {
|
||||||
|
super(skin, "info-pane");
|
||||||
|
|
||||||
this.musicFile = musicFile;
|
this.musicFile = musicFile;
|
||||||
|
|
||||||
if (musicFile.extension().toLowerCase().equals("mp3")) {
|
if (musicFile.extension().toLowerCase().equals("mp3")) {
|
||||||
@ -43,6 +49,9 @@ public class MusicSelectable extends WidgetGroup {
|
|||||||
float scale = 0.25f*Gdx.graphics.getHeight()/imageIcon.getHeight();
|
float scale = 0.25f*Gdx.graphics.getHeight()/imageIcon.getHeight();
|
||||||
|
|
||||||
imageIcon.setScale(scale);
|
imageIcon.setScale(scale);
|
||||||
|
|
||||||
|
add(imageIcon);
|
||||||
|
|
||||||
albumArtTexture.dispose();
|
albumArtTexture.dispose();
|
||||||
|
|
||||||
songName = id3v2tag.getTitle();
|
songName = id3v2tag.getTitle();
|
||||||
|
@ -16,6 +16,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
|||||||
import zero1hd.polyjet.Polyjet;
|
import zero1hd.polyjet.Polyjet;
|
||||||
import zero1hd.polyjet.audio.AudioAnalyzer;
|
import zero1hd.polyjet.audio.AudioAnalyzer;
|
||||||
import zero1hd.polyjet.audio.WavAudioData;
|
import zero1hd.polyjet.audio.WavAudioData;
|
||||||
|
import zero1hd.polyjet.screens.MainMenu;
|
||||||
import zero1hd.polyjet.ui.windows.BeatViewer;
|
import zero1hd.polyjet.ui.windows.BeatViewer;
|
||||||
import zero1hd.polyjet.ui.windows.FPSWindow;
|
import zero1hd.polyjet.ui.windows.FPSWindow;
|
||||||
import zero1hd.polyjet.ui.windows.GraphWindow;
|
import zero1hd.polyjet.ui.windows.GraphWindow;
|
||||||
@ -58,7 +59,7 @@ public class CreativeStage extends Stage {
|
|||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
dispose();
|
dispose();
|
||||||
core.setScreen(core.mainMenuScreen);
|
core.setScreen(new MainMenu(core));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
backButton.setPosition(10, Gdx.graphics.getHeight()-backButton.getHeight()-10);
|
backButton.setPosition(10, Gdx.graphics.getHeight()-backButton.getHeight()-10);
|
||||||
|
@ -43,7 +43,7 @@ public class MusicController extends Window {
|
|||||||
|
|
||||||
add(rewind).center();
|
add(rewind).center();
|
||||||
|
|
||||||
togglePlay = new Image(skin.getDrawable("three-quart-circle")) {
|
togglePlay = new Image(skin.getDrawable("loading")) {
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
if (audiofile.getPlaybackMusic() != null) {
|
if (audiofile.getPlaybackMusic() != null) {
|
||||||
@ -118,7 +118,7 @@ public class MusicController extends Window {
|
|||||||
public void setMusicReady(boolean musicReady) {
|
public void setMusicReady(boolean musicReady) {
|
||||||
this.musicReady = musicReady;
|
this.musicReady = musicReady;
|
||||||
if (!musicReady) {
|
if (!musicReady) {
|
||||||
togglePlay.setDrawable(skin.getDrawable("three-quart-circle"));
|
togglePlay.setDrawable(skin.getDrawable("loading"));
|
||||||
info.setText("Analyzing...");
|
info.setText("Analyzing...");
|
||||||
} else {
|
} else {
|
||||||
togglePlay.setDrawable(skin.getDrawable("arrow"));
|
togglePlay.setDrawable(skin.getDrawable("arrow"));
|
||||||
|
Loading…
Reference in New Issue
Block a user