diff --git a/battle/entity/Entity.java b/battle/entity/Entity.java index 087b34b4..0e693903 100755 --- a/battle/entity/Entity.java +++ b/battle/entity/Entity.java @@ -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.*; diff --git a/io/assets/Admin.java b/io/assets/Admin.java index 070c4bb4..89ba7b47 100644 --- a/io/assets/Admin.java +++ b/io/assets/Admin.java @@ -89,6 +89,9 @@ public void initProfile() { UserProfile.getBCData().load((str) -> { }, (d) -> { }); + UserProfile.getBCUData().load((str) -> { + }, (d) -> { + }); BasisSet.read(); // UserProfile.loadPacks(); TODO } diff --git a/io/assets/UpdateCheck.java b/io/assets/UpdateCheck.java index 4884b6b4..89f133da 100644 --- a/io/assets/UpdateCheck.java +++ b/io/assets/UpdateCheck.java @@ -116,6 +116,7 @@ public static class AnnouncementJson { public ApkJson[] apk_update; public long text_update; public int music; + public int customMusic; } @@ -246,6 +247,33 @@ public static List checkNewMusic(int count) { return ans; } + public static List 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 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> checkMusic(int count) { return () -> { boolean[] exi = new boolean[count]; diff --git a/pack/Identifier.java b/pack/Identifier.java index 808d4b79..cdd12bd6 100644 --- a/pack/Identifier.java +++ b/pack/Identifier.java @@ -22,6 +22,7 @@ public class Identifier> implements Comparable>, Cloneable { public static final String DEF = "000000"; + public static final String BCU = "000001"; @Nullable public static > T get(Identifier id) { diff --git a/pack/PackData.java b/pack/PackData.java index 3e601b81..ae7a677d 100644 --- a/pack/PackData.java +++ b/pack/PackData.java @@ -276,6 +276,50 @@ private void loadUnits(Consumer 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 progress, Consumer 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; diff --git a/pack/UserProfile.java b/pack/UserProfile.java index 4c190760..b8b64d42 100644 --- a/pack/UserProfile.java +++ b/pack/UserProfile.java @@ -71,11 +71,12 @@ public static List getAll(String pack, Class cls) { } /** - * get all packs, including default pack + * get all packs, including default and bcu pack */ public static Collection getAllPacks() { List ans = new ArrayList<>(); ans.add(getBCData()); + ans.add(getBCUData()); ans.addAll(getUserPacks()); return ans; } @@ -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 */ @@ -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 packmap = new HashMap<>(); public final Set packlist = new HashSet<>();