1 /**
2  * @file
3  * @brief Functions used to manage sounds, but see libutil for actually playing them.
4 **/
5 
6 #pragma once
7 
8 #ifdef USE_SOUND
9 #include "options.h"
10 
11 /*************************************
12  * CONFIGURABLE CONSTANTS START HERE *
13  *************************************/
14 
15 // Uncomment to play sounds. winmm must be linked in if this is uncommented.
16 // #define WINMM_PLAY_SOUNDS
17 
18 // Uncomment (and edit as appropriate) to play sounds.
19 //
20 // WARNING: Filenames passed to this command *are not validated in any way*.
21 //
22 // #define SOUND_PLAY_COMMAND "%%LOCALBASE%%/play -v .5 \"%s\" 2>/dev/null &"
23 
24 // Uncomment this to enable playing sounds that play sounds that pause the
25 // gameplay until they finish.
26 //
27 // WARNING: This feature is not fully implemented yet!
28 //
29 // #define HOLD_SOUND_PLAY_COMMAND "%%LOCALBASE%%/play -v .5 \"%s\" 2>/dev/null"
30 
31 
32 // These are generic queues for playing sounds; they're intended for
33 // console outputs that are either so generic that regexes can't match
34 // them, or have other issues.
35 //
36 // DO NOT HARD CODE THESE STRINGS! The purpose of defining these things is
37 // to allow them to be easily language-configurable.
38 //
39 // To use them, just include the matching string in your sound option; the
40 // regex search will use that sound if it's found.
41 #define PICKUP_SOUND             "PICKUP"
42 
43 #define CHANGE_QUIVER_SOUND      "CHANGE_QUIVER"
44 #define FIRE_PROMPT_SOUND        "FIRE_PROMPT"
45 
46 #define WIELD_WEAPON_SOUND       "WIELD_WEAPON"
47 #define WIELD_NOTHING_SOUND      "WIELD_NOTHING"
48 #define EQUIP_ARMOUR_SOUND       "EQUIP_ARMOUR"
49 #define DEQUIP_ARMOUR_SOUND      "DEQUIP_ARMOUR"
50 #define WEAR_JEWELLERY_SOUND     "WEAR_JEWELLERY"
51 #define REMOVE_JEWELLERY_SOUND   "REMOVE_JEWELLERY"
52 
53 #define MEMORISE_SPELL_SOUND     "MEMORISE_SPELL"
54 
55 
56 /***********************************
57  * CONFIGURABLE CONSTANTS END HERE *
58  ***********************************/
59 
60 // This should match up with what's in play_sound, which will prioritize
61 // the various backends in a certain order.
62 #if defined(WINMM_PLAY_SOUNDS)
63  #define SOUND_BACKEND "Sound support (Windows Multimedia API)"
64 #elif defined(SOUND_PLAY_COMMAND)
65  #define SOUND_BACKEND "Sound support (External command)"
66 #elif defined(USE_SDL)
67  #define SOUND_BACKEND "Sound support (SDL_mixer)"
68 #endif
69 
70 void toggle_sound();
71 
72 void parse_sound(const string& message);
73 
74 // This function will return the sound_mapping it finds that matches
75 // the given string. If none is found, then a sound mapping with an empty
76 // string for the soundfile is returned.
77 sound_mapping check_sound_patterns(const string& message);
78 
79 void play_sound(sound_mapping sound_data);
80 void play_sound(const char *file, bool interrupt_game = false);
81 
82 
83 #endif  // End ifdef USE_SOUND
84