author | unc0rr |
Sun, 11 Feb 2007 00:14:42 +0000 | |
changeset 429 | 7f69c7ac2e97 |
parent 409 | 4f1841929ccc |
child 520 | e83dfb7ffead |
permissions | -rw-r--r-- |
184 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
393 | 3 |
* Copyright (c) 2006, 2007 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, |
|
22 |
sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle, |
|
211 | 23 |
sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds, |
409 | 24 |
sidParachute, sidAirAttack, sidMineStrike, sidBlowTorch, |
25 |
sidGirder); |
|
285 | 26 |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
27 |
TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused); |
285 | 28 |
|
184 | 29 |
var trammo: array[TAmmoStrId] of string; |
30 |
trmsg: array[TMsgStrId] of string; |
|
31 |
||
32 |
procedure LoadLocale(FileName: string); |
|
33 |
function Format(fmt: shortstring; var arg: shortstring): shortstring; |
|
34 |
||
35 |
implementation |
|
36 |
uses uMisc; |
|
37 |
||
38 |
procedure LoadLocale(FileName: string); |
|
39 |
var s: shortstring; |
|
40 |
f: textfile; |
|
371 | 41 |
a, b, c: LongInt; |
184 | 42 |
begin |
43 |
{$I-} |
|
351 | 44 |
Assign(f, FileName); |
184 | 45 |
reset(f); |
46 |
TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true); |
|
47 |
while not eof(f) do |
|
48 |
begin |
|
49 |
readln(f, s); |
|
50 |
if Length(s) = 0 then continue; |
|
51 |
if s[1] = ';' then continue; |
|
52 |
TryDo(Length(s) > 6, 'Load locale: empty string', true); |
|
53 |
val(s[1]+s[2], a, c); |
|
54 |
TryDo(c = 0, 'Load locale: numbers should be two-digit', true); |
|
55 |
TryDo(s[3] = ':', 'Load locale: ":" expected', true); |
|
56 |
val(s[4]+s[5], b, c); |
|
57 |
TryDo(c = 0, 'Load locale: numbers should be two-digit', true); |
|
58 |
TryDo(s[6] = '=', 'Load locale: "=" expected', true); |
|
59 |
Delete(s, 1, 6); |
|
60 |
case a of |
|
61 |
0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s; |
|
62 |
1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s; |
|
63 |
end; |
|
64 |
end; |
|
351 | 65 |
Close(f) |
184 | 66 |
{$I+} |
67 |
end; |
|
68 |
||
69 |
function Format(fmt: shortstring; var arg: shortstring): shortstring; |
|
371 | 70 |
var i: LongInt; |
184 | 71 |
begin |
72 |
i:= Pos('%1', fmt); |
|
351 | 73 |
if i = 0 then Format:= fmt |
74 |
else Format:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg) |
|
184 | 75 |
end; |
76 |
||
77 |
end. |