hedgewars/uLocale.pas
changeset 4436 94c948a92759
parent 4403 0dfe26f48ec1
child 4807 180dbfb13903
equal deleted inserted replaced
4366:d19adc635c99 4436:94c948a92759
    18 
    18 
    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, sidBee, sidShotgun,
    23 uses uTypes;
    24             sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle,
       
    25             sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds,
       
    26             sidParachute, sidAirAttack, sidMineStrike, sidBlowTorch,
       
    27             sidGirder, sidTeleport, sidSwitch, sidMortar, sidWhip,
       
    28             sidKamikaze, sidCake, sidSeduction, sidWatermelon,
       
    29             sidHellishBomb, sidDrill, sidBallgun, sidNapalm, sidRCPlane,
       
    30             sidLowGravity, sidExtraDamage, sidInvulnerable, sidExtraTime,
       
    31             sidLaserSight, sidVampiric, sidSniperRifle, sidJetpack,
       
    32             sidMolotov, sidBirdy, sidPortalGun, sidPiano, sidGasBomb, sidSineGun, sidFlamethrower,
       
    33             sidSMine, sidHammer, sidResurrector, sidDrillStrike);
       
    34 
       
    35     TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused,
       
    36             sidConfirm, sidSuddenDeath, sidRemaining, sidFuel, sidSync,
       
    37             sidNoEndTurn, sidNotYetAvailable, sidRoundSD, sidRoundsSD, sidReady);
       
    38 
       
    39     TEventId = (eidDied, eidDrowned, eidRoundStart, eidRoundWin, eidRoundDraw,
       
    40             eidNewHealthPack, eidNewAmmoPack, eidNewUtilityPack, eidTurnSkipped, eidHurtSelf,
       
    41             eidHomerun, eidGone);
       
    42 
       
    43     TGoalStrId = (gidCaption, gidSubCaption, gidForts, gidLowGravity, gidInvulnerable,
       
    44             gidVampiric, gidKarma, gidKing, gidPlaceHog, gidArtillery,
       
    45             gidSolidLand, gidSharedAmmo, gidMineTimer, gidNoMineTimer, gidRandomMineTimer,
       
    46             gidDamageModifier, gidResetHealth, gidAISurvival, gidInfAttack, gidResetWeps, gidPerHogAmmo);
       
    47 
    24 
    48 const MAX_EVENT_STRINGS = 100;
    25 const MAX_EVENT_STRINGS = 100;
    49 var trammo:  array[TAmmoStrId] of ansistring;   // name of the weapon
       
    50     trammoc: array[TAmmoStrId] of ansistring;   // caption of the weapon
       
    51     trammod: array[TAmmoStrId] of ansistring;   // description of the weapon
       
    52     trmsg:   array[TMsgStrId]  of ansistring;   // message of the event
       
    53     trgoal:  array[TGoalStrId] of ansistring;   // message of the goal
       
    54 
    26 
    55 procedure LoadLocale(FileName: shortstring);
    27 procedure LoadLocale(FileName: shortstring);
    56 function  Format(fmt: shortstring; var arg: shortstring): shortstring;
    28 function  Format(fmt: shortstring; var arg: shortstring): shortstring;
    57 function  Format(fmt: ansistring; var arg: ansistring): ansistring;
    29 function  Format(fmt: ansistring; var arg: ansistring): ansistring;
    58 function  GetEventString(e: TEventId): ansistring;
    30 function  GetEventString(e: TEventId): ansistring;
    59 
    31 
    60 implementation
    32 implementation
    61 uses uMisc, uRandom;
    33 uses uRandom, uUtils, uVariables, uDebug;
    62 
    34 
    63 var trevt: array[TEventId] of array [0..Pred(MAX_EVENT_STRINGS)] of ansistring;
    35 var trevt: array[TEventId] of array [0..Pred(MAX_EVENT_STRINGS)] of ansistring;
    64     trevt_n: array[TEventId] of integer;
    36     trevt_n: array[TEventId] of integer;
    65 
    37 
    66 procedure LoadLocale(FileName: shortstring);
    38 procedure LoadLocale(FileName: shortstring);
    98        Delete(s, 1, 6);
    70        Delete(s, 1, 6);
    99        case a of
    71        case a of
   100            0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b+1)]:= s;
    72            0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b+1)]:= s;
   101            1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
    73            1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
   102            2: if (b >=0) and (b <= ord(High(TEventId))) then begin
    74            2: if (b >=0) and (b <= ord(High(TEventId))) then begin
   103                TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + inttostr(a) + ':' + inttostr(b), false);
    75                TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + IntToStr(a) + ':' + IntToStr(b), false);
   104                if first[TEventId(b)] then
    76                if first[TEventId(b)] then
   105                    begin
    77                    begin
   106                    trevt_n[TEventId(b)]:= 0;
    78                    trevt_n[TEventId(b)]:= 0;
   107                    first[TEventId(b)]:= false;
    79                    first[TEventId(b)]:= false;
   108                    end;
    80                    end;