Advanced Strategic Command
soundList.h
Go to the documentation of this file.
1 #ifndef soundListH
2 #define soundListH
3 
8 #include <map>
9 
10 #include "global.h"
11 #include "sdl/sound.h"
12 #include "ascstring.h"
13 #include "textfile_evaluation.h"
14 
20  Sound* sound;
21  bool active;
22  public:
23  SoundLoopManager ( Sound* snd, bool _active = true );
24  // void setSound ( Sound* snd ) { sound = snd; };
25  void activate ( int dummy );
26  void fadeOut ( int ms ) { if ( sound && active ) sound->fadeOut( ms ); };
27  ~SoundLoopManager() { if ( sound && active ) sound->stop(); };
28 };
29 
30 
31 
35 class SoundList {
36  SoundList() {};
37  static SoundList* instance;
38 public:
39  static SoundList& getInstance();
41 
42  static void init( );
43  Sound* playSound ( Sample snd, int subType = 0, bool looping = false, const ASCString& label = "" );
44  Sound* getSound ( Sample snd, int subType = 0, const ASCString& label = "", int height = -1);
45 
46  ~SoundList();
47 private:
48  void initialize();
49 
50  typedef map<ASCString,Sound*> SoundFiles;
51  SoundFiles soundFiles;
52 
53  Sound* getSound( const ASCString& filename );
54 
55  struct SoundAssignment {
56  SoundList::Sample sample;
57  int subType;
58  Sound* defaultSound;
59  map<ASCString,Sound*> snd;
60  };
61  vector<SoundAssignment> soundAssignments;
62  void readLine( PropertyContainer& pc, const ASCString& name, SoundList::Sample sample, int subtype = 0 );
63 };
64 
65 #endif
Definition: sound.h:20
void stop()
Definition: sound.cpp:471
static SoundList & getInstance()
Definition: soundList.cpp:60
This class provides all the sounds required by the games user interface.
Definition: soundList.h:35
Functions to evaluate the parsed *.asctxt files.
void activate(int dummy)
Definition: soundList.cpp:50
Global platform dependant definitions. This file just branches to the platform specific files in thei...
SoundLoopManager(Sound *snd, bool _active=true)
Definition: soundList.cpp:43
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
static void init()
Definition: soundList.cpp:69
Sound * getSound(Sample snd, int subType=0, const ASCString &label="", int height=-1)
Definition: soundList.cpp:231
void fadeOut(int ms)
Definition: soundList.h:26
A helper class for managing looping sounds.
Definition: soundList.h:19
Sound * playSound(Sample snd, int subType=0, bool looping=false, const ASCString &label="")
Definition: soundList.cpp:265
void fadeOut(int ms)
Definition: sound.cpp:501