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
)
21 procedure GetMaps(FileName
: String; placeName
: Boolean; ArchiveFormat
: String);
22 procedure FormActivate(Sender
: TObject
);
23 procedure eMapNameChange(Sender
: TObject
);
24 procedure lbMapListClick(Sender
: TObject
);
25 procedure bOKClick(Sender
: TObject
);
28 { Private declarations }
30 { Public declarations }
34 SaveMapForm
: TSaveMapForm
;
39 BinEditor
, MAPREADER
, WADEDITOR
, WADSTRUCT
, MAPSTRUCT
, g_language
;
43 procedure TSaveMapForm
.FormActivate(Sender
: TObject
);
45 bOK
.Enabled
:= (eMapName
.Text <> '');
49 procedure TSaveMapForm
.eMapNameChange(Sender
: TObject
);
51 if eMapName
.Text <> '' then
57 procedure TSaveMapForm
.lbMapListClick(Sender
: TObject
);
59 if lbMapList
.ItemIndex
> -1 then
60 eMapName
.Text := lbMapList
.Items
[lbMapList
.ItemIndex
];
63 procedure TSaveMapForm
.bOKClick(Sender
: TObject
);
70 for a
:= 0 to lbMapList
.Count
-1 do
71 if eMapName
.Text = lbMapList
.Items
[a
] then
73 ok
:= Application
.MessageBox(PChar(Format(MsgMsgMapExists
,
76 MB_ICONQUESTION
or MB_YESNO
or MB_DEFBUTTON1
) = mrYes
;
85 ModalResult
:= mrCancel
;
88 procedure TSaveMapForm
.GetMaps(FileName
: String; placeName
: Boolean; ArchiveFormat
: String);
91 a
, max_num
, j
: Integer;
95 Sign
: Array [0..2] of Char;
99 lbMapList
.Items
.Clear();
102 if ArchiveFormat
= '' then
104 // format not specified -> try open automatically and append to it (or create new default)
105 WAD
:= gWADEditorFactory
.OpenFile(FileName
);
107 WAD
:= gWADEditorFactory
.CreateDefaultEditor();
111 // format specified -> append using exactly this format (overwrite if not compatible)
112 WAD
:= gWADEditorFactory
.CreateEditor(ArchiveFormat
);
113 if WAD
.ReadFile(FileName
) = False then
117 ResList
:= WAD
.GetResourcesList('');
119 if ResList
<> nil then
120 for a
:= 0 to High(ResList
) do
122 if not WAD
.GetResource('', ResList
[a
], Data
, Len
) then
125 CopyMemory(@Sign
[0], Data
, 3);
128 if Sign
= MAP_SIGNATURE
then
130 nm
:= win2utf(ResList
[a
]);
131 lbMapList
.Items
.Add(nm
);
140 nm
:= Trim(Copy(nm
, 4, Length(nm
)-3));
141 j
:= StrToIntDef(nm
, 0);
155 nm
:= IntToStr(max_num
);
156 if Length(nm
) < 2 then
166 SaveMapForm
:= TSaveMapForm
.Create(Application
);