3 {$INCLUDE ../shared/a_modes.inc}
8 LCLIntf
, LCLType
, LMessages
, SysUtils
, Variants
, Classes
,
9 Graphics
, Controls
, Forms
, Dialogs
, StdCtrls
, ExtCtrls
, utils
;
12 TSaveMapForm
= class (TForm
)
20 procedure GetMaps(FileName
: String; placeName
: Boolean);
21 procedure FormActivate(Sender
: TObject
);
22 procedure eMapNameChange(Sender
: TObject
);
23 procedure lbMapListClick(Sender
: TObject
);
24 procedure bOKClick(Sender
: TObject
);
27 { Private declarations }
29 { Public declarations }
33 SaveMapForm
: TSaveMapForm
;
38 MAPREADER
, MAPSTRUCT
, g_language
, g_resources
, sfs
;
42 procedure TSaveMapForm
.FormActivate(Sender
: TObject
);
44 bOK
.Enabled
:= (eMapName
.Text <> '');
48 procedure TSaveMapForm
.eMapNameChange(Sender
: TObject
);
50 if eMapName
.Text <> '' then
56 procedure TSaveMapForm
.lbMapListClick(Sender
: TObject
);
58 if lbMapList
.ItemIndex
> -1 then
59 eMapName
.Text := lbMapList
.Items
[lbMapList
.ItemIndex
];
62 procedure TSaveMapForm
.bOKClick(Sender
: TObject
);
69 for a
:= 0 to lbMapList
.Count
-1 do
70 if eMapName
.Text = lbMapList
.Items
[a
] then
72 ok
:= MessageBox(0, PChar(Format(_lc
[I_MSG_MAP_EXISTS
],
74 PChar(_lc
[I_MSG_SAVE_MAP
]),
75 MB_ICONQUESTION
or MB_YESNO
or MB_DEFBUTTON1
) = mrYes
;
82 SaveMapForm
.ModalResult
:= mrOk
84 SaveMapForm
.ModalResult
:= mrCancel
;
87 procedure TSaveMapForm
.GetMaps(FileName
: String; placeName
: Boolean);
92 i
, j
, len
, max_num
: Integer;
93 sign
: Array [0..2] of Char;
95 lbMapList
.Items
.Clear();
98 list
:= SFSFileList(FileName
);
101 for i
:= 0 to list
.Count
- 1 do
103 g_ReadResource(FileName
, win2utf(list
.Files
[i
].path
), win2utf(list
.Files
[i
].name
), data
, len
);
107 sign
[0] := chr(data
[0]);
108 sign
[1] := chr(data
[1]);
109 sign
[2] := chr(data
[2]);
110 if sign
= MAP_SIGNATURE
then
112 nm
:= win2utf(list
.Files
[i
].name
);
113 lbMapList
.Items
.Add(nm
);
117 if (nm
[1] = 'M') and (nm
[2] = 'A') and (nm
[3] = 'P') then
119 nm
:= Trim(Copy(nm
, 4, Length(nm
)-3));
120 j
:= StrToIntDef(nm
, 0);
128 if len
> 0 then FreeMem(data
)
137 nm
:= IntToStr(max_num
);
138 if Length(nm
) < 2 then
140 eMapName
.Text := 'MAP' + nm