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.
--- 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);
--- 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]
--- 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 = './';