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; ArchiveFormat
: String);
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 BinEditor
, MAPREADER
, WADEDITOR
, WADSTRUCT
, MAPSTRUCT
, g_language
;
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
:= Application
.MessageBox(PChar(Format(MsgMsgMapExists
,
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; ArchiveFormat
: String);
90 a
, max_num
, j
: Integer;
94 Sign
: Array [0..2] of Char;
98 lbMapList
.Items
.Clear();
101 if ArchiveFormat
= '' then
103 // format not specified -> try open automatically and append to it (or create new default)
104 WAD
:= gWADEditorFactory
.OpenFile(FileName
);
106 WAD
:= gWADEditorFactory
.CreateDefaultEditor();
110 // format specified -> append using exactly this format (overwrite if not compatible)
111 WAD
:= gWADEditorFactory
.CreateEditor(ArchiveFormat
);
112 if WAD
.ReadFile(FileName
) = False then
116 ResList
:= WAD
.GetResourcesList('');
118 if ResList
<> nil then
119 for a
:= 0 to High(ResList
) do
121 if not WAD
.GetResource('', ResList
[a
], Data
, Len
) then
124 CopyMemory(@Sign
[0], Data
, 3);
127 if Sign
= MAP_SIGNATURE
then
129 nm
:= win2utf(ResList
[a
]);
130 lbMapList
.Items
.Add(nm
);
139 nm
:= Trim(Copy(nm
, 4, Length(nm
)-3));
140 j
:= StrToIntDef(nm
, 0);
154 nm
:= IntToStr(max_num
);
155 if Length(nm
) < 2 then