change in structure for different platform support; major change

This commit is contained in:
2018-01-03 16:58:58 -06:00
parent cebf36dff9
commit 15a35f65dc
76 changed files with 225 additions and 208 deletions

View File

@@ -1,340 +0,0 @@
package zero1hd.rhythmbullet;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.assets.loaders.ParticleEffectLoader;
import com.badlogic.gdx.assets.loaders.SoundLoader;
import com.badlogic.gdx.assets.loaders.TextureAtlasLoader;
import com.badlogic.gdx.assets.loaders.TextureLoader;
import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver;
import com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox.CheckBoxStyle;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle;
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.ScrollPane.ScrollPaneStyle;
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox.SelectBoxStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
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.TextField.TextFieldStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Window.WindowStyle;
import zero1hd.rhythmbullet.screens.LoadingScreen;
import zero1hd.rhythmbullet.util.GenericFileTypeHandler;
import zero1hd.rhythmbullet.util.RoundingResolutionHandler;
import zero1hd.rhythmbullet.util.TransitionAdapter;
public class RhythmBullet extends Game {
private boolean initComplete = false;
private boolean resizing;
public static final int GAME_AREA_WIDTH = 64;
public static final int GAME_AREA_HEIGHT = 48;
public static final String VERSION = "(0.1)R1-PreAlpha";
private AssetManager assetManager = new AssetManager();
private Skin defaultSkin = new Skin();
private FreeTypeFontGenerator default_fontGenerator;
private FreeTypeFontGenerator darktech_ldr_fontGenerator;
TextureAtlas skinAtlas;
private Preferences prefs;
private RoundingResolutionHandler rRHandler;
@Override
public void create() {
Gdx.app.setLogLevel(Application.LOG_DEBUG);
prefs = Gdx.app.getPreferences("PolyJet_Preferences");
if (getPrefs().getBoolean("fullscreen", true)) {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
} else {
Gdx.graphics.setWindowedMode(getPrefs().getInteger("screen-width"), getPrefs().getInteger("screen-height"));
}
Resolution[] resolution = {
new Resolution(1280, 720, "1280x720"),
new Resolution(1366, 768, "1366x768"),
new Resolution(1280, 800, "1280x800"),
new Resolution(1920, 1080, "1920x1080"),
new Resolution(1920, 1200, "1920x1200"),
new Resolution(2560, 1440, "2560x1440"),
new Resolution(3840, 2160, "3840x2160")
};
InternalFileHandleResolver internalFileResolver = new InternalFileHandleResolver();
rRHandler = new RoundingResolutionHandler(internalFileResolver, resolution);
GenericFileTypeHandler genericFileFinder = new GenericFileTypeHandler(internalFileResolver);
assetManager.setLoader(TextureAtlas.class, new TextureAtlasLoader(rRHandler));
assetManager.setLoader(Texture.class, new TextureLoader(rRHandler));
assetManager.setLoader(ParticleEffect.class, new ParticleEffectLoader(genericFileFinder));
assetManager.setLoader(Sound.class, new SoundLoader(genericFileFinder));
default_fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/Gasalt-Regular.ttf"));
darktech_ldr_fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/darktech_ldr.ttf"));
getrRHandler().setResolution(getPrefs().getInteger("screen-width"), getPrefs().getInteger("screen-height"));
Gdx.app.debug("Prelaunch Debug Info", "\ncurrent window size: "
+ Gdx.graphics.getWidth() + "x" + Gdx.graphics.getHeight() +"\n"
+ "Pixel density (PPI): " + Gdx.graphics.getDensity());
setScreen(new LoadingScreen(this));
Logger.getLogger("org.jaudiotagger").setLevel(Level.OFF);
}
@Override
public void render() {
if (resizing) {
if (assetManager.update()) {
Gdx.app.debug("Resize", "Post transition is happening");
resizing = false;
generateFonts(Gdx.graphics.getHeight());
defineSkinStyles();
assetManager.get("standard_thrust.p", ParticleEffect.class).flipY();
if (initComplete) {
((TransitionAdapter) getScreen()).postTransition(false);
}
}
}
super.render();
}
@Override
public void dispose() {
Gdx.app.debug("Core", "disposing...");
if (initComplete) {
skinAtlas.dispose();
getDefaultSkin().dispose();
default_fontGenerator.dispose();
darktech_ldr_fontGenerator.dispose();
assetManager.dispose();
getScreen().dispose();
}
super.dispose();
}
@Override
public void resize(int width, int height) {
if (initComplete) {
Gdx.app.debug("Resize", "Pre-transition is happening. Using resolution " + width + "x" + height);
rRHandler.setResolution(width, height);
((TransitionAdapter) getScreen()).preTransition();
assetManager.clear();
prefs.putInteger("screen-width", width);
prefs.putInteger("screen-height", height);
prefs.flush();
resizing = true;
queueAssets();
}
super.resize(width, height);
}
public int fontScale(float fontSize, int height) {
int size = MathUtils.round(Gdx.graphics.getDensity()*(fontSize*height));
if (size >= 200) {
size = 200;
}
return size;
}
public AssetManager getAssetManager() {
return assetManager;
}
public Skin getDefaultSkin() {
return defaultSkin;
}
public Preferences getPrefs() {
return prefs;
}
public void setInitComplete() {
initComplete = true;
}
public void queueAssets() {
assetManager.load("uiskin.atlas", TextureAtlas.class);
assetManager.load("Tech-Circle1.png", Texture.class);
assetManager.load("polyjet-standard.png", Texture.class);
assetManager.load("standard_thrust.p", ParticleEffect.class);
assetManager.load("keyboard.atlas", TextureAtlas.class);
assetManager.load("cybercircle3B.png", Texture.class);
assetManager.load("title.png", Texture.class);
assetManager.load("cybercircle1.png", Texture.class);
assetManager.load("defaultCover.png", Texture.class);
assetManager.load("teleport-cloak.p", ParticleEffect.class);
assetManager.load("pop_open.ogg", Sound.class);
assetManager.load("pop_close.ogg", Sound.class);
assetManager.load("laser.png", Texture.class);
assetManager.load("pellet.png", Texture.class);
assetManager.load("shard.png", Texture.class);
assetManager.load("bar.png", Texture.class);
assetManager.load("flake.png", Texture.class);
assetManager.load("star_bg.png", Texture.class);
assetManager.load("void_circle.png", Texture.class);
assetManager.load("laser.ogg", Sound.class);
assetManager.load("explosion.ogg", Sound.class);
assetManager.load("disintegrate.ogg", Sound.class);
assetManager.load("explosion-s.p", ParticleEffect.class);
assetManager.load("beateffect.p", ParticleEffect.class);
assetManager.load("tpSelector.png", Texture.class);
assetManager.load("magic1.png", Texture.class);
assetManager.load("gradients.atlas", TextureAtlas.class);
}
public void generateFonts(final int height) {
defaultSkin = new Skin();
Gdx.app.debug("Prelaunch Debug Info", "Generating fonts with screen height of " + height);
skinAtlas = assetManager.get("uiskin.atlas", TextureAtlas.class);
getDefaultSkin().addRegions(skinAtlas);
getDefaultSkin().add("window-font", default_fontGenerator.generateFont(new FreeTypeFontParameter() {
{
size = 18;
}
}));
getDefaultSkin().add("sub-font", default_fontGenerator.generateFont(new FreeTypeFontParameter() {
{
size = fontScale(0.05f, height);
}
}));
getDefaultSkin().add("default-font", default_fontGenerator.generateFont(new FreeTypeFontParameter() {
{
size = fontScale(0.07f, height);
}
}));
getDefaultSkin().add("large-font", default_fontGenerator.generateFont(new FreeTypeFontParameter() {
{
size = fontScale(0.085f, height);
}
}));
getDefaultSkin().add("special-font", darktech_ldr_fontGenerator.generateFont(new FreeTypeFontParameter() {
{
size = fontScale(0.075f, height);
}
}));
}
public void defineSkinStyles() {
getDefaultSkin().add("default", Color.WHITE);
getDefaultSkin().add("inverse", Color.BLACK);
TextButtonStyle defaultTextButton = new TextButtonStyle();
defaultTextButton.up = getDefaultSkin().getDrawable("rect");
defaultTextButton.down = getDefaultSkin().getDrawable("rect-down");
defaultTextButton.font = getDefaultSkin().getFont("default-font");
defaultTextButton.fontColor = getDefaultSkin().getColor("default");
defaultTextButton.disabled = getDefaultSkin().getDrawable("rect-disabled");
getDefaultSkin().add("default", defaultTextButton);
TextButtonStyle subTextbutton = new TextButtonStyle(defaultTextButton);
subTextbutton.font = getDefaultSkin().getFont("sub-font");
getDefaultSkin().add("sub", subTextbutton);
TextButtonStyle windowTextButton = new TextButtonStyle(defaultTextButton);
windowTextButton.font = getDefaultSkin().getFont("window-font");
getDefaultSkin().add("window", windowTextButton);
TextButtonStyle textButtonLeft = new TextButtonStyle();
textButtonLeft.up = getDefaultSkin().getDrawable("left-button");
textButtonLeft.down = getDefaultSkin().getDrawable("left-button-down");
textButtonLeft.font = getDefaultSkin().getFont("default-font");
textButtonLeft.fontColor = getDefaultSkin().getColor("default");
getDefaultSkin().add("left", textButtonLeft);
SliderStyle defaultSlider = new SliderStyle(getDefaultSkin().getDrawable("default-slider"), getDefaultSkin().getDrawable("default-slider-knob"));
getDefaultSkin().add("default-horizontal", defaultSlider);
SliderStyle vertSlider = new SliderStyle(defaultSlider);
vertSlider.knob = getDefaultSkin().getDrawable("vertical-slider-knob");
getDefaultSkin().add("default-vertical", vertSlider);
LabelStyle defaultLabel = new LabelStyle();
defaultLabel.font = getDefaultSkin().getFont("default-font");
defaultLabel.fontColor = getDefaultSkin().getColor("default");
getDefaultSkin().add("default", defaultLabel);
TextFieldStyle defaultTextField = new TextFieldStyle(getDefaultSkin().getFont("sub-font"), getDefaultSkin().getColor("default"), getDefaultSkin().getDrawable("cursor"), getDefaultSkin().getDrawable("selection"), getDefaultSkin().getDrawable("textfield"));
getDefaultSkin().add("default", defaultTextField);
TextFieldStyle uiTextField = new TextFieldStyle(defaultTextField);
uiTextField.font = getDefaultSkin().getFont("window-font");
getDefaultSkin().add("ui", uiTextField);
WindowStyle defaultWindow = new WindowStyle(getDefaultSkin().getFont("window-font"), getDefaultSkin().getColor("default"), getDefaultSkin().getDrawable("default-window"));
getDefaultSkin().add("default", defaultWindow);
WindowStyle tintedWindow = new WindowStyle(defaultWindow);
tintedWindow.titleFontColor = getDefaultSkin().getColor("inverse");
tintedWindow.background = getDefaultSkin().getDrawable("tinted-window");
getDefaultSkin().add("tinted", tintedWindow);
ListStyle defaultList = new ListStyle(getDefaultSkin().getFont("window-font"), getDefaultSkin().getColor("inverse"), getDefaultSkin().getColor("default"), getDefaultSkin().getDrawable("selection"));
getDefaultSkin().add("default", defaultList);
ScrollPaneStyle defaultScrollPane = new ScrollPaneStyle();
defaultScrollPane.vScroll = getDefaultSkin().getDrawable("default-scroll");
defaultScrollPane.hScrollKnob = getDefaultSkin().getDrawable("default-round-large");
defaultScrollPane.hScroll = getDefaultSkin().getDrawable("default-scroll");
defaultScrollPane.vScrollKnob = getDefaultSkin().getDrawable("default-round-large");
getDefaultSkin().add("default", defaultScrollPane);
CheckBoxStyle defaultCheckBox = new CheckBoxStyle(getDefaultSkin().getDrawable("check-off"), getDefaultSkin().getDrawable("check-on"), getDefaultSkin().getFont("window-font"), getDefaultSkin().getColor("default"));
defaultCheckBox.checkboxOffDisabled = getDefaultSkin().getDrawable("check-disabled");
getDefaultSkin().add("default", defaultCheckBox);
SelectBoxStyle defaultSelectBox = new SelectBoxStyle(getDefaultSkin().getFont("default-font"), getDefaultSkin().getColor("default"), getDefaultSkin().getDrawable("default-select"), defaultScrollPane, defaultList);
getDefaultSkin().add("default", defaultSelectBox);
Gdx.app.debug("Prelaunch Debug Info", "UI Skin has been defined.");
CheckBoxStyle playButtonStyle = new CheckBoxStyle(defaultCheckBox);
playButtonStyle.checkboxOn = getDefaultSkin().getDrawable("play-down");
playButtonStyle.checkboxOff = getDefaultSkin().getDrawable("play");
getDefaultSkin().add("play-button", playButtonStyle);
ImageButtonStyle pauseButtonStyle = new ImageButtonStyle();
pauseButtonStyle.down = getDefaultSkin().getDrawable("pause-down");
pauseButtonStyle.up = getDefaultSkin().getDrawable("pause");
getDefaultSkin().add("pause-button", pauseButtonStyle);
ImageButtonStyle fastForwardButtonStyle = new ImageButtonStyle();
fastForwardButtonStyle.down = getDefaultSkin().getDrawable("fast-forward-down");
fastForwardButtonStyle.up = getDefaultSkin().getDrawable("fast-forward");
getDefaultSkin().add("fast-forward-button", fastForwardButtonStyle);
ImageButtonStyle reverseButtonStyle = new ImageButtonStyle();
reverseButtonStyle.down = getDefaultSkin().getDrawable("rewind-down");
reverseButtonStyle.up = getDefaultSkin().getDrawable("rewind");
getDefaultSkin().add("rewind-button", reverseButtonStyle);
CheckBoxStyle shuffleButtonStyle = new CheckBoxStyle(defaultCheckBox);
shuffleButtonStyle.checkboxOff = getDefaultSkin().getDrawable("shuffle");
shuffleButtonStyle.checkboxOn = getDefaultSkin().getDrawable("shuffle-down");
getDefaultSkin().add("shuffle-button", shuffleButtonStyle);
}
public RoundingResolutionHandler getrRHandler() {
return rRHandler;
}
}

View File

