hedgewars/uSound.pas
changeset 5107 d7fc678d78f4
parent 5052 74a81c276d67
child 5134 97827ad5c904
equal deleted inserted replaced
5104:e31409482740 5107:d7fc678d78f4
    18 
    18 
    19 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    20 
    20 
    21 unit uSound;
    21 unit uSound;
    22 interface
    22 interface
    23 uses SDLh, uConsts, uTypes;
    23 uses SDLh, uConsts, uTypes, sysutils;
    24 
    24 
    25 var MusicFN: shortstring;
    25 var MusicFN: shortstring;
    26 
    26 
    27 procedure initModule;
    27 procedure initModule;
    28 procedure freeModule;
    28 procedure freeModule;
    59     defVoicepack: PVoicepack;
    59     defVoicepack: PVoicepack;
    60     Mus: PMixMusic = nil;
    60     Mus: PMixMusic = nil;
    61 
    61 
    62 function  AskForVoicepack(name: shortstring): Pointer;
    62 function  AskForVoicepack(name: shortstring): Pointer;
    63 var i: Longword;
    63 var i: Longword;
       
    64     locName, path: shortstring;
    64 begin
    65 begin
    65 i:= 0;
    66 i:= 0;
       
    67     // First, attempt to locate a localised version of the voice
       
    68     if cLocale <> 'en' then
       
    69         begin
       
    70         locName:= name+'_'+cLocale;
       
    71         path:= Pathz[ptVoices] + '/' + locName;
       
    72         if DirectoryExists(path) then name:= locName
       
    73         else if Length(cLocale) > 2 then
       
    74             begin
       
    75             locName:= name+'_'+Copy(cLocale,1,2);
       
    76             path:= Pathz[ptVoices] + '/' + locName;
       
    77             if DirectoryExists(path) then name:= locName
       
    78             end
       
    79         end;
       
    80 
       
    81     // If that fails, use the unmodified one
    66     while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do
    82     while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do
    67     begin
    83         begin
    68         inc(i);
    84         inc(i);
    69         TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true)
    85         TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true)
    70     end;
    86         end;
    71 
    87 
    72     voicepacks[i].name:= name;
    88     voicepacks[i].name:= name;
    73     AskForVoicepack:= @voicepacks[i]
    89     AskForVoicepack:= @voicepacks[i]
    74 end;
    90 end;
    75 
    91