Skip to content

Commit

Permalink
WIP #6: recursively load SFX (easier to organize)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobmaxfrank committed Feb 16, 2016
1 parent ce3c0fe commit 52e0830
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public InternalTeam(EngineeringConsoleManager.EnhancedDamconStatus damcon_status
public void setSelected(boolean selected) {
if (selected) {
System.out.println("Selecting " + this);
AudioManager.playSound("test_2amr4.75k_16b.wav");
AudioManager.playSound("voice/test_2amr4.75k_16b.wav");
}

this.selected = selected;
Expand Down
14 changes: 10 additions & 4 deletions src/com/brindyblitz/artemis/utils/AudioManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ public abstract class AudioManager {
private static HashMap<String, File> soundBank = new HashMap<>();

public static void initialize(String path) {
File sfx = new File(path);
// TODO: SFX > make this recursive so I can better organize assets
for (File f : sfx.listFiles()) {
soundBank.put(f.getName(), f);
loadAssetsInDirectory(path, "");
}

private static void loadAssetsInDirectory(String path, String prefix) {
for (File f : new File(path).listFiles()) {
if (f.isDirectory()) {
loadAssetsInDirectory(f.getPath(), new File(prefix, f.getName()).getPath());
} else {
soundBank.put(new File(prefix, f.getName()).getPath().substring(1), f);
}
}
}

Expand Down

0 comments on commit 52e0830

Please sign in to comment.