# HG changeset patch # User nemo # Date 1302035032 14400 # Node ID d7fc678d78f40aa59e68e0011c7af98a36922754 # Parent e31409482740fba9a4d5df2001872f1fb7e3d1d9 Allow override of voicepack with a locale voicepack. Untested, but should mean that a Default voice should use the Ukranian version if that is their locale. diff -r e31409482740 -r d7fc678d78f4 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Tue Apr 05 20:28:44 2011 +0200 +++ b/hedgewars/hwengine.pas Tue Apr 05 16:23:52 2011 -0400 @@ -266,11 +266,14 @@ LoadLocale(Pathz[ptLocale] + '/en.txt'); // Do an initial load with english if cLocaleFName <> 'en.txt' then begin + if (Length(cLocaleFName) > 6) then cLocale := Copy(cLocaleFName,1,5) + else cLocale := Copy(cLocaleFName,1,2); // Try two letter locale first before trying specific locale overrides if (Length(cLocaleFName) > 6) and (Copy(cLocaleFName,1,2)+'.txt' <> 'en.txt') then LoadLocale(Pathz[ptLocale] + '/' + Copy(cLocaleFName,1,2)+'.txt'); LoadLocale(Pathz[ptLocale] + '/' + cLocaleFName); - end; + end + else cLocale := 'en'; WriteLnToConsole(msgGettingConfig); diff -r e31409482740 -r d7fc678d78f4 hedgewars/uSound.pas --- a/hedgewars/uSound.pas Tue Apr 05 20:28:44 2011 +0200 +++ b/hedgewars/uSound.pas Tue Apr 05 16:23:52 2011 -0400 @@ -20,7 +20,7 @@ unit uSound; interface -uses SDLh, uConsts, uTypes; +uses SDLh, uConsts, uTypes, sysutils; var MusicFN: shortstring; @@ -61,13 +61,29 @@ function AskForVoicepack(name: shortstring): Pointer; var i: Longword; + locName, path: shortstring; begin i:= 0; + // First, attempt to locate a localised version of the voice + if cLocale <> 'en' then + begin + locName:= name+'_'+cLocale; + path:= Pathz[ptVoices] + '/' + locName; + if DirectoryExists(path) then name:= locName + else if Length(cLocale) > 2 then + begin + locName:= name+'_'+Copy(cLocale,1,2); + path:= Pathz[ptVoices] + '/' + locName; + if DirectoryExists(path) then name:= locName + end + end; + + // If that fails, use the unmodified one while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do - begin + begin inc(i); TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true) - end; + end; voicepacks[i].name:= name; AskForVoicepack:= @voicepacks[i] diff -r e31409482740 -r d7fc678d78f4 hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Tue Apr 05 20:28:44 2011 +0200 +++ b/hedgewars/uVariables.pas Tue Apr 05 16:23:52 2011 -0400 @@ -33,6 +33,7 @@ isSoundEnabled : boolean = true; isMusicEnabled : boolean = false; cLocaleFName : shortstring = 'en.txt'; + cLocale : shortstring = 'en'; cInitVolume : LongInt = 100; cTimerInterval : LongInt = 8; PathPrefix : shortstring = './';