author | koda |
Tue, 18 Jan 2011 23:08:47 +0100 | |
changeset 4855 | 2480ab325057 |
parent 4748 | ce9b48de1f52 |
child 4948 | c3dc41ae68fa |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1654 | 3 |
* Copyright (c) 2005, 2007, 2009 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
4 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
4 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
4 | 21 |
unit uSound; |
22 |
interface |
|
4357
a1fcfc341a52
Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents:
3825
diff
changeset
|
23 |
uses SDLh, uConsts, uTypes; |
4 | 24 |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
25 |
var MusicFN: shortstring; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
26 |
|
3038 | 27 |
procedure initModule; |
28 |
procedure freeModule; |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
29 |
|
4 | 30 |
procedure InitSound; |
31 |
procedure ReleaseSound; |
|
32 |
procedure SoundLoad; |
|
2745 | 33 |
procedure PlaySound(snd: TSound); |
3202 | 34 |
procedure PlaySound(snd: TSound; keepPlaying: boolean); |
2745 | 35 |
procedure PlaySound(snd: TSound; voicepack: PVoicepack); |
3201 | 36 |
procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean); |
3529 | 37 |
function LoopSound(snd: TSound): LongInt; |
38 |
function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; |
|
4 | 39 |
procedure PlayMusic; |
1712 | 40 |
procedure PauseMusic; |
41 |
procedure ResumeMusic; |
|
4748 | 42 |
procedure ChangeMusic; |
282 | 43 |
procedure StopSound(snd: TSound); |
2745 | 44 |
procedure StopSound(chn: LongInt); |
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
45 |
function ChangeVolume(voldelta: LongInt): LongInt; |
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
46 |
function AskForVoicepack(name: shortstring): Pointer; |
4 | 47 |
|
1097 | 48 |
|
4 | 49 |
implementation |
4461
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4404
diff
changeset
|
50 |
uses uVariables, uConsole, uUtils, uCommands, uDebug, uMobile; |
564 | 51 |
|
3418 | 52 |
const chanTPU = 32; |
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
53 |
var Volume: LongInt; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
54 |
lastChan: array [TSound] of LongInt; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
55 |
voicepacks: array[0..cMaxTeams] of TVoicepack; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
56 |
defVoicepack: PVoicepack; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
57 |
Mus: PMixMusic = nil; |
1654 | 58 |
|
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
59 |
function AskForVoicepack(name: shortstring): Pointer; |
1654 | 60 |
var i: Longword; |
61 |
begin |
|
62 |
i:= 0; |
|
3529 | 63 |
while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
64 |
begin |
3529 | 65 |
inc(i); |
66 |
TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true) |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
67 |
end; |
1654 | 68 |
|
3529 | 69 |
voicepacks[i].name:= name; |
70 |
AskForVoicepack:= @voicepacks[i] |
|
1654 | 71 |
end; |
4 | 72 |
|
73 |
procedure InitSound; |
|
2647 | 74 |
var i: TSound; |
3825 | 75 |
channels: LongInt; |
4 | 76 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
77 |
if not isSoundEnabled then exit; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
78 |
WriteToConsole('Init sound...'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
79 |
isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; |
2671
7e0f88013fe8
smaller patches, one missing Sky-lowres, IMG_Init and Mix_Init (might require newer libraries), updates to SDL bindings, code cleanup, new compile flags
koda
parents:
2647
diff
changeset
|
80 |
|
3825 | 81 |
{$IFDEF IPHONEOS} |
82 |
channels:= 1; |
|
83 |
{$ELSE} |
|
84 |
channels:= 2; |
|
85 |
{$ENDIF} |
|
86 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
87 |
if isSoundEnabled then |
3825 | 88 |
isSoundEnabled:= Mix_OpenAudio(44100, $8010, channels, 1024) = 0; |
2327 | 89 |
|
3182 | 90 |
{$IFDEF SDL_MIXER_NEWER} |
91 |
WriteToConsole('Init SDL_mixer... '); |
|
92 |
SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); |
|
93 |
WriteLnToConsole(msgOK); |
|
94 |
{$ENDIF} |
|
95 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
96 |
if isSoundEnabled then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
97 |
WriteLnToConsole(msgOK) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
98 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
99 |
WriteLnToConsole(msgFailed); |
2647 | 100 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
101 |
Mix_AllocateChannels(Succ(chanTPU)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
102 |
if isMusicEnabled then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
103 |
Mix_VolumeMusic(50); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
104 |
for i:= Low(TSound) to High(TSound) do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
105 |
lastChan[i]:= -1; |
2671
7e0f88013fe8
smaller patches, one missing Sky-lowres, IMG_Init and Mix_Init (might require newer libraries), updates to SDL bindings, code cleanup, new compile flags
koda
parents:
2647
diff
changeset
|
106 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
107 |
Volume:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
108 |
ChangeVolume(cInitVolume) |
4 | 109 |
end; |
110 |
||
111 |
procedure ReleaseSound; |
|
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
112 |
var i: TSound; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
113 |
t: Longword; |
4 | 114 |
begin |
3529 | 115 |
for t:= 0 to cMaxTeams do |
116 |
if voicepacks[t].name <> '' then |
|
117 |
for i:= Low(TSound) to High(TSound) do |
|
118 |
if voicepacks[t].chunks[i] <> nil then |
|
119 |
Mix_FreeChunk(voicepacks[t].chunks[i]); |
|
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
120 |
|
3529 | 121 |
if Mus <> nil then |
122 |
Mix_FreeMusic(Mus); |
|
3182 | 123 |
|
124 |
{$IFDEF SDL_MIXER_NEWER} |
|
3529 | 125 |
// make sure all instances of sdl_mixer are unloaded before continuing |
126 |
while Mix_Init(0) <> 0 do |
|
127 |
Mix_Quit(); |
|
3697 | 128 |
{$ENDIF} |
3182 | 129 |
|
3529 | 130 |
Mix_CloseAudio(); |
4 | 131 |
end; |
132 |
||
133 |
procedure SoundLoad; |
|
134 |
var i: TSound; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
135 |
t: Longword; |
3667 | 136 |
s:shortstring; |
4 | 137 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
138 |
if not isSoundEnabled then exit; |
1656
209cf0e2fc36
Finish voicepacks support in engine (not tested though)
unc0rr
parents:
1654
diff
changeset
|
139 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
140 |
defVoicepack:= AskForVoicepack('Default'); |
3697 | 141 |
|
3529 | 142 |
for t:= 0 to cMaxTeams do |
143 |
if voicepacks[t].name <> '' then |
|
144 |
for i:= Low(TSound) to High(TSound) do |
|
3667 | 145 |
voicepacks[t].chunks[i]:= nil; |
3697 | 146 |
|
3667 | 147 |
for i:= Low(TSound) to High(TSound) do |
148 |
begin |
|
149 |
defVoicepack^.chunks[i]:= nil; |
|
150 |
// preload all the big sound files (>32k) that would otherwise lockup the game |
|
4461
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4404
diff
changeset
|
151 |
if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, |
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4404
diff
changeset
|
152 |
sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo]) |
3667 | 153 |
and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then |
154 |
begin |
|
155 |
s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
|
156 |
WriteToConsole(msgLoading + s + ' '); |
|
157 |
defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
|
158 |
TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true); |
|
159 |
WriteLnToConsole(msgOK); |
|
160 |
end; |
|
161 |
end; |
|
3664 | 162 |
|
4 | 163 |
end; |
164 |
||
2745 | 165 |
procedure PlaySound(snd: TSound); |
166 |
begin |
|
3201 | 167 |
PlaySound(snd, nil, false); |
2745 | 168 |
end; |
169 |
||
3202 | 170 |
procedure PlaySound(snd: TSound; keepPlaying: boolean); |
171 |
begin |
|
172 |
PlaySound(snd, nil, keepPlaying); |
|
173 |
end; |
|
174 |
||
2745 | 175 |
procedure PlaySound(snd: TSound; voicepack: PVoicepack); |
4 | 176 |
begin |
3201 | 177 |
PlaySound(snd, voicepack, false); |
178 |
end; |
|
179 |
||
180 |
procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean); |
|
3664 | 181 |
var s:shortstring; |
3201 | 182 |
begin |
4461
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4404
diff
changeset
|
183 |
if (not isSoundEnabled) or fastUntilLag or isDeviceMute() then |
3529 | 184 |
exit; |
3201 | 185 |
|
3529 | 186 |
if keepPlaying and (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then |
187 |
exit; |
|
188 |
||
3664 | 189 |
if (voicepack <> nil) then |
190 |
begin |
|
191 |
if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then |
|
192 |
begin |
|
193 |
s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
|
194 |
WriteToConsole(msgLoading + s + ' '); |
|
195 |
voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
|
196 |
if voicepack^.chunks[snd] = nil then |
|
197 |
WriteLnToConsole(msgFailed) |
|
198 |
else |
|
199 |
WriteLnToConsole(msgOK) |
|
200 |
end; |
|
3529 | 201 |
lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], 0, -1) |
3664 | 202 |
end |
3529 | 203 |
else |
3664 | 204 |
begin |
205 |
if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then |
|
206 |
begin |
|
207 |
s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
|
208 |
WriteToConsole(msgLoading + s + ' '); |
|
209 |
defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
|
210 |
TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); |
|
211 |
WriteLnToConsole(msgOK); |
|
212 |
end; |
|
3529 | 213 |
lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1) |
3664 | 214 |
end; |
4 | 215 |
end; |
216 |
||
2745 | 217 |
function LoopSound(snd: TSound): LongInt; |
218 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
219 |
LoopSound:= LoopSound(snd, nil) |
2745 | 220 |
end; |
221 |
||
222 |
function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; |
|
3664 | 223 |
var s: shortstring; |
2647 | 224 |
begin |
4461
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4404
diff
changeset
|
225 |
if (not isSoundEnabled) or fastUntilLag or isDeviceMute() then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
226 |
begin |
3529 | 227 |
LoopSound:= -1; |
228 |
exit |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
229 |
end; |
2647 | 230 |
|
3664 | 231 |
if (voicepack <> nil) then |
232 |
begin |
|
233 |
if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then |
|
234 |
begin |
|
235 |
s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
|
236 |
WriteToConsole(msgLoading + s + ' '); |
|
237 |
voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
|
238 |
if voicepack^.chunks[snd] = nil then |
|
239 |
WriteLnToConsole(msgFailed) |
|
240 |
else |
|
241 |
WriteLnToConsole(msgOK) |
|
242 |
end; |
|
3529 | 243 |
LoopSound:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1) |
3664 | 244 |
end |
3529 | 245 |
else |
3664 | 246 |
begin |
247 |
if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then |
|
248 |
begin |
|
249 |
s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
|
250 |
WriteToConsole(msgLoading + s + ' '); |
|
251 |
defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
|
252 |
TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); |
|
253 |
WriteLnToConsole(msgOK); |
|
254 |
end; |
|
255 |
LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1); |
|
256 |
end; |
|
2647 | 257 |
end; |
258 |
||
282 | 259 |
procedure StopSound(snd: TSound); |
4 | 260 |
begin |
3529 | 261 |
if not isSoundEnabled then exit; |
262 |
if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
263 |
begin |
3529 | 264 |
Mix_HaltChannel(lastChan[snd]); |
265 |
lastChan[snd]:= -1; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
266 |
end; |
4 | 267 |
end; |
268 |
||
2745 | 269 |
procedure StopSound(chn: LongInt); |
270 |
begin |
|
3529 | 271 |
if not isSoundEnabled then exit; |
272 |
||
273 |
if (chn <> -1) and (Mix_Playing(chn) <> 0) then |
|
274 |
Mix_HaltChannel(chn); |
|
2745 | 275 |
end; |
276 |
||
4 | 277 |
procedure PlayMusic; |
2905 | 278 |
var s: shortstring; |
4 | 279 |
begin |
3529 | 280 |
if (not isSoundEnabled) or (MusicFN = '') or (not isMusicEnabled) then |
281 |
exit; |
|
282 |
||
283 |
s:= PathPrefix + '/Music/' + MusicFN; |
|
284 |
WriteToConsole(msgLoading + s + ' '); |
|
565 | 285 |
|
3529 | 286 |
Mus:= Mix_LoadMUS(Str2PChar(s)); |
287 |
TryDo(Mus <> nil, msgFailed, false); |
|
288 |
WriteLnToConsole(msgOK); |
|
565 | 289 |
|
3529 | 290 |
SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, false) |
4 | 291 |
end; |
292 |
||
371 | 293 |
function ChangeVolume(voldelta: LongInt): LongInt; |
174 | 294 |
begin |
3529 | 295 |
if not isSoundEnabled then |
296 |
exit(0); |
|
2327 | 297 |
|
3529 | 298 |
inc(Volume, voldelta); |
299 |
if Volume < 0 then Volume:= 0; |
|
300 |
Mix_Volume(-1, Volume); |
|
301 |
Volume:= Mix_Volume(-1, -1); |
|
302 |
if isMusicEnabled then Mix_VolumeMusic(Volume * 4 div 8); |
|
303 |
ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME |
|
174 | 304 |
end; |
305 |
||
1712 | 306 |
procedure PauseMusic; |
307 |
begin |
|
3529 | 308 |
if (MusicFN = '') or (not isMusicEnabled) then |
309 |
exit; |
|
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
310 |
|
3529 | 311 |
Mix_PauseMusic(Mus); |
1712 | 312 |
end; |
313 |
||
314 |
procedure ResumeMusic; |
|
315 |
begin |
|
3529 | 316 |
if (MusicFN = '') or (not isMusicEnabled) then |
317 |
exit; |
|
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
318 |
|
3529 | 319 |
Mix_ResumeMusic(Mus); |
1712 | 320 |
end; |
321 |
||
4748 | 322 |
procedure ChangeMusic; |
323 |
begin |
|
324 |
if (MusicFN = '') or (not isMusicEnabled) then |
|
325 |
exit; |
|
326 |
||
327 |
if Mus <> nil then |
|
328 |
Mix_FreeMusic(Mus); |
|
329 |
||
330 |
PlayMusic; |
|
331 |
end; |
|
332 |
||
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
333 |
procedure chVoicepack(var s: shortstring); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
334 |
begin |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
335 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/voicepack"', true); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
336 |
if s[1]='"' then Delete(s, 1, 1); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
337 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
338 |
CurrentTeam^.voicepack:= AskForVoicepack(s) |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
339 |
end; |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
340 |
|
3038 | 341 |
procedure initModule; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
342 |
begin |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
343 |
RegisterVariable('voicepack', vtCommand, @chVoicepack, false); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
344 |
MusicFN:=''; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
345 |
end; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
346 |
|
3038 | 347 |
procedure freeModule; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
348 |
begin |
3615 | 349 |
if isSoundEnabled then |
350 |
ReleaseSound(); |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
351 |
end; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
352 |
|
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
353 |
end. |
2192
4763a778c033
- Fix quickplay sound bug triggered by two faults: ttsmj's (passing voicepack with empty name in team config) and koda's (he changed fallback to default scheme condition)
unc0rr
parents:
2191
diff
changeset
|
354 |