104 i:= 0; |
104 i:= 0; |
105 // First, attempt to locate a localised version of the voice |
105 // First, attempt to locate a localised version of the voice |
106 if cLocale <> 'en' then |
106 if cLocale <> 'en' then |
107 begin |
107 begin |
108 locName:= name+'_'+cLocale; |
108 locName:= name+'_'+cLocale; |
109 path:= Pathz[ptVoices] + '/' + locName; |
109 path:= UserPathz[ptVoices] + '/' + locName; |
110 if DirectoryExists(path) then name:= locName |
110 if DirectoryExists(path) then name:= locName |
111 else if Length(cLocale) > 2 then |
111 else |
112 begin |
112 begin |
113 locName:= name+'_'+Copy(cLocale,1,2); |
|
114 path:= Pathz[ptVoices] + '/' + locName; |
113 path:= Pathz[ptVoices] + '/' + locName; |
115 if DirectoryExists(path) then name:= locName |
114 if DirectoryExists(path) then name:= locName |
|
115 else if Length(cLocale) > 2 then |
|
116 begin |
|
117 locName:= name+'_'+Copy(cLocale,1,2); |
|
118 path:= UserPathz[ptVoices] + '/' + locName; |
|
119 if DirectoryExists(path) then name:= locName |
|
120 else |
|
121 begin |
|
122 path:= Pathz[ptVoices] + '/' + locName; |
|
123 if DirectoryExists(path) then name:= locName |
|
124 end |
|
125 end |
116 end |
126 end |
117 end; |
127 end; |
118 |
128 |
119 // If that fails, use the unmodified one |
129 // If that fails, use the unmodified one |
120 while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do |
130 while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do |
207 // preload all the big sound files (>32k) that would otherwise lockup the game |
217 // preload all the big sound files (>32k) that would otherwise lockup the game |
208 if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, |
218 if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, |
209 sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo]) |
219 sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo]) |
210 and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then |
220 and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then |
211 begin |
221 begin |
212 s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
222 s:= UserPathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
|
223 if not FileExists(s) then s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
213 WriteToConsole(msgLoading + s + ' '); |
224 WriteToConsole(msgLoading + s + ' '); |
214 defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
225 defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
215 TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true); |
226 TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true); |
216 WriteLnToConsole(msgOK); |
227 WriteLnToConsole(msgOK); |
217 end; |
228 end; |
245 |
256 |
246 if (voicepack <> nil) then |
257 if (voicepack <> nil) then |
247 begin |
258 begin |
248 if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then |
259 if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then |
249 begin |
260 begin |
250 s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
261 s:= UserPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
|
262 if not FileExists(s) then s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
251 WriteToConsole(msgLoading + s + ' '); |
263 WriteToConsole(msgLoading + s + ' '); |
252 voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
264 voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
253 if voicepack^.chunks[snd] = nil then |
265 if voicepack^.chunks[snd] = nil then |
254 WriteLnToConsole(msgFailed) |
266 WriteLnToConsole(msgFailed) |
255 else |
267 else |
259 end |
271 end |
260 else |
272 else |
261 begin |
273 begin |
262 if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then |
274 if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then |
263 begin |
275 begin |
264 s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
276 s:= UserPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
|
277 if not FileExists(s) then s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
265 WriteToConsole(msgLoading + s + ' '); |
278 WriteToConsole(msgLoading + s + ' '); |
266 defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
279 defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
267 TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); |
280 TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); |
268 WriteLnToConsole(msgOK); |
281 WriteLnToConsole(msgOK); |
269 end; |
282 end; |
298 |
311 |
299 if (voicepack <> nil) then |
312 if (voicepack <> nil) then |
300 begin |
313 begin |
301 if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then |
314 if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then |
302 begin |
315 begin |
303 s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
316 s:= UserPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
|
317 if not FileExists(s) then s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
304 WriteToConsole(msgLoading + s + ' '); |
318 WriteToConsole(msgLoading + s + ' '); |
305 voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
319 voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
306 if voicepack^.chunks[snd] = nil then |
320 if voicepack^.chunks[snd] = nil then |
307 WriteLnToConsole(msgFailed) |
321 WriteLnToConsole(msgFailed) |
308 else |
322 else |
312 end |
326 end |
313 else |
327 else |
314 begin |
328 begin |
315 if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then |
329 if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then |
316 begin |
330 begin |
317 s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
331 s:= UserPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
|
332 if not FileExists(s) then s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
318 WriteToConsole(msgLoading + s + ' '); |
333 WriteToConsole(msgLoading + s + ' '); |
319 defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
334 defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
320 TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); |
335 TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); |
321 WriteLnToConsole(msgOK); |
336 WriteLnToConsole(msgOK); |
322 end; |
337 end; |
358 var s: shortstring; |
373 var s: shortstring; |
359 begin |
374 begin |
360 if (not isSoundEnabled) or (MusicFN = '') or (not isMusicEnabled) then |
375 if (not isSoundEnabled) or (MusicFN = '') or (not isMusicEnabled) then |
361 exit; |
376 exit; |
362 |
377 |
363 s:= PathPrefix + '/Music/' + MusicFN; |
378 s:= UserPathPrefix + '/Music/' + MusicFN; |
|
379 if not FileExists(s) then s:= PathPrefix + '/Music/' + MusicFN; |
364 WriteToConsole(msgLoading + s + ' '); |
380 WriteToConsole(msgLoading + s + ' '); |
365 |
381 |
366 Mus:= Mix_LoadMUS(Str2PChar(s)); |
382 Mus:= Mix_LoadMUS(Str2PChar(s)); |
367 TryDo(Mus <> nil, msgFailed, false); |
383 TryDo(Mus <> nil, msgFailed, false); |
368 WriteLnToConsole(msgOK); |
384 WriteLnToConsole(msgOK); |