hedgewars/uLocale.pas
changeset 1263 24677a82531d
parent 1261 903058d382c7
child 1573 cf88e0ace609
equal deleted inserted replaced
1262:e9191c693e44 1263:24677a82531d
    17  *)
    17  *)
    18 
    18 
    19 unit uLocale;
    19 unit uLocale;
    20 interface
    20 interface
    21 type TAmmoStrId = (sidGrenade, sidClusterBomb, sidBazooka, sidUFO, sidShotgun,
    21 type TAmmoStrId = (sidGrenade, sidClusterBomb, sidBazooka, sidUFO, sidShotgun,
    22                    sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle,
    22 			sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle,
    23                    sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds,
    23 			sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds,
    24                    sidParachute, sidAirAttack, sidMineStrike, sidBlowTorch,
    24 			sidParachute, sidAirAttack, sidMineStrike, sidBlowTorch,
    25                    sidGirder, sidTeleport, sidSwitch, sidMortar, sidWhip,
    25 			sidGirder, sidTeleport, sidSwitch, sidMortar, sidWhip,
    26                    sidKamikaze, sidCake, sidSeduction, sidWatermelon);
    26 			sidKamikaze, sidCake, sidSeduction, sidWatermelon,
       
    27 			sidHellishBomb);
    27 
    28 
    28      TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused,
    29 	TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused,
    29                   sidConfirm, sidSuddenDeath);
    30 			sidConfirm, sidSuddenDeath);
    30 
    31 
    31 var trammo: array[TAmmoStrId] of string;
    32 var trammo: array[TAmmoStrId] of string;
    32     trmsg: array[TMsgStrId] of string;
    33     trmsg: array[TMsgStrId] of string;
    33 
    34 
    34 procedure LoadLocale(FileName: string);
    35 procedure LoadLocale(FileName: string);
    45 {$I-}
    46 {$I-}
    46 Assign(f, FileName);
    47 Assign(f, FileName);
    47 reset(f);
    48 reset(f);
    48 TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true);
    49 TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true);
    49 while not eof(f) do
    50 while not eof(f) do
    50       begin
    51 	begin
    51       readln(f, s);
    52 	readln(f, s);
    52       if Length(s) = 0 then continue;
    53 	if Length(s) = 0 then continue;
    53       if s[1] = ';' then continue;
    54 	if s[1] = ';' then continue;
    54       TryDo(Length(s) > 6, 'Load locale: empty string', true);
    55 	TryDo(Length(s) > 6, 'Load locale: empty string', true);
    55       val(s[1]+s[2], a, c);
    56 	val(s[1]+s[2], a, c);
    56       TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true);
    57 	TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true);
    57       TryDo(s[3] = ':', 'Load locale: ":" expected', true);
    58 	TryDo(s[3] = ':', 'Load locale: ":" expected', true);
    58       val(s[4]+s[5], b, c);
    59 	val(s[4]+s[5], b, c);
    59       TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true);
    60 	TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true);
    60       TryDo(s[6] = '=', 'Load locale: "=" expected', true);
    61 	TryDo(s[6] = '=', 'Load locale: "=" expected', true);
    61       Delete(s, 1, 6);
    62 	Delete(s, 1, 6);
    62       case a of
    63 	case a of
    63            0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s;
    64 		0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s;
    64            1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
    65 		1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
    65            end;
    66 		end;
    66       end;
    67 	end;
    67 Close(f)
    68 Close(f)
    68 {$I+}
    69 {$I+}
    69 end;
    70 end;
    70 
    71 
    71 function Format(fmt: shortstring; var arg: shortstring): shortstring;
    72 function Format(fmt: shortstring; var arg: shortstring): shortstring;