hedgewars/uLocale.pas
changeset 2948 3f21a9dc93d0
parent 2908 bd1909984a09
child 2999 30c4d62cd0c3
equal deleted inserted replaced
2947:803b277e4894 2948:3f21a9dc93d0
    19 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    20 
    20 
    21 unit uLocale;
    21 unit uLocale;
    22 interface
    22 interface
    23 type TAmmoStrId = (sidNothing, sidGrenade, sidClusterBomb, sidBazooka, sidUFO, sidShotgun,
    23 type TAmmoStrId = (sidNothing, sidGrenade, sidClusterBomb, sidBazooka, sidUFO, sidShotgun,
    24 			sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle,
    24             sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle,
    25 			sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds,
    25             sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds,
    26 			sidParachute, sidAirAttack, sidMineStrike, sidBlowTorch,
    26             sidParachute, sidAirAttack, sidMineStrike, sidBlowTorch,
    27 			sidGirder, sidTeleport, sidSwitch, sidMortar, sidWhip,
    27             sidGirder, sidTeleport, sidSwitch, sidMortar, sidWhip,
    28 			sidKamikaze, sidCake, sidSeduction, sidWatermelon,
    28             sidKamikaze, sidCake, sidSeduction, sidWatermelon,
    29 			sidHellishBomb, sidDrill, sidBallgun, sidNapalm, sidRCPlane,
    29             sidHellishBomb, sidDrill, sidBallgun, sidNapalm, sidRCPlane,
    30             sidLowGravity, sidExtraDamage, sidInvulnerable, sidExtraTime,
    30             sidLowGravity, sidExtraDamage, sidInvulnerable, sidExtraTime,
    31             sidLaserSight, sidVampiric, sidSniperRifle, sidJetpack, sidMolotov);
    31             sidLaserSight, sidVampiric, sidSniperRifle, sidJetpack, sidMolotov);
    32 
    32 
    33 	TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused,
    33     TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused,
    34 			sidConfirm, sidSuddenDeath, sidRemaining, sidFuel, sidSync,
    34             sidConfirm, sidSuddenDeath, sidRemaining, sidFuel, sidSync,
    35 			sidNoEndTurn, sidNotYetAvailable);
    35             sidNoEndTurn, sidNotYetAvailable);
    36 
    36 
    37 	TEventId = (eidDied, eidDrowned, eidRoundStart, eidRoundWin, eidRoundDraw,
    37     TEventId = (eidDied, eidDrowned, eidRoundStart, eidRoundWin, eidRoundDraw,
    38 			eidNewHealthPack, eidNewAmmoPack, eidNewUtilityPack, eidTurnSkipped, eidHurtSelf,
    38             eidNewHealthPack, eidNewAmmoPack, eidNewUtilityPack, eidTurnSkipped, eidHurtSelf,
    39 			eidHomerun, eidFrozen);
    39             eidHomerun, eidFrozen);
    40 
    40 
    41 	TGoalStrId = (gidCaption, gidSubCaption, gidForts, gidLowGravity, gidInvulnerable,
    41     TGoalStrId = (gidCaption, gidSubCaption, gidForts, gidLowGravity, gidInvulnerable,
    42 			gidVampiric, gidKarma, gidKing, gidPlaceHog, gidArtillery,
    42             gidVampiric, gidKarma, gidKing, gidPlaceHog, gidArtillery,
    43 			gidSolidLand, gidSharedAmmo, gidMineTimer, gidNoMineTimer, gidRandomMineTimer,
    43             gidSolidLand, gidSharedAmmo, gidMineTimer, gidNoMineTimer, gidRandomMineTimer,
    44 			gidDamageModifier);
    44             gidDamageModifier);
    45 
    45 
    46 const MAX_EVENT_STRINGS = 100;
    46 const MAX_EVENT_STRINGS = 100;
    47 var trammo: array[TAmmoStrId] of ansistring;
    47 var trammo: array[TAmmoStrId] of ansistring;
    48     trammoc: array[TAmmoStrId] of ansistring;
    48     trammoc: array[TAmmoStrId] of ansistring;
    49     trammod: array[TAmmoStrId] of ansistring;
    49     trammod: array[TAmmoStrId] of ansistring;
    57 function GetEventString(e: TEventId): ansistring;
    57 function GetEventString(e: TEventId): ansistring;
    58 
    58 
    59 implementation
    59 implementation
    60 uses uMisc, uRandom, uConsole;
    60 uses uMisc, uRandom, uConsole;
    61 
    61 
    62 var	trevt: array[TEventId] of array [0..Pred(MAX_EVENT_STRINGS)] of ansistring;
    62 var trevt: array[TEventId] of array [0..Pred(MAX_EVENT_STRINGS)] of ansistring;
    63 	trevt_n: array[TEventId] of integer;
    63     trevt_n: array[TEventId] of integer;
    64 
    64 
    65 procedure LoadLocale(FileName: shortstring);
    65 procedure LoadLocale(FileName: shortstring);
    66 var s: shortstring;
    66 var s: shortstring;
    67     f: textfile;
    67     f: textfile;
    68     a, b, c: LongInt;
    68     a, b, c: LongInt;
    69 	first: array[TEventId] of boolean;
    69     first: array[TEventId] of boolean;
    70 	e: TEventId;
    70     e: TEventId;
    71     loaded: boolean;
    71     loaded: boolean;
    72 begin
    72 begin
    73 loaded:= false;
    73 loaded:= false;
    74 trammo[sidNothing]:= ' ';
    74 trammo[sidNothing]:= ' ';
    75 for e:= Low(TEventId) to High(TEventId) do first[e]:= true;
    75 for e:= Low(TEventId) to High(TEventId) do first[e]:= true;
   118 {$I+}
   118 {$I+}
   119 end;
   119 end;
   120 
   120 
   121 function GetEventString(e: TEventId): ansistring;
   121 function GetEventString(e: TEventId): ansistring;
   122 begin
   122 begin
   123 	if trevt_n[e] = 0 then // no messages for this event type?
   123     if trevt_n[e] = 0 then // no messages for this event type?
   124 		GetEventString:= '*missing translation*'
   124         GetEventString:= '*missing translation*'
   125 	else
   125     else
   126 		GetEventString:= trevt[e][GetRandom(trevt_n[e])]; // Pick a random message and return it
   126         GetEventString:= trevt[e][GetRandom(trevt_n[e])]; // Pick a random message and return it
   127 end;
   127 end;
   128 
   128 
   129 function Format(fmt: shortstring; var arg: shortstring): shortstring;
   129 function Format(fmt: shortstring; var arg: shortstring): shortstring;
   130 var i: LongInt;
   130 var i: LongInt;
   131 begin
   131 begin