hedgewars/uSound.pas
branchwebgl
changeset 8833 c13ebed437cb
parent 8444 75db7bb8dce8
parent 8678 fb62d23c70f8
child 9127 e350500c4edb
equal deleted inserted replaced
8450:404ddce27b23 8833:c13ebed437cb
   103 
   103 
   104 // Returns a pointer to the voicepack with the given name.
   104 // Returns a pointer to the voicepack with the given name.
   105 function  AskForVoicepack(name: shortstring): Pointer;
   105 function  AskForVoicepack(name: shortstring): Pointer;
   106 
   106 
   107 
   107 
       
   108 var Volume: LongInt;
       
   109     SoundTimerTicks: Longword;
   108 implementation
   110 implementation
   109 uses uVariables, uConsole, uCommands, uDebug, uPhysFSLayer;
   111 uses uVariables, uConsole, uCommands, uDebug, uPhysFSLayer;
   110 
   112 
   111 const chanTPU = 32;
   113 const chanTPU = 32;
   112 var Volume: LongInt;
   114 var cInitVolume: LongInt;
   113     cInitVolume: LongInt;
       
   114     previousVolume: LongInt; // cached volume value
   115     previousVolume: LongInt; // cached volume value
   115     lastChan: array [TSound] of LongInt;
   116     lastChan: array [TSound] of LongInt;
   116     voicepacks: array[0..cMaxTeams] of TVoicepack;
   117     voicepacks: array[0..cMaxTeams] of TVoicepack;
   117     defVoicepack: PVoicepack;
   118     defVoicepack: PVoicepack;
   118     Mus: PMixMusic; // music pointer
   119     Mus: PMixMusic; // music pointer
   260     // First, attempt to locate a localised version of the voice
   261     // First, attempt to locate a localised version of the voice
   261     if cLocale <> 'en' then
   262     if cLocale <> 'en' then
   262         begin
   263         begin
   263         locName:= name+'_'+cLocale;
   264         locName:= name+'_'+cLocale;
   264         path:= cPathz[ptVoices] + '/' + locName;
   265         path:= cPathz[ptVoices] + '/' + locName;
   265         if DirectoryExists(path) then
   266         if pfsExists(path) then
   266             name:= locName
   267             name:= locName
   267         else
   268         else
   268             if Length(cLocale) > 3 then
   269             if Length(cLocale) > 3 then
   269                 begin
   270                 begin
   270                 locName:= name+'_'+Copy(cLocale,1,2);
   271                 locName:= name+'_'+Copy(cLocale,1,2);
   271                 path:= cPathz[ptVoices] + '/' + locName;
   272                 path:= cPathz[ptVoices] + '/' + locName;
   272                 if DirectoryExists(path) then
   273                 if pfsExists(path) then
   273                     name:= locName
   274                     name:= locName
   274                 end
   275                 end
   275         end;
   276         end;
   276 
   277 
   277     // If that fails, use the unmodified one
   278     // If that fails, use the unmodified one
   710     MusicFN:='';
   711     MusicFN:='';
   711     Mus:= nil;
   712     Mus:= nil;
   712     isAudioMuted:= false;
   713     isAudioMuted:= false;
   713     isSEBackup:= isSoundEnabled;
   714     isSEBackup:= isSoundEnabled;
   714     Volume:= 0;
   715     Volume:= 0;
       
   716     SoundTimerTicks:= 0;
   715     defVoicepack:= AskForVoicepack('Default');
   717     defVoicepack:= AskForVoicepack('Default');
   716 
   718 
   717     for i:= Low(TSound) to High(TSound) do
   719     for i:= Low(TSound) to High(TSound) do
   718         lastChan[i]:= -1;
   720         lastChan[i]:= -1;
   719 
   721