From ab48262ff895c1b2bf57c8a897c8e7aac4918070 Mon Sep 17 00:00:00 2001 From: Recrown Date: Tue, 4 Sep 2018 20:19:28 -0500 Subject: [PATCH] cleaned up imports; options page slight improvement; --- .../audio/metadata/MP3Metadata.java | 1 - .../desktop/screens/main/OptionsPage.java | 42 +++++++++---------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/core/src/zero1hd/rhythmbullet/audio/metadata/MP3Metadata.java b/core/src/zero1hd/rhythmbullet/audio/metadata/MP3Metadata.java index a4055fd..d7e0190 100755 --- a/core/src/zero1hd/rhythmbullet/audio/metadata/MP3Metadata.java +++ b/core/src/zero1hd/rhythmbullet/audio/metadata/MP3Metadata.java @@ -6,7 +6,6 @@ import java.util.Date; import org.jaudiotagger.audio.AudioFileIO; import org.jaudiotagger.audio.exceptions.CannotReadException; -import org.jaudiotagger.audio.exceptions.CannotWriteException; import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; import org.jaudiotagger.audio.exceptions.ReadOnlyFileException; import org.jaudiotagger.audio.mp3.MP3File; diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/screens/main/OptionsPage.java b/desktop/src/zero1hd/rhythmbullet/desktop/screens/main/OptionsPage.java index f227962..4937489 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/screens/main/OptionsPage.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/screens/main/OptionsPage.java @@ -1,12 +1,9 @@ package zero1hd.rhythmbullet.desktop.screens.main; -import java.text.DecimalFormat; import java.text.NumberFormat; -import java.util.Formatter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Preferences; -import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar; @@ -27,13 +24,13 @@ public class OptionsPage extends Page { private TextField directoryField; private float musicSearchTimer; private Preferences prefs; - private NumberFormat formatter; + private NumberFormat percentFormat; public OptionsPage(MusicController musicController, Skin skin, Preferences preferences, ChangeListener backButtonListener, ChangeListener graphicsButtonListener, ChangeListener controlsButtonListener) { super(-1, 0, "General", skin); this.prefs = preferences; - formatter = NumberFormat.getPercentInstance(); - formatter.setMaximumFractionDigits(1); + percentFormat = NumberFormat.getPercentInstance(); + percentFormat.setMaximumFractionDigits(1); //Back button TextButton backButton = new TextButton("Back", skin); @@ -43,44 +40,43 @@ public class OptionsPage extends Page { addActor(backButton); optionsTable = new Table(); - optionsTable.defaults().center().space(10f); - optionsTable.setSize(getWidth(), getHeight()); + optionsTable.defaults().space(10f); + addActor(optionsTable); Label musicVolSliderLabel = new Label("Music Volume: ", skin); optionsTable.add(musicVolSliderLabel); musicVolSlider = new Slider(0, 100, 0.1f, false, skin); - musicVolSlider.setValue(preferences.getFloat("music vol", 100f)*100f); + musicVolSlider.setValue(preferences.getFloat("music vol", 100f)); optionsTable.add(musicVolSlider).minWidth(0.3f*getWidth()); - final Label musicVolPercentage = new Label(MathUtils.round(musicVolSlider.getValue()) + "%", skin); + final Label musicVolPercentage = new Label(percentFormat.format(musicVolSlider.getPercent()), skin); musicVolSlider.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { - musicVolPercentage.setText(MathUtils.round(musicVolSlider.getValue()) + "%"); + musicVolPercentage.setText(percentFormat.format(musicVolSlider.getPercent())); musicController.getCurrentMusic().setVolume(musicVolSlider.getPercent()); - - preferences.putFloat("music vol", musicVolSlider.getPercent()); + preferences.putFloat("music vol", musicVolSlider.getValue()); } }); - optionsTable.add(musicVolPercentage); + optionsTable.add(musicVolPercentage).expandX().left(); optionsTable.row(); Label fxVolSliderLabel = new Label("FX Volume: ", skin); optionsTable.add(fxVolSliderLabel); fxVolSlider = new Slider(0, 100, 0.1f, false, skin); - fxVolSlider.setValue(preferences.getFloat("fx vol", 100f)*100f); + fxVolSlider.setValue(preferences.getFloat("fx vol", 100f)); optionsTable.add(fxVolSlider).fillX(); - final Label fxVolPercentage = new Label(MathUtils.round(fxVolSlider.getValue()) + "%", skin); + final Label fxVolPercentage = new Label(percentFormat.format(fxVolSlider.getPercent()), skin); fxVolSlider.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { - fxVolPercentage.setText(MathUtils.round(fxVolSlider.getValue()) + "%"); - preferences.putFloat("fx vol", fxVolSlider.getPercent()); + fxVolPercentage.setText(percentFormat.format(fxVolSlider.getPercent())); + preferences.putFloat("fx vol", fxVolSlider.getValue()); } }); - optionsTable.add(fxVolPercentage); + optionsTable.add(fxVolPercentage).left(); optionsTable.row(); @@ -140,7 +136,7 @@ public class OptionsPage extends Page { refreshTime -= delta; if (refreshTime <= 0) { refreshTime = 4; - String formatted = formatter.format(((float)(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/(float)Runtime.getRuntime().totalMemory())); + String formatted = percentFormat.format(((float)(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/(float)Runtime.getRuntime().totalMemory())); setText("Current usage (JVM): " + formatted); } super.act(delta); @@ -148,13 +144,17 @@ public class OptionsPage extends Page { }; optionsTable.add(usageLabel).colspan(2); + + optionsTable.pack(); + optionsTable.setX((getWidth()-optionsTable.getWidth())/2f); + optionsTable.setSize(getWidth() - optionsTable.getX(), backButton.getY()); } public void saveOptions() { prefs.putString("music dir", directoryField.getText()); Gdx.app.debug("Preferences", "Saved all basic options page values."); } - + @Override public void dispose() { saveOptions();