@@ -4,6 +4,8 @@ import java.security.InvalidParameterException;
import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.util.MusicManager;
public class AudioDataPackage {
private FloatArray bassPeaks;
private FloatArray mPeaks;

View File

@@ -1,214 +0,0 @@
package zero1hd.rhythmbullet.audio;
import java.io.IOException;
import java.util.Map;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.tritonus.share.sampled.TAudioFormat;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Music.OnCompletionListener;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.math.MathUtils;
import zero1hd.rhythmbullet.audio.wavedecoder.AudioSampleReader;
public class Mp3Manager implements MusicManager {
private int readWindowSize = 1024;
private Music music;
private int playbackIndex, readIndex;
private FileHandle fileHandle;
AudioInputStream in;
private AudioInputStream ais;
private AudioFormat af;
private AudioSampleReader d;
private Map<String, Object> properties;
public Mp3Manager(FileHandle file) {
this.fileHandle = file;
try {
in = AudioSystem.getAudioInputStream(file.file());
AudioFormat baseFormat = in.getFormat();
properties = ((TAudioFormat)baseFormat).properties();
af = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
baseFormat.getSampleRate(),
16, baseFormat.getChannels(),
baseFormat.getChannels()*2,
baseFormat.getSampleRate(), false);
ais = AudioSystem.getAudioInputStream(baseFormat, in);
d = new AudioSampleReader(ais);
music = Gdx.audio.newMusic(file);
} catch (UnsupportedAudioFileException | IOException e) {
e.printStackTrace();
}
}
@Override
public void dispose() {
music.dispose();
try {
ais.close();
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void playbackIndexUpdate() {
playbackIndex = (int) ((getDuration()*getSampleRate())/getReadWindowSize());
}
@Override
public int getPlaybackIndexPosition() {
return playbackIndex;
}
@Override
public int getReadWindowSize() {
return readWindowSize;
}
@Override
public int readSamples(float[] samples) {
try {
readIndex++;
return d.readSamples(samples);
} catch (IOException e) {
e.printStackTrace();
};
return 0;
}
@Override
public long getSampleCount() {
return ais.getFrameLength();
}
@Override
public float getDuration() {
return ((long) properties.get("duration"))/1000000f;
}
@Override
public float getSampleRate() {
return af.getSampleRate();
}
@Override
public void pause() {
music.pause();
}
@Override
public void play() {
music.play();
}
@Override
public boolean isPlaying() {
return music.isPlaying();
}
@Override
public float getPositionInSeconds() {
return music.getPosition();
}
@Override
public void setPosition(float position) {
music.setPosition(position);
}
@Override
public void setOnCompletionListener(OnCompletionListener listener) {
music.setOnCompletionListener(listener);
}
@Override
public void setVolume(float percent) {
music.setVolume(percent);
}
@Override
public boolean isFinishedLoading() {
return true;
}
@Override
public String getBasicSongName() {
return fileHandle.nameWithoutExtension();
}
@Override
public FileHandle getMusicFile() {
return fileHandle;
}
public void seek(long position) {
closeStream();
reInitStream();
skip(position);
}
private void closeStream() {
if (ais != null) {
try {
ais.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private void reInitStream() {
try {
AudioInputStream in = AudioSystem.getAudioInputStream(fileHandle.file());
ais = AudioSystem.getAudioInputStream(af, in);
in.close();
} catch (UnsupportedAudioFileException | IOException e) {
e.printStackTrace();
}
}
@Override
public void synchronize() {
seek(MathUtils.round(((Integer) properties.get("audio.length.bytes")).intValue() * (getPositionInSeconds()/getDuration())));
}
@Override
public int getReadIndex() {
return readIndex;
}
public void skip(long bytes) {
long totalSkipped = 0;
long skipped = 0;
while (totalSkipped < bytes) {
try {
skipped = ais.skip(bytes-totalSkipped);
} catch (IOException e) {
e.printStackTrace();
}
if (skipped == 0) break;
totalSkipped += skipped;
}
}
@Override
public void skipReadWindow() {
skip(readWindowSize*af.getFrameSize());
readIndex++;
}
}

View File

@@ -1,64 +0,0 @@
package zero1hd.rhythmbullet.audio;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Disposable;
public class MusicInfoController implements Disposable {
private MusicList musicList;
private ExecutorService exec;
private Array<MusicInfo> songInfoArray;
private Preferences musicAnnotation;
private boolean doneLoading;
public MusicInfoController(MusicList musicList) {
this.musicList = musicList;
songInfoArray = new Array<>();
exec = Executors.newSingleThreadExecutor();
musicAnnotation = Gdx.app.getPreferences("MusicAnnotation");
}
public MusicList getMusicList() {
return musicList;
}
/**
* Non-blocking, loads on separate thread.
*/
public void loadSongInfo() {
doneLoading = false;
for (int i = 0; i < songInfoArray.size; i++) {
songInfoArray.get(i).dispose();
}
songInfoArray.clear();
exec.submit(() -> {
for (int i = 0; i < musicList.getTotal(); i++) {
MusicInfo musicInfo = new MusicInfo(musicList.getMusicList().get(i), musicAnnotation);
musicInfo.loadInfo();
songInfoArray.add(musicInfo);
}
doneLoading = true;
});
}
@Override
public void dispose() {
exec.shutdown();
}
/**
* Verify if loading song info is done.
* @return
*/
public synchronized boolean isDoneLoading() {
return doneLoading;
}
public Array<MusicInfo> getSongInfoArray() {
return songInfoArray;
}
}

View File

@@ -1,122 +0,0 @@
package zero1hd.rhythmbullet.audio;
import java.util.Observable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Sort;
import zero1hd.rhythmbullet.util.FileHandleAlphabeticalComparator;
public class MusicList extends Observable {
private Array<FileHandle> musicList;
private String searchPath;
private boolean searched;
private FileHandleAlphabeticalComparator fhac;
private ExecutorService exec;
public MusicList() {
musicList = new Array<>();
fhac = new FileHandleAlphabeticalComparator();
exec = Executors.newSingleThreadExecutor();
}
private Array<FileHandle> recursiveMusicFileList(FileHandle fileHandle) {
Array<FileHandle> musicFiles = new Array<>();
FileHandle[] files = fileHandle.list();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
musicFiles.addAll(recursiveMusicFileList(files[i]));
} else {
if (files[i].extension().equalsIgnoreCase("wav") || files[i].extension().equalsIgnoreCase("mp3")) {
musicFiles.add(files[i]);
}
}
}
return musicFiles;
}
/**
* refreshes song list, notifies any observers of the refresh while passing no argument to the notifier.
* Blocking.
*/
public void refresh(boolean notify) {
musicList.clear();
Gdx.app.debug("SongController", "Searching path: " + searchPath);
if (Gdx.files.absolute(searchPath).exists() && Gdx.files.absolute(searchPath).isDirectory()) {
musicList.addAll(recursiveMusicFileList(Gdx.files.absolute(searchPath)));
}
if (!Gdx.files.external("RhythmBullet/Alan Walker - Spectre.mp3").exists()) {
Gdx.files.internal("music/Alan Walker - Spectre.mp3").copyTo(Gdx.files.external("RhythmBullet/Alan Walker - Spectre.mp3"));
}
musicList.add(Gdx.files.external("RhythmBullet/Alan Walker - Spectre.mp3"));
setChanged();
Sort.instance().sort(musicList, fhac);
searched = true;
if (notify) {
notifyObservers();
}
}
/**
* Wrapper method that uses asynch refresh.
* Also notifies listeners that are on the main thread.
*/
public void asynchRefresh() {
searched = false;
exec.submit(() -> {
refresh(false);
Gdx.app.debug("Asynch-MusicList", "Async refresh done. Notification has been sent.");
Gdx.app.postRunnable(() -> {
notifyObservers();
searched = true;
});
});
}
public void setSearchPath(String searchPath) {
this.searchPath = searchPath;
setChanged();
}
/**
* creates an audio manager for the given music file.
* @param file
* @return a music manager of the given music file.
*/
public MusicManager getAudioData(FileHandle file) {
if (file.extension().equalsIgnoreCase("wav")) {
return new WAVManager(file);
} else if (file.extension().equalsIgnoreCase("mp3")) {
return new Mp3Manager(file);
}
return null;
}
public MusicManager getMusicInfoFromIndex(int index) {
if (!searched) Gdx.app.debug("SongList", "Warning, this list hasn't even searched yet...");
return getAudioData(musicList.get(index));
}
public int getTotal() {
return musicList.size;
}
public FileHandle getSongFileHandleFromIndex(int index) {
if (!searched) Gdx.app.debug("SongList", "Warning, this list hasn't even searched yet...");
return musicList.get(index);
}
public Array<FileHandle> getMusicList() {
return musicList;
}
public boolean isSearched() {
return searched;
}
}

View File

@@ -1,149 +0,0 @@
package zero1hd.rhythmbullet.audio;
import java.util.Observable;
import java.util.Observer;
import java.util.Random;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Music.OnCompletionListener;
public class MusicListController extends Observable implements OnCompletionListener, Observer {
private MusicList musicList;
private MusicManager mm;
private int currentPlaybackID;
private boolean autoPlay;
private boolean shuffle;
private Random rand;
private Preferences prefs;
public MusicListController(MusicList musicList, Preferences prefs) {
if (prefs == null) throw new NullPointerException("preferences can't be null...");
if (musicList == null) throw new NullPointerException("music list can't be null...");
musicList.addObserver(this);
this.prefs = prefs;
this.musicList = musicList;
rand = new Random();
}
/**
* This play method automatically sets the volume.
*/
public void play() {
if (mm != null) {
Gdx.app.debug("MusicListController", "Playing from MLC.");
mm.play();
mm.setVolume(prefs.getFloat("music vol", 1f));
} else {
Gdx.app.debug("MusicListController", "failed to begin playing. Load the music!!!");
}
}
public void setMusicByIndex(int index) {
this.currentPlaybackID = index;
loadMusic();
}
public void skip() {
currentPlaybackID++;
if (shuffle) {
shuffle(false);
}
loadMusic();
}
public void previous() {
currentPlaybackID--;
if (shuffle) {
shuffle(false);
}
loadMusic();
}
@Override
public void onCompletion(Music music) {
if (autoPlay) {
if (shuffle) {
if (musicList.getTotal() != 0) {
currentPlaybackID = rand.nextInt(musicList.getTotal());
} else {
currentPlaybackID = 0;
}
} else {
currentPlaybackID++;
}
loadMusic();
play();
}
}
/**
* Shuffles the controller whether the shuffle boolean is true or false.
* @param load whether this method should also make sure to load the music, dispose of the last one, etc. Normally called unless you plan to manually call it elswhere.
*/
public void shuffle(boolean load) {
if (musicList.getTotal() == 0) {
currentPlaybackID = 0;
} else {
currentPlaybackID = rand.nextInt(musicList.getTotal());
}
if (load) {
loadMusic();
}
}
public void setAutoPlay(boolean autoPlay) {
this.autoPlay = autoPlay;
}
public void setShuffle(boolean shuffle) {
this.shuffle = shuffle;
}
public boolean isShuffle() {
return shuffle;
}
public boolean isAutoPlay() {
return autoPlay;
}
/**
* Loads the current selected song.
*/
public void loadMusic() {
Gdx.app.debug("MusicListController", "music is being loaded and listeners are being notified.");
if (mm != null) {
mm.dispose();
}
if (currentPlaybackID < 0) {
currentPlaybackID = musicList.getTotal();
}
if (currentPlaybackID > musicList.getTotal()) {
currentPlaybackID = 0;
}
this.mm = musicList.getMusicInfoFromIndex(currentPlaybackID);
mm.setOnCompletionListener(this);
setChanged();
notifyObservers(mm);
}
public MusicList getMusicList() {
return musicList;
}
public MusicManager getCurrentMusicManager() {
return mm;
}
@Override
public void update(Observable o, Object arg) {
if (o == musicList) {
loadMusic();
play();
}
}
}

View File

@@ -1,190 +0,0 @@
package zero1hd.rhythmbullet.audio;
import java.io.IOException;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Music.OnCompletionListener;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.math.MathUtils;
import zero1hd.rhythmbullet.audio.wavedecoder.AudioSampleReader;
public class WAVManager implements MusicManager {
private int readWindowSize = 1024;
private int playbackIndex, readIndex;
private Music music;
private FileHandle fileHandle;
private AudioInputStream ais;
private AudioFormat af;
private AudioSampleReader d;
public WAVManager(FileHandle file) {
this.fileHandle = file;
try {
ais = AudioSystem.getAudioInputStream(file.file());
d = new AudioSampleReader(ais);
af = ais.getFormat();
} catch (UnsupportedAudioFileException | IOException e) {
e.printStackTrace();
}
music = Gdx.audio.newMusic(file);
}
@Override
public void dispose() {
music.dispose();
try {
ais.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void playbackIndexUpdate() {
playbackIndex = (int) ((getSampleRate() * getDuration())/getReadWindowSize());
}
@Override
public int getPlaybackIndexPosition() {
return playbackIndex;
}
@Override
public int getReadWindowSize() {
return readWindowSize;
}
@Override
public int readSamples(float[] samples) {
try {
readIndex++;
return d.readSamples(samples);
} catch (IOException e) {
e.printStackTrace();
}
return 0;
}
@Override
public long getSampleCount() {
return ais.getFrameLength();
}
@Override
public float getDuration() {
return ais.getFrameLength()/af.getFrameRate();
}
@Override
public float getSampleRate() {
return af.getSampleRate();
}
@Override
public void pause() {
music.pause();
}
@Override
public void play() {
music.play();
}
@Override
public boolean isPlaying() {
return music.isPlaying();
}
@Override
public float getPositionInSeconds() {
return music.getPosition();
}
@Override
public void setPosition(float position) {
music.setPosition(position);
}
@Override
public void setOnCompletionListener(OnCompletionListener listener) {
music.setOnCompletionListener(listener);
}
@Override
public void setVolume(float percent) {
music.setVolume(percent);
}
@Override
public boolean isFinishedLoading() {
return true;
}
@Override
public String getBasicSongName() {
return fileHandle.nameWithoutExtension();
}
@Override
public FileHandle getMusicFile() {
return fileHandle;
}
public void seek(long position) {
restartStream();
skip(position);
}
private void restartStream() {
try {
ais.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
ais = AudioSystem.getAudioInputStream(fileHandle.file());
} catch (UnsupportedAudioFileException | IOException e) {
e.printStackTrace();
}
}
@Override
public void synchronize() {
seek(MathUtils.round(getPositionInSeconds()*getSampleRate()));
readIndex = playbackIndex;
}
@Override
public int getReadIndex() {
return readIndex;
}
public void skip(long bytes) {
long totalSkipped = 0;
long skipped = 0;
while (totalSkipped < bytes) {
try {
skipped = ais.skip(bytes-totalSkipped);
} catch (IOException e) {
e.printStackTrace();
}
if (skipped == 0) break;
totalSkipped += skipped;
}
}
@Override
public void skipReadWindow() {
skip(af.getFrameSize()*readWindowSize);
readIndex++;
}
}

View File

@@ -5,7 +5,7 @@ import java.util.concurrent.Executors;
import com.badlogic.gdx.utils.Disposable;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.util.MusicManager;
public class AudioAnalyzer implements Disposable {
private ExecutorService exec;

View File

@@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.audio.AudioDataPackage;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.util.MusicManager;
public class PeakDetectionRunnable implements Runnable {
boolean work = true, done;

View File

@@ -3,7 +3,7 @@ package zero1hd.rhythmbullet.audio.analyzer;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.util.MusicManager;
public class PruneFluxRunnable implements Runnable {
boolean work = true;

View File

@@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.FloatArray;
import edu.emory.mathcs.jtransforms.fft.FloatFFT_1D;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.util.MusicManager;
public class SpectralFluxAnalysisRunnable implements Runnable {
boolean work = true;

View File

@@ -3,7 +3,7 @@ package zero1hd.rhythmbullet.audio.analyzer;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.util.MusicManager;
public class ThresholdCalcRunnable implements Runnable {
boolean work = true;

View File

@@ -1,28 +0,0 @@
package zero1hd.rhythmbullet.audio.map;
import java.util.HashMap;
import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityFrame;
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame;
public class EntitySpawnInfo {
private EntityFrame<? extends Entity> entityToSpawn;
private CoordinatorFrame<? extends Coordinator> entityCoordinator;
public HashMap<String, Float> parameters;
public EntitySpawnInfo(EntityFrame<? extends Entity> entityToSpawn, CoordinatorFrame<? extends Coordinator> coordinator) {
this.entityToSpawn = entityToSpawn;
parameters = new HashMap<>();
}
public EntityFrame<? extends Entity> getEntityToSpawn() {
return entityToSpawn;
}
public CoordinatorFrame<? extends Coordinator> getEntityCoordinator() {
return entityCoordinator;
}
}

View File

@@ -1,106 +0,0 @@
package zero1hd.rhythmbullet.audio.map;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityFrame;
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame;
public class GamePlayMap {
private MusicManager musicData;
private MapWindowData[] spawnList;
private boolean building;
private int index;
private byte[] hudType;
/**
* GamePlayMap is what the game area will use to generate entities and judge current audio data
* @param audioData audio data
*/
public GamePlayMap(MusicManager audioData, int totalWindows) {
this.musicData = audioData;
spawnList = new MapWindowData[totalWindows];
hudType = new byte[totalWindows];
}
public int setIndex(int index) {
int previousIndex = this.index;
if (index < 0) {
this.index = 0;
} else if (index >= spawnList.length) {
toHead();
} else {
this.index = index;
}
return previousIndex;
}
public void setHUDType(byte data) {
hudType[index] = data;
}
public byte[] getHudType() {
return hudType;
}
public EntitySpawnInfo addEntity(EntityFrame<? extends Entity> entityType, CoordinatorFrame<? extends Coordinator> coordinator) {
if (building) {
if (spawnList[index] == null) {
spawnList[index] = new MapWindowData();
}
EntitySpawnInfo esi = new EntitySpawnInfo(entityType, coordinator);
spawnList[index].addEntity(esi);
return esi;
} else {
throw new IllegalStateException("Stupid, you need to call begin building first first.");
}
}
public void nextWindowData() {
if (building) {
index++;
} else {
throw new IllegalStateException("Stupid, you need to call begin building first first.");
}
}
public void toHead() {
index = spawnList.length-1;
}
public MusicManager getMusicData() {
return musicData;
}
public void beginBuild() {
if (!building) {
index = 0;
building = true;
} else {
throw new IllegalStateException("Excuse me, but your already building...");
}
}
public void endBuild() {
if (building) {
index = 0;
building = false;
} else {
throw new IllegalStateException("Nothings being built...");
}
}
public MapWindowData getCurrentWindowBasedOnIndex() {
if (index != musicData.getPlaybackIndexPosition()) {
index = musicData.getPlaybackIndexPosition();
if (index < spawnList.length) {
return spawnList[index];
}
}
return null;
}
public int getIndex() {
return index;
}
}

View File

@@ -1,19 +0,0 @@
package zero1hd.rhythmbullet.audio.map;
import com.badlogic.gdx.utils.Array;
public class MapWindowData {
Array<EntitySpawnInfo> entityDatas;
public MapWindowData() {
entityDatas = new Array<>(EntitySpawnInfo.class);
}
public void addEntity(EntitySpawnInfo entity) {
entityDatas.add(entity);
}
public EntitySpawnInfo[] getArray() {
return entityDatas.toArray();
}
}

View File

@@ -1,156 +0,0 @@
package zero1hd.rhythmbullet.audio.map;
import org.apache.commons.math3.random.MersenneTwister;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.AudioDataPackage;
import zero1hd.rhythmbullet.entity.EntityManager;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
import zero1hd.rhythmbullet.util.MiniEvents;
import zero1hd.rhythmbullet.util.MiniSender;
public class RhythmMapAlgorithm implements Runnable {
private MiniSender sender;
private EntityManager em;
private CoordinatorManager cm;
private FloatArray bassPeaks;
private FloatArray mPeaks;
private FloatArray umPeaks;
private MersenneTwister rand;
private GamePlayMap map;
private float avgBass;
private float avgUM;
private float avgSPB;
private float umMax, bassMax;
private float speedMod, healthMod, difficultyMod;
private float windowPerSecond;
private volatile int progress;
public RhythmMapAlgorithm(EntityManager em, CoordinatorManager cm, AudioDataPackage adp, float speedMod, float healthMod, float difficultyMod) {
this.cm = cm;
this.em = em;
sender = new MiniSender();
bassPeaks = adp.getBassPeaks();
mPeaks = adp.getmPeaks();
umPeaks = adp.getuMPeaks();
map = new GamePlayMap(adp.getMusicInfo(), umPeaks.size);
rand = new MersenneTwister(adp.getPUID());
avgSPB = adp.getAvgSPB();
windowPerSecond = 1/adp.getSecPerWin();
this.speedMod = speedMod;
this.healthMod = healthMod;
this.difficultyMod = difficultyMod;
umMax = adp.getuMMaxval();
avgUM = adp.getuMAvg();
bassMax = adp.getBassMaxVal();
avgBass = adp.getBassAvg();
}
EntitySpawnInfo esi;
@Override
public void run() {
map.beginBuild();
for (int index = 0; index < bassPeaks.size; index++) {
if (bassPeaks.get(index) != 0 || umPeaks.get(index) != 0) {
if (bassPeaks.get(index) != 0) {
//If there is a value of some sorts that is not zero, we generate some beat for the map
if (index > 1.5*windowPerSecond && bassPeaks.get(index) > avgBass) {
//If bass peak is greater than the bass peak average, then:
int normalIndexPos = map.setIndex((int) (map.getIndex() - windowPerSecond*1.5f));
float waitTime = 1.5f;
float endRadius = (bassPeaks.get(index)/bassMax)*(RhythmBullet.GAME_AREA_HEIGHT/4f);
esi = map.addEntity(em.voidCircle, null);
esi.parameters.put("warningTime", waitTime);
esi.parameters.put("endRadius", endRadius);
esi.parameters.put("growthRate", endRadius/(avgSPB*0.8f));
esi.parameters.put("x", rand.nextFloat()*RhythmBullet.GAME_AREA_WIDTH);
esi.parameters.put("y", rand.nextFloat()*RhythmBullet.GAME_AREA_HEIGHT);
map.setIndex(normalIndexPos);
} else {
}
}
if (umPeaks.get(index) != 0) {
if (umPeaks.get(index) >= avgUM*1.75f) {
//If upper midrange peaks are greater than average, the:
esi = map.addEntity(em.flake, null);
float xSpawn = (rand.nextFloat()*RhythmBullet.GAME_AREA_WIDTH) < RhythmBullet.GAME_AREA_WIDTH/2f ? 0 : RhythmBullet.GAME_AREA_WIDTH;
float ySpawn = (rand.nextFloat()*RhythmBullet.GAME_AREA_HEIGHT < RhythmBullet.GAME_AREA_HEIGHT/2f ? 0 : RhythmBullet.GAME_AREA_HEIGHT);
float angle = rand.nextFloat()*90;
if (xSpawn == 0) {
if (ySpawn != 0) {
angle += 270;
}
} else {
if (ySpawn == 0) {
angle += 90;
} else {
angle += 180;
}
}
esi.parameters.put("shardCount", (1f+(difficultyMod/100f))*4f);
esi.parameters.put("x", xSpawn);
esi.parameters.put("y", ySpawn);
esi.parameters.put("rate", (5/avgSPB)*speedMod);
esi.parameters.put("fuse", avgSPB*10f);
esi.parameters.put("angle", angle);
} else {
}
}
if (rand.nextFloat() < 0.15f) {
switch(rand.nextInt(10)) {
case 0:
break;
}
}
}
map.nextWindowData();
progress = MathUtils.round(100f*index/bassPeaks.size);
if (bassPeaks.get(index) > avgBass) {
map.setHUDType((byte) 1);
} else if (umPeaks.get(index) > avgUM) {
map.setHUDType((byte) 2);
}
sender.send(MiniEvents.MAPGEN_ITERATED);
}
map.endBuild();
sender.send(MiniEvents.MAP_GENERATED);
}
public synchronized GamePlayMap getMap() {
return map;
}
public synchronized int getProgress() {
return progress;
}
public MiniSender getSender() {
return sender;
}
}

View File

@@ -11,7 +11,7 @@ import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.util.MusicManager;
public class BasicVisualizer extends VisualizerCore {
private Pixmap pixmap;

View File

@@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.utils.Disposable;
import edu.emory.mathcs.jtransforms.fft.FloatFFT_1D;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.util.MusicManager;
public class VisualizerCore implements Disposable {
protected MusicManager mm;
@@ -33,6 +33,7 @@ public class VisualizerCore implements Disposable {
updateTimer += delta;
if (updateTimer >= updateRate) {
mm.playbackIndexUpdate();
System.out.println(mm.getPlaybackIndexPosition() + "vs" + mm.getReadIndex());
while (mm.getPlaybackIndexPosition() > mm.getReadIndex()) {
mm.skipReadWindow();
}

View File

@@ -1,101 +0,0 @@
package zero1hd.rhythmbullet.entity;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool;
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect;
import com.badlogic.gdx.utils.Array;
import zero1hd.rhythmbullet.RhythmBullet;
public class CollisionDetector {
Array<Entity> enemies;
Array<Entity> allies;
AssetManager assets;
Preferences prefs;
//Particle pools;
ParticleEffectPool explosionEffectPool;
Array<PooledEffect> effects = new Array<>();
private int amassedPoints;
Sound explosionSFX;
public CollisionDetector(Array<Entity> enemies, Array<Entity> allies, AssetManager assetManager, Preferences prefs) {
this.enemies = enemies;
this.allies = allies;
assets = assetManager;
this.prefs = prefs;
explosionEffectPool = new ParticleEffectPool(assets.get("explosion-s.p", ParticleEffect.class), 1, 64);
explosionSFX = assets.get("explosion.ogg", Sound.class);
}
public void collisionCheck() {
if ((enemies.size != 0) && (allies.size != 0)) {
for (int f = 0; f < enemies.size; f++) {
Entity enemy = enemies.get(f);
if (enemy.getHitZone() != null) {
for (int s = 0; s < allies.size; s++) {
Entity ally = allies.get(s);
if (ally.getHitZone() != null) {
if (enemy.getHitZone().overlaps(ally.getHitZone())) {
Gdx.app.debug("Collision Detector", "Collision between entities: " + enemy.getClass().getSimpleName() + " and " + ally.getClass().getSimpleName());
//Play FX;
if (ally.playCollideSFX() && enemy.playCollideSFX()) {
explosionSFX.play(prefs.getFloat("fx vol")/100f, 1f, (enemy.getX()/RhythmBullet.GAME_AREA_WIDTH));
}
if (ally.playCollidePFX() && enemy.playCollidePFX()) {
PooledEffect currentPFX;
currentPFX = explosionEffectPool.obtain();
currentPFX.setPosition(ally.getX() + ally.getWidth()/2f, ally.getY() + ally.getHeight()/2f);
effects.add(currentPFX);
}
enemy.collided(ally);
ally.collided(enemy);
amassedPoints += enemy.getPoints();
break;
}
}
}
}
}
}
}
/**
* draws the explosion particles where necessary.
* @param batch the batch used to draw the said particles
* @param cleanBatch whether this method should call begin and end on the batch.
*/
public void renderParticles(Batch batch, float delta, boolean cleanBatch) {
if (cleanBatch) {
batch.begin();
}
for (int i = 0; i < effects.size; i++) {
effects.get(i).draw(batch, delta);
if (effects.get(i).isComplete()) {
effects.get(i).free();
effects.removeIndex(i);
}
}
if (cleanBatch) {
batch.end();
}
}
public int getAmassedPoints() {
int amassedPoints = this.amassedPoints;
this.amassedPoints = 0;
return amassedPoints;
}
}

View File

@@ -1,208 +0,0 @@
package zero1hd.rhythmbullet.entity;
import java.util.HashMap;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Pool.Poolable;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
public class Entity extends Actor implements Poolable {
private Coordinator coordinator;
private EntityFrame<?> ef;
protected AssetManager assets;
protected Preferences prefs;
protected EntityManager ec;
protected boolean enemy;
protected boolean simple = true;
protected boolean nonStnrd = false;
protected boolean move = true;
protected boolean dead;
protected Rectangle hitbox;
protected Sprite sprite;
protected Vector2 rotRatios;
protected Vector2 center;
public float angle;
public float speed;
protected int points;
/**
* called by the entity frame and only once (when this object is created).
* Used by the frame to setup variables for simple calling later.
* Anything that needs to be setup for the entity on first call should not override this.
* (Unless you call the super of this and then the rest which is fine too).
* This will then call preInit() which is the method you should override.
*/
protected void setup(EntityManager ec, EntityFrame<?> ef) {
this.ec = ec;
this.ef = ef;
assets = ec.getAssets();
prefs = ec.getPrefs();
rotRatios = new Vector2();
center = new Vector2();
hitbox = new Rectangle();
preInit();
}
/**
* Method to override should any setup need to be done once (on entity first creation).
*/
public void preInit() {
if (sprite.getTexture() == null) throw new NullPointerException("what, your not going to have a texture for your entity?");
sprite.setOriginCenter();
}
/**
* used by the game stage to pass parameters for different types of entities.
* @param params a hashmap containing parameters necessary for different entities.
*/
public void init(HashMap<String, Float> params) {
}
/**
* Called whenever a collision is detected
* @param entity is the entity that hit this one.
*/
public void collided(Entity entity) {
}
/**
* gets the box that represents the hit box to calculate whether there is a collision or not
* @return the object that represents the hit box
*/
public Rectangle getHitZone() {
return hitbox;
}
public boolean isDead() {
return dead;
}
@Override
public void act(float delta) {
if (!nonStnrd) {
if (coordinator != null) {
coordinator.coordinate(delta);
}
if (move) {
move(delta, true);
}
if (dead) {
ef.recycleEntity(this);
}
}
if (angle >= 360f) {
angle -= 360f;
}
if (getX() > RhythmBullet.GAME_AREA_WIDTH || getY() > RhythmBullet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
dead = true;
}
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
if (!nonStnrd) {
sprite.draw(batch);
}
batch.setColor(Color.WHITE);
super.draw(batch, parentAlpha);
}
public boolean playCollidePFX() {
return true;
}
public boolean playCollideSFX() {
return true;
}
public void move(float delta, boolean update) {
rotRatios.set(MathUtils.cosDeg(angle), MathUtils.sinDeg(angle));
moveBy(rotRatios.x*speed*delta, rotRatios.y*speed*delta);
center.set(getX() + getWidth()/2f, getY() + getHeight()/2f);
if (update) {
updatePositionData();
}
}
public void updatePositionData() {
if (simple) {
sprite.setPosition(getX(), getY());
hitbox.setPosition(getX(), getY());
sprite.setSize(getWidth(), getHeight());
hitbox.setSize(getWidth(), getHeight());
} else {
sprite.setCenter(center.x, center.y);
hitbox.setCenter(center);
sprite.setOriginCenter();
sprite.setRotation(angle);
}
}
@Override
public void reset() {
if (coordinator != null) {
coordinator.clean();
coordinator = null;
}
rotRatios.set(0, 0);
sprite.setPosition(0, 0);
hitbox.set(0, 0, 0, 0);
sprite.setRotation(0);
sprite.setColor(Color.WHITE);
setPosition(0, 0);
center.set(0, 0);
angle = 0;
speed = 0;
points = 0;
dead = false;
}
public Vector2 getCenter() {
return center;
}
public float getAngle() {
return angle;
}
public void setSpeed(float speed) {
this.speed = speed;
}
public float getSpeed() {
return speed;
}
public void setCoordinator(Coordinator coordinator) {
this.coordinator = coordinator;
coordinator.setEntity(this);
}
public void kill() {
dead = true;
}
public int getPoints() {
return points + (coordinator != null ? coordinator.getScoreBonus() : 0);
}
}

View File

@@ -1,61 +0,0 @@
package zero1hd.rhythmbullet.entity;
import com.badlogic.gdx.utils.Pool;
public class EntityFrame<T extends Entity> {
private Pool<T> pool;
private EntityManager ec;
Class<T> ct;
EntityFrame<T> ef;
public EntityFrame(EntityManager entityController, Class<T> classType) {
this.ct = classType;
ef = this;
ec = entityController;
pool = new Pool<T>() {
@Override
protected T newObject() {
try {
T entity = ct.newInstance();
entity.setup(ec, ef);
return entity;
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
return null;
}
}
};
}
public T buildEntity() {
T entity = pool.obtain();
if (entity.enemy) {
ec.activeEnemies.add(entity);
} else {
ec.activeAllies.add(entity);
}
return entity;
}
/**
* Free the entity if no longer used.
* @param entity to be freed.
*/
protected void recycleEntity(Entity entity) {
if (entity.enemy) {
ec.activeEnemies.removeValue(entity, true);
} else {
ec.activeAllies.removeValue(entity, true);
}
entity.remove();
pool.free(ct.cast(entity));
}
@Override
public String toString() {
return ct.getSimpleName();
}
}

View File

@@ -1,59 +0,0 @@
package zero1hd.rhythmbullet.entity;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.Array;
import zero1hd.rhythmbullet.entity.ally.Laser;
import zero1hd.rhythmbullet.entity.enemies.Flake;
import zero1hd.rhythmbullet.entity.enemies.Pellet;
import zero1hd.rhythmbullet.entity.enemies.Shard;
import zero1hd.rhythmbullet.entity.enemies.VoidCircle;
public class EntityManager {
private AssetManager assets;
private Preferences prefs;
private Stage stage;
public Array<Entity> activeAllies;
public Array<Entity> activeEnemies;
public EntityFrame<VoidCircle> voidCircle;
public EntityFrame<Pellet> pellet;
public EntityFrame<Shard> shard;
public EntityFrame<Flake> flake;
public EntityFrame<Laser> laser;
public EntityManager(AssetManager assetManager, Preferences preferences, Stage stage) {
activeAllies = new Array<Entity>();
activeEnemies = new Array<Entity>();
this.assets = assetManager;
this.prefs = preferences;
this.stage = stage;
setup();
}
private void setup() {
voidCircle = new EntityFrame<>(this, VoidCircle.class);
pellet = new EntityFrame<>(this, Pellet.class);
shard = new EntityFrame<>(this, Shard.class);
flake = new EntityFrame<>(this, Flake.class);
laser = new EntityFrame<>(this, Laser.class);
}
public Stage getStage() {
return stage;
}
public AssetManager getAssets() {
return assets;
}
public Preferences getPrefs() {
return prefs;
}
}

View File

@@ -1,69 +0,0 @@
package zero1hd.rhythmbullet.entity.ally;
import java.util.HashMap;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.entity.Entity;
public class Laser extends Entity {
Sound sfx;
@Override
public void preInit() {
sprite = new Sprite(assets.get("laser.png", Texture.class));
sfx = assets.get("laser.ogg", Sound.class);
setSize(0.25f, 2f);
super.preInit();
}
public void init(float x, float y, float rate) {
setPosition(x-getWidth()/2f, y-getHeight()/2f);
speed = rate;
sfx.play(prefs.getFloat("fx vol")/100f);
toBack();
angle = 90f;
}
/**
* Vars: x, y, rate;
*/
@Override
public void init(HashMap<String, Float> params) {
setX(params.get("x") - getWidth()/2f);
setY(params.get("y") - getHeight()/2f);
speed = params.get("rate");
angle = 90f;
sfx.play(prefs.getFloat("fx vol")/100f);
super.init(params);
}
@Override
public void act(float delta) {
toBack();
if (getY() > RhythmBullet.GAME_AREA_HEIGHT) {
dead = true;
}
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
}
@Override
public void reset() {
super.reset();
}
@Override
public void collided(Entity entity) {
dead = true;
}
}

View File

@@ -1,118 +0,0 @@
package zero1hd.rhythmbullet.entity.ally;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.entity.Entity;
public class PolyjetEntity extends Entity {
public float health;
private ParticleEffect thrust;
private Texture polyjet;
private ParticleEffect teleportCloak;
public boolean moveLeft, moveRight, moveUp, moveDown, teleporting, accelerate;
private float speed, accel;
private float rate;
private int maxH;
public PolyjetEntity(AssetManager assets, float speed, float accel,int maxHealth, String jet) {
nonStnrd = true;
health = 100;
this.speed = speed;
this.accel = accel;
setSize(1.5f, 1.5f);
setPosition(RhythmBullet.GAME_AREA_WIDTH/2 - getWidth()/2, -4f);
maxH = maxHealth;
hitbox = new Rectangle(getX(), getY(), getWidth(), getHeight());
polyjet = assets.get("polyjet-" + jet + ".png", Texture.class);
thrust = assets.get("standard_thrust.p", ParticleEffect.class);
thrust.start();
teleportCloak = assets.get("teleport-cloak.p", ParticleEffect.class);
addAction(Actions.moveTo(getX(), 4f, 0.5f));
}
@Override
public void act(float delta) {
hitbox.setPosition(getX(), getY());
thrust.setPosition(getX()+(getWidth())/2 - 1f/16f, getY()-0.2f);
thrust.update(delta);
teleportCloak.setPosition(getX() +(getWidth()-1)/2, getY() + (getHeight()-1)/2);
hitbox.setPosition(getX(), getY());
//Movement!
if (accelerate) {
rate = speed + accel;
} else {
rate = speed;
}
if (moveLeft && !moveRight) {
moveBy(-(rate*delta), 0);
}
if (moveRight && !moveLeft) {
moveBy(rate*delta, 0);
}
if (moveUp && !moveDown) {
moveBy(0, rate*delta);
}
if (moveDown && !moveUp) {
moveBy(0, -rate*delta);
}
if (health <= 0) {
dead = true;
} else if (health > maxH) {
health = maxH;
}
if (getX() <= 1) {
moveLeft = false;
setX(1f);
}
if (getX() >= RhythmBullet.GAME_AREA_WIDTH-1-getWidth()) {
moveRight = false;
setX(RhythmBullet.GAME_AREA_WIDTH-1f-getWidth());
}
if (getY() >= RhythmBullet.GAME_AREA_HEIGHT - 1 - getHeight()) {
moveUp = false;
setY(RhythmBullet.GAME_AREA_HEIGHT - 1 - getHeight());
}
if (getY() <= 1) {
moveDown = false;
setY(1f);
}
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
thrust.draw(batch);
batch.draw(polyjet, getX(), getY(), getWidth(), getHeight());
super.draw(batch, parentAlpha);
}
@Override
public void collided(Entity entity) {
}
public Rectangle getHitbox() {
return hitbox;
}
public void setHealth(float health) {
this.health = health;
}
}

View File

@@ -1,42 +0,0 @@
package zero1hd.rhythmbullet.entity.coordinator;
import com.badlogic.gdx.utils.Pool.Poolable;
import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityManager;
public class Coordinator implements Poolable {
private CoordinatorFrame<? extends Coordinator> cf;
protected EntityManager em;
protected Entity entity;
protected int scoreBonus;
public void setup(EntityManager em, CoordinatorFrame<? extends Coordinator> cf) {
this.em = em;
this.cf = cf;
}
public void init(Entity entity) {
this.entity = entity;
}
public void coordinate(float delta) {
}
public void clean() {
cf.recycleCoordinator(this);
}
public void setEntity(Entity entity) {
this.entity = entity;
}
@Override
public void reset() {
entity = null;
}
public int getScoreBonus() {
return scoreBonus;
}
}

View File

@@ -1,44 +0,0 @@
package zero1hd.rhythmbullet.entity.coordinator;
import com.badlogic.gdx.utils.Pool;
import zero1hd.rhythmbullet.entity.EntityManager;
public class CoordinatorFrame<T extends Coordinator> {
private Pool<T> pool;
private EntityManager em;
CoordinatorFrame<T> cf;
Class<T> coordinatorType;
public CoordinatorFrame(EntityManager entityManager, Class<T> classtype) {
this.em = entityManager;
coordinatorType = classtype;
cf = this;
pool = new Pool<T>() {
@Override
protected T newObject() {
try {
T coordinator = coordinatorType.newInstance();
coordinator.setup(em, cf);
return coordinator;
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
return null;
}
}
};
}
public T buildCoordinator() {
T coordinator = pool.obtain();
return coordinator;
}
protected void recycleCoordinator(Coordinator coordinator) {
pool.free(coordinatorType.cast(coordinator));
}
@Override
public String toString() {
return coordinatorType.getSimpleName();
}
}

View File

@@ -1,20 +0,0 @@
package zero1hd.rhythmbullet.entity.coordinator;
import zero1hd.rhythmbullet.entity.EntityManager;
public class CoordinatorManager {
private EntityManager em;
public CoordinatorFrame<SlowLeftCoordinator> slowLeft;
public CoordinatorFrame<SlowRightCoordinator> slowRight;
public CoordinatorManager(EntityManager em) {
this.em = em;
setup();
}
private void setup() {
slowLeft = new CoordinatorFrame<>(em, SlowLeftCoordinator.class);
slowRight = new CoordinatorFrame<>(em, SlowRightCoordinator.class);
}
}

View File

@@ -1,9 +0,0 @@
package zero1hd.rhythmbullet.entity.coordinator;
public class SlowLeftCoordinator extends Coordinator {
@Override
public void coordinate(float delta) {
entity.angle -= 32*delta;
super.coordinate(delta);
}
}

View File

@@ -1,9 +0,0 @@
package zero1hd.rhythmbullet.entity.coordinator;
public class SlowRightCoordinator extends Coordinator {
@Override
public void coordinate(float delta) {
entity.angle += 32*delta;
super.coordinate(delta);
}
}

View File

@@ -1,116 +0,0 @@
package zero1hd.rhythmbullet.entity.enemies;
import java.util.HashMap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Rectangle;
import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.ally.Laser;
public class Flake extends Entity {
private float timer;
private float totalTime;
private Shard[] shards;
@Override
public void preInit() {
sprite = new Sprite(assets.get("flake.png", Texture.class));
simple = true;
enemy = true;
move = false;
setSize(3f, 3f);
sprite.setSize(getWidth(), getHeight());
super.preInit();
}
public void init(float x, float y, float rate, float fuse, float angle, int shardCount) {
this.shards = new Shard[shardCount];
for (int i = 0; i < shards.length; i++) {
shards[i] = ec.shard.buildEntity();
shards[i].init(x, y, 360/shards.length*i, 0, 2);
ec.getStage().addActor(shards[i]);
}
this.speed = rate;
this.timer = fuse;
this.totalTime = fuse;
this.angle = angle;
setPosition(x-getWidth()/2f, y-getHeight()/2f);
}
/**
* params: shardCount, x, y, rate, fuse, angle;
*/
@Override
public void init(HashMap<String, Float> params) {
this.shards = new Shard[params.get("shardCount").intValue()];
for (int i = 0; i < shards.length; i++) {
shards[i] = ec.shard.buildEntity();
shards[i].init(params.get("x"), params.get("y"), 360/shards.length*i, 0, 1);
ec.getStage().addActor(shards[i]);
}
this.speed = params.get("rate");
this.timer = params.get("fuse");
this.totalTime = timer;
this.angle = params.get("angle");
hitbox.setSize(getWidth(), getHeight());
setPosition(params.get("x")-getWidth()/2f, params.get("y")-getHeight()/2f);
super.init(params);
}
@Override
public void act(float delta) {
if (timer > 0) {
timer -= delta;
}
move(delta, true);
for (int i = 0; i < shards.length; i++) {
shards[i].setPosition(center.x-shards[i].getWidth()/2f, center.y-shards[i].getWidth()/2f);
shards[i].move(delta, true);
}
if (timer <= 0) {
for (int i = 0; i < shards.length; i++) {
shards[i].setSpeed(30f);
}
dead = true;
}
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
sprite.setColor(0f, 0f, 0f, 1-(timer/totalTime));
super.draw(batch, parentAlpha);
}
@Override
public void collided(Entity entity) {
if (entity.getClass() == Laser.class) {
dead = true;
for (int i = 0; i < shards.length; i++) {
shards[i].kill();
}
}
}
@Override
public Rectangle getHitZone() {
return hitbox;
}
@Override
public void reset() {
timer = 0;
shards = null;
totalTime = 0;
super.reset();
}
}

View File

@@ -1,56 +0,0 @@
package zero1hd.rhythmbullet.entity.enemies;
import java.util.HashMap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.utils.Pool.Poolable;
import zero1hd.rhythmbullet.entity.Entity;
public class Pellet extends Entity implements Poolable {
@Override
public void preInit() {
sprite = new Sprite(assets.get("pellet.png", Texture.class));
enemy = true;
setSize(0.5f, 0.5f);
sprite.setColor(0.5f, 1f, 1f, 0.5f);
super.preInit();
}
public void init(float x, float y, float angle, float rate) {
setPosition(x, y);
this.speed = rate;
this.angle = angle;
}
/**
* Vars: x, y, speed, angle;
*/
@Override
public void init(HashMap<String, Float> params) {
setPosition(params.get("x"), params.get("y"));
speed = params.get("speed");
angle = params.get("angle");
super.init(params);
}
@Override
public void act(float delta) {
super.act(delta);
}
@Override
public void collided(Entity entity) {
dead = true;
super.collided(entity);
}
@Override
public void reset() {
dead = false;
super.reset();
}
}

View File

@@ -1,84 +0,0 @@
package zero1hd.rhythmbullet.entity.enemies;
import java.util.HashMap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Rectangle;
import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.ally.Laser;
public class Shard extends Entity {
private int hp;
private int maxHp;
@Override
public void preInit() {
sprite = new Sprite(assets.get("shard.png", Texture.class));
setSize(2f, 2f);
sprite.setSize(3f, 2f);
simple = false;
enemy = true;
super.preInit();
}
public void init(float x, float y, float angle, float rate, int hp) {
speed = rate;
this.hp = hp;
maxHp = hp;
this.angle = angle;
setPosition(x-(getWidth()/2f), y-(getHeight()/2f));
hitbox.setSize(getWidth(), getHeight());
}
/**
* x, y, angle, rate, hp;
*/
@Override
public void init(HashMap<String, Float> params) {
setX(params.get("x"));
setY(params.get("y"));
angle = params.get("angle");
speed = params.get("rate");
hp = params.get("hp").intValue();
super.init(params);
}
@Override
public void reset() {
hp = 0;
maxHp = 0;
super.reset();
}
@Override
public void act(float delta) {
if (hp <= 0) {
dead = true;
}
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
sprite.setColor(((float)hp/(float)maxHp), ((float)hp/(float)maxHp), ((float)hp/(float)maxHp), 0.5f);
super.draw(batch, parentAlpha);
}
@Override
public void collided(Entity entity) {
if (entity.getClass() == Laser.class) {
hp --;
} else {
dead = true;
}
}
@Override
public Rectangle getHitZone() {
return hitbox;
}
}

View File

@@ -1,126 +0,0 @@
package zero1hd.rhythmbullet.entity.enemies;
import java.util.HashMap;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import zero1hd.rhythmbullet.entity.Entity;
public class VoidCircle extends Entity {
private float timer;
private float endRadius;
private float currentRadius;
private float growthRate;
private boolean begin;
private float maxTime;
private Sound sound;
@Override
public void preInit() {
sprite = new Sprite(assets.get("void_circle.png", Texture.class));
simple = false;
enemy = true;
sound = assets.get("disintegrate.ogg", Sound.class);
super.preInit();
}
public void init(float endRadius, float x, float y, float growthRate, float warningTime) {
timer = warningTime;
maxTime = warningTime;
this.endRadius = endRadius;
setSize(2f*endRadius, 2f*endRadius);
setPosition(x-getWidth()/2f, y-getHeight()/2f);
this.growthRate = growthRate;
}
/**
* warningTime, endRadius, growthRate, x, y;
*/
@Override
public void init(HashMap<String, Float> params) {
timer = params.get("warningTime");
maxTime = timer;
endRadius = params.get("endRadius");
setSize(2f*endRadius, 2f*endRadius);
setPosition(params.get("x")-getWidth()/2f, params.get("y")-getHeight()/2f);
growthRate = params.get("growthRate");
super.init(params);
}
@Override
public void act(float delta) {
toFront();
if (begin) {
sprite.setSize(2*currentRadius, 2*currentRadius);
sprite.setColor(0f,0f,0f,1f);
} else {
sprite.setSize(2*endRadius, 2*endRadius);
sprite.setColor(1f,0.52f,0.32f,0.1f*(timer/maxTime));
}
if (timer > 0) {
timer -= delta;
} else {
begin = true;
if (currentRadius < endRadius) {
growCurrentRadius(delta*growthRate);
} else {
endRadius = -1f;
if (currentRadius > 0) {
growCurrentRadius(delta*-growthRate);
} else {
dead = true;
}
}
}
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
}
@Override
public void reset() {
currentRadius = 0;
growthRate = 0;
timer = 0;
maxTime = 0;
endRadius = 0;
begin = false;
setSize(0, 0);
super.reset();
}
public void growCurrentRadius(float radius) {
currentRadius += radius;
float length = (float) Math.sqrt(2*(currentRadius*currentRadius));
if (length < 0) {
length = 0;
}
hitbox.setSize(length, length);
}
@Override
public void collided(Entity entity) {
if (begin) {
sound.play(prefs.getFloat("fx vol"));
}
}
@Override
public boolean playCollidePFX() {
return false;
}
@Override
public boolean playCollideSFX() {
return false;
}
}

View File

@@ -1,148 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.audio.MusicManager;
public class AudioGraph extends Actor {
private MusicManager audioData;
ShapeRenderer shapeRender;
FloatArray mainGraph;
FloatArray overlayGraph;
int dataIndex;
int displayMode;
public float normalDataG1 = 1f, normalDataG2 = 1f, avgG1 = 1f, avgG2 = 1f;
float scale;
public AudioGraph(int graphSizeW, int graphSizeH) {
shapeRender = new ShapeRenderer();
setSize(graphSizeW, graphSizeH);
scale = graphSizeH;
}
public void setAudioDataIndex(int audioDataIndex) {
this.dataIndex = audioDataIndex;
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.end();
shapeRender.begin(ShapeType.Line);
shapeRender.setColor(0f, 0f, 0f, 0.35f);
shapeRender.rect(getX(), getY(), getWidth(), getHeight());
if (overlayGraph != null) {
if (Gdx.input.isKeyPressed(Keys.COMMA)) {
if (scale > 0.05f) {
scale -= 0.25f;
}
} else if (Gdx.input.isKeyPressed(Keys.PERIOD)) {
if (scale < getHeight()*2) {
scale += 0.4f;
}
}
if (Gdx.input.isKeyJustPressed(Keys.M)) {
Gdx.app.debug("Graph", "Switching to another graph.");
displayMode++;
if (displayMode == 3) {
displayMode = 0;
}
}
}
switch (displayMode) {
case 0:
shapeRender.setColor(1f, 0f, 0f, 1f);
for (int x = 0; x < getWidth(); x++) {
try {
shapeRender.line(
getX()+x,
getY(),
getX()+x,
(int) ((mainGraph.get((int) (dataIndex+x-getWidth()/2))/normalDataG1)*scale)+getY());
} catch (NullPointerException | IndexOutOfBoundsException e) {
}
shapeRender.line(
getX(),
MathUtils.round(scale*(avgG1/normalDataG1))+getY(),
getWidth() + getX(),
MathUtils.round(scale*(avgG1/normalDataG1))+getY());
}
case 1:
shapeRender.setColor(0f, 0f, 1f, 0.75f);
for (int x = 0; x < getWidth(); x++) {
try {
shapeRender.line(
getX()+x,
getY(),
getX()+x,
(int) ((overlayGraph.get((int) (dataIndex+x-getWidth()/2))/normalDataG2)*scale)+getY());
} catch (NullPointerException | IndexOutOfBoundsException e) {
}
shapeRender.line(
getX(),
MathUtils.round(scale*(avgG2/normalDataG2)) + getY(),
getWidth() + getX(),
MathUtils.round(scale*(avgG2/normalDataG2))+getY());
}
break;
case 2:
shapeRender.setColor(1f, 0f, 0f, 0.75f);
for (int x = 0; x < getWidth(); x++) {
try {
shapeRender.line(
getX()+x,
getY(),
getX()+x,
(int) ((mainGraph.get((int) (dataIndex+x-getWidth()/2))/normalDataG1)*scale)+getY());
} catch (NullPointerException | IndexOutOfBoundsException e) {
}
shapeRender.line(
getX(),
MathUtils.round(scale*(avgG1/normalDataG1))+getY(),
getWidth() + getX(),
MathUtils.round(scale*(avgG1/normalDataG1))+getY());
}
break;
}
shapeRender.setColor(0f, 1f, 0f, 1f);
shapeRender.line(getX()+getWidth()/2, 0, getX()+getWidth()/2, getHeight()+getY());
shapeRender.end();
batch.begin();
super.draw(batch, parentAlpha);
}
@Override
public void act(float delta) {
if (audioData != null) {
setAudioDataIndex(audioData.getPlaybackIndexPosition());
}
super.act(delta);
}
/**
* Set what arrays to graph
* @param dataSet1 first audio data set
* @param dataSet2 overlay graph. This one can be null.
* @param audioData actual basic audio information for index position
*/
public void setGraphingData(FloatArray dataSet1, FloatArray dataSet2, MusicManager audioData) {
this.mainGraph = dataSet1;
this.overlayGraph = dataSet2;
if (dataSet2 == null) {
displayMode = 2;
} else {
displayMode = 0;
}
this.audioData = audioData;
}
}

View File

@@ -1,148 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.audio.MusicManager;
public class AudioGraphRelation extends Actor {
private MusicManager audioData;
ShapeRenderer shapeRender;
FloatArray mainGraph;
FloatArray overlayGraph;
int dataIndex;
int displayMode;
public float normalDataG1 = 1f, normalDataG2 = 1f, avgG1 = 1f, avgG2 = 1f;
float scale;
public AudioGraphRelation(int graphSizeW, int graphSizeH) {
shapeRender = new ShapeRenderer();
setSize(graphSizeW, graphSizeH);
scale = graphSizeH;
}
public void setAudioDataIndex(int audioDataIndex) {
this.dataIndex = audioDataIndex;
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.end();
shapeRender.begin(ShapeType.Line);
shapeRender.setColor(0f, 0f, 0f, 0.35f);
shapeRender.rect(getX(), getY(), getWidth(), getHeight());
if (overlayGraph != null) {
if (Gdx.input.isKeyPressed(Keys.COMMA)) {
if (scale > 0.05f) {
scale -= 0.25f;
}
} else if (Gdx.input.isKeyPressed(Keys.PERIOD)) {
if (scale < getHeight()*2) {
scale += 0.4f;
}
}
if (Gdx.input.isKeyJustPressed(Keys.M)) {
Gdx.app.debug("Graph", "Switching to another graph.");
displayMode++;
if (displayMode == 3) {
displayMode = 0;
}
}
}
switch (displayMode) {
case 0:
shapeRender.setColor(1f, 0f, 0f, 1f);
for (int x = 0; x < getHeight() -1; x++) {
try {
shapeRender.line(
getX()+x,
getY(),
getX()+x+1,
(int) ((mainGraph.get((int) (dataIndex+x +1 -getWidth()/2))/normalDataG1)*scale)+getY());
} catch (NullPointerException | IndexOutOfBoundsException e) {
}
shapeRender.line(
getX(),
MathUtils.round(scale*(avgG1/normalDataG1))+getY(),
getWidth() + getX(),
MathUtils.round(scale*(avgG1/normalDataG1))+getY());
}
case 1:
shapeRender.setColor(0f, 0f, 1f, 0.75f);
for (int x = 0; x < getHeight() -1; x++) {
try {
shapeRender.line(
getX()+x,
getY(),
getX()+x+1,
(int) ((overlayGraph.get((int) (dataIndex+x +1 -getWidth()/2))/normalDataG2)*scale)+getY());
} catch (NullPointerException | IndexOutOfBoundsException e) {
}
shapeRender.line(
getX(),
MathUtils.round(scale*(avgG2/normalDataG2)) + getY(),
getWidth() + getX(),
MathUtils.round(scale*(avgG2/normalDataG2))+getY());
}
break;
case 2:
shapeRender.setColor(1f, 0f, 0f, 0.75f);
for (int x = 0; x < getWidth(); x++) {
try {
shapeRender.line(
getX()+x,
getY(),
getX()+x+1,
(int) ((mainGraph.get((int) (dataIndex+x +1 -getWidth()/2))/normalDataG1)*scale)+getY());
} catch (NullPointerException | IndexOutOfBoundsException e) {
}
shapeRender.line(
getX(),
MathUtils.round(scale*(avgG1/normalDataG1))+getY(),
getWidth() + getX(),
MathUtils.round(scale*(avgG1/normalDataG1))+getY());
}
break;
}
shapeRender.setColor(0f, 1f, 0f, 1f);
shapeRender.line(getX()+getWidth()/2, 0, getX()+getWidth()/2, getHeight()+getY());
shapeRender.end();
batch.begin();
super.draw(batch, parentAlpha);
}
@Override
public void act(float delta) {
if (audioData != null) {
setAudioDataIndex(audioData.getPlaybackIndexPosition());
}
super.act(delta);
}
/**
* Set what arrays to graph
* @param dataSet1 first audio data set
* @param dataSet2 overlay graph. This one can be null.
* @param audioData actual basic audio information for index position
*/
public void setGraphingData(FloatArray dataSet1, FloatArray dataSet2, MusicManager audioData) {
this.mainGraph = dataSet1;
this.overlayGraph = dataSet2;
if (dataSet2 == null) {
displayMode = 2;
} else {
displayMode = 0;
}
this.audioData = audioData;
}
}

View File

@@ -1,100 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array;
import zero1hd.rhythmbullet.controls.KeyMap;
public class ControlOptions extends Table {
public ControlOptions(Skin skin, KeyMap keyMap) {
super(skin);
align(Align.center);
//first
Label forwardKeyLabel = new Label("Forward: ",skin);
forwardKeyLabel.setName(KeyMap.UP);
add(forwardKeyLabel).left();
KeyBindButton forwardKeySetter = new KeyBindButton(keyMap, KeyMap.UP);
add(forwardKeySetter).spaceRight(45f);
Label shootKeyLabel = new Label("Shoot: ", skin);
shootKeyLabel.setName(KeyMap.SHOOT);
add(shootKeyLabel).left();
KeyBindButton shootKeySetter = new KeyBindButton(keyMap, KeyMap.SHOOT);
add(shootKeySetter);
row();
//second
Label backwardKeyLabel = new Label("Backward: ", skin);
backwardKeyLabel.setName(KeyMap.DOWN);
add(backwardKeyLabel).left();
KeyBindButton backwardKeySetter = new KeyBindButton(keyMap, KeyMap.DOWN);
add(backwardKeySetter).spaceRight(45f);
Label sector1TPKeyLabel = new Label("Left Teleport", skin);
sector1TPKeyLabel.setName(KeyMap.FIRSTTHIRDTELEPORT);
add(sector1TPKeyLabel).left();
KeyBindButton Sector1TPKeySetter = new KeyBindButton(keyMap, KeyMap.FIRSTTHIRDTELEPORT);
add(Sector1TPKeySetter);
row();
Label leftKeyLabel = new Label("Left: ", skin);
leftKeyLabel.setName(KeyMap.LEFT);
add(leftKeyLabel).left();
KeyBindButton leftKeySetter = new KeyBindButton(keyMap, KeyMap.LEFT);
add(leftKeySetter).spaceRight(45f);
Label sector2TPKeyLabel = new Label("Middle Teleport: ", skin);
sector2TPKeyLabel.setName(KeyMap.SECONDTHIRDTELEPORT);
add(sector2TPKeyLabel).left();
KeyBindButton sector2TPKeySetter = new KeyBindButton(keyMap, KeyMap.SECONDTHIRDTELEPORT);
add(sector2TPKeySetter);
row();
Label rightKeyLabel = new Label("Right: ", skin);
rightKeyLabel.setName(KeyMap.RIGHT);
add(rightKeyLabel).left();
KeyBindButton rightKeySetter = new KeyBindButton(keyMap, KeyMap.RIGHT);
add(rightKeySetter).spaceRight(45f);
Label sector3TPKeyLabel = new Label("Right Teleport: ", skin);
sector3TPKeyLabel.setName(KeyMap.THIRDTHIRDTELEPORT);
add(sector3TPKeyLabel).left();
KeyBindButton sector3TPKeySetter = new KeyBindButton(keyMap, KeyMap.THIRDTHIRDTELEPORT);
add(sector3TPKeySetter);
addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
unselect();
if (event.getTarget() instanceof KeyBindButton) {
getStage().setKeyboardFocus(event.getTarget());
event.getTarget().setColor(Color.ORANGE);
} else {
unselect();
}
super.clicked(event, x, y);
}
});
setFillParent(true);
}
public void unselect() {
Array<Actor> keys = getChildren();
for (int i = 0; i < keys.size; i++) {
keys.get(i).setColor(Color.WHITE);;
}
}
@Override
public void act(float delta) {
super.act(delta);
}
}

View File

@@ -1,130 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.utils.Align;
import zero1hd.rhythmbullet.screens.MainMenu;
public class GraphicsOptions extends Table {
private Label resolutions, shaders;
private Preferences prefs;
private CheckBox glowShader, enhancedGlow;
private ResolutionButton
_3840x2160,
_2560x1440,
_1920x1200,
_1920x1080,
_1280x800,
_1280x720,
_1366x768;
public GraphicsOptions(MainMenu mainMenu, Skin skin, Preferences prefs) {
align(Align.center);
defaults().space(10f);
this.prefs = prefs;
shaders = new Label("OpenGL Shaders", skin);
add(shaders).fillX();
row();
glowShader = new CheckBox(" Glow Shader", skin);
glowShader.setChecked(prefs.getBoolean("glow shader", true));
glowShader.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
save();
if (glowShader.isChecked()) {
mainMenu.attemptLoadShaders();
enhancedGlow.setDisabled(false);
} else {
enhancedGlow.setChecked(false);
enhancedGlow.setDisabled(true);
mainMenu.unloadShaders();
}
}
});
add(glowShader);
row();
enhancedGlow = new CheckBox(" Enhanced Glow", skin);
enhancedGlow.setChecked(prefs.getBoolean("enhanced glow", false));
enhancedGlow.setDisabled(!prefs.getBoolean("glow shader", false));
enhancedGlow.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
save();
if (enhancedGlow.isChecked()) {
mainMenu.setBlurlvl(5);
} else {
mainMenu.setBlurlvl(1);
}
}
});
add(enhancedGlow);
row();
resolutions = new Label("Resolutions: ", skin);
add(resolutions).left();
row();
TextButton fullscreen = new TextButton("Fullscreen", skin);
fullscreen.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (!Gdx.graphics.isFullscreen()) {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
prefs.putBoolean("fullscreen", true);
prefs.flush();
}
}
});
add(fullscreen).fillX();
row();
_3840x2160 = new ResolutionButton(3840, 2160, skin, prefs);
add(_3840x2160).fillX();
row();
_2560x1440 = new ResolutionButton(2560, 1440, skin, prefs);
add(_2560x1440).fillX();
row();
_1920x1200 = new ResolutionButton(1920, 1200, skin, prefs);
add(_1920x1200).fillX();
row();
_1920x1080 = new ResolutionButton(1920, 1080, skin, prefs);
add(_1920x1080).fillX();
row();
_1280x800 = new ResolutionButton(1280, 800, skin, prefs);
add(_1280x800).fillX();
row();
_1366x768 = new ResolutionButton(1366, 768, skin, prefs);
add(_1366x768).fillX();
row();
_1280x720 = new ResolutionButton(1280, 720, skin, prefs);
add(_1280x720).fillX();
row();
pack();
}
public void save() {
Gdx.app.debug("Preferences", "Saved shading values values.");
prefs.putBoolean("glow shader", glowShader.isChecked());
prefs.putBoolean("enhanced glow", enhancedGlow.isChecked());
}
}

View File

@@ -1,71 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.math.MathUtils;
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 com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
import zero1hd.rhythmbullet.entity.ally.PolyjetEntity;
public class HealthBar extends WidgetGroup {
Image empty;
Image filler;
float health;
float maxHealth;
PolyjetEntity pje;
public HealthBar(Skin skin, float maxHealth) {
super();
filler = new Image(skin.getPatch("bar-fill"));
addActor(filler);
empty = new Image(skin.getPatch("bar-empty"));
addActor(empty);
this.maxHealth = maxHealth;
}
public void setPolyjetEntity(PolyjetEntity pje) {
this.pje = pje;
}
public void setHealth(float health) {
this.health = health;
filler.addAction(Actions.sizeTo(getWidth(), MathUtils.round((health/maxHealth)*getHeight()), 0.1f));;
}
@Override
public void act(float delta) {
if (pje != null) {
health = pje.health;
}
super.act(delta);
}
@Override
public void setSize(float width, float height) {
empty.setSize(width, height);
filler.setSize(width, height);
super.setSize(width, height);
}
@Override
public void setWidth(float width) {
empty.setWidth(width);
filler.setWidth(width);
super.setWidth(width);
}
@Override
public void setHeight(float height) {
empty.setHeight(height);
super.setHeight(height);
}
public float getMaxHealth() {
return maxHealth;
}
}

View File

@@ -1,64 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import zero1hd.rhythmbullet.controls.KeyMap;
public class KeyBindButton extends Actor {
TextureRegion keyIcon;
KeyMap keyMap;
public KeyBindButton(final KeyMap keyMap, final String control) {
this.keyMap = keyMap;
keyIcon = keyMap.getIcon(keyMap.stringToID(control));
setSize(keyIcon.getRegionWidth(), keyIcon.getRegionHeight());
InputListener keyListener = new InputListener() {
@Override
public boolean keyUp(InputEvent event, int keycode) {
getStage().setKeyboardFocus(null);
Gdx.app.debug("KeySetter", "input keycode received: " + keycode);
if (keycode != Keys.ESCAPE) {
Gdx.app.debug("keySetter", "input has been set to: " + Keys.toString(keycode));
if (setKey(keycode, control)) {
keyMap.updateKeys();
addAction(Actions.sequence(Actions.color(Color.GREEN, 0.2f), Actions.color(Color.WHITE, 0.2f)));
} else {
addAction(Actions.sequence(Actions.color(Color.RED, 0.2f), Actions.delay(0.1f), Actions.color(Color.WHITE, 0.2f)));
}
}
return super.keyUp(event, keycode);
}
};
addListener(keyListener);
}
public boolean setKey(int keycode, String control) {
if (keyMap.getIcon(keycode) != null) {
keyMap.getKeys().putInteger(control, keycode);
keyIcon = keyMap.getIcon(keycode);
return true;
} else {
return false;
}
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.setColor(getColor());
batch.draw(keyIcon, getX(), getY(), getWidth(), getHeight());
super.draw(batch, parentAlpha);
}
}

View File

@@ -1,117 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
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 zero1hd.rhythmbullet.audio.MusicListController;
public class MusicControls extends HorizontalGroup {
private ImageButton reverse, forward;
private CheckBox shuffle, play;
private float disableTimer;
public MusicControls(Skin skin, MusicListController sc) {
reverse = new ImageButton(skin, "rewind-button");
reverse.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (sc.getCurrentMusicManager() != null) {
boolean wasPlaying = sc.getCurrentMusicManager().isPlaying();
sc.previous();
if (wasPlaying) {
sc.play();
}
}
forward.setDisabled(true);
reverse.setDisabled(true);
disableTimer = 0.75f;
}
});
addActor(reverse);
play = new CheckBox(null, skin, "play-button") {
@Override
public void act(float delta) {
if (sc.getCurrentMusicManager() != null) {
play.setChecked(sc.getCurrentMusicManager().isPlaying());
} else {
play.setChecked(false);
}
super.act(delta);
}
};
play.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (sc.getCurrentMusicManager() != null) {
if (play.isChecked()) {
sc.getCurrentMusicManager().play();
} else {
sc.getCurrentMusicManager().pause();
}
}
}
});
addActor(play);
forward = new ImageButton(skin, "fast-forward-button");
forward.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (sc.getCurrentMusicManager() != null) {
boolean wasPlaying = sc.getCurrentMusicManager().isPlaying();
sc.skip();
if (wasPlaying) {
sc.play();
}
}
forward.setDisabled(true);
reverse.setDisabled(true);
disableTimer = 0.75f;
}
});
addActor(forward);
shuffle = new CheckBox(null, skin, "shuffle-button") {
@Override
public void act(float delta) {
shuffle.setChecked(sc.isShuffle());
super.act(delta);
}
};
shuffle.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (shuffle.isChecked()) {
sc.setShuffle(true);
} else {
sc.setShuffle(false);
}
}
});
addActor(shuffle);
space(15);
invalidate();
}
@Override
public void act(float delta) {
setWidth(getMinWidth());
setHeight(getMinHeight());
if (disableTimer > 0) {
disableTimer -= delta;
if (disableTimer <= 0) {
forward.setDisabled(false);
reverse.setDisabled(false);
disableTimer = 0;
}
}
super.act(delta);
}
}

