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
2 changes: 2 additions & 0 deletions battle/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
import common.util.pack.EffAnim;
import common.util.pack.EffAnim.*;
import common.util.pack.Soul;
import common.util.stage.Music;
import common.util.stage.StageLimit;
import common.util.unit.Level;
import common.util.unit.Trait;
import io.BCMusic;

import java.util.*;

Expand Down
3 changes: 3 additions & 0 deletions io/assets/Admin.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public void initProfile() {
UserProfile.getBCData().load((str) -> {
}, (d) -> {
});
UserProfile.getBCUData().load((str) -> {
}, (d) -> {
});
BasisSet.read();
// UserProfile.loadPacks(); TODO
}
Expand Down
28 changes: 28 additions & 0 deletions io/assets/UpdateCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public static class AnnouncementJson {
public ApkJson[] apk_update;
public long text_update;
public int music;
public int customMusic;

}

Expand Down Expand Up @@ -246,6 +247,33 @@ public static List<Downloader> checkNewMusic(int count) {
return ans;
}

public static List<Downloader> checkNewCustomMusic(int count) {
boolean[] exists = new boolean[count];
File musicFolder = CommonStatic.ctx.getAssetFile("./music/");
if (musicFolder.exists()) {
File[] musicList = musicFolder.listFiles();

if (musicList != null) {
for (File music : musicList)
if (music.getName().length() == 9 && music.getName().endsWith("_c.ogg")) {
int id = CommonStatic.parseIntN(music.getName());
if (id < count && id != -1) // prevents array index out of bounds
exists[id] = true;
}
}
}
List<Downloader> ans = new ArrayList<>();
for (int i = 0; i < count; i++)
if (!exists[i]) {
File target = CommonStatic.ctx.getAssetFile("./music/" + Data.trio(i) + "_c.ogg");
File temp = CommonStatic.ctx.getAssetFile("./music/_c.ogg.temp");
String url = URL_MUSIC + Data.trio(i) + "_c.ogg";
ans.add(new Downloader(target, temp, "bcu custom music " + Data.trio(i), false, url));
System.out.println("bcu custom music " + Data.trio(i));
}
return ans;
}

public static Context.SupExc<List<Downloader>> checkMusic(int count) {
return () -> {
boolean[] exi = new boolean[count];
Expand Down
1 change: 1 addition & 0 deletions pack/Identifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
public class Identifier<T extends IndexContainer.Indexable<?, T>> implements Comparable<Identifier<?>>, Cloneable {

public static final String DEF = "000000";
public static final String BCU = "000001";

@Nullable
public static <T extends IndexContainer.Indexable<?, T>> T get(Identifier<T> id) {
Expand Down
44 changes: 44 additions & 0 deletions pack/PackData.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,50 @@ private void loadUnits(Consumer<Double> bar) {

}

public static class DefBcuPack extends PackData {

public VFileRoot root = new VFileRoot(".");

protected DefBcuPack() {

}

@Override
public String getSID() {
return Identifier.BCU;
}

public void load(Consumer<String> progress, Consumer<Double> bar) {
System.out.println("LOADING BCU DATA");
progress.accept("loading BCU musics");
loadMusic();
}

@Override
public String toString() {
return "Custom BCU Data";
}

private void loadMusic() {
File dict = CommonStatic.ctx.getAssetFile("./music/");
if (!dict.exists())
return;
File[] fs = dict.listFiles();
for (File f : fs) {
String str = f.getName();
if (str.length() != 9)
continue;
if (!str.endsWith("_c.ogg"))
continue;
int id = CommonStatic.parseIntN(str.substring(0, 3));
if (id == -1)
continue;
System.out.println("Loaded " + str + " as custom");
musics.set(id, new Music(new Identifier<>(Identifier.BCU, Music.class, id), 0, new FDFile(f)));
}
}
}

@JsonClass(noTag = NoTag.LOAD)
public static class PackDesc {
public String BCU_VERSION;
Expand Down
8 changes: 7 additions & 1 deletion pack/UserProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ public static <T> List<T> getAll(String pack, Class<T> cls) {
}

/**
* get all packs, including default pack
* get all packs, including default and bcu pack
*/
public static Collection<PackData> getAllPacks() {
List<PackData> ans = new ArrayList<>();
ans.add(getBCData());
ans.add(getBCUData());
ans.addAll(getUserPacks());
return ans;
}
Expand All @@ -84,6 +85,10 @@ public static DefPack getBCData() {
return profile().def;
}

public static PackData.DefBcuPack getBCUData() {
return profile().defbcu;
}

/**
* get a PackData from a String
*/
Expand Down Expand Up @@ -345,6 +350,7 @@ public static void unregister(String id) {
}

public final DefPack def = new DefPack();
public final PackData.DefBcuPack defbcu = new PackData.DefBcuPack();
public final Map<String, UserPack> packmap = new HashMap<>();

public final Set<UserPack> packlist = new HashSet<>();
Expand Down