index fde781fdd7c483fa68bc99e1ca71fd9c259f52fb..a78e6009a44a3dd6d6c165eadb50f7a7c3299155 100644 (file)
--- a/src/editor/f_savemap.pas
+++ b/src/editor/f_savemap.pas
unit f_savemap;
-{$MODE Delphi}
+{$INCLUDE ../shared/a_modes.inc}
interface
uses
LCLIntf, LCLType, LMessages, SysUtils, Variants, Classes,
- Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
+ Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, utils;
type
TSaveMapForm = class (TForm)
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);
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;
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;
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
CopyMemory(@Sign[0], Data, 3);
FreeMem(Data);
-
+
if Sign = MAP_SIGNATURE then
begin
- nm := ResList[a];
+ nm := win2utf(ResList[a]);
lbMapList.Items.Add(nm);
if placeName then