View File

@@ -1,137 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Disposable;
import zero1hd.rhythmbullet.audio.MusicInfo;
import zero1hd.rhythmbullet.graphics.ui.pages.MusicSelectionPage;
public class MusicSelectable extends WidgetGroup implements Disposable {
private Table table;
private ShortenedTextLabel displayName;
private Label durationLabel;
private ShortenedTextLabel authorLabel;
private boolean selected;
private MusicSelectionPage msp;
private MusicInfo musicInfo;
private FileHandle musicFile;
public MusicSelectable(FileHandle musicFile, Skin skin, MusicSelectionPage msp) {
this.musicFile = musicFile;
table = new Table(skin);
table.setBackground("holo-pane");
table.setFillParent(true);
this.msp = msp;
setName(musicFile.nameWithoutExtension());
table.defaults().pad(5f).space(15f).expandX();
displayName = new ShortenedTextLabel(musicFile.nameWithoutExtension().replace('_', ' '), skin, "sub-font", skin.getColor("default"));
table.add(displayName);
durationLabel = new Label("Loading...", skin, "sub-font", skin.getColor("default"));
table.add(durationLabel);
authorLabel = new ShortenedTextLabel("Loading...", skin, "sub-font", skin.getColor("default"));
table.add(authorLabel);
table.pack();
addActor(table);
addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
select();
super.clicked(event, x, y);
}
});
}
/**
* updates the UI side of information.
* needs to be called in thread with gl context.
* @param musicInfo the music information for this song.
*/
public void updateInfo(MusicInfo musicInfo) {
Gdx.app.debug("MusicSelectable", "Updating info for: " + getName());
this.musicInfo = musicInfo;
displayName.setOriginalText(musicInfo.getMusicName());
durationLabel.setText("Runtime: "
+ ((musicInfo.getDurationInSeconds() / 60 < 1) ? "00" : musicInfo.getDurationInSeconds() / 60) + ":"
+ ((musicInfo.getDurationInSeconds() - (musicInfo.getDurationInSeconds() / 60) * 60) < 10
? "0" + (musicInfo.getDurationInSeconds() - (musicInfo.getDurationInSeconds() / 60) * 60)
: (musicInfo.getDurationInSeconds() - (musicInfo.getDurationInSeconds() / 60) * 60)));
authorLabel.setOriginalText("Author: " + musicInfo.getAuthor());
authorLabel.setToOriginalText();
}
@Override
public void layout() {
displayName.setTargetWidth((int) (getWidth()*0.43f));
authorLabel.setTargetWidth((int) (getWidth()/3f));
displayName.resize();
authorLabel.resize();
super.layout();
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
}
@Override
public void act(float delta) {
super.act(delta);
}
public boolean isMusicInvalid() {
return musicInfo.isInvalidMusic();
}
/**
* Selects this panel
*/
public void select() {
msp.deselectAll();
table.setBackground("holo-pane-down");
selected = true;
msp.setCurrentlySelected(this);
}
public void deselect() {
table.setBackground("holo-pane");
selected = false;
}
public boolean isSelected() {
return selected;
}
@Override
public float getPrefHeight() {
return table.getMinHeight();
}
@Override
public void dispose() {
}
public FileHandle getMusicFile() {
return musicFile;
}
public MusicInfo getMusicInfo() {
return musicInfo;
}
}

