Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/java/io/BCJSON.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void check() {
UpdateJson json = Data.silent(UpdateCheck::checkUpdate);

CommonStatic.Config cfg = CommonStatic.getConfig();
List<Downloader> assets = null, musics = null, libs = null, lang;
List<Downloader> assets = null, musics = null, custMusics = null, libs = null, lang;
UpdateJson.JarJson[] jars = null;
try {
for (UpdateJson.AnnouncementJson announce : json.pc_announcement) {
Expand Down Expand Up @@ -57,6 +57,9 @@ public static void check() {
}
} else
musics = UpdateCheck.checkNewMusic(count);

int customCount = json.customMusic;
custMusics = UpdateCheck.checkNewCustomMusic(customCount);
}

ArrayList<String> langList = new ArrayList<>();
Expand All @@ -74,6 +77,7 @@ public static void check() {
clearList(libs, true);
clearList(assets, true);
clearList(musics, false);
clearList(custMusics, false);
clearList(lang, false);

Downloader font = UpdateCheck.checkFont();
Expand Down
26 changes: 25 additions & 1 deletion src/main/java/io/BCMusic.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
public class BCMusic extends Data {
private static final byte INVALID = 0, CANNON_CHARGE = 1, TOUCH = 2;
private static final short TOT = 191;
private static final short BCU_TOT = 1;
private static final byte[][] CACHE = new byte[TOT][];
private static final byte[][] BCU_CACHE = new byte[BCU_TOT][];
public final static Map<Identifier<Music>, byte[]> CACHE_CUSTOM = new LinkedHashMap<>();

public static boolean play = true;
public static Identifier<Music> music = null;
public static int VOL_BG = 20, VOL_SE = 20, VOL_UI = 20;
private static boolean[] secall = new boolean[TOT];
private static boolean[] bcu_secall = new boolean[BCU_TOT];

public static BCPlayer BG;
private static BCPlayer End;
Expand Down Expand Up @@ -214,6 +217,18 @@ public static synchronized void flush(boolean allow) {
e.printStackTrace();
}
secall = new boolean[TOT];

for (int i = 0; i < BCU_TOT; i++)
if (bcu_secall[i] && allow)
try {
if (BCU_CACHE[i] == null)
loadSound(i, UserProfile.getBCUData().musics.get(i), false, 0);
else
loadSound(i, BCU_CACHE[i]);
} catch (Exception e) {
e.printStackTrace();
}
bcu_secall = new boolean[BCU_TOT];
}

public static synchronized void play(Identifier<Music> mus) {
Expand Down Expand Up @@ -255,6 +270,12 @@ public static synchronized void setSE(int ind) {
secall[ind] = true;
}

public static synchronized void setBCUSE(int ind) {
if (!play || VOL_SE == 0)
return;
bcu_secall[ind] = true;
}

public static synchronized void setSE(Identifier<Music> mus) {
if (!play || VOL_SE == 0)
return;
Expand All @@ -266,14 +287,17 @@ public static synchronized void setSE(Identifier<Music> mus) {

try {
Music m = Identifier.get(mus);
if (m == null)
if (m == null) {
System.out.println("Sound does not exist");
return;
}
if (CACHE_CUSTOM.containsKey(mus)) {
loadSound(-1, CACHE_CUSTOM.get(mus));
} else {
Clip c = openFile(m);
if (c.getMicrosecondLength() < 10_000_000L)
CACHE_CUSTOM.put(mus, m.data.getBytes());
System.out.println("Attempting to load sound");
loadSound(-1, c); // TODO stop audio if battle is exited after
}
} catch (Exception e) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/main/MainBCU.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public void initProfile() {
AssetLoader.load(LoadPage::prog);
LoadPage.prog("reading BC data");
UserProfile.getBCData().load(LoadPage::prog, LoadPage::prog);
LoadPage.prog("reading BCU custom data");
UserProfile.getBCUData().load(LoadPage::prog, LoadPage::prog);
LoadPage.prog("reading backups");
Backup.loadBackups();

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/page/view/MusicPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public class MusicPage extends Page implements SupPage<Music> {
public MusicPage(Page p) {
super(p);
List<Music> mus = new ArrayList<>();
for (PackData pac : UserProfile.getAllPacks())
for (PackData pac : UserProfile.getAllPacks()) {
mus.addAll(pac.musics.getList());
}

jlf.setListData(mus.toArray(new Music[0]));
ini();
Expand Down