diff --git a/client/src/main/java/com/aapeli/client/Class86.java b/client/src/main/java/com/aapeli/client/Class86.java deleted file mode 100644 index 41ec369a..00000000 --- a/client/src/main/java/com/aapeli/client/Class86.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.aapeli.client; - -import java.applet.Applet; -import java.applet.AudioClip; -import java.net.URL; - -class Class86 { - - private Applet anApplet1473; - private URL anURL1474; - private String aString1475; - private boolean aBoolean1476; - private AudioClip anAudioClip1477; - private boolean aBoolean1478; - private static final String[] aStringArray1479 = new String[2]; - - - protected Class86(Applet var1, URL var2, String var3, boolean var4) { - this.anApplet1473 = var1; - this.anURL1474 = var2; - this.aString1475 = var3; - this.aBoolean1476 = var4; - this.anAudioClip1477 = null; - this.aBoolean1478 = false; - } - - protected boolean method1682() { - return this.aBoolean1478; - } - - protected void method1683() { - if (!this.aBoolean1478) { - if (this.aBoolean1476) { - System.out.println("SoundClip.defineClip(): \'dir\'=\"" + this.anURL1474 + "\", \'file\'=\"" + this.aString1475 + "\""); - } - - //todo this.anAudioClip1477 = this.anApplet1473.getAudioClip(this.anURL1474, this.aString1475); - URL url = anURL1474; - try { - url = new URL(anURL1474, aString1475); - } catch (Exception ex) { - } - anAudioClip1477 = Applet.newAudioClip(url); - this.aBoolean1478 = true; - } - } - - protected AudioClip method1684() { - return this.anAudioClip1477; - } - - static { - aStringArray1479[0] = "SoundClip.defineClip(): \'dir\'=\""; - aStringArray1479[1] = "\", \'file\'=\""; - } -} diff --git a/client/src/main/java/com/aapeli/client/SoundClip.java b/client/src/main/java/com/aapeli/client/SoundClip.java new file mode 100755 index 00000000..5a97c480 --- /dev/null +++ b/client/src/main/java/com/aapeli/client/SoundClip.java @@ -0,0 +1,51 @@ +package com.aapeli.client; + +import java.applet.Applet; +import java.applet.AudioClip; +import java.net.URL; + +class SoundClip { + + private Applet applet; + private URL dir; + private String file; + private boolean debug; + private AudioClip audioClip; + private boolean defined; + + + protected SoundClip(Applet applet, URL dir, String file, boolean debug) { + this.applet = applet; + this.dir = dir; + this.file = file; + this.debug = debug; + this.audioClip = null; + this.defined = false; + } + + protected boolean isDefined() { + return this.defined; + } + + protected void defineClip() { + if (!this.defined) { + if (this.debug) { + System.out.println("SoundClip.defineClip(): 'dir'=\"" + this.dir + "\", 'file'=\"" + this.file + "\""); + } + + //todo this.audioClip = this.applet.getAudioClip(this.dir, this.file); + URL url = dir; + try { + url = new URL(dir, file); + } catch (Exception ex) { + System.out.println("SoundClip.defineClip(): failed to load sound clip"); + } + audioClip = Applet.newAudioClip(url); + this.defined = true; + } + } + + protected AudioClip getAudioClip() { + return this.audioClip; + } +} diff --git a/client/src/main/java/com/aapeli/client/SoundManager.java b/client/src/main/java/com/aapeli/client/SoundManager.java index e4925bee..65568537 100644 --- a/client/src/main/java/com/aapeli/client/SoundManager.java +++ b/client/src/main/java/com/aapeli/client/SoundManager.java @@ -62,11 +62,11 @@ public void run() { var3 = false; Enumeration var1 = this.aHashtable1489.elements(); - Class86 var2; + SoundClip soundClip; while (var1.hasMoreElements()) { - var2 = (Class86) ((Class86) var1.nextElement()); - if (!var2.method1682()) { - var2.method1683(); + soundClip = (SoundClip) var1.nextElement(); + if (!soundClip.isDefined()) { + soundClip.defineClip(); var3 = true; } } @@ -74,9 +74,9 @@ public void run() { var1 = this.aHashtable1490.elements(); while (var1.hasMoreElements()) { - var2 = (Class86) ((Class86) var1.nextElement()); - if (!var2.method1682()) { - var2.method1683(); + soundClip = (SoundClip) var1.nextElement(); + if (!soundClip.isDefined()) { + soundClip.defineClip(); var3 = true; } } @@ -104,8 +104,8 @@ public void defineSound(String var1, String var2) { this.anAApplet1492.printSUD("SoundManager: Defining sound \"" + var2 + "\""); } - Class86 var3 = new Class86(this.anApplet1485, this.anURL1486, var2, this.aBoolean1488); - this.aHashtable1490.put(var1, var3); + SoundClip soundClip = new SoundClip(this.anApplet1485, this.anURL1486, var2, this.aBoolean1488); + this.aHashtable1490.put(var1, soundClip); if (this.aBoolean1487) { this.method1690(); } @@ -234,7 +234,7 @@ private void method1688() { } private void method1689(int var1, URL var2, String var3) { - this.aHashtable1489.put(new Integer(var1), new Class86(this.anApplet1485, var2, var3 + ".au", this.aBoolean1488)); + this.aHashtable1489.put(new Integer(var1), new SoundClip(this.anApplet1485, var2, var3 + ".au", this.aBoolean1488)); } private synchronized void method1690() { @@ -247,11 +247,11 @@ private synchronized void method1690() { } private void method1691(int var1) { - Class86 var2 = (Class86) ((Class86) this.aHashtable1489.get(new Integer(var1))); - if (var2 != null) { - AudioClip var3 = var2.method1684(); - if (var3 != null) { - var3.play(); + SoundClip soundClip = (SoundClip) this.aHashtable1489.get(new Integer(var1)); + if (soundClip != null) { + AudioClip audioClip = soundClip.getAudioClip(); + if (audioClip != null) { + audioClip.play(); } } } @@ -262,16 +262,16 @@ private void method1692(String var1, int var2) { System.out.println("SoundManager." + aStringArray1484[var2] + "(\"" + var1 + "\")"); } - Class86 var3 = (Class86) ((Class86) this.aHashtable1490.get(var1)); - if (var3 != null) { - AudioClip var4 = var3.method1684(); - if (var4 != null) { + SoundClip soundClip = (SoundClip) this.aHashtable1490.get(var1); + if (soundClip != null) { + AudioClip audioClip = soundClip.getAudioClip(); + if (audioClip != null) { if (var2 == 0) { - var4.stop(); + audioClip.stop(); } else if (var2 == 1) { - var4.play(); + audioClip.play(); } else if (var2 == 2) { - var4.loop(); + audioClip.loop(); } } else if (this.aBoolean1488) { System.out.println("SoundManager." + aStringArray1484[var2] + "(\"" + var1 + "\"): AudioClip not ready!");