View File

@@ -1,36 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import java.awt.Dimension;
import java.awt.Toolkit;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
public class ResolutionButton extends TextButton {
public ResolutionButton(final int width, final int height, Skin skin, final Preferences prefs) {
super(width + "x" + height, skin);
Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
if (screenDim.getWidth() < width || screenDim.getHeight() < height) {
setDisabled(true);
}
addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Gdx.graphics.setWindowedMode(width, height);
prefs.putInteger("screen-width", width);
prefs.putInteger("screen-height", height);
prefs.putBoolean("fullscreen", false);
prefs.flush();
}
});
}
}

View File

@@ -1,188 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Widget;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack;
public class ScrollText extends Widget {
Rectangle scissors = new Rectangle();
Rectangle clipBounds = new Rectangle();
GlyphLayout gLayout;
String text1;
String text2;
BitmapFont font;
private float textHeight;
private float text1Width;
private float text2Width;
private boolean scrollOnHover;
private boolean scroll;
private float text1Offset, text2Offset;
private NinePatch background;
private Vector2 coords;
public ScrollText(String text, String text2, Skin skin, boolean scrollOnHover, boolean useBackground) {
super();
font = skin.getFont("default-font");
init(text, text2, skin, scrollOnHover, useBackground);
}
public ScrollText(String text, String text2, Skin skin, String fontName, Color color, boolean scrollOnHover, boolean useBackground) {
super();
font = skin.getFont(fontName);
font.setColor(color);
init(text, text2, skin, scrollOnHover, useBackground);
}
private void init(String text1, String text2, Skin skin, boolean scrollOnHover, boolean useBackground) {
setName(text1);
if (useBackground) {
this.background = skin.getPatch("side-bars");
}
this.scrollOnHover = scrollOnHover;
coords = new Vector2();
addListener(new ClickListener() {
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
scroll = true;
super.enter(event, x, y, pointer, fromActor);
}
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
scroll = false;
super.exit(event, x, y, pointer, toActor);
}
@Override
public void clicked(InputEvent event, float x, float y) {
}
});
setText(text1, text2);
layout();
}
public float getFontHeight() {
return textHeight;
}
public float getFontWidth() {
return text1Width;
}
@Override
public void layout() {
if (getHeight() < (textHeight+4)) {
setHeight(textHeight + 4);
}
clipBounds.setSize(getWidth()-2, getHeight()*1.5f);
text2Offset = clipBounds.getWidth();
if (text1Width < clipBounds.getWidth()) {
text1Offset = (clipBounds.getWidth()-text1Width)/2f;
}
super.layout();
}
@Override
public void act(float delta) {
setSize(getWidth(), textHeight + 4);
clipBounds.setSize(getWidth()-2, getHeight()*1.5f);
if (text1Width + text2Width > clipBounds.getWidth()) {
if (scrollOnHover) {
if (scroll || text1Offset < 0 || text1Offset > 2) {
scroll(delta);
}
} else {
scroll(delta);
}
}
super.act(delta);
}
public void scroll(float delta) {
if (text1Offset >= -text1Width) {
text1Offset -= 60*delta;
if ((text1Offset < - Math.abs((text1Width - clipBounds.getWidth())) - 50) || text2Offset != clipBounds.getWidth()) {
text2Offset -= 60*delta;
if (text2Offset <= -text2Width) {
text2Offset = clipBounds.getWidth();
}
}
} else {
text2Offset -= 60*delta;
if (text2Offset < - Math.abs((text2Width - clipBounds.getWidth())) - 50) {
text1Offset = clipBounds.getWidth();
}
}
}
@Override
public void draw(Batch batch, float parentAlpha) {
if (background != null) {
background.draw(batch, getX(), getY(), getWidth(), getHeight());
}
coords.x = getX();
coords.y = getY();
clipBounds.setX(coords.x+1);
clipBounds.setY(coords.y - 0.5f*getHeight());
getStage().calculateScissors(clipBounds, scissors);
batch.flush();
if (ScissorStack.pushScissors(scissors)) {
font.draw(batch, text1, coords.x + text1Offset, coords.y + getFontHeight() + 4);
font.draw(batch, text2, coords.x + text2Offset, coords.y + getFontHeight() + 4);
batch.flush();
ScissorStack.popScissors();
};
}
@Override
public float getMinHeight() {
return textHeight;
}
/**
* Sets the two strings that will be scrolling.
* @param text1 cannot be null.
* @param text2 can be null.
*/
public void setText(String text1, String text2) {
this.text1 = text1;
gLayout = new GlyphLayout(font, text1);
text1Width = gLayout.width;
textHeight = gLayout.height;
if (text2 != null) {
this.text2 = text2;
gLayout = new GlyphLayout(font, text2);
text2Width = gLayout.width;
} else {
this.text2 = text1;
this.text2Width = text1Width;
}
layout();
}
}

