28 sidLowGravity, sidExtraDamage, sidInvulnerable, sidExtraTime, |
28 sidLowGravity, sidExtraDamage, sidInvulnerable, sidExtraTime, |
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 |
|
34 TEventId = (eidDied, eidDrowned, eidRoundStart); |
33 |
35 |
34 var trammo: array[TAmmoStrId] of string; |
36 var trammo: array[TAmmoStrId] of string; |
35 trmsg: array[TMsgStrId] of string; |
37 trmsg: array[TMsgStrId] of string; |
|
38 trevt: array[TEventId] of array[1..100] of string; |
|
39 trevt_n: array[TEventId] of integer; |
36 |
40 |
37 procedure LoadLocale(FileName: string); |
41 procedure LoadLocale(FileName: string); |
38 function Format(fmt: shortstring; var arg: shortstring): shortstring; |
42 function Format(fmt: shortstring; var arg: shortstring): shortstring; |
|
43 |
|
44 function GetEventString(e: TEventId): string; |
39 |
45 |
40 implementation |
46 implementation |
41 uses uMisc; |
47 uses uMisc; |
42 |
48 |
43 procedure LoadLocale(FileName: string); |
49 procedure LoadLocale(FileName: string); |
44 var s: shortstring; |
50 var s: shortstring; |
45 f: textfile; |
51 f: textfile; |
46 a, b, c: LongInt; |
52 a, b, c: LongInt; |
47 begin |
53 begin |
|
54 |
|
55 // clear event locales |
|
56 for a:= 0 to ord(High(TEventId)) do trevt_n[TEventId(a)]:= 0; |
|
57 |
48 {$I-} |
58 {$I-} |
49 Assign(f, FileName); |
59 Assign(f, FileName); |
50 reset(f); |
60 reset(f); |
51 TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true); |
61 TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true); |
52 while not eof(f) do |
62 while not eof(f) do |
63 TryDo(s[6] = '=', 'Load locale: "=" expected', true); |
73 TryDo(s[6] = '=', 'Load locale: "=" expected', true); |
64 Delete(s, 1, 6); |
74 Delete(s, 1, 6); |
65 case a of |
75 case a of |
66 0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s; |
76 0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s; |
67 1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s; |
77 1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s; |
|
78 2: if (b >=0) and (b <= ord(High(TEventId))) then begin |
|
79 inc(trevt_n[TEventId(b)]); |
|
80 trevt[TEventId(b)][trevt_n[TEventId(b)]]:= s; |
|
81 end; |
68 end; |
82 end; |
69 end; |
83 end; |
70 Close(f) |
84 Close(f) |
71 {$I+} |
85 {$I+} |
|
86 end; |
|
87 |
|
88 function GetEventString(e: TEventId): string; |
|
89 begin |
|
90 if trevt_n[e] = 0 then // no messages for this event type? |
|
91 GetEventString:= '*missing translation*' |
|
92 else |
|
93 GetEventString:= trevt[e][Random(trevt_n[e]) + 1]; // Pick a random message and return it |
72 end; |
94 end; |
73 |
95 |
74 function Format(fmt: shortstring; var arg: shortstring): shortstring; |
96 function Format(fmt: shortstring; var arg: shortstring): shortstring; |
75 var i: LongInt; |
97 var i: LongInt; |
76 begin |
98 begin |