hedgewars/uLocale.pas
changeset 2143 ad05f6b2d1c0
parent 2142 48ed98cfd119
child 2144 c76a2f7bd452
equal deleted inserted replaced
2142:48ed98cfd119 2143:ad05f6b2d1c0
    29             sidLaserSight, sidVampiric, sidSniperRifle);
    29             sidLaserSight, sidVampiric, sidSniperRifle);
    30 
    30 
    31 	TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused,
    31 	TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused,
    32 			sidConfirm, sidSuddenDeath);
    32 			sidConfirm, sidSuddenDeath);
    33 			
    33 			
    34 	TEventId = (eidDied, eidDrowned, eidRoundStart);
    34 	TEventId = (eidDied, eidDrowned, eidRoundStart, eidRoundWin, eidRoundDraw,
       
    35 			eidNewHealthPack, eidNewAmmoPack, eidNewUtilityPack, eidTurnSkipped, eidHurtSelf);
    35 
    36 
    36 const MAX_EVENT_STRINGS = 100;
    37 const MAX_EVENT_STRINGS = 100;
    37 
       
    38 var trammo: array[TAmmoStrId] of string;
    38 var trammo: array[TAmmoStrId] of string;
    39     trmsg: array[TMsgStrId] of string;
    39     trmsg: array[TMsgStrId] of string;
    40 
    40 
    41 procedure LoadLocale(FileName: string);
    41 procedure LoadLocale(FileName: string);
    42 function Format(fmt: shortstring; var arg: shortstring): shortstring;
    42 function Format(fmt: shortstring; var arg: shortstring): shortstring;
    51 
    51 
    52 procedure LoadLocale(FileName: string);
    52 procedure LoadLocale(FileName: string);
    53 var s: shortstring;
    53 var s: shortstring;
    54     f: textfile;
    54     f: textfile;
    55     a, b, c: LongInt;
    55     a, b, c: LongInt;
    56     e: TEventId;
    56 	first: array[TEventId] of boolean;
    57 begin
    57 begin
    58 
    58 
    59 // clear event locales
    59 // clear event locales
    60 for e:= Low(TEventId) to High(TEventId) do trevt_n[e]:= 0;
    60 //for a:= 0 to ord(High(TEventId)) do trevt_n[TEventId(a)]:= 0;
       
    61 
       
    62 for a:= ord(Low(TEventId)) to ord(High(TEventId)) do first[TEventId(a)]:= true;
    61 
    63 
    62 {$I-}
    64 {$I-}
    63 Assign(f, FileName);
    65 Assign(f, FileName);
    64 reset(f);
    66 reset(f);
    65 TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true);
    67 TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true);
    78 	Delete(s, 1, 6);
    80 	Delete(s, 1, 6);
    79 	case a of
    81 	case a of
    80 		0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s;
    82 		0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s;
    81 		1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
    83 		1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
    82 		2: if (b >=0) and (b <= ord(High(TEventId))) then begin
    84 		2: if (b >=0) and (b <= ord(High(TEventId))) then begin
    83 			TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings', true);
    85 			TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + inttostr(a) + ':' + inttostr(b), false);
       
    86 			if first[TEventId(b)] then
       
    87 				begin
       
    88 				trevt_n[TEventId(b)]:= 0;
       
    89 				first[TEventId(b)]:= false;
       
    90 				end;
    84 			trevt[TEventId(b)][trevt_n[TEventId(b)]]:= s;
    91 			trevt[TEventId(b)][trevt_n[TEventId(b)]]:= s;
    85 			inc(trevt_n[TEventId(b)]);
    92 			inc(trevt_n[TEventId(b)]);
    86 			end;
    93 			end;
    87 		end;
    94 		end;
    88 	end;
    95 	end;