View File

@@ -1,54 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
public class ShortenedTextLabel extends Label {
private String originalText;
private int targetWidth;
private GlyphLayout gl;
private BitmapFont font;
public ShortenedTextLabel(CharSequence text, Skin skin, String fontName, Color color) {
super(text, skin, fontName, color);
originalText = text.toString();
font = skin.getFont(fontName);
if (text != null) {
gl = new GlyphLayout(skin.getFont(fontName), text);
}
}
public void setTargetWidth(int targetWidth) {
this.targetWidth = targetWidth;
}
public void resize() {
setToOriginalText();
while (gl.width > targetWidth && (getText().length - 4) > 0) {
setText(getText().substring(0, getText().length - 4).concat("..."));
gl.setText(font, getText());
}
}
public void setToOriginalText() {
setText(originalText);
gl.setText(font, originalText);
}
@Override
public void layout() {
super.layout();
}
public void setOriginalText(String originalText) {
this.originalText = originalText;
gl.setText(font, originalText);
}
public int getTargetWidth() {
return targetWidth;
}
}

View File

@@ -1,134 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool;
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Disposable;
import zero1hd.rhythmbullet.audio.visualizer.MirrorVisualizer;
public class TitleBarVisualizer extends Group implements Disposable {
private Visualizer visual;
private MirrorVisualizer visual2;
private Texture bgTexture;
private Image bg;
private Image titleImage;
//Particle pools;
ParticleEffectPool beatEffectPool;
Array<PooledEffect> effects = new Array<>();
private float particleLimitTime;
private boolean lastEffect;
public TitleBarVisualizer(AssetManager assets) {
if (assets == null) throw new NullPointerException("TitleBarVisualizer requires assets manager... ITS NULL YOU FOOL");
visual = new Visualizer();
visual.getVis().setSpaceBetweenBars(visual.getVis().getBarWidth()- 2);
addActor(visual);
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()*0.2f);
setPosition(0, (Gdx.graphics.getHeight()-getHeight())/2f);
visual.setWidth(getWidth());
visual.setHeight(getHeight());
visual.getVis().flip();
visual.getVis().reverse();
visual2 = new MirrorVisualizer();
visual.setUpdatePositioning(false);
visual.getVis().addMirrorVisualizer(visual2);
visual2.setyPos(MathUtils.round(getHeight()));
visual.setY(-2);
visual.updateVisualPosition();
Pixmap pixmap = new Pixmap(MathUtils.round(getWidth()), MathUtils.round(getHeight()), Format.RGBA8888);
pixmap.setColor(Color.WHITE);
pixmap.drawLine(0, 0, pixmap.getWidth(), 0);
pixmap.drawLine(0, 1, pixmap.getWidth(), 1);
pixmap.drawLine(0, pixmap.getHeight()-1, pixmap.getWidth(), pixmap.getHeight()-1);
pixmap.drawLine(0, pixmap.getHeight()-2, pixmap.getWidth(), pixmap.getHeight()-2);
bgTexture = new Texture(pixmap);
pixmap.dispose();
bg = new Image(bgTexture);
bg.setSize(getWidth(), getHeight());
addActor(bg);
titleImage = new Image(assets.get("title.png", Texture.class));
titleImage.setScale((bg.getHeight()-(0.1f*Gdx.graphics.getHeight()))/titleImage.getHeight());
if (titleImage.getWidth() > 0.8f*getWidth()) {
titleImage.setScale((bg.getWidth()-(0.2f*Gdx.graphics.getWidth()))/titleImage.getWidth());
}
titleImage.setPosition((getWidth() - titleImage.getWidth()*titleImage.getScaleX())/2f, (getHeight() - titleImage.getHeight()*titleImage.getScaleY())/2f -5);
titleImage.setColor(Color.WHITE);
addActor(titleImage);
beatEffectPool = new ParticleEffectPool(assets.get("beateffect.p", ParticleEffect.class), 0, 8) {
@Override
protected PooledEffect newObject() {
PooledEffect effect = super.newObject();
effect.scaleEffect(Gdx.graphics.getWidth()/64f);
return effect;
}
};
}
@Override
public void act(float delta) {
if (particleLimitTime > 1f/60f) {
if (visual.getVis().getMm() != null && visual.getVis().getMm().isPlaying() && visual.getVis().getCurrentAvg() > visual.getVis().getMaxAvgHeight()*0.55f) {
PooledEffect effect = beatEffectPool.obtain();
effect.setPosition(0, 0);
effects.add(effect);
lastEffect = true;
particleLimitTime = 0;
}
} else {
particleLimitTime += delta;
}
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
for (int i = 0; i < effects.size; i++) {
effects.get(i).draw(batch, Gdx.graphics.getDeltaTime());
if (effects.get(i).isComplete()) {
effects.get(i).free();
effects.removeIndex(i);
}
}
super.draw(batch, parentAlpha);
}
public Visualizer getHvisual() {
return visual;
}
@Override
public void dispose() {
visual.dispose();
bgTexture.dispose();
}
@Override
public void setColor(Color color) {
super.setColor(color);
}
@Override
public void setColor(float r, float g, float b, float a) {
super.setColor(r, g, b, a);
}
}

View File

@@ -1,99 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.ui.Widget;
import com.badlogic.gdx.utils.Disposable;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.audio.visualizer.BasicVisualizer;
public class Visualizer extends Widget implements Disposable {
private BasicVisualizer vis;
private boolean updatePositioning = true;
private boolean mmSet;
private MusicManager mm;
public Visualizer() {
vis = new BasicVisualizer();
}
@Override
public void draw(Batch batch, float parentAlpha) {
vis.render(batch, parentAlpha);
super.draw(batch, parentAlpha);
}
@Override
public void act(float delta) {
if (mm != null && mm.isFinishedLoading() && !mmSet) {
Gdx.app.debug("Visualizer", "\nsample count: " + mm.getSampleCount()
+ "\nDuration in seconds: " + mm.getDuration() +
"\nSample rate: " + mm.getSampleRate());
vis.setMM(mm);
mmSet = true;
}
vis.modify(delta);
updateVisualizerProperties();
if (updatePositioning) {
vis.updatePositionInfo();
vis.setxPos((getWidth() - vis.getActualWidth())/2f);
}
vis.calculate(delta);
super.act(delta);
}
public void setMM(MusicManager mm) {
this.mm = mm;
mmSet = false;
}
@Override
public void setColor(Color color) {
vis.setColor(color);
super.setColor(color);
}
@Override
public void setColor(float r, float g, float b, float a) {
vis.setColor(r, g, b, a);
super.setColor(r, g, b, a);
}
public void updateVisualizerProperties() {
vis.setHeight(getHeight());
vis.setWidth(getWidth());
vis.setxPos(getX());
vis.setyPos(getY());
vis.setRotation(getRotation());
}
public void setUpdatePositioning(boolean updatePositioning) {
updateVisualPosition();
this.updatePositioning = updatePositioning;
}
public void updateVisualPosition() {
updateVisualizerProperties();
vis.updatePositionInfo();
vis.setxPos(((vis.getWidth() - vis.getActualWidth())/2f));
Gdx.app.debug("Visualizer", "currently offseting visualizer by (px): " + vis.getxPos());
vis.updatePositionInfo();
}
public boolean isUpdatePositioning() {
return updatePositioning;
}
public BasicVisualizer getVis() {
return vis;
}
@Override
public void dispose() {
vis.dispose();
}
}

View File

@@ -1,105 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.pages;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.audio.analyzer.AudioAnalyzer;
public class AnalysisPage extends Page {
private boolean confirmed;
private AudioAnalyzer aa;
private Table table;
private Label difficultyModLabel, healthModLabel, speedModLabel;
private Slider difficultyModifierSlider, healthModifierSlider, speedModifierSlider;
private Label diffModPercentLabel, heltModPercentLabel, speeModPercentLabel;
private Label progressLabel;
private TextButton confirmButton;
public AnalysisPage(Skin skin, AssetManager assets) {
setTextureBackground(assets.get("gradients.atlas", TextureAtlas.class).findRegion("red-round"));
table = new Table();
table.setFillParent(true);
table.defaults().space(10f);
addActor(table);
difficultyModLabel = new Label("Difficulty Modifier: ", skin, "sub-font", skin.getColor("default"));
difficultyModifierSlider = new Slider(1, 3, 0.5f, false, skin);
diffModPercentLabel = new Label(String.valueOf(difficultyModifierSlider.getValue()) + "x", skin);
difficultyModifierSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
diffModPercentLabel.setText(String.valueOf(difficultyModifierSlider.getValue()) + "x");
}
});
table.add(difficultyModLabel);
table.add(difficultyModifierSlider).minWidth(0.5f*getWidth());
table.add(diffModPercentLabel).minWidth(diffModPercentLabel.getWidth()*1.5f);
table.row();
healthModLabel = new Label("Health Modifier: ", skin, "sub-font", skin.getColor("default"));
healthModifierSlider = new Slider(1f, 3f, 0.5f, false, skin);
heltModPercentLabel = new Label(String.valueOf(healthModifierSlider.getValue()) + "x", skin);
healthModifierSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
heltModPercentLabel.setText(String.valueOf(healthModifierSlider.getValue()) + "x");
}
});
table.add(healthModLabel);
table.add(healthModifierSlider).fillX();
table.add(heltModPercentLabel).fillX();
table.row();
speedModLabel = new Label("Speed Modifier: ", skin, "sub-font", skin.getColor("default"));
speedModifierSlider = new Slider(1, 3, 0.5f, false, skin);
speeModPercentLabel = new Label(String.valueOf(speedModifierSlider.getValue()) + "x", skin);
speedModifierSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
speeModPercentLabel.setText(String.valueOf(speedModifierSlider.getValue()) + "x");
}
});
table.add(speedModLabel);
table.add(speedModifierSlider).fillX();
table.add(speeModPercentLabel).fillX();
table.row();
confirmButton = new TextButton("Confirm", skin);
confirmButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
confirmed = true;
confirmButton.setDisabled(true);
}
});
table.add(confirmButton).colspan(3).fillX();
table.row();
progressLabel = new Label("Loading... ", skin);
table.add(progressLabel).colspan(2).left().spaceTop(20f);
}
public void processSong(MusicManager mm) {
aa = new AudioAnalyzer(mm);
aa.start();
}
@Override
public void act(float delta) {
if (aa != null && aa.isDone() && confirmed) {
//TODO GAMESCREEN!!!
}
super.act(delta);
}
@Override
public void dispose() {
aa.dispose();
super.dispose();
}
}

View File

@@ -1,26 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.pages;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
public class CreditsPage extends Page {
public CreditsPage(Skin skin) {
Label title = new Label("Credits", skin, "large-font", skin.getColor("default"));
title.setPosition(15, getHeight()-title.getHeight()-15);
addActor(title);
Label subtitle = new Label("This game wouldn't be possible without these people.", skin, "sub-font", skin.getColor("default"));
subtitle.setPosition(title.getX(), title.getY()-subtitle.getHeight());
addActor(subtitle);
Label listOfNames = new Label(
"TheClimbingHippo (texture)\n"
+ "Crepitus (sound effects)\n"
+ "Neoqueto - Darktech LDR (font)\n"
+ "Rémi Lagast - Gasalt (font)\n"
+ "Timour Jgenti - Iron Maiden (font)", skin, "sub-font", skin.getColor("default"));
listOfNames.setPosition(subtitle.getX()+16, subtitle.getY()-listOfNames.getHeight()-10);
addActor(listOfNames);
}
}

View File

@@ -1,42 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.pages;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.controls.KeyMap;
import zero1hd.rhythmbullet.graphics.ui.components.ControlOptions;
public class KeybindOptionsPage extends Page {
private ControlOptions controlTable;
private KeyMap keyMap;
private TextButton backButton;
public KeybindOptionsPage(Skin skin, AssetManager assets, Vector3 cameraPosition) {
setTextureBackground(assets.get("gradients.atlas", TextureAtlas.class).findRegion("red-round"));
keyMap = new KeyMap(assets);
controlTable = new ControlOptions(skin, keyMap);
addActor(controlTable);
backButton = new TextButton("Back", skin);
backButton.setPosition(10, getHeight() - 10 - backButton.getHeight());
backButton.setWidth(backButton.getWidth() + 20);
backButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
cameraPosition.y = 0.5f*getHeight();
}
});
addActor(backButton);
}
public void unselect() {
controlTable.unselect();
}
}

View File

@@ -1,139 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.pages;
import java.util.Observable;
import java.util.Observer;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.utils.Align;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.audio.MusicListController;
import zero1hd.rhythmbullet.graphics.ui.components.MusicControls;
import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;
import zero1hd.rhythmbullet.graphics.ui.components.TitleBarVisualizer;
import zero1hd.rhythmbullet.screens.MainMenu;
public class MainPage extends Page implements Observer {
private Label versionLabel;
private MusicListController mlc;
private TitleBarVisualizer titleBar;
private Table table;
private TextButton playButton;
private TextButton optionsButton;
private TextButton quitButton;
private MusicControls musicControls;
private MainMenu mMenu;
private ScrollText scrollText;
public MainPage(RhythmBullet core, Vector3 targetPosition, MusicListController mlc, MainMenu mainMenu) {
this.mlc = mlc;
setTextureBackground(core.getAssetManager().get("gradients.atlas", TextureAtlas.class).findRegion("red-linear"));
this.mMenu = mainMenu;
titleBar = new TitleBarVisualizer(core.getAssetManager());
addActor(titleBar);
versionLabel = new Label("Version: " + RhythmBullet.VERSION, core.getDefaultSkin(), "sub-font",
core.getDefaultSkin().getColor("default"));
versionLabel.setPosition(3, 3);
addActor(versionLabel);
table = new Table();
table.setSize(getWidth(), titleBar.getY());
table.align(Align.center);
table.defaults().space(10f);
addActor(table);
playButton = new TextButton("Start!", core.getDefaultSkin());
playButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
targetPosition.x = Gdx.graphics.getWidth()*1.5f;
getStage().setKeyboardFocus(mainMenu.getMusicSelectionPage());
}
});
table.add(playButton).width(Gdx.graphics.getWidth()*0.2f);
table.row();
optionsButton = new TextButton("Options", core.getDefaultSkin(), "sub");
optionsButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
targetPosition.x = Gdx.graphics.getWidth()*-0.5f;
}
});
table.add(optionsButton).fillX();
table.row();
quitButton = new TextButton("Quit", core.getDefaultSkin(), "sub");
quitButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Gdx.app.exit();
}
});
table.add(quitButton).fillX();
musicControls = new MusicControls(core.getDefaultSkin(), mlc);
musicControls.setPosition((getWidth()-musicControls.getMinWidth() - 20f), getHeight()-musicControls.getMinHeight()-15f);
addActor(musicControls);
scrollText = new ScrollText("...", "...", core.getDefaultSkin(), false, true);
scrollText.setWidth(0.5f*getWidth());
scrollText.setPosition(15, getHeight() - scrollText.getHeight()-15f);
addActor(scrollText);
if (mlc.getMusicList().isSearched() && mlc.getCurrentMusicManager() != null) {
MusicManager mManager = mlc.getCurrentMusicManager();
updateVisualsForDifferentSong(mManager);
mMenu.getMusicSelectionPage().refreshUIList();
}
}
@Override
public void act(float delta) {
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
}
@Override
public void dispose() {
titleBar.dispose();
super.dispose();
}
@Override
public void update(Observable o, Object arg) {
if (o == mlc.getMusicList() && mlc.getMusicList().isSearched()) {
mlc.shuffle(true);
MusicManager mm = mlc.getCurrentMusicManager();
updateVisualsForDifferentSong(mm);
mMenu.getMusicSelectionPage().refreshUIList();
} else if (o == mlc) {
MusicManager mm = mlc.getCurrentMusicManager();
mlc.play();
updateVisualsForDifferentSong(mm);
}
}
public void updateVisualsForDifferentSong(MusicManager mm) {
titleBar.getHvisual().setMM(mm);
scrollText.setText("Currently playing: " + mm.getBasicSongName(), null);
}
}

View File

