DEADSOFTWARE

system: implement zip support again
[d2df-editor.git] / src / editor / f_savemap.pas
index f5feee313ce5291af9041bcdb5c43ba9646c6ebe..a78e6009a44a3dd6d6c165eadb50f7a7c3299155 100644 (file)
@@ -17,7 +17,7 @@ type
     Panel2: TPanel;
     eMapName: TEdit;
 
-    procedure GetMaps(FileName: String; placeName: Boolean);
+    procedure GetMaps(FileName: String; placeName: Boolean; ArchiveFormat: String);
     procedure FormActivate(Sender: TObject);
     procedure eMapNameChange(Sender: TObject);
     procedure lbMapListClick(Sender: TObject);
@@ -69,9 +69,9 @@ begin
   for a := 0 to lbMapList.Count-1 do
     if eMapName.Text = lbMapList.Items[a] then
     begin
-      ok := MessageBox(0, PChar(Format(_lc[I_MSG_MAP_EXISTS],
+      ok := Application.MessageBox(PChar(Format(MsgMsgMapExists,
                                        [eMapName.Text])),
-                       PChar(_lc[I_MSG_SAVE_MAP]),
+                       PChar(MsgMsgSaveMap),
                        MB_ICONQUESTION or MB_YESNO or MB_DEFBUTTON1) = mrYes;
       if not ok then
         Exit;
@@ -84,9 +84,9 @@ begin
     SaveMapForm.ModalResult := mrCancel;
 end;
 
-procedure TSaveMapForm.GetMaps(FileName: String; placeName: Boolean);
+procedure TSaveMapForm.GetMaps(FileName: String; placeName: Boolean; ArchiveFormat: String);
 var
-  WAD: TWADEditor_1;
+  WAD: TWADEditor;
   a, max_num, j: Integer;
   ResList: SArray;
   Data: Pointer;
@@ -98,9 +98,22 @@ begin
   lbMapList.Items.Clear();
   max_num := 1;
 
-  WAD := TWADEditor_1.Create();
-  WAD.ReadFile(FileName);
-  ResList := WAD.GetResourcesList('');  
+  if ArchiveFormat = '' then
+  begin
+    // format not specified -> try open automatically and append to it (or create new default)
+    WAD := gWADEditorFactory.OpenFile(FileName);
+    if WAD = nil then
+      WAD := gWADEditorFactory.CreateDefaultEditor();
+  end
+  else
+  begin
+    // format specified -> appned using exactly this format (overwrite if not compatible)
+    WAD := gWADEditorFactory.CreateEditor(ArchiveFormat);
+    if WAD.ReadFile(FileName) = False then
+      WAD.FreeWAD();
+  end;
+
+  ResList := WAD.GetResourcesList('');
 
   if ResList <> nil then
     for a := 0 to High(ResList) do
@@ -110,7 +123,7 @@ begin
 
       CopyMemory(@Sign[0], Data, 3);
       FreeMem(Data);
-   
+
       if Sign = MAP_SIGNATURE then
       begin
         nm := win2utf(ResList[a]);