mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
@@ -497,7 +497,10 @@ public class GameHUD extends Stage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Pair<FileHandle, Music> getMusic(MusicPlaylist playlist) {
|
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);
|
Music music = Forge.getAssets().getMusic(file);
|
||||||
if (music != null) {
|
if (music != null) {
|
||||||
currentAudioPlaylist = playlist;
|
currentAudioPlaylist = playlist;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public final class ForgeConstants {
|
|||||||
public static final String RES_DIR = ASSETS_DIR + "res" + PATH_SEPARATOR;
|
public static final String RES_DIR = ASSETS_DIR + "res" + PATH_SEPARATOR;
|
||||||
public static final String ADVENTURE_DIR = RES_DIR + "adventure" + PATH_SEPARATOR;
|
public static final String ADVENTURE_DIR = RES_DIR + "adventure" + PATH_SEPARATOR;
|
||||||
public static final String ADVENTURE_DEFAULT_PLANE_DIR = ADVENTURE_DIR + "Shandalar" + PATH_SEPARATOR;
|
public static final String ADVENTURE_DEFAULT_PLANE_DIR = ADVENTURE_DIR + "Shandalar" + PATH_SEPARATOR;
|
||||||
public static final String ADVENTURE_COMMON_DIR=ADVENTURE_DIR+"common"+PATH_SEPARATOR;
|
public static final String ADVENTURE_COMMON_DIR = ADVENTURE_DIR + "common" + PATH_SEPARATOR;
|
||||||
public static final String LISTS_DIR = RES_DIR + "lists" + PATH_SEPARATOR;
|
public static final String LISTS_DIR = RES_DIR + "lists" + PATH_SEPARATOR;
|
||||||
public static final String SETLOOKUP_DIR = RES_DIR + "setlookup" + PATH_SEPARATOR;
|
public static final String SETLOOKUP_DIR = RES_DIR + "setlookup" + PATH_SEPARATOR;
|
||||||
public static final String KEYWORD_LIST_FILE = LISTS_DIR + "NonStackingKWList.txt";
|
public static final String KEYWORD_LIST_FILE = LISTS_DIR + "NonStackingKWList.txt";
|
||||||
@@ -88,7 +88,7 @@ public final class ForgeConstants {
|
|||||||
public static final String SOUND_DIR = RES_DIR + "sound" + PATH_SEPARATOR;
|
public static final String SOUND_DIR = RES_DIR + "sound" + PATH_SEPARATOR;
|
||||||
public static final String MUSIC_DIR = RES_DIR + "music" + PATH_SEPARATOR;
|
public static final String MUSIC_DIR = RES_DIR + "music" + PATH_SEPARATOR;
|
||||||
public static final String ADVENTURE_MUSIC_DIR = ADVENTURE_DEFAULT_PLANE_DIR + "music" + PATH_SEPARATOR;
|
public static final String ADVENTURE_MUSIC_DIR = ADVENTURE_DEFAULT_PLANE_DIR + "music" + PATH_SEPARATOR;
|
||||||
public static final String ADVENTURE_COMMON_MUSIC_DIR=ADVENTURE_COMMON_DIR+"music"+PATH_SEPARATOR;
|
public static final String ADVENTURE_COMMON_MUSIC_DIR = ADVENTURE_COMMON_DIR + "music" + PATH_SEPARATOR;
|
||||||
public static final String LANG_DIR = RES_DIR + "languages" + PATH_SEPARATOR;
|
public static final String LANG_DIR = RES_DIR + "languages" + PATH_SEPARATOR;
|
||||||
public static final String EFFECTS_DIR = RES_DIR + "effects" + PATH_SEPARATOR;
|
public static final String EFFECTS_DIR = RES_DIR + "effects" + PATH_SEPARATOR;
|
||||||
public static final String PUZZLE_DIR = RES_DIR + "puzzle" + PATH_SEPARATOR;
|
public static final String PUZZLE_DIR = RES_DIR + "puzzle" + PATH_SEPARATOR;
|
||||||
@@ -108,7 +108,6 @@ public final class ForgeConstants {
|
|||||||
|
|
||||||
private static final String CONQUEST_DIR = RES_DIR + "conquest" + PATH_SEPARATOR;
|
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 CONQUEST_PLANES_DIR = CONQUEST_DIR + "planes" + PATH_SEPARATOR;
|
||||||
|
|
||||||
public static final String BASE_SKINS_DIR = RES_DIR + "skins" + 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 COMMON_FONTS_DIR = RES_DIR + "fonts" + PATH_SEPARATOR;
|
||||||
public static final String DEFAULT_SKINS_DIR = BASE_SKINS_DIR + "default" + PATH_SEPARATOR;
|
public static final String DEFAULT_SKINS_DIR = BASE_SKINS_DIR + "default" + PATH_SEPARATOR;
|
||||||
@@ -143,7 +142,7 @@ public final class ForgeConstants {
|
|||||||
public static final String MATCH_BG_NIGHT_FILE = "bg_night.jpg";
|
public static final String MATCH_BG_NIGHT_FILE = "bg_night.jpg";
|
||||||
public static final String ADV_MATCH_BG_FILE = "adv_bg_match.jpg";
|
public static final String ADV_MATCH_BG_FILE = "adv_bg_match.jpg";
|
||||||
public static final String ADV_MATCH_BG_DAY_FILE = "adv_bg_match_day.jpg";
|
public static final String ADV_MATCH_BG_DAY_FILE = "adv_bg_match_day.jpg";
|
||||||
public static final String ADV_MATCH_BG_NIGHT_FILE= "adv_bg_match_nigh.jpg";
|
public static final String ADV_MATCH_BG_NIGHT_FILE = "adv_bg_match_nigh.jpg";
|
||||||
public static final String ADV_TEXTURE_BG_FILE = "adv_bg_texture.jpg";
|
public static final String ADV_TEXTURE_BG_FILE = "adv_bg_texture.jpg";
|
||||||
public static final String TEXTURE_BG_FILE = "bg_texture.jpg";
|
public static final String TEXTURE_BG_FILE = "bg_texture.jpg";
|
||||||
public static final String SPACE_BG_FILE = "bg_space.png";
|
public static final String SPACE_BG_FILE = "bg_space.png";
|
||||||
@@ -480,7 +479,7 @@ public final class ForgeConstants {
|
|||||||
|
|
||||||
TOP("Top of Card"), BOTTOM("Bottom of Card");
|
TOP("Top of Card"), BOTTOM("Bottom of Card");
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
CounterDisplayLocation(final String name) {
|
CounterDisplayLocation(final String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package forge.sound;
|
|||||||
import forge.gui.GuiBase;
|
import forge.gui.GuiBase;
|
||||||
import forge.localinstance.properties.ForgeConstants;
|
import forge.localinstance.properties.ForgeConstants;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
@@ -23,7 +24,7 @@ public enum MusicPlaylist {
|
|||||||
|
|
||||||
private final String subDir;
|
private final String subDir;
|
||||||
private int mostRecentTrackIdx = -1;
|
private int mostRecentTrackIdx = -1;
|
||||||
private String[] filenames;
|
private File[] filenames;
|
||||||
private static boolean isInvalidated = false;
|
private static boolean isInvalidated = false;
|
||||||
|
|
||||||
MusicPlaylist(String subDir0) {
|
MusicPlaylist(String subDir0) {
|
||||||
@@ -35,26 +36,21 @@ public enum MusicPlaylist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getRandomFilename() {
|
public String getRandomFilename() {
|
||||||
String path = SoundSystem.instance.getMusicDirectory()+subDir;
|
String path = SoundSystem.instance.getMusicDirectory() + subDir;
|
||||||
if (filenames == null || isInvalidated) {
|
if (filenames == null || isInvalidated) {
|
||||||
try {
|
try {
|
||||||
FilenameFilter filter = new FilenameFilter(){
|
FilenameFilter filter = (file, name) -> name.endsWith(".mp3") || name.endsWith(".wav") || name.endsWith(".m4a");
|
||||||
@Override
|
filenames = new File(path).listFiles(filter);
|
||||||
public boolean accept(File file, String name) {
|
if (GuiBase.isAdventureMode() && filenames == null || ArrayUtils.isEmpty(filenames)) {
|
||||||
return name.endsWith(".mp3") || name.endsWith(".wav") || name.endsWith(".m4a");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
filenames = new File(path).list(filter);
|
|
||||||
if (GuiBase.isAdventureMode() && filenames == null) {
|
|
||||||
path = ForgeConstants.ADVENTURE_COMMON_MUSIC_DIR + subDir;
|
path = ForgeConstants.ADVENTURE_COMMON_MUSIC_DIR + subDir;
|
||||||
filenames = new File(path).list(filter);
|
filenames = new File(path).listFiles(filter);
|
||||||
}
|
}
|
||||||
if (filenames == null)
|
if (filenames == null)
|
||||||
filenames = new String[0];
|
filenames = new File[0];
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
filenames = new String[0];
|
filenames = new File[0];
|
||||||
}
|
}
|
||||||
isInvalidated = false;
|
isInvalidated = false;
|
||||||
}
|
}
|
||||||
@@ -73,23 +69,18 @@ public enum MusicPlaylist {
|
|||||||
mostRecentTrackIdx = newIndex;
|
mostRecentTrackIdx = newIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path + filenames[mostRecentTrackIdx];
|
return filenames[mostRecentTrackIdx].getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNewRandomFilename() {
|
public String getNewRandomFilename() {
|
||||||
String[] music;
|
File[] music;
|
||||||
String path = SoundSystem.instance.getMusicDirectory() + subDir;
|
String path = SoundSystem.instance.getMusicDirectory() + subDir;
|
||||||
try {
|
try {
|
||||||
FilenameFilter filter = new FilenameFilter(){
|
FilenameFilter filter = (file, name) -> name.endsWith(".mp3") || name.endsWith(".wav") || name.endsWith(".m4a");
|
||||||
@Override
|
music = new File(path).listFiles(filter);
|
||||||
public boolean accept(File file, String name) {
|
|
||||||
return name.endsWith(".mp3") || name.endsWith(".wav") || name.endsWith(".m4a");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
music = new File(path).list(filter);
|
|
||||||
if (GuiBase.isAdventureMode() && music == null) {
|
if (GuiBase.isAdventureMode() && music == null) {
|
||||||
path = ForgeConstants.ADVENTURE_COMMON_MUSIC_DIR + subDir;
|
path = ForgeConstants.ADVENTURE_COMMON_MUSIC_DIR + subDir;
|
||||||
music = new File(path).list(filter);
|
music = new File(path).listFiles(filter);
|
||||||
}
|
}
|
||||||
if (music == null)
|
if (music == null)
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user