@@ -1,343 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.pages;
import java.util.Observable;
import java.util.Observer;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
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.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Array;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.audio.MusicInfo;
import zero1hd.rhythmbullet.audio.MusicInfoController;
import zero1hd.rhythmbullet.audio.MusicListController;
import zero1hd.rhythmbullet.graphics.ui.components.MusicSelectable;
import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;
public class MusicSelectionPage extends Page implements Observer {
Preferences musicFileAnnotation;
private MusicListController mc;
private MusicInfoController mic;
private Array<MusicSelectable> selectables;
private Table musicTable;
private ScrollPane musicTableScrollPane;
private TextButton back;
private Table musicInfoTable;
private Table musicSubInfo;
private ScrollText songTitle;
private Label author;
private Label songLength;
private Label previousTop;
private Label ratedDifficulty;
private Texture albumCoverTexture;
private Image albumCover;
private AssetManager assets;
private MusicSelectable currentlySelected;
private Skin skin;
private boolean down, up;
private int musicSelectableIndex;
private TextButton beginButton;
private int uiSongCount;
private int uiSongInfoCount;
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
public MusicSelectionPage(Skin skin, MusicListController musicListController, AssetManager assetManager, Vector3 cameraTarget, AnalysisPage ap) {
setTextureBackground(assetManager.get("gradients.atlas", TextureAtlas.class).findRegion("red-round"));
this.assets = assetManager;
this.skin = skin;
this.mc = musicListController;
mic = new MusicInfoController(mc.getMusicList());
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
musicTable = new Table();
musicTableScrollPane = new ScrollPane(musicTable, skin);
musicTable.defaults().spaceTop(5f).spaceBottom(5f);
musicTableScrollPane.setSize(0.45f*getWidth(), getHeight());
musicTableScrollPane.setFadeScrollBars(false);
musicTableScrollPane.setOverscroll(false, false);
addActor(musicTableScrollPane);
selectables = new Array<>();
back = new TextButton("Back", skin);
back.setWidth(back.getWidth()+20f);
back.setPosition(getWidth()-back.getWidth()-15f, getHeight() - back.getHeight() - 15f);
back.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
cameraTarget.x = 0.5f*Gdx.graphics.getWidth();
}
});
addActor(back);
back.toFront();
addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
scrollTimer = 0;
scrollDelMod = 1f;
if (keycode == Keys.DOWN) {
down = true;
}
if (keycode == Keys.UP) {
up = true;
}
return super.keyDown(event, keycode);
}
@Override
public boolean keyUp(InputEvent event, int keycode) {
if (keycode == Keys.DOWN) {
down = false;
}
if (keycode == Keys.UP) {
up = false;
}
return super.keyUp(event, keycode);
}
});
musicInfoTable = new Table();
musicInfoTable.defaults().center();
musicInfoTable.setPosition(musicTableScrollPane.getWidth() + musicTableScrollPane.getX(), 0);
musicInfoTable.setSize(getWidth()-musicTableScrollPane.getWidth(), getHeight());
addActor(musicInfoTable);
musicSubInfo = new Table(skin);
musicSubInfo.setBackground("corner-panel");
songTitle = new ScrollText("", null, skin, true, true);
author = new Label(null, skin, "sub-font", skin.getColor("default"));
songLength = new Label(null, skin, "sub-font", skin.getColor("default"));
previousTop = new Label(null, skin, "sub-font", skin.getColor("default"));
ratedDifficulty = new Label(null, skin, "sub-font", skin.getColor("default"));
albumCover = new Image(assetManager.get("defaultCover.png", Texture.class));
beginButton = new TextButton("Begin", skin);
beginButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
cameraTarget.x = 2.5f*getWidth();
ap.processSong(mc.getMusicList().getAudioData(getSelectedMusic()));
}
});
}
@Override
public void act(float delta) {
if (down) {
if (scrollDelMod > 0.25f) {
scrollDelMod -= delta/0.5f;
}
if (scrollTimer <= 0) {
scrollTimer = scrollDelay*scrollDelMod;
scrollDown();
} else {
scrollTimer -= delta;
}
}
if (up) {
if (scrollDelMod > 0.25f) {
scrollDelMod -= delta/0.5f;
}
if (scrollTimer <= 0) {
scrollTimer = scrollDelay*scrollDelMod;
scrollUp();
} else {
scrollTimer -= delta;
}
}
if (songSelectionTimer > 0f) {
songSelectionTimer -= delta;
if (songSelectionTimer <= 0f) {
setCurrentMusic();
}
}
attemptRefreshUpdate();
super.act(delta);
}
private void attemptRefreshUpdate() {
if (uiSongInfoCount != mc.getMusicList().getTotal()) {
if (uiSongCount < mc.getMusicList().getTotal()) {
MusicSelectable selectable = new MusicSelectable(mc.getMusicList().getSongFileHandleFromIndex(uiSongCount), skin, this);
selectables.add(selectable);
musicTable.add(selectables.get(uiSongCount)).expandX().fillX();
uiSongCount++;
musicTable.row();
if (uiSongCount == mc.getMusicList().getTotal()) {
selectMusicUI(mc.getCurrentMusicManager());
}
} else if (uiSongInfoCount < selectables.size && mic.isDoneLoading()) {
selectables.get(uiSongInfoCount).updateInfo(mic.getSongInfoArray().get(uiSongInfoCount));
uiSongInfoCount++;
if (uiSongInfoCount == selectables.size) {
updateInformation();
}
}
}
}
public FileHandle getSelectedMusic() {
return currentlySelected.getMusicFile();
}
public MusicInfo getSelectedMusicInfo() {
return currentlySelected.getMusicInfo();
}
public void refreshUIList() {
for (int i = 0; i < selectables.size; i++) {
selectables.get(i).dispose();
}
mic.loadSongInfo();
musicTable.clear();
selectables.clear();
musicInfoTable.clear();
musicSubInfo.clear();
uiSongCount = 0;
uiSongInfoCount = 0;
Gdx.app.debug("MusicSelectionPage", "Refreshing...");
musicInfoTable.add(songTitle).width(musicInfoTable.getWidth()*0.6f).spaceBottom(30f);
musicInfoTable.row();
musicSubInfo.add(author);
musicSubInfo.row();
musicSubInfo.add(songLength);
musicSubInfo.row();
musicSubInfo.add(previousTop);
musicSubInfo.row();
musicSubInfo.add(ratedDifficulty);
musicSubInfo.pack();
musicInfoTable.add(musicSubInfo).spaceBottom(20f);
musicInfoTable.row();
musicInfoTable.add(albumCover).size(musicInfoTable.getWidth()/2f);
musicInfoTable.row();
musicInfoTable.add(beginButton).spaceTop(20f).fillX();
}
@Override
public void dispose() {
super.dispose();
}
public void deselectAll() {
if (currentlySelected != null) {
currentlySelected.deselect();
} else {
for (int i = 0; i < selectables.size; i++) {
selectables.get(i).deselect();
}
}
}
public void setCurrentlySelected(MusicSelectable currentlySelected) {
this.currentlySelected = currentlySelected;
songSelectionTimer = 1f;
if (mic.isDoneLoading() && uiSongInfoCount == selectables.size) {
updateInformation();
}
}
private void scrollDown() {
if ((musicSelectableIndex = (musicTable.getChildren().indexOf(currentlySelected, true) + 1)) == musicTable.getChildren().size) {
musicSelectableIndex = 0;
}
((MusicSelectable)musicTable.getChildren().get(musicSelectableIndex)).select();
musicTableScrollPane.scrollTo(currentlySelected.getX(), currentlySelected.getY(), currentlySelected.getWidth(), currentlySelected.getHeight());
}
private void scrollUp() {
if ((musicSelectableIndex = (musicTable.getChildren().indexOf(currentlySelected, true) - 1)) < 0) {
musicSelectableIndex = musicTable.getChildren().size-1;
}
((MusicSelectable)musicTable.getChildren().get(musicSelectableIndex)).select();
musicTableScrollPane.scrollTo(currentlySelected.getX(), currentlySelected.getY(), currentlySelected.getWidth(), currentlySelected.getHeight());
}
@Override
public void update(Observable o, Object arg) {
if (o == mc) {
MusicManager mm = (MusicManager) arg;
selectMusicUI(mm);
}
}
public void selectMusicUI(MusicManager mm) {
if (currentlySelected == null || mm.getMusicFile() != currentlySelected.getMusicFile()) {
for (int i = 0; i < selectables.size; i++) {
if (selectables.get(i).getMusicFile() == mm.getMusicFile()) {
selectables.get(i).select();
musicSelectableIndex = i;
break;
}
}
}
}
private void setCurrentMusic() {
playSelectedMusic();
}
private void playSelectedMusic() {
if (currentlySelected.getMusicFile() != mc.getCurrentMusicManager().getMusicFile()) {
int index = mc.getMusicList().getMusicList().indexOf(currentlySelected.getMusicFile(), true);
mc.setMusicByIndex(index);
}
}
/**
* This should only be called when everything is loaded.
*/
private void updateInformation() {
Gdx.app.debug("MusicSelectionPage", "Updating song info panel...");
if (currentlySelected == null) throw new NullPointerException("Buddy, you need to update this page to have the proper current music selected...");
if (currentlySelected.getMusicInfo() == null) throw new NullPointerException("K, ur music info is null.");
songTitle.setText(currentlySelected.getMusicInfo().getMusicName(), null);
author.setText("Author: " + currentlySelected.getMusicInfo().getAuthor());
if (albumCoverTexture != null) {
albumCoverTexture.dispose();
}
long lengthInSeconds = currentlySelected.getMusicInfo().getDurationInSeconds();
int min = (int) (lengthInSeconds/60);
int sec = (int) (lengthInSeconds - (min*60));
songLength.setText("Length: " + min + ":" + (sec > 9 ? sec : "0" + sec));
previousTop.setText("Highscore: " + currentlySelected.getMusicInfo().getPreviousTop());
String difficulty = (getSelectedMusicInfo().getRatedDifficulty() == -1 ? "N/A" : String.valueOf(getSelectedMusicInfo().getRatedDifficulty()));
ratedDifficulty.setText("Rated Difficulty: " + difficulty);
albumCoverTexture = currentlySelected.getMusicInfo().loadTexture();
if (albumCoverTexture != null) {
albumCover.setDrawable((new TextureRegionDrawable(new TextureRegion(albumCoverTexture))));
} else {
albumCover.setDrawable((new TextureRegionDrawable(new TextureRegion(assets.get("defaultCover.png", Texture.class)))));
}
}
}

View File

@@ -1,38 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.pages;
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.Button;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
public class MusicStatusPage extends Page {
Label statusText;
Image loading;
Button back;
public MusicStatusPage(Skin skin, final Vector3 v3) {
super("Info", skin);
back = new Button(skin, "arrow-button");
back.setPosition(15f, (getHeight()-back.getHeight())/2 -15);
back.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
v3.x = 0.5f*getWidth();
}
});
addActor(back);
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);
}
}

View File

@@ -1,168 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.pages;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar;
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.MusicListController;
public class OptionsPage extends Page {
Table optionsTable;
private ProgressBar musicVolSlider;
private ProgressBar fxVolSlider;
private TextField directoryField;
private float musicSearchTimer;
public OptionsPage(RhythmBullet core, Vector3 targetPosition, KeybindOptionsPage moreOptionsPage, MusicListController sc) {
super("General", core.getDefaultSkin());
setTextureBackground(core.getAssetManager().get("gradients.atlas", TextureAtlas.class).findRegion("red-round"));
//Back button
TextButton backButton = new TextButton("Back", core.getDefaultSkin());
backButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
targetPosition.x = 0.5f*Gdx.graphics.getWidth();
}
});
backButton.setPosition(10, getHeightBelowTitle() + 5);
addActor(backButton);
backButton.setWidth(backButton.getWidth() + 20);
addSpaceToTitle(backButton.getWidth() + backButton.getX() + 20);
optionsTable = new Table();
optionsTable.defaults().center().space(10f);
optionsTable.setSize(getWidth(), getHeight());
addActor(optionsTable);
Label musicVolSliderLabel = new Label("Music Volume: ", core.getDefaultSkin());
optionsTable.add(musicVolSliderLabel);
musicVolSlider = new Slider(0, 100, 0.1f, false, core.getDefaultSkin());
musicVolSlider.setValue(core.getPrefs().getFloat("music vol", 100f)*100f);
optionsTable.add(musicVolSlider).minWidth(0.3f*getWidth());
final Label musicVolPercentage = new Label(MathUtils.round(musicVolSlider.getValue()) + "%", core.getDefaultSkin());
musicVolSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
musicVolPercentage.setText(MathUtils.round(musicVolSlider.getValue()) + "%");
sc.getCurrentMusicManager().setVolume(musicVolSlider.getPercent());
core.getPrefs().putFloat("music vol", musicVolSlider.getPercent());
}
});
optionsTable.add(musicVolPercentage);
optionsTable.row();
Label fxVolSliderLabel = new Label("FX Volume: ", core.getDefaultSkin());
optionsTable.add(fxVolSliderLabel);
fxVolSlider = new Slider(0, 100, 0.1f, false, core.getDefaultSkin());
fxVolSlider.setValue(core.getPrefs().getFloat("fx vol", 100f)*100f);
optionsTable.add(fxVolSlider).fillX();
final Label fxVolPercentage = new Label(MathUtils.round(fxVolSlider.getValue()) + "%", core.getDefaultSkin());
fxVolSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
fxVolPercentage.setText(MathUtils.round(fxVolSlider.getValue()) + "%");
core.getPrefs().putFloat("fx vol", fxVolSlider.getPercent());
}
});
optionsTable.add(fxVolPercentage);
optionsTable.row();
Label musicDirectoryLabel = new Label("Music Directory: ", core.getDefaultSkin());
optionsTable.add(musicDirectoryLabel);
Label songCount = new Label("Songs: " + sc.getMusicList().getTotal(), core.getDefaultSkin(), "sub-font", core.getDefaultSkin().getColor("default"));
directoryField = new TextField(null, core.getDefaultSkin() ) {
@Override
public void act(float delta) {
if (musicSearchTimer > 0) {
musicSearchTimer -= delta;
if (musicSearchTimer <= 0) {
sc.getMusicList().setSearchPath(directoryField.getText());
sc.getMusicList().asynchRefresh();
songCount.setText("Songs: " + sc.getMusicList().getTotal());
}
}
super.act(delta);
}
};
directoryField.setText(core.getPrefs().getString("music dir", System.getProperty("user.home")+System.getProperty("file.separator")+"Music"));
directoryField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
musicSearchTimer = 2;
songCount.setText("...");
}
});
optionsTable.add(directoryField).fillX();
optionsTable.add(songCount);
optionsTable.row();
TextButton keybindSettings = new TextButton("Set Controls", core.getDefaultSkin());
keybindSettings.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
targetPosition.y = -0.5f*Gdx.graphics.getHeight();
}
});
optionsTable.add(keybindSettings).colspan(2).fillX();
optionsTable.row();
TextButton graphicsSettings = new TextButton("Graphics", core.getDefaultSkin());
graphicsSettings.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
targetPosition.y = 1.5f*Gdx.graphics.getHeight();
}
});
optionsTable.add(graphicsSettings).colspan(2).fillX();
optionsTable.row();
Label fpsLabel = new Label("", core.getDefaultSkin()) {
@Override
public void act(float delta) {
setText("Current Frames Per Second: " + Gdx.graphics.getFramesPerSecond());
super.act(delta);
}
};
optionsTable.add(fpsLabel).colspan(2);
optionsTable.row();
Label usageLabel = new Label("Current usage (lower the better): " + 100f*((float)(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/(float)Runtime.getRuntime().totalMemory()) + "%", core.getDefaultSkin()) {
float refreshTime = 60;
@Override
public void act(float delta) {
refreshTime -= delta;
if (refreshTime <= 0) {
refreshTime = 60;
setText("Current usage (lower the better): " + 100f*((float)(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/(float)Runtime.getRuntime().totalMemory()) + "%");
}
super.act(delta);
}
};
optionsTable.add(usageLabel).colspan(2);
}
public void saveOptions(Preferences prefs) {
Gdx.app.debug("Preferences", "Saved all basic options page values.");
prefs.putString("music dir", directoryField.getText());
}
}

View File

@@ -1,52 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.pages;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.utils.Disposable;
public class Page extends Group implements Disposable {
private Label pageTitle;
private TextureRegion background;
public Page() {
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
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);
}
public float getHeightBelowTitle() {
return pageTitle.getY();
}
@Override
public void draw(Batch batch, float parentAlpha) {
if (background != null) {
batch.draw(background, getX(), getY(), getWidth(), getHeight());
}
super.draw(batch, parentAlpha);
}
public void addSpaceToTitle(float space) {
pageTitle.moveBy(space, 0);
}
public void setTextureBackground(TextureRegion texture) {
background = texture;
}
@Override
public void dispose() {
}
}

View File

@@ -1,44 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.pages;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
public class StatPage extends Page {
private Table table;
private Label winLabel;
private Label finalScore, damageTaken, enemiesKilled, shotsTaken, shotsMissed, accuracy;
public StatPage(Skin skin, int score, int damageTake, int enemiesKilled, int shotsTaken, int shotsMissed, int accuracy) {
table = new Table(skin);
addActor(table);
table.setFillParent(true);
winLabel = new Label("Win!", skin);
table.add(winLabel);
table.row();
this.finalScore = new Label("Your score: " + score, skin, "sub-font", skin.getColor("default"));
table.add(this.finalScore);
table.row();
this.damageTaken = new Label("Damage Taken: " + damageTake, skin, "sub-font", skin.getColor("default"));
table.add(this.damageTaken);
table.row();
this.enemiesKilled = new Label("Enemies slayed: " + enemiesKilled, skin, "sub-font", skin.getColor("default"));
table.add(this.enemiesKilled);
table.row();
this.shotsTaken = new Label("Shots taken: " + shotsTaken, skin, "sub-font", skin.getColor("default"));
table.add(this.shotsTaken);
table.row();
this.shotsMissed = new Label("Shots missed: " + shotsMissed, skin, "sub-font", skin.getColor("default"));
table.add(this.shotsMissed);
table.row();
this.accuracy = new Label("Accuracy: " + accuracy, skin, "sub-font", skin.getColor("default"));
table.add(this.accuracy);
}
}

View File

@@ -1,55 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.pages;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.graphics.ui.components.GraphicsOptions;
import zero1hd.rhythmbullet.screens.MainMenu;
public class VideoOptionsPage extends Page {
private ScrollPane scrollPane;
private GraphicsOptions graphicsTable;
private TextButton backButton;
public VideoOptionsPage(Skin skin, Preferences prefs, MainMenu menu, AssetManager assets) {
setTextureBackground(assets.get("gradients.atlas", TextureAtlas.class).findRegion("red-round"));
graphicsTable = new GraphicsOptions(menu, skin, prefs);
scrollPane = new ScrollPane(graphicsTable, skin);
scrollPane.setFadeScrollBars(false);
scrollPane.setFillParent(true);
addActor(scrollPane);
backButton = new TextButton("Back", skin);
backButton.setPosition(10, getHeight() - 10 - backButton.getHeight());
backButton.setWidth(backButton.getWidth() + 20);
backButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
menu.getCameraPosition().y = 0.5f*getHeight();
}
});
addActor(backButton);
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
}
@Override
public void act(float delta) {
super.act(delta);
}
public void save() {
graphicsTable.save();
}
}

View File

@@ -1,132 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.windows;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture;
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 com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import zero1hd.rhythmbullet.audio.AudioDataPackage;
import zero1hd.rhythmbullet.audio.MusicManager;
public class BeatViewer extends Window {
Pixmap lights;
int songIndex;
MusicManager music;
Texture lightOn;
private AudioDataPackage data;
public BeatViewer(String title, Skin skin) {
super(title, skin, "tinted");
defaults().space(5f);
setSize(64, 100);
//Draw the 'lights'
lights = new Pixmap(16, 16, Format.RGBA8888);
lights.setColor(1, 0.2f, 0.2f, 1f);
lights.fillCircle(lights.getWidth()/2, lights.getHeight()/2, 7);
lightOn = new Texture(lights);
WidgetGroup bassBar = new WidgetGroup();
final Image bgBassBar = new Image(skin.getPatch("bar-empty"));
bgBassBar.setHeight(50f);
bassBar.setSize(bgBassBar.getWidth(), bgBassBar.getHeight());
final Image bassBarFill = new Image(skin.getPatch("bar-fill")) {
@Override
public void act(float delta) {
try {
if (music != null && data.getBassPeaks().get(songIndex) != 0) {
clearActions();
addAction(Actions.sequence(Actions.sizeTo(getWidth(), (data.getBassPeaks().get(songIndex)/data.getBassMaxVal())*bgBassBar.getHeight()), Actions.sizeTo(getWidth(), 0, 0.3f)));
}
} catch (IndexOutOfBoundsException e) {
}
super.act(delta);
}
};
bassBarFill.setHeight(0f);
bassBar.addActor(bgBassBar);
bassBar.addActor(bassBarFill);
add(bassBar).minSize(bassBar.getWidth(), bassBar.getHeight());
WidgetGroup UMBar = new WidgetGroup();
final Image bgUMBar = new Image(skin.getPatch("bar-empty"));
bgUMBar.setHeight(50f);
UMBar.setSize(bgUMBar.getWidth(), bgUMBar.getHeight());
Image UMBarFill = new Image(skin.getPatch("bar-fill")) {
@Override
public void act(float delta) {
try {
if (music != null && data.getBassPeaks().get(songIndex) != 0) {
clearActions();
addAction(Actions.sequence(Actions.sizeTo(getWidth(), (data.getuMPeaks().get(songIndex)/data.getuMMaxval())*bgUMBar.getHeight()), Actions.sizeTo(getWidth(), 0f, 0.3f)));
}
} catch (IndexOutOfBoundsException e) {
}
super.act(delta);
}
};
UMBarFill.setHeight(0f);
UMBar.addActor(bgUMBar);
UMBar.addActor(UMBarFill);
add(UMBar).minSize(UMBar.getWidth(), UMBar.getHeight());
row();
Image bassIndicator = new Image(lightOn) {
@Override
public void act(float delta) {
try {
if (music != null && data.getBassPeaks().get(songIndex) != 0) {
clearActions();
addAction(Actions.sequence(Actions.alpha(1f), Actions.fadeOut(0.15f)));
}
} catch (IndexOutOfBoundsException e) {
}
super.act(delta);
}
};
bassIndicator.setColor(1f, 1f, 1f, 0f);
add(bassIndicator).center();
Image UMIndicator = new Image(lightOn) {
@Override
public void act(float delta) {
try {
if (music != null && data.getuMPeaks().get(songIndex) != 0) {
clearActions();
addAction(Actions.sequence(Actions.alpha(1f), Actions.fadeOut(0.15f)));
}
} catch (IndexOutOfBoundsException e) {
}
super.act(delta);
}
};
UMIndicator.setColor(1f, 1f, 1f, 0f);
add(UMIndicator).center();
}
@Override
public void act(float delta) {
if (music != null) {
songIndex = music.getPlaybackIndexPosition();
}
super.act(delta);
}
public void setMusic(MusicManager audioData, AudioDataPackage adp) {
this.music = audioData;
this.data = adp;
}
}

View File

@@ -1,77 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.windows;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
public class DifficultyWindow extends Window {
private Slider sensitivityRating;
private Label sensitivityRatingTitle;
private Slider speedModifier;
private Label speedModifierTitle;
private Slider healthModifier;
private Label healthModifierTitle;
public DifficultyWindow(Skin skin) {
super("Difficulty Adjuster", skin, "tinted");
sensitivityRating = new Slider(0f, 100f, 1f, false, skin);
sensitivityRating.setValue(0f);
sensitivityRating.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
sensitivityRatingTitle.setText("Base Difficulty: " + sensitivityRating.getValue());
}
});
sensitivityRatingTitle = new Label("Base Difficulty: " + sensitivityRating.getValue(), skin, "sub-font", skin.getColor("default"));
add(sensitivityRatingTitle);
add(sensitivityRating);
row();
speedModifier = new Slider(1f, 3f, 0.25f, false, skin);
speedModifier.setValue(1f);
speedModifier.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
speedModifierTitle.setText("Speed Modifier: " + speedModifier.getValue());
}
});
speedModifierTitle = new Label("Speed Modifier: " + speedModifier.getValue(), skin, "sub-font", skin.getColor("default"));
add(speedModifierTitle);
add(speedModifier);
row();
healthModifier = new Slider(0f, 5f, 1f, false, skin);
healthModifier.setValue(0f);
healthModifier.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
healthModifierTitle.setText("Health modifier: " + healthModifier.getValue());
}
});
healthModifierTitle = new Label("Health modifier: " + healthModifier.getValue(), skin, "sub-font", skin.getColor("default"));
add(healthModifierTitle);
add(healthModifier);
pack();
}
public float getOverallDiffMod() {
return sensitivityRating.getValue();
}
public float getSpeedModifier() {
return speedModifier.getValue();
}
public float getHealthModifier() {
return healthModifier.getValue();
}
}

