Worked on code architecture, edited music selection ui, worked on clipping text
This commit is contained in:
parent
f57602788e
commit
c6a80e9e57
@ -67,7 +67,6 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
||||
targetPosition.y = 0.5f*Gdx.graphics.getHeight();
|
||||
}
|
||||
moreOptionsPage.controlUnselect();
|
||||
optionsPage.saveOptions(core.prefs);
|
||||
}
|
||||
return super.keyUp(event, keycode);
|
||||
}
|
||||
@ -93,6 +92,14 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
||||
super.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
if (optionsPage != null) {
|
||||
optionsPage.saveOptions(core.prefs);
|
||||
}
|
||||
super.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(float delta) {
|
||||
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
|
||||
|
@ -32,12 +32,12 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter {
|
||||
|
||||
private MainMenu mainMenu;
|
||||
|
||||
public PreGameScreen(final Polyjet core) {
|
||||
public PreGameScreen(final Polyjet core, MainMenu mainMenu) {
|
||||
this.core = core;
|
||||
analyzer = new AudioAnalyzer();
|
||||
rhythmMap = new RhythmMap(analyzer);
|
||||
|
||||
mainMenu = (MainMenu) core.getScreen();
|
||||
this.mainMenu = mainMenu;
|
||||
|
||||
stage = new Stage();
|
||||
|
||||
|
@ -49,6 +49,8 @@ public class MusicSelectable extends Button implements Disposable {
|
||||
super(skin, "info-button");
|
||||
this.skin = skin;
|
||||
|
||||
setName(musicFile.name());
|
||||
|
||||
this.albumCover = defaultAlbumC;
|
||||
|
||||
if (musicFile.extension().toLowerCase().equals("mp3")) {
|
||||
@ -57,7 +59,7 @@ public class MusicSelectable extends Button implements Disposable {
|
||||
mp3File = new MP3File(musicFile.file());
|
||||
durationInSeconds = mp3File.getAudioHeader().getTrackLength();
|
||||
|
||||
if (mp3File.getTag() != null) {
|
||||
if (mp3File.getTag() != null && mp3File.getTag().getFirstArtwork() != null) {
|
||||
albumWorkBytes = mp3File.getTag().getFirstArtwork().getBinaryData();
|
||||
}
|
||||
|
||||
@ -91,8 +93,8 @@ public class MusicSelectable extends Button implements Disposable {
|
||||
songName = musicFile.nameWithoutExtension();
|
||||
}
|
||||
|
||||
previousTop = musicData.getInteger(songName + ":previous top");
|
||||
ratedDifficulty = musicData.getInteger(songName + ":difficulty");
|
||||
previousTop = musicData.getInteger(songName + ":previous top", -1);
|
||||
ratedDifficulty = musicData.getInteger(songName + ":difficulty", -1);
|
||||
|
||||
if (author == null || author.isEmpty()) {
|
||||
author = "N/A";
|
||||
@ -105,7 +107,7 @@ public class MusicSelectable extends Button implements Disposable {
|
||||
|
||||
defaults().align(Align.top);
|
||||
|
||||
add(displayName).fillX().padTop(15f).top();
|
||||
add(displayName).expandX().fillX().padTop(15f).top();
|
||||
row();
|
||||
|
||||
String formattedTime = "Run time: "+ String.valueOf(durationInSeconds/60) + ":";
|
||||
@ -124,11 +126,11 @@ public class MusicSelectable extends Button implements Disposable {
|
||||
songInfoTable.add(authorLabel).expandY();
|
||||
songInfoTable.row();
|
||||
|
||||
previousTopLabel = new Label("Previous Top: " + previousTop, skin, "sub-font", skin.getColor("default"));
|
||||
previousTopLabel = new Label("High Score: " + (previousTop != -1 ? previousTop : "N/A"), skin, "sub-font", skin.getColor("default"));
|
||||
songInfoTable.add(previousTopLabel).center();
|
||||
songInfoTable.row();
|
||||
|
||||
ratedDifficultyLabel = new Label("Difficulty: " + ratedDifficulty, skin, "sub-font", skin.getColor("default"));
|
||||
ratedDifficultyLabel = new Label("Difficulty: " + (ratedDifficulty != -1 ? ratedDifficulty : "N/A"), skin, "sub-font", skin.getColor("default"));
|
||||
songInfoTable.add(ratedDifficultyLabel).expandY();
|
||||
songInfoTable.row();
|
||||
|
||||
@ -148,7 +150,7 @@ public class MusicSelectable extends Button implements Disposable {
|
||||
}
|
||||
Gdx.app.debug("UI", "album cover invalid or null for image: " + songName);
|
||||
}
|
||||
add(imageIcon).size(246f);
|
||||
add(imageIcon).prefSize(256f).expandY().center();
|
||||
}
|
||||
|
||||
public int getPreviousTop() {
|
||||
|
@ -77,18 +77,21 @@ public class ScrollText extends Widget {
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (scrollOnHover) {
|
||||
if ((int) textOffset != 0 || currentlyHovering) {
|
||||
clipBounds.setPosition(getParent().getX()+getX(), getParent().getY()+getY());
|
||||
if (fontWidth > clipBounds.getWidth()) {
|
||||
if (scrollOnHover) {
|
||||
if ((int) textOffset != 0 || currentlyHovering) {
|
||||
if (textOffset < -fontWidth) {
|
||||
textOffset = clipBounds.getWidth();
|
||||
}
|
||||
textOffset -= 60*delta;
|
||||
}
|
||||
} else {
|
||||
if (textOffset < -fontWidth) {
|
||||
textOffset = clipBounds.getWidth();
|
||||
}
|
||||
textOffset -= 60*delta;
|
||||
}
|
||||
} else {
|
||||
if (textOffset < -fontWidth) {
|
||||
textOffset = clipBounds.getWidth();
|
||||
}
|
||||
textOffset -= 60*delta;
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
|
||||
import zero1hd.polyjet.Polyjet;
|
||||
import zero1hd.polyjet.screens.MainMenu;
|
||||
import zero1hd.polyjet.screens.PreGameScreen;
|
||||
|
||||
public class MainPage extends Page {
|
||||
@ -99,7 +100,7 @@ public class MainPage extends Page {
|
||||
Actions.run(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
core.setScreen(new PreGameScreen(core));
|
||||
core.setScreen(new PreGameScreen(core, (MainMenu) core.getScreen()));
|
||||
}
|
||||
}), Actions.parallel(Actions.scaleTo(1, 1), Actions.alpha(0.6f))));
|
||||
}
|
||||
|
@ -7,9 +7,11 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
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 com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
@ -20,10 +22,11 @@ import zero1hd.polyjet.screens.MainMenu;
|
||||
import zero1hd.polyjet.ui.builders.MusicSelectable;
|
||||
|
||||
public class MusicSelectionPage extends Page {
|
||||
Image loading;
|
||||
private volatile Image loading;
|
||||
private volatile Table musicChoices;
|
||||
Preferences musicFileAnnotation;
|
||||
private Polyjet core;
|
||||
private volatile Label status;
|
||||
|
||||
public MusicSelectionPage(final Polyjet core, final MainMenu mainMenu) {
|
||||
super("Select music", core.defaultSkin);
|
||||
@ -43,11 +46,16 @@ public class MusicSelectionPage extends Page {
|
||||
addActor(back);
|
||||
|
||||
loading = new Image(core.defaultSkin, "loading");
|
||||
loading.setPosition((getWidth()-loading.getWidth())/2, (getHeight()-loading.getHeight())/2);
|
||||
loading.setPosition((getWidth()-loading.getWidth())/2, getHeight()-loading.getHeight() - 32f);
|
||||
loading.setOrigin(loading.getWidth()/2, loading.getHeight()/2);
|
||||
loading.addAction(Actions.forever(Actions.rotateBy(-360f, 2f)));
|
||||
addActor(loading);
|
||||
|
||||
status = new Label("Loading: ", core.defaultSkin, "sub-font", core.defaultSkin.getColor("default"));
|
||||
status.setPosition(loading.getX()+loading.getWidth()+12f, loading.getY()-15f);
|
||||
addActor(status);
|
||||
|
||||
|
||||
musicChoices = new Table();
|
||||
musicChoices.defaults().pad(10f);
|
||||
ScrollPane musicChoiceScroller = new ScrollPane(musicChoices);
|
||||
@ -57,9 +65,7 @@ public class MusicSelectionPage extends Page {
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (musicChoices.hasChildren()) {
|
||||
loading.remove();
|
||||
}
|
||||
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
@ -68,7 +74,6 @@ public class MusicSelectionPage extends Page {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
FileHandle[] musicFiles = new FileHandle(core.prefs.getString("music dir")).list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
@ -78,17 +83,32 @@ public class MusicSelectionPage extends Page {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
for (int music = 0; music < musicFiles.length; music++) {
|
||||
final MusicSelectable selectable = new MusicSelectable(musicFiles[music], musicFileAnnotation, core.defaultSkin, core.assetManager.get("defaultCover.png", Texture.class));
|
||||
Gdx.app.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
musicChoices.add(selectable).size(256f, 0.8f*getHeight());
|
||||
selectable.addInfoToPanel();
|
||||
}
|
||||
});
|
||||
|
||||
if (musicFiles.length != 0) {
|
||||
for (int music = 0; music < musicFiles.length; music++) {
|
||||
final MusicSelectable selectable = new MusicSelectable(musicFiles[music], musicFileAnnotation, core.defaultSkin, core.assetManager.get("defaultCover.png", Texture.class));
|
||||
Gdx.app.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Gdx.app.debug("Music Search Thread", "Finished loading: " + selectable.getName());
|
||||
musicChoices.add(selectable).prefSize(256, 0.8f*getHeight());
|
||||
selectable.addInfoToPanel();
|
||||
}
|
||||
});
|
||||
System.out.println(music);
|
||||
int prog = (int) (100f*music/(musicFiles.length-1f));
|
||||
status.setText("Loading: " + prog + "%");
|
||||
}
|
||||
|
||||
loading.clearActions();
|
||||
status.setText("Done!");
|
||||
} else {
|
||||
loading.clearActions();
|
||||
status.setText("No music found.");
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,6 @@ public class OptionsPage extends Page {
|
||||
musicVolSlider.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
saveOptions(core.prefs);
|
||||
musicVolPercentage.setText(MathUtils.round(musicVolSlider.getValue()) + "%");
|
||||
}
|
||||
});
|
||||
@ -62,7 +61,6 @@ public class OptionsPage extends Page {
|
||||
fxVolSlider.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
saveOptions(core.prefs);
|
||||
fxVolPercentage.setText(MathUtils.round(fxVolSlider.getValue()) + "%");
|
||||
}
|
||||
});
|
||||
@ -88,7 +86,6 @@ public class OptionsPage extends Page {
|
||||
if (keycode == Keys.ENTER) {
|
||||
Gdx.app.debug("Debug Field", debugCodeField.getText());
|
||||
if (debugCodeField.getText().equals("creative")) {
|
||||
saveOptions(core.prefs);
|
||||
Gdx.app.debug("Debug Field", "going to creative test room...");
|
||||
goToScreen = 1;
|
||||
}
|
||||
@ -140,10 +137,10 @@ public class OptionsPage extends Page {
|
||||
});
|
||||
optionsTable.add(graphicsSettings).colspan(2).fill();
|
||||
|
||||
saveOptions(core.prefs);
|
||||
}
|
||||
|
||||
public void saveOptions(Preferences prefs) {
|
||||
Gdx.app.debug("Preferences", "Saved all basic options page values.");
|
||||
prefs.putFloat("music vol", musicVolSlider.getValue());
|
||||
prefs.putFloat("fx vol", fxVolSlider.getValue());
|
||||
prefs.putString("music dir", directoryField.getText());
|
||||
|
Loading…
Reference in New Issue
Block a user