44
55import com .badlogic .gdx .audio .Sound ;
66
7- import snoddasmannen .galimulator .AudioManager$AudioSample ;
7+ /**
8+ * Wrapper for sounds. They can be used to enrich the user experience, however this does not meant that the game is limited to
9+ * this selection of sounds, as extensions can implement their own sounds. Due to the relative simplicity of such actions,
10+ * the Starloader API does not (yet) provide a harmony or registry API for this and extensions need to work out their own
11+ * systems to do these actions.
12+ */
13+ public abstract class AudioSampleWrapper implements ResourceWrapper <Sound > {
814
9- public final class AudioSampleWrapper implements ResourceWrapper < Sound > { // TODO maybe we can use the AudioSample directly, but how would an IDE react to this?
15+ public static AudioSampleWrapper ACTOR_ORDERED = null ;
1016
17+ public static AudioSampleWrapper ACTOR_SELECTED = null ;
18+
19+ public static AudioSampleWrapper ALARM = null ;
20+ public static AudioSampleWrapper BAD_MINI = null ;
21+ public static AudioSampleWrapper BIG_LASER = null ;
22+ public static AudioSampleWrapper BIGBOOM_1 = null ;
23+ public static AudioSampleWrapper BIGBOOM_2 = null ;
24+ public static AudioSampleWrapper CLONE = null ;
25+ public static AudioSampleWrapper GOOD_MINI = null ;
26+ public static AudioSampleWrapper HEALRAY = null ;
27+ public static AudioSampleWrapper HIT_1 = null ;
28+ public static AudioSampleWrapper HIT_2 = null ;
29+ public static AudioSampleWrapper HIT_3 = null ;
30+ public static AudioSampleWrapper MISSILE = null ;
31+ public static AudioSampleWrapper SMALL_LASER = null ;
32+ public static AudioSampleWrapper UI_BIG_SELECT = null ;
33+ public static AudioSampleWrapper UI_ERROR = null ;
34+ public static AudioSampleWrapper UI_SMALL_SELECT = null ;
35+ /**
36+ * The location of the resource within the respective data folder.
37+ */
1138 private final String location ;
12- private final AudioManager$AudioSample sample ;
39+ /**
40+ * The sound resource that should be used
41+ */
1342 private final Sound sound ;
1443
15- // This is madness
16- public static final AudioSampleWrapper ACTOR_SELECTED = new AudioSampleWrapper ("uismallselect.wav" , AudioManager$AudioSample .a );
17- public static final AudioSampleWrapper ACTOR_ORDERED = new AudioSampleWrapper ("actoraction.wav" , AudioManager$AudioSample .b );
18- public static final AudioSampleWrapper GOOD_MINI = new AudioSampleWrapper ("goodmini.wav" , AudioManager$AudioSample .c );
19- public static final AudioSampleWrapper BAD_MINI = new AudioSampleWrapper ("badmini.wav" , AudioManager$AudioSample .d );
20- public static final AudioSampleWrapper UI_SMALL_SELECT = new AudioSampleWrapper ("uismallselect.wav" , AudioManager$AudioSample .e );
21- public static final AudioSampleWrapper UI_BIG_SELECT = new AudioSampleWrapper ("uiselect.wav" , AudioManager$AudioSample .f );
22- public static final AudioSampleWrapper UI_ERROR = new AudioSampleWrapper ("error.wav" , AudioManager$AudioSample .g );
23- public static final AudioSampleWrapper BIG_LASER = new AudioSampleWrapper ("biglaser.wav" , AudioManager$AudioSample .h );
24- public static final AudioSampleWrapper SMALL_LASER = new AudioSampleWrapper ("biglaser.wav" , AudioManager$AudioSample .i );
25- public static final AudioSampleWrapper HIT_1 = new AudioSampleWrapper ("smallhit1.wav" , AudioManager$AudioSample .j );
26- public static final AudioSampleWrapper HIT_2 = new AudioSampleWrapper ("smallhit2.wav" , AudioManager$AudioSample .k );
27- public static final AudioSampleWrapper HIT_3 = new AudioSampleWrapper ("smallhit3.wav" , AudioManager$AudioSample .l );
28- public static final AudioSampleWrapper ALARM = new AudioSampleWrapper ("alarm.wav" , AudioManager$AudioSample .m );
29- public static final AudioSampleWrapper BIGBOOM_1 = new AudioSampleWrapper ("bigboom1.wav" , AudioManager$AudioSample .n );
30- public static final AudioSampleWrapper BIGBOOM_2 = new AudioSampleWrapper ("bigboom2.wav" , AudioManager$AudioSample .o );
31- public static final AudioSampleWrapper HEALRAY = new AudioSampleWrapper ("healray.wav" , AudioManager$AudioSample .p );
32- public static final AudioSampleWrapper CLONE = new AudioSampleWrapper ("clone.wav" , AudioManager$AudioSample .q );
33- public static final AudioSampleWrapper MISSILE = new AudioSampleWrapper ("missile.wav" , AudioManager$AudioSample .r );
34-
35- private AudioSampleWrapper (String loc , AudioManager$AudioSample sample ) {
44+ /**
45+ * Constructor.
46+ *
47+ * @param loc The location of the resource, should be formatted like a file name
48+ * @param sample The sound sample of the instance
49+ */
50+ protected AudioSampleWrapper (String loc , Sound sample ) {
3651 this .location = loc ;
37- this .sample = sample ;
38- this .sound = sample .sound ; // FIXME DOES NOT WORK!
52+ this .sound = sample ;
3953 }
4054
4155 @ Override
@@ -48,11 +62,15 @@ private AudioSampleWrapper(String loc, AudioManager$AudioSample sample) {
4862 return sound ;
4963 }
5064
51- public void play () {
52- sample .a ();
53- }
65+ /**
66+ * Plays the sample.
67+ */
68+ public abstract void play ();
5469
55- public void play (float volume ) {
56- sample .a (volume );
57- }
70+ /**
71+ * Plays the sample at a strictly defined volume. Note that 1.0 is not always the default, however it often is.
72+ *
73+ * @param volume The volume of the sound, should range between 0.0 and 1.0
74+ */
75+ public abstract void play (float volume );
5876}
0 commit comments