View File

@@ -1,21 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.windows;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
public class FPSWindow extends Window {
public FPSWindow(String title, Skin skin) {
super(title, skin, "tinted");
Label FPS = new Label("FPS: ", skin, "window-font", skin.getColor("default")) {
@Override
public void act(float delta) {
setText("FPS: " + Gdx.graphics.getFramesPerSecond());
super.act(delta);
}
};
add(FPS).center();
setSize(70, 70);
}
}

View File

@@ -1,86 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.windows;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.audio.Sound;
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.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import com.badlogic.gdx.utils.Disposable;
public class LoadingWindow extends Window implements Disposable {
private Label status;
private Sound closeSound;
private Sound openSound;
private float vol;
public LoadingWindow(Skin skin, boolean progress, AssetManager assets, float vol) {
super("loading...", skin, "tinted");
this.openSound = assets.get("pop_open.ogg", Sound.class);
this.closeSound = assets.get("pop_close.ogg", Sound.class);
this.vol = vol;
Image loading = new Image(skin, "loading");
loading.addAction(Actions.forever(Actions.rotateBy(-360f, 2f)));
add(loading).left();
System.out.println(loading.getHeight());
setSize(loading.getWidth()+20f, loading.getHeight()+40f);
loading.setOrigin(loading.getWidth()/2, loading.getHeight()/2);
if (progress) {
status = new Label("[ ]", skin, "sub-font", skin.getColor("default"));
add(status).spaceLeft(10f).expandX().right();
setSize(getWidth() + status.getWidth() + 45f, (loading.getHeight() >= status.getHeight() ? loading.getHeight() : status.getHeight()) + 74);
}
}
public LoadingWindow(Skin skin, String styleName, boolean progress, AssetManager assets, float vol) {
super("loading...", skin, styleName);
this.openSound = assets.get("pop_open.ogg", Sound.class);
this.closeSound = assets.get("pop_close.ogg", Sound.class);
this.vol = vol;
Image loading = new Image(skin, "loading");
loading.addAction(Actions.forever(Actions.rotateBy(-360f, 2f)));
add(loading).left();
setSize(loading.getWidth()+20f, loading.getHeight()+40f);
loading.setOrigin(loading.getWidth()/2, loading.getHeight()/2);
if (progress) {
status = new Label("[ ]", skin, "sub-font", skin.getColor("default"));
add(status).spaceLeft(10f).expandX().right();
setSize(getWidth() + status.getWidth() + 45f, (loading.getHeight() >= status.getHeight() ? loading.getHeight() : status.getHeight()) + 74);
}
}
public void playOpenSound() {
openSound.play(vol/100f);
}
@Override
public boolean remove() {
closeSound.play(vol/100f);
return super.remove();
}
public void setProgress(float progress) {
status.setText(String.valueOf((int) progress) + '%');
}
@Override
public void dispose() {
openSound.dispose();
closeSound.dispose();
}
}

View File

@@ -1,63 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.windows;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.utils.Align;
public class NoticeWindow extends Window {
private Label noticeText;
private Skin skin;
private Sound closeSound;
private Sound openSound;
private float vol;
public NoticeWindow(Skin skin, String styleName, String text, float vol, AssetManager assets) {
super("Notice", skin, "tinted");
this.skin = skin;
this.openSound = assets.get("pop_open.ogg", Sound.class);
this.closeSound = assets.get("pop_close.ogg", Sound.class);
this.vol = vol;
noticeText = new Label(text, skin, "sub-font", skin.getColor("default"));
noticeText.setWrap(true);
noticeText.setAlignment(Align.center);
add(noticeText).expandX().fill().center().padLeft(20f).padRight(20f);
}
public NoticeWindow(Skin skin, String styleName, String title, String text, float vol, AssetManager assets) {
super(title, skin, styleName);
this.skin = skin;
this.openSound = assets.get("pop_open.ogg", Sound.class);
this.closeSound = assets.get("pop_close.ogg", Sound.class);
this.vol = vol;
noticeText = new Label(text, skin, "sub-font", skin.getColor("default"));
noticeText.setWrap(true);
noticeText.setAlignment(Align.center);
add(noticeText).expandX().fill().center().padLeft(20f).padRight(20f);
}
public void setupButton(String text, ChangeListener changeListener, int alignment) {
TextButton button = new TextButton(text, skin, "sub");
button.addListener(changeListener);
add(button).align(alignment);
}
public void playOpenSound() {
openSound.play(vol/100f);
}
@Override
public boolean remove() {
closeSound.play(vol/100f);
return super.remove();
}
}

View File

@@ -1,35 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.windows;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
public class PauseMenu extends Window {
private Label label;
private TextButton resumeButton;
private TextButton quit;
public PauseMenu(Skin skin) {
super("Paused", skin, "tinted");
defaults().pad(25f);
label = new Label("Game is paused.", skin);
add(label).spaceBottom(15f);
row();
resumeButton = new TextButton("Resume", skin, "sub");
add(resumeButton).spaceBottom(8f);
quit = new TextButton("Quit", skin, "sub");
add(quit);
pack();
setModal(true);
}
public TextButton getResumeButton() {
return resumeButton;
}
public TextButton getQuitButton() {
return quit;
}
}

View File

@@ -1,20 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.windows;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
public class Spawnables extends Window {
public Spawnables(String title, Skin skin) {
super(title, skin, "tinted");
Table spawnButtons = new Table(skin);
ScrollPane entityListScroller = new ScrollPane(spawnButtons);
entityListScroller.setSize(180, 80);
add(entityListScroller);
setSize(185, 85);
}
}

View File

@@ -1,119 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.windows;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import com.badlogic.gdx.utils.Array;
import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityFrame;
import zero1hd.rhythmbullet.entity.EntityManager;
import zero1hd.rhythmbullet.entity.ally.Laser;
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
import zero1hd.rhythmbullet.entity.enemies.Flake;
import zero1hd.rhythmbullet.entity.enemies.Pellet;
import zero1hd.rhythmbullet.entity.enemies.Shard;
import zero1hd.rhythmbullet.entity.enemies.VoidCircle;
public class SpawnerWindow extends Window {
private Stage stage;
private Array<EntityFrame<? extends Entity>> entityFrames = new Array<>();
private List<EntityFrame<? extends Entity>> listOfEntities;
private ScrollPane entityListScroller;
private Array<CoordinatorFrame<? extends Coordinator>> coordinatorFrames = new Array<>();
private List<CoordinatorFrame<? extends Coordinator>> listOfCoordinators;
private ScrollPane coordinatorListScroller;
private Slider mod1;
private Slider mod2;
private Slider mod3;
private Slider mod4;
public SpawnerWindow(String title, Skin skin, EntityManager em, CoordinatorManager cm, Stage stageForEntities) {
super(title, skin, "tinted");
stage = stageForEntities;
defaults().pad(15f);
mod1 = new Slider(0.1f, 50f, 0.01f, true, skin);
mod2 = new Slider(0f, 15f, 0.01f, true, skin);
mod3 = new Slider(0.1f, 15f, 0.01f, true, skin);
mod4 = new Slider(1f, 12f, 0.01f, true, skin);
add(mod1, mod2, mod3, mod4);
listOfEntities = new List<>(skin);
entityFrames.add(em.flake);
entityFrames.add(em.laser);
entityFrames.add(em.pellet);
entityFrames.add(em.shard);
entityFrames.add(em.voidCircle);
listOfEntities.setItems(entityFrames);
entityListScroller = new ScrollPane(listOfEntities, skin);
add(entityListScroller).width(100f).fillY();
listOfCoordinators = new List<>(skin);
coordinatorFrames.add(cm.slowLeft);
coordinatorFrames.add(cm.slowRight);
listOfCoordinators.setItems(coordinatorFrames);
coordinatorListScroller = new ScrollPane(listOfCoordinators, skin);
add(coordinatorListScroller).width(100f).fillY();
pack();
}
@Override
public boolean remove() {
return super.remove();
}
private Vector2 coords = new Vector2();
@Override
public void act(float delta) {
if (Gdx.input.justTouched() && Gdx.input.isKeyPressed(Keys.CONTROL_LEFT)) {
coords.set(Gdx.input.getX(), Gdx.input.getY());
stage.screenToStageCoordinates(coords);
Entity entity = listOfEntities.getSelected().buildEntity();
if (Gdx.input.isKeyPressed(Keys.ALT_LEFT)) {
entity.setCoordinator(listOfCoordinators.getSelected().buildCoordinator());
}
if (entity.getClass() == Laser.class) {
Laser laser = (Laser) entity;
laser.init(coords.x, coords.y, mod1.getValue());
} else if (entity.getClass() == Pellet.class) {
Pellet pellet = (Pellet) entity;
pellet.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue());
} else if (entity.getClass() == VoidCircle.class) {
VoidCircle voidCircle = (VoidCircle) entity;
voidCircle.init(mod2.getValue(), coords.x, coords.y, mod1.getValue(), mod3.getValue());
} else if (entity.getClass() == Shard.class) {
Shard shard = (Shard) entity;
shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue());
} else if (entity.getClass() == Flake.class) {
Flake flake = (Flake) entity;
flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, (int) mod4.getValue());
}
stage.addActor(entity);
}
super.act(delta);
}
}

View File

@@ -1,76 +0,0 @@
package zero1hd.rhythmbullet.graphics.ui.windows;
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.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.audio.MusicManager;
public class VolumeWindow extends Window {
private Slider fxVolSlider;
private Slider musicVolSlider;
private Preferences prefs;
private MusicManager music;
public VolumeWindow(String title, Skin skin, Preferences prefs) {
super(title, skin, "tinted");
this.prefs = prefs;
setSize(360f, 100f);
Label musicVolSliderLabel = new Label("Music Volume: ", skin, "window-font", skin.getColor("default"));
add(musicVolSliderLabel).left().padLeft(5f);
musicVolSlider = new Slider(0, 100, 0.1f, false, skin);
musicVolSlider.setValue(prefs.getFloat("music vol", 100f));
add(musicVolSlider).width(200f);
final Label musicVolPercentage = new Label(MathUtils.round(musicVolSlider.getValue()) + "%", skin, "window-font", skin.getColor("default"));
musicVolSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
save();
musicVolPercentage.setText(MathUtils.round(musicVolSlider.getValue()) + "%");
if (music != null) {
music.setVolume(musicVolSlider.getValue());
}
}
});
add(musicVolPercentage).spaceLeft(10f).expandX().left();
row();
Label fxVolSliderLabel = new Label("FX Volume: ", skin, "window-font", skin.getColor("default"));
add(fxVolSliderLabel).left().padLeft(5f);
fxVolSlider = new Slider(0, 100, 1, false, skin);
fxVolSlider.setValue(prefs.getFloat("fx vol", 100f));
add(fxVolSlider).width(200f);
final Label fxVolPercentage = new Label(MathUtils.round(fxVolSlider.getValue()) + "%", skin, "window-font", skin.getColor("default"));
fxVolSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
save();
fxVolPercentage.setText(MathUtils.round(fxVolSlider.getValue()) + "%");
}
});
add(fxVolPercentage).spaceLeft(10f).expandX().left();
}
public void save() {
prefs.putFloat("music vol", musicVolSlider.getValue());
prefs.putFloat("fx vol", fxVolSlider.getValue());
prefs.flush();
}
public void setMusic(MusicManager music) {
this.music = music;
if (music != null) {
music.setVolume(prefs.getFloat("music vol"));
}
}
}

View File

@@ -1,8 +0,0 @@
package zero1hd.rhythmbullet.screens;
import com.badlogic.gdx.ScreenAdapter;
public class EndScreen extends ScreenAdapter {
public EndScreen() {
}
}

View File

@@ -1,290 +0,0 @@
package zero1hd.rhythmbullet.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.audio.map.GamePlayMap;
import zero1hd.rhythmbullet.stages.GameHUD;
import zero1hd.rhythmbullet.stages.GamePlayArea;
public class GameScreen extends ScreenAdapter {
protected GamePlayArea gameArea;
public GameHUD gameHUD;
protected InputMultiplexer inputs;
public RhythmBullet core;
private MusicManager music;
private ShaderProgram gaussianBlurShader;
private ShaderProgram brightFilterShader;
private ShaderProgram combineShader;
private FrameBuffer lightFilterBuffer;
private FrameBuffer normalBuffer;
private FrameBuffer hBlur, vBlur;
private TextureRegion fboRegion;
private int fboSize;
private Batch batch;
private ScreenViewport screenViewport;
private int blurlvl = 4;
/**
* The game screen where the game play area, and hud are placed.
* @param core The game context object
* @param screen the screen to return to if player decides to press "quit" button.
*/
public GameScreen(RhythmBullet core, Screen screen) {
this.core = core;
// Overlay stuff
ImageButton pause = new ImageButton(core.getDefaultSkin().getDrawable("pause"),
core.getDefaultSkin().getDrawable("pause-down"));
pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 25,
Gdx.graphics.getHeight() - pause.getHeight() - 25);
pause.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
pause();
}
});
gameArea = new GamePlayArea(core.getAssetManager(), core.getPrefs());
gameHUD = new GameHUD(core.getDefaultSkin(), 100f, gameArea, screen, core);
inputs = new InputMultiplexer();
inputs.addProcessor(gameHUD);
inputs.addProcessor(gameArea);
}
public void setGamePlayMap(GamePlayMap gpm) {
music = gpm.getMusicData();
gameArea.setAudioMap(gpm);
gameHUD.setMusic(gpm.getMusicData());
}
@Override
public void show() {
Gdx.input.setInputProcessor(inputs);
loadShaders();
super.show();
}
/**
* needs to be called right after set as screen (should be called in show method).
* This is due to the saving preference being done once the screen is hidden.
* @param prefs
*/
public void loadShaders() {
if (core.getPrefs().getBoolean("glow shader")) {
batch = new SpriteBatch();
screenViewport = new ScreenViewport();
Gdx.app.debug("Shader", "using glow shader");
brightFilterShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/bright_filter.fsh"));
if (!brightFilterShader.isCompiled()) {
System.err.println(brightFilterShader.getLog());
System.exit(0);
}
if (brightFilterShader.getLog().length() != 0) {
System.out.println(brightFilterShader.getLog());
}
gaussianBlurShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/gaussian_blur.fsh"));
if (!gaussianBlurShader.isCompiled()) {
System.err.println(gaussianBlurShader.getLog());
System.exit(0);
}
if (gaussianBlurShader.getLog().length() != 0) {
System.out.println(gaussianBlurShader.getLog());
}
combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh"));
if (!combineShader.isCompiled()) {
System.err.println(combineShader.getLog());
System.exit(0);
}
if (combineShader.getLog().length() != 0) {
System.out.println(combineShader.getLog());
}
if (Gdx.graphics.getWidth() < 1024) {
fboSize = 2048;
} else if (Gdx.graphics.getWidth() < 2048) {
fboSize = 4096;
} else {
fboSize = 4096;
}
lightFilterBuffer = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false);
normalBuffer = new FrameBuffer(Format.RGBA8888, fboSize, fboSize, false);
hBlur = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false);
vBlur = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false);
fboRegion = new TextureRegion(normalBuffer.getColorBufferTexture());
fboRegion.flip(false, true);
combineShader.begin();
combineShader.setUniformi("u_texture1", 1);
combineShader.end();
vBlur.getColorBufferTexture().bind(1);
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
}
ShaderProgram.pedantic = false;
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
//actual game and hud
if (!gameHUD.isPaused()) {
gameArea.act(delta);
if (gameArea.getPolyjetEntity().isDead()) {
end(false);
}
gameHUD.act(delta);
}
gameArea.getViewport().apply();
blurlvl = 4;
if (gaussianBlurShader != null) {
//Begin drawing a normal version of screen
gameArea.getViewport().apply();
normalBuffer.begin();
Gdx.gl.glClearColor(0.22f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
gameArea.draw();
normalBuffer.end();
//END STAGE BATCH
//BEGINNING NORMAL SCREEN RENDER
screenViewport.apply();
//Begin light filtering
lightFilterBuffer.begin();
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
batch.setShader(brightFilterShader);
batch.begin(); //BATCH STARTS HERE
batch.draw(fboRegion, 0, 0, gameArea.getWidth(), gameArea.getHeight());
batch.flush();
lightFilterBuffer.end();
for (int i = 0; i < blurlvl; i++) {
//Horizontal gaussian blur
hBlur.begin();
if (i > 0) {
fboRegion.setTexture(vBlur.getColorBufferTexture());
} else {
fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture());
} batch.setShader(gaussianBlurShader);
gaussianBlurShader.setUniformi("horizontal", 1);
batch.draw(fboRegion, 0f, 0f, gameArea.getWidth(), gameArea.getHeight());
batch.flush();
hBlur.end();
//Vertical gaussian blur
vBlur.begin();
fboRegion.setTexture(hBlur.getColorBufferTexture());
batch.setShader(gaussianBlurShader);
gaussianBlurShader.setUniformi("horizontal", 0);
batch.draw(fboRegion, 0f, 0f, gameArea.getWidth(), gameArea.getHeight());
batch.flush();
vBlur.end();
}
//draw a final copy to a fbo
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.setShader(combineShader);
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
batch.draw(fboRegion, 0f, 0f, gameArea.getWidth(), gameArea.getHeight());
batch.setShader(null);
batch.end(); //STAGE BATCH ENDS HERE
} else {
gameArea.draw();
}
gameHUD.getViewport().apply();
gameHUD.draw();
if (music != null && !music.isPlaying()) {
end(true);
}
super.render(delta);
}
private void end(boolean trueEnd) {
if (trueEnd) {
// TODO they didn't die
} else {
// TODO They done goofed and ended up dying.
}
}
@Override
public void dispose() {
gameHUD.dispose();
gameArea.dispose();
if (gaussianBlurShader != null) {
normalBuffer.dispose();
lightFilterBuffer.dispose();
hBlur.dispose();
vBlur.dispose();
brightFilterShader.dispose();
gaussianBlurShader.dispose();
combineShader.dispose();
gaussianBlurShader.dispose();
}
super.dispose();
}
@Override
public void pause() {
gameHUD.setPaused(true);
super.pause();
}
@Override
public void resize(int width, int height) {
gameArea.getViewport().update(width, height, true);
gameHUD.getViewport().update(width, height, true);
super.resize(width, height);
}
public GamePlayArea getGameArea() {
return gameArea;
}
public void play() {
if (music == null) throw new NullPointerException("Idiot, you can't have a music game not have music on the gameplay screen...");
Gdx.input.setInputProcessor(inputs);
if (!gameHUD.isPaused()) {
music.play();
}
}
}

View File

