author | nemo |
Fri, 22 May 2009 02:01:45 +0000 | |
changeset 2087 | 79472a9be025 |
parent 2039 | 3001445b4500 |
child 2140 | 75e5c4fcae2a |
permissions | -rw-r--r-- |
184 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
925 | 3 |
* Copyright (c) 2006-2008 Andrey Korotaev <unC0Rr@gmail.com> |
184 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*) |
|
18 |
||
19 |
unit uLocale; |
|
20 |
interface |
|
21 |
type TAmmoStrId = (sidGrenade, sidClusterBomb, sidBazooka, sidUFO, sidShotgun, |
|
1263 | 22 |
sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle, |
23 |
sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds, |
|
24 |
sidParachute, sidAirAttack, sidMineStrike, sidBlowTorch, |
|
25 |
sidGirder, sidTeleport, sidSwitch, sidMortar, sidWhip, |
|
26 |
sidKamikaze, sidCake, sidSeduction, sidWatermelon, |
|
1854 | 27 |
sidHellishBomb, sidDrill, sidBallgun, sidNapalm, sidRCPlane, |
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
28 |
sidLowGravity, sidExtraDamage, sidInvulnerable, sidExtraTime, |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
29 |
sidLaserSight, sidVampiric, sidSniperRifle); |
285 | 30 |
|
1263 | 31 |
TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused, |
32 |
sidConfirm, sidSuddenDeath); |
|
285 | 33 |
|
184 | 34 |
var trammo: array[TAmmoStrId] of string; |
35 |
trmsg: array[TMsgStrId] of string; |
|
36 |
||
37 |
procedure LoadLocale(FileName: string); |
|
38 |
function Format(fmt: shortstring; var arg: shortstring): shortstring; |
|
39 |
||
40 |
implementation |
|
41 |
uses uMisc; |
|
42 |
||
43 |
procedure LoadLocale(FileName: string); |
|
44 |
var s: shortstring; |
|
45 |
f: textfile; |
|
371 | 46 |
a, b, c: LongInt; |
184 | 47 |
begin |
48 |
{$I-} |
|
351 | 49 |
Assign(f, FileName); |
184 | 50 |
reset(f); |
51 |
TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true); |
|
52 |
while not eof(f) do |
|
1263 | 53 |
begin |
54 |
readln(f, s); |
|
55 |
if Length(s) = 0 then continue; |
|
2039 | 56 |
if not (s[1] in ['0'..'9']) then continue; |
1263 | 57 |
TryDo(Length(s) > 6, 'Load locale: empty string', true); |
58 |
val(s[1]+s[2], a, c); |
|
59 |
TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true); |
|
60 |
TryDo(s[3] = ':', 'Load locale: ":" expected', true); |
|
61 |
val(s[4]+s[5], b, c); |
|
62 |
TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true); |
|
63 |
TryDo(s[6] = '=', 'Load locale: "=" expected', true); |
|
64 |
Delete(s, 1, 6); |
|
65 |
case a of |
|
66 |
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; |
|
68 |
end; |
|
69 |
end; |
|
351 | 70 |
Close(f) |
184 | 71 |
{$I+} |
72 |
end; |
|
73 |
||
74 |
function Format(fmt: shortstring; var arg: shortstring): shortstring; |
|
371 | 75 |
var i: LongInt; |
184 | 76 |
begin |
77 |
i:= Pos('%1', fmt); |
|
351 | 78 |
if i = 0 then Format:= fmt |
79 |
else Format:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg) |
|
184 | 80 |
end; |
81 |
||
82 |
end. |