mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
@@ -497,7 +497,10 @@ public class GameHUD extends Stage {
|
||||
}
|
||||
|
||||
private Pair<FileHandle, Music> getMusic(MusicPlaylist playlist) {
|
||||
FileHandle file = Gdx.files.absolute(playlist.getNewRandomFilename());
|
||||
String filename = playlist.getNewRandomFilename();
|
||||
if (filename == null)
|
||||
return null;
|
||||
FileHandle file = Gdx.files.absolute(filename);
|
||||
Music music = Forge.getAssets().getMusic(file);
|
||||
if (music != null) {
|
||||
currentAudioPlaylist = playlist;
|
||||
|
||||
@@ -108,7 +108,6 @@ public final class ForgeConstants {
|
||||
|
||||
private static final String CONQUEST_DIR = RES_DIR + "conquest" + PATH_SEPARATOR;
|
||||
public static final String CONQUEST_PLANES_DIR = CONQUEST_DIR + "planes" + PATH_SEPARATOR;
|
||||
|
||||
public static final String BASE_SKINS_DIR = RES_DIR + "skins" + PATH_SEPARATOR;
|
||||
public static final String COMMON_FONTS_DIR = RES_DIR + "fonts" + PATH_SEPARATOR;
|
||||
public static final String DEFAULT_SKINS_DIR = BASE_SKINS_DIR + "default" + PATH_SEPARATOR;
|
||||
@@ -480,7 +479,7 @@ public final class ForgeConstants {
|
||||
|
||||
TOP("Top of Card"), BOTTOM("Bottom of Card");
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
CounterDisplayLocation(final String name) {
|
||||
this.name = name;
|
||||
|
||||
@@ -3,6 +3,7 @@ package forge.sound;
|
||||
import forge.gui.GuiBase;
|
||||
import forge.localinstance.properties.ForgeConstants;
|
||||
import forge.util.MyRandom;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
@@ -23,7 +24,7 @@ public enum MusicPlaylist {
|
||||
|
||||
private final String subDir;
|
||||
private int mostRecentTrackIdx = -1;
|
||||
private String[] filenames;
|
||||
private File[] filenames;
|
||||
private static boolean isInvalidated = false;
|
||||
|
||||
MusicPlaylist(String subDir0) {
|
||||
@@ -38,23 +39,18 @@ public enum MusicPlaylist {
|
||||
String path = SoundSystem.instance.getMusicDirectory() + subDir;
|
||||
if (filenames == null || isInvalidated) {
|
||||
try {
|
||||
FilenameFilter filter = new FilenameFilter(){
|
||||
@Override
|
||||
public boolean accept(File file, String name) {
|
||||
return name.endsWith(".mp3") || name.endsWith(".wav") || name.endsWith(".m4a");
|
||||
}
|
||||
};
|
||||
filenames = new File(path).list(filter);
|
||||
if (GuiBase.isAdventureMode() && filenames == null) {
|
||||
FilenameFilter filter = (file, name) -> name.endsWith(".mp3") || name.endsWith(".wav") || name.endsWith(".m4a");
|
||||
filenames = new File(path).listFiles(filter);
|
||||
if (GuiBase.isAdventureMode() && filenames == null || ArrayUtils.isEmpty(filenames)) {
|
||||
path = ForgeConstants.ADVENTURE_COMMON_MUSIC_DIR + subDir;
|
||||
filenames = new File(path).list(filter);
|
||||
filenames = new File(path).listFiles(filter);
|
||||
}
|
||||
if (filenames == null)
|
||||
filenames = new String[0];
|
||||
filenames = new File[0];
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
filenames = new String[0];
|
||||
filenames = new File[0];
|
||||
}
|
||||
isInvalidated = false;
|
||||
}
|
||||
@@ -73,23 +69,18 @@ public enum MusicPlaylist {
|
||||
mostRecentTrackIdx = newIndex;
|
||||
}
|
||||
|
||||
return path + filenames[mostRecentTrackIdx];
|
||||
return filenames[mostRecentTrackIdx].getPath();
|
||||
}
|
||||
|
||||
public String getNewRandomFilename() {
|
||||
String[] music;
|
||||
File[] music;
|
||||
String path = SoundSystem.instance.getMusicDirectory() + subDir;
|
||||
try {
|
||||
FilenameFilter filter = new FilenameFilter(){
|
||||
@Override
|
||||
public boolean accept(File file, String name) {
|
||||
return name.endsWith(".mp3") || name.endsWith(".wav") || name.endsWith(".m4a");
|
||||
}
|
||||
};
|
||||
music = new File(path).list(filter);
|
||||
FilenameFilter filter = (file, name) -> name.endsWith(".mp3") || name.endsWith(".wav") || name.endsWith(".m4a");
|
||||
music = new File(path).listFiles(filter);
|
||||
if (GuiBase.isAdventureMode() && music == null) {
|
||||
path = ForgeConstants.ADVENTURE_COMMON_MUSIC_DIR + subDir;
|
||||
music = new File(path).list(filter);
|
||||
music = new File(path).listFiles(filter);
|
||||
}
|
||||
if (music == null)
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user