@@ -1,91 +0,0 @@
package zero1hd.rhythmbullet.screens;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
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.utils.viewport.ScreenViewport;
import zero1hd.rhythmbullet.RhythmBullet;
public class LoadingScreen extends ScreenAdapter implements ApplicationListener {
private Stage stage;
private RhythmBullet core;
private Texture splash;
private Image zero1HD;
private boolean done;
public LoadingScreen(RhythmBullet core) {
this.core = core;
stage = new Stage(new ScreenViewport());
splash = new Texture(Gdx.files.internal("splashlogo.png"));
zero1HD = new Image(splash);
zero1HD.setScale((Gdx.graphics.getHeight()*0.8f)/zero1HD.getHeight());
zero1HD.setColor(0f,1f,1f,0f);
stage.addActor(zero1HD);
zero1HD.setPosition((stage.getWidth() - zero1HD.getWidth()*zero1HD.getScaleX())/2f, (stage.getHeight() - zero1HD.getHeight()*zero1HD.getScaleY())/2f);
zero1HD.addAction(Actions.sequence(Actions.color(Color.WHITE, 1f), Actions.fadeOut(0.5f)));
core.getrRHandler().setResolution(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
core.queueAssets();
}
@Override
public void show() {
super.show();
}
float count = 0;
@Override
public void render(float delta) {
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(delta);
if (!zero1HD.hasActions() & core.getAssetManager().update()) {
moveOn();
}
stage.draw();
super.render(delta);
}
private void moveOn() {
if (!done) {
Gdx.app.debug("Loading Screen", "queue has all been loaded. Action is done playing.");
done = true;
core.generateFonts(Gdx.graphics.getHeight());
core.defineSkinStyles();
core.setScreen(new MainMenu(core));
zero1HD.remove();
}
}
@Override
public void resize(int width, int height) {
stage.getViewport().update(width, height, true);
super.resize(width, height);
}
@Override
public void hide() {
core.setInitComplete();
splash.dispose();
super.hide();
}
@Override
public void create() {
}
@Override
public void render() {
}
}

View File

@@ -1,391 +0,0 @@
package zero1hd.rhythmbullet.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.MusicList;
import zero1hd.rhythmbullet.audio.MusicListController;
import zero1hd.rhythmbullet.graphics.ui.pages.AnalysisPage;
import zero1hd.rhythmbullet.graphics.ui.pages.CreditsPage;
import zero1hd.rhythmbullet.graphics.ui.pages.KeybindOptionsPage;
import zero1hd.rhythmbullet.graphics.ui.pages.MainPage;
import zero1hd.rhythmbullet.graphics.ui.pages.MusicSelectionPage;
import zero1hd.rhythmbullet.graphics.ui.pages.OptionsPage;
import zero1hd.rhythmbullet.graphics.ui.pages.VideoOptionsPage;
import zero1hd.rhythmbullet.util.TransitionAdapter;
public class MainMenu extends ScreenAdapter implements TransitionAdapter {
public Stage stage;
private Vector3 cameraPosition;
private MainPage mainPage;
private OptionsPage optionsPage;
private CreditsPage creditsPage;
private KeybindOptionsPage keybindPage;
private VideoOptionsPage graphicsPage;
private MusicSelectionPage musicSelectionPage;
private AnalysisPage analysisPage;
private RhythmBullet core;
private MusicListController mlc;
private float lerpAlpha;
private ShaderProgram gaussianBlurShader;
private ShaderProgram brightFilterShader;
private ShaderProgram combineShader;
private FrameBuffer lightFilterBuffer;
private FrameBuffer normalBuffer;
private FrameBuffer hBlur, vBlur;
private TextureRegion fboRegion;
private int fboSize;
private int blurlvl;
private Batch batch;
private ScreenViewport screenViewport;
public MainMenu(RhythmBullet core) {
this.core = core;
stage = new Stage(new ScreenViewport());
cameraPosition = new Vector3(stage.getCamera().position);
MusicList musicList = new MusicList();
musicList.setSearchPath(core.getPrefs().getString("music dir"));
musicList.asynchRefresh();
mlc = new MusicListController(musicList, core.getPrefs());
mlc.setAutoPlay(true);
mlc.setShuffle(true);
postTransition(true);
}
@Override
public void postTransition(boolean first) {
attemptLoadShaders();
mainPage = new MainPage(core, cameraPosition, mlc, this);
mainPage.setPosition(0, 0);
stage.addActor(mainPage);
//End main menu
keybindPage = new KeybindOptionsPage(core.getDefaultSkin(), core.getAssetManager(), cameraPosition);
keybindPage.setPosition(-1f*Gdx.graphics.getWidth(), -1f*Gdx.graphics.getHeight());
stage.addActor(keybindPage);
graphicsPage = new VideoOptionsPage(core.getDefaultSkin(), core.getPrefs(), this, core.getAssetManager());
graphicsPage.setPosition(-1f*Gdx.graphics.getWidth(), 1f*Gdx.graphics.getHeight());
stage.addActor(graphicsPage);
optionsPage = new OptionsPage(core, cameraPosition, keybindPage, mlc);
optionsPage.setPosition(-Gdx.graphics.getWidth(), 0);
stage.addActor(optionsPage);
creditsPage = new CreditsPage(core.getDefaultSkin());
creditsPage.setPosition(0, Gdx.graphics.getHeight());
stage.addActor(creditsPage);
analysisPage = new AnalysisPage(core.getDefaultSkin(),core.getAssetManager());
analysisPage.setPosition(2*Gdx.graphics.getWidth(), 0f);
stage.addActor(analysisPage);
musicSelectionPage = new MusicSelectionPage(core.getDefaultSkin(), mlc, core.getAssetManager(), cameraPosition, analysisPage);
musicSelectionPage.setPosition(1f*Gdx.graphics.getWidth(), 0f);
stage.addActor(musicSelectionPage);
stage.addListener(new InputListener() {
@Override
public boolean keyUp(InputEvent event, int keycode) {
if (keycode == Keys.ESCAPE) {
stage.unfocusAll();
if (cameraPosition.x != 0.5f*Gdx.graphics.getWidth() || cameraPosition.y != 0.5f*Gdx.graphics.getHeight()) {
cameraPosition.x = 0.5f*Gdx.graphics.getWidth();
cameraPosition.y = 0.5f*Gdx.graphics.getHeight();
}
keybindPage.unselect();
}
return super.keyUp(event, keycode);
}
});
stage.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (stage.hit(x, y, true) == null) {
stage.unfocusAll();
keybindPage.unselect();
}
super.clicked(event, x, y);
}
});
mlc.getMusicList().deleteObservers();
mlc.deleteObservers();;
mlc.addObserver(musicSelectionPage);
mlc.addObserver(mainPage);
mlc.getMusicList().addObserver(mainPage);
}
public void attemptLoadShaders() {
if (core.getPrefs().getBoolean("glow shader", true)) {
if (core.getPrefs().getBoolean("enhanced glow", false)) {
blurlvl = 5;
} else {
blurlvl = 1;
}
batch = new SpriteBatch();
screenViewport = new ScreenViewport();
screenViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
((OrthographicCamera) screenViewport.getCamera()).setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.app.debug("Shader", "using glow shader");
brightFilterShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/bright_filter.fsh"));
if (!brightFilterShader.isCompiled()) {
System.err.println(brightFilterShader.getLog());
System.exit(0);
}
if (brightFilterShader.getLog().length() != 0) {
System.out.println(brightFilterShader.getLog());
}
gaussianBlurShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/gaussian_blur.fsh"));
if (!gaussianBlurShader.isCompiled()) {
System.err.println(gaussianBlurShader.getLog());
System.exit(0);
}
if (gaussianBlurShader.getLog().length() != 0) {
System.out.println(gaussianBlurShader.getLog());
}
combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh"));
if (!combineShader.isCompiled()) {
System.err.println(combineShader.getLog());
System.exit(0);
}
if (combineShader.getLog().length() != 0) {
System.out.println(combineShader.getLog());
}
if (Gdx.graphics.getWidth() < 1024) {
fboSize = 1024;
} else if (Gdx.graphics.getWidth() < 2048) {
fboSize = 2048;
} else {
fboSize = 4096;
}
lightFilterBuffer = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false);
normalBuffer = new FrameBuffer(Format.RGBA8888, fboSize, fboSize, false);
hBlur = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false);
vBlur = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false);
fboRegion = new TextureRegion(normalBuffer.getColorBufferTexture());
fboRegion.flip(false, true);
combineShader.begin();
combineShader.setUniformi("u_texture1", 1);
combineShader.end();
vBlur.getColorBufferTexture().bind(1);
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
}
ShaderProgram.pedantic = false;
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0.22f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(delta);
if (blurlvl > 0) {
// Begin drawing a normal version of screen
normalBuffer.begin();
stage.getViewport().apply();
Gdx.gl.glClearColor(0.22f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.draw();
normalBuffer.end();
// BEGINNING NORMAL SCREEN RENDER
screenViewport.apply();
// Begin light filtering
lightFilterBuffer.begin();
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
batch.setShader(brightFilterShader);
batch.setProjectionMatrix(screenViewport.getCamera().combined);
batch.begin(); //BATCH STARTS HERE
batch.draw(fboRegion, 0, 0, stage.getWidth(), stage.getHeight());
batch.flush();
lightFilterBuffer.end();
//
for (int i = 0; i < blurlvl; i++) {
// Horizontal gaussian blur
hBlur.begin();
if (i > 0) {
fboRegion.setTexture(vBlur.getColorBufferTexture());
} else {
fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture());
}
batch.setShader(gaussianBlurShader);
gaussianBlurShader.setUniformi("horizontal", 1);
batch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
batch.flush();
hBlur.end();
// //Vertical gaussian blur
vBlur.begin();
fboRegion.setTexture(hBlur.getColorBufferTexture());
batch.setShader(gaussianBlurShader);
gaussianBlurShader.setUniformi("horizontal", 0);
batch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
batch.flush();
vBlur.end();
}
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.setShader(combineShader);
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
batch.draw(fboRegion, 0f, 0f, fboSize, fboSize);
batch.setShader(null);
batch.end(); //STAGE BATCH ENDS HERE
} else {
stage.draw();
}
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
stage.getCamera().position.lerp(cameraPosition, delta*lerpAlpha);
stage.getViewport().apply();
}
super.render(delta);
}
@Override
public void preTransition() {
stage.clear();
mainPage.dispose();
optionsPage.dispose();
creditsPage.dispose();
keybindPage.dispose();
}
@Override
public void show() {
Gdx.input.setInputProcessor(stage);
calcLerpAlpha(Gdx.graphics.getWidth());
super.show();
}
@Override
public void hide() {
saveAll();
super.hide();
}
public void saveAll() {
if (optionsPage != null) {
optionsPage.saveOptions(core.getPrefs());
core.getPrefs().flush();
}
}
@Override
public void resize(int width, int height) {
stage.getViewport().update(width, height, false);
cameraPosition.x = width/2;
cameraPosition.y = height/2;
calcLerpAlpha(width);
super.resize(width, height);
}
@Override
public void dispose() {
stage.dispose();
unloadShaders();
super.dispose();
}
private void calcLerpAlpha(int width) {
if (width <= 3835) {
lerpAlpha = 5.0f;
} else {
lerpAlpha = 5.5f;
}
}
public void unloadShaders() {
try {
brightFilterShader.dispose();
combineShader.dispose();
gaussianBlurShader.dispose();
normalBuffer.dispose();
lightFilterBuffer.dispose();
vBlur.dispose();
hBlur.dispose();
} catch (NullPointerException e) {
saveAll();
}
brightFilterShader = null;
combineShader = null;
gaussianBlurShader = null;
normalBuffer = null;
lightFilterBuffer = null;
vBlur = null;
hBlur = null;
setBlurlvl(0);
}
public void setBlurlvl(int blurlvl) {
this.blurlvl = blurlvl;
}
public Vector3 getCameraPosition() {
return cameraPosition;
}
public MainPage getMainPage() {
return mainPage;
}
public CreditsPage getCreditsPage() {
return creditsPage;
}
public VideoOptionsPage getGraphicsPage() {
return graphicsPage;
}
public KeybindOptionsPage getKeybindPage() {
return keybindPage;
}
public MusicSelectionPage getMusicSelectionPage() {
return musicSelectionPage;
}
public OptionsPage getOptionsPage() {
return optionsPage;
}
}

View File

@@ -1,241 +0,0 @@
package zero1hd.rhythmbullet.stages;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.scenes.scene2d.Actor;
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.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.graphics.ui.components.HealthBar;
import zero1hd.rhythmbullet.graphics.ui.windows.FPSWindow;
import zero1hd.rhythmbullet.graphics.ui.windows.PauseMenu;
import zero1hd.rhythmbullet.util.ScoreManager;
public class GameHUD extends Stage {
private Screen returnScreen;
private Label scoreLabel;
private ImageButton pause;
private boolean paused;
private FPSWindow fpsWindow;
private PauseMenu pauseMenu;
private HealthBar healthBar;
private Pixmap pixmap;
private Texture leftStatTexture;
private Texture rightStatTexture;
private Image leftStatusBar;
private Image rightStatusBar;
private GamePlayArea gpa;
private MusicManager music;
private ScoreManager sm;
private Color original, bass, um;
public GameHUD(Skin skin, float maxHealth, GamePlayArea gpa, Screen rs, final RhythmBullet core) {
super();
scoreLabel = new Label("Score: 0", skin, "default-font", Color.WHITE);
scoreLabel.setPosition(10f, Gdx.graphics.getHeight()-scoreLabel.getHeight() - 10f);
addActor(scoreLabel);
this.sm = gpa.score;
this.gpa = gpa;
this.returnScreen = rs;
pause = new ImageButton(skin.getDrawable("pause"),
skin.getDrawable("pause-down"));
pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 15f,
Gdx.graphics.getHeight() - pause.getHeight() - 15f);
pause.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
setPaused(true);
}
});
addActor(pause);
fpsWindow = new FPSWindow("FPS", skin);
fpsWindow.setPosition(15f, 15f);
pauseMenu = new PauseMenu(skin);
pauseMenu.getResumeButton().addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
setPaused(false);
}
});
pauseMenu.getQuitButton().addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
core.setScreen(returnScreen);
}
});
pauseMenu.setPosition((Gdx.graphics.getWidth()-pauseMenu.getWidth())/2f, (Gdx.graphics.getHeight()-pauseMenu.getHeight())/2f);
healthBar = new HealthBar(skin, maxHealth);
healthBar.setSize(30f, Gdx.graphics.getHeight()/3);
healthBar.setHealth(maxHealth);
healthBar.setPosition(Gdx.graphics.getWidth() -(gpa.getViewport().getRightGutterWidth()/4f), (Gdx.graphics.getHeight()-healthBar.getHeight())/2f);
addActor(healthBar);
healthBar.setPolyjetEntity(gpa.getPolyjetEntity());
pixmap = new Pixmap(3, 3, Format.RGBA8888);
int excess = 2*gpa.getViewport().getLeftGutterWidth()/pixmap.getWidth();
Gdx.app.debug("GHUD", "offset on size: " + excess);
pixmap.setColor(Color.WHITE);
pixmap.drawLine(0, 0, 0, 2);
pixmap.setColor(1f, 1f, 1f, 0.5f);
pixmap.drawLine(1, 0, 1, 2);
leftStatTexture = new Texture(pixmap);
leftStatTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
leftStatusBar = new Image(leftStatTexture);
leftStatusBar.setSize(gpa.getViewport().getLeftGutterWidth()+excess, getHeight());
leftStatusBar.setPosition(0, 0);
addActor(leftStatusBar);
leftStatusBar.toBack();
pixmap.dispose();
pixmap = new Pixmap(3, 3, Format.RGBA8888);
pixmap.setColor(Color.WHITE);
pixmap.drawLine(2, 0, 2, 2);
pixmap.setColor(1f, 1f, 1f, 0.5f);
pixmap.drawLine(1, 0, 1, 2);
rightStatTexture = new Texture(pixmap);
rightStatTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
rightStatusBar = new Image(rightStatTexture);
rightStatusBar.setSize(gpa.getViewport().getRightGutterWidth()+excess, getHeight());
rightStatusBar.setPosition(getWidth()-gpa.getViewport().getRightGutterWidth()-excess, 0f);
addActor(rightStatusBar);
rightStatusBar.toBack();
pixmap.dispose();
original = new Color(0.6f, 0.8f, 255f, 0.55f);
bass = new Color(0.8f, 0, 1, 0.9f);
um = new Color(1f, 0.6f, 0.4f, 0.9f);
setStatusColor(original);
}
@Override
public void act(float delta) {
if (sm.checkDifferent()) {
setScore(sm.getScore());
}
if (gpa.getAudioMap() != null && gpa.getAudioMap().getHudType().length > gpa.getAudioMap().getIndex()) {
if (gpa.getAudioMap() != null && gpa.getAudioMap().getHudType()[gpa.getAudioMap().getIndex()] != 0) {
switch (gpa.getAudioMap().getHudType()[gpa.getAudioMap().getIndex()]) {
case 1:
changeStatusColor(bass, 0.2f, original);
break;
case 2:
changeStatusColor(um, 0.2f, original);
}
}
}
super.act(delta);
}
/**
* sets the label for scoring to the designated score
* @param score designated score
*/
public void setScore(int score) {
this.scoreLabel.setText("Score: " + score);
}
public void setPaused(boolean paused) {
if (paused) {
addActor(pauseMenu);
if (music != null) {
music.pause();
}
} else {
pauseMenu.remove();
if (music != null) {
music.play();
}
}
this.paused = paused;
}
/**
* toggle's between the two states of paused and unpaused
* @return whatever the new game state is (true for paused)
*/
public boolean togglePause() {
if (isPaused()) {
setPaused(false);
} else {
setPaused(true);
}
return isPaused();
}
public boolean isPaused() {
return paused;
}
@Override
public boolean keyUp(int keycode) {
switch (keycode) {
case Keys.F3:
if (fpsWindow.hasParent()) {
fpsWindow.remove();
} else {
addActor(fpsWindow);
}
break;
case Keys.ESCAPE:
togglePause();
break;
default:
break;
}
return false;
}
public void setMusic(MusicManager music) {
this.music = music;
}
public void setStatusColor(Color color) {
leftStatusBar.setColor(color);
rightStatusBar.setColor(color);
}
public void setLeftStatusColor(Color color) {
leftStatusBar.setColor(color);
}
public void setRightStatusColor(Color color) {
rightStatusBar.setColor(color);
}
public void changeStatusColor(Color color, float duration, Color endColor) {
leftStatusBar.clearActions();
rightStatusBar.clearActions();
leftStatusBar.addAction(Actions.sequence(Actions.color(color, duration*0.8f), Actions.color(endColor, duration)));
rightStatusBar.addAction(Actions.sequence(Actions.color(color, duration*0.8f), Actions.color(endColor, duration)));
}
public HealthBar getHealthBar() {
return healthBar;
}
@Override
public void dispose() {
leftStatTexture.dispose();
rightStatTexture.dispose();
super.dispose();
}
}

View File

@@ -1,148 +0,0 @@
package zero1hd.rhythmbullet.stages;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.FitViewport;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.map.EntitySpawnInfo;
import zero1hd.rhythmbullet.audio.map.GamePlayMap;
import zero1hd.rhythmbullet.audio.map.MapWindowData;
import zero1hd.rhythmbullet.controls.KeyMap;
import zero1hd.rhythmbullet.entity.CollisionDetector;
import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityManager;
import zero1hd.rhythmbullet.entity.ally.Laser;
import zero1hd.rhythmbullet.entity.ally.PolyjetEntity;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
import zero1hd.rhythmbullet.util.ScoreManager;
public class GamePlayArea extends Stage {
public PolyjetEntity polyjet;
private GamePlayMap audioMap;
public CoordinatorManager cm;
public EntityManager em;
private CollisionDetector collisionDetector;
public ScoreManager score = new ScoreManager();
public GamePlayArea(AssetManager assetManager, Preferences prefs) {
super(new FitViewport(RhythmBullet.GAME_AREA_WIDTH, RhythmBullet.GAME_AREA_HEIGHT));
Gdx.app.debug("Game Area", "new area created");
polyjet = new PolyjetEntity(assetManager, 25f, 25f, 100, "standard");
em = new EntityManager(assetManager, prefs, this);
cm = new CoordinatorManager(em);
collisionDetector = new CollisionDetector(em.activeEnemies, em.activeAllies, assetManager, prefs);
em.activeAllies.add(polyjet);
addActor(polyjet);
}
public void setAudioMap(GamePlayMap audioMap) {
this.audioMap = audioMap;
}
public GamePlayMap getAudioMap() {
return audioMap;
}
@Override
public void draw() {
super.draw();
}
@Override
public void act(float delta) {
MapWindowData mwd;
if (audioMap != null && audioMap.getMusicData().isPlaying()) {
audioMap.getMusicData().playbackIndexUpdate();
if ((mwd = audioMap.getCurrentWindowBasedOnIndex()) != null) {
EntitySpawnInfo[] currentSpawnInfo = mwd.getArray();
if (currentSpawnInfo != null) {
for (int i = 0; i < currentSpawnInfo.length; i++) {
Entity entity = currentSpawnInfo[i].getEntityToSpawn().buildEntity();
if (currentSpawnInfo[i].getEntityCoordinator() != null) {
entity.setCoordinator(currentSpawnInfo[i].getEntityCoordinator().buildCoordinator());
}
entity.init(currentSpawnInfo[i].parameters);
addActor(entity);
}
}
}
}
collisionDetector.collisionCheck();
score.addScore(collisionDetector.getAmassedPoints());
super.act(delta);
}
@Override
public boolean keyDown(int keycode) {
if (keycode == KeyMap.left) {
polyjet.moveLeft = true;
}
if (keycode == KeyMap.right) {
polyjet.moveRight = true;
}
if (keycode == KeyMap.up) {
polyjet.moveUp = true;
}
if (keycode == KeyMap.down) {
polyjet.moveDown = true;
}
if (keycode == KeyMap.accelerate) {
polyjet.accelerate = true;
}
return false;
}
@Override
public boolean keyUp(int keycode) {
if (keycode == KeyMap.left) {
polyjet.moveLeft = false;
}
if (keycode == KeyMap.right) {
polyjet.moveRight = false;
}
if (keycode == KeyMap.up) {
polyjet.moveUp = false;
}
if (keycode == KeyMap.down) {
polyjet.moveDown = false;
}
if (keycode == KeyMap.accelerate) {
polyjet.accelerate = false;
}
if (keycode == KeyMap.shoot) {
Laser laser = em.laser.buildEntity();
laser.init(polyjet.getX() + polyjet.getWidth()/2f, polyjet.getY() + polyjet.getHeight()+1f, 60f);
addActor(laser);
}
return false;
}
public PolyjetEntity getPolyjetEntity() {
return polyjet;
}
@Override
public void dispose() {
super.dispose();
}
public CollisionDetector getCollisionDetector() {
return collisionDetector;
}
}

View File

@@ -1,5 +1,5 @@
package zero1hd.rhythmbullet.audio;
package zero1hd.rhythmbullet.util;
import com.badlogic.gdx.audio.Music.OnCompletionListener;
import com.badlogic.gdx.files.FileHandle;

View File

@@ -8,7 +8,7 @@ import com.badlogic.gdx.files.FileHandle;
public class RoundingResolutionHandler implements FileHandleResolver {
private final Resolution[] descriptors;
private final FileHandleResolver resolver;
private boolean silent = true;
private int width, height;
public RoundingResolutionHandler(FileHandleResolver fileResolver, Resolution... descriptors) {
if (descriptors.length == 0) throw new IllegalArgumentException("At least one Resolution needs to be supplied.");
@@ -65,9 +65,11 @@ public class RoundingResolutionHandler implements FileHandleResolver {
@Override
public FileHandle resolve(String fileName) {
Gdx.app.debug("RResolution Handler", "Finding best match for resolution: " + width + "x" + height + " for file: " + fileName);
Resolution bestRes = chooseRounded(descriptors);
Gdx.app.debug("RResolution Handler", "Selected folder: " + bestRes.folder);
if (!silent) {
Gdx.app.debug("RResolution Handler", "Finding best match for resolution: " + width + "x" + height + " for file: " + fileName);
Gdx.app.debug("RResolution Handler", "Selected folder: " + bestRes.folder);
}
FileHandle resSpecificFile = resolver.resolve(bestRes.folder + "/" + fileName);
if (!resSpecificFile.exists()) resSpecificFile = resolver.resolve(fileName);
return resSpecificFile;