DEADSOFTWARE

Added new optios(thanks GranMinigun!), added .dfz extension(now default) and fixed...
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Wed, 16 Jan 2019 14:45:07 +0000 (17:45 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Wed, 16 Jan 2019 14:45:07 +0000 (17:45 +0300)
src/editor/f_main.lfm
src/editor/f_main.pas
src/editor/f_options.lfm
src/editor/f_options.pas
src/editor/f_packmap.lfm
src/editor/f_packmap.pas
src/editor/g_language.pas
src/editor/g_resources.pas
src/sfs/sfsZipFS.pas

index 344fefb0dac03850713cd2f0183a1e359ac9738e..4eae45a4aefda5f34bb7961ab5340e3200a312bf 100644 (file)
@@ -747,8 +747,8 @@ object MainForm: TMainForm
     end
   end
   object OpenDialog: TOpenDialog
     end
   end
   object OpenDialog: TOpenDialog
-    DefaultExt = '.wad'
-    Filter = 'Карты Doom 2D: Forever (*.wad)|*.wad|Старые карты Doom 2D: Forever (*.ini)|*.ini|Все файлы (*.*)|*.*'
+    DefaultExt = '.dfz'
+    Filter = 'Карты Doom 2D: Forever (*.dfz, *.wad)|*.dfz;*.wad|Старые карты Doom 2D: Forever 0.30 (*.ini)|*.ini|Все файлы (*.*)|*.*'
     Options = [ofHideReadOnly, ofNoChangeDir, ofPathMustExist, ofFileMustExist, ofEnableSizing, ofDontAddToRecent]
     left = 32
     top = 64
     Options = [ofHideReadOnly, ofNoChangeDir, ofPathMustExist, ofFileMustExist, ofEnableSizing, ofDontAddToRecent]
     left = 32
     top = 64
@@ -1721,8 +1721,8 @@ object MainForm: TMainForm
     }
   end
   object SaveDialog: TSaveDialog
     }
   end
   object SaveDialog: TSaveDialog
-    DefaultExt = '.wad'
-    Filter = 'Карты Doom 2D: Forever (*.wad)|*.wad|Все файлы (*.*)|*.*'
+    DefaultExt = '.dfz'
+    Filter = 'Карты Doom 2D: Forever (*.dfz)|*.dfz|Карты Doom 2D: Forever (*.wad)|Все файлы (*.*)|*.*'
     Options = [ofHideReadOnly, ofNoChangeDir, ofPathMustExist, ofNoReadOnlyReturn, ofEnableSizing, ofDontAddToRecent]
     left = 64
     top = 64
     Options = [ofHideReadOnly, ofNoChangeDir, ofPathMustExist, ofNoReadOnlyReturn, ofEnableSizing, ofDontAddToRecent]
     left = 64
     top = 64
index 5624e6a3def924542f32448cd3f59d6138b67cef..95d468df1917067c9c67c1b4bb77d8423009a1e8 100644 (file)
@@ -2737,6 +2737,9 @@ begin
   s := config.ReadStr('Editor', 'Language', '');
   gLanguage := s;
 
   s := config.ReadStr('Editor', 'Language', '');
   gLanguage := s;
 
+  Compress := config.ReadBool('Editor', 'Compress', True);
+  Backup := config.ReadBool('Editor', 'Backup', True);
+
   RecentCount := config.ReadInt('Editor', 'RecentCount', 5);
   if RecentCount > 10 then
     RecentCount := 10;
   RecentCount := config.ReadInt('Editor', 'RecentCount', 5);
   if RecentCount > 10 then
     RecentCount := 10;
index b100ee3e6d2ac823a27912076782c6034189feea..3e6cc235e4b523aee0d1fc122379ad46e2be9171 100644 (file)
@@ -1,12 +1,12 @@
 object OptionsForm: TOptionsForm
   Left = 202
 object OptionsForm: TOptionsForm
   Left = 202
-  Height = 262
+  Height = 285
   Top = 174
   Width = 435
   BorderIcons = [biSystemMenu]
   BorderStyle = bsSingle
   Caption = 'Настройки редактора'
   Top = 174
   Width = 435
   BorderIcons = [biSystemMenu]
   BorderStyle = bsSingle
   Caption = 'Настройки редактора'
-  ClientHeight = 262
+  ClientHeight = 285
   ClientWidth = 435
   Color = clBtnFace
   Font.Color = clWindowText
   ClientWidth = 435
   Color = clBtnFace
   Font.Color = clWindowText
@@ -14,14 +14,14 @@ object OptionsForm: TOptionsForm
   Font.Name = 'MS Sans Serif'
   OnActivate = FormActivate
   Position = poScreenCenter
   Font.Name = 'MS Sans Serif'
   OnActivate = FormActivate
   Position = poScreenCenter
-  LCLVersion = '1.6.4.0'
+  LCLVersion = '1.8.4.0'
   object GroupBox1: TGroupBox
     Left = 8
   object GroupBox1: TGroupBox
     Left = 8
-    Height = 225
+    Height = 248
     Top = 0
     Width = 425
     Top = 0
     Width = 425
-    ClientHeight = 207
-    ClientWidth = 421
+    ClientHeight = 246
+    ClientWidth = 423
     TabOrder = 0
     object sDotColor: TShape
       Left = 344
     TabOrder = 0
     object sDotColor: TShape
       Left = 344
@@ -31,25 +31,25 @@ object OptionsForm: TOptionsForm
     end
     object LabelGrid: TLabel
       Left = 6
     end
     object LabelGrid: TLabel
       Left = 6
-      Height = 13
+      Height = 14
       Top = 74
       Top = 74
-      Width = 61
+      Width = 73
       Caption = 'Шаги сетки:'
       ParentColor = False
     end
     object LabelGridCol: TLabel
       Left = 190
       Caption = 'Шаги сетки:'
       ParentColor = False
     end
     object LabelGridCol: TLabel
       Left = 190
-      Height = 13
+      Height = 14
       Top = 2
       Top = 2
-      Width = 60
+      Width = 69
       Caption = 'Цвет сетки:'
       ParentColor = False
     end
     object LabelBack: TLabel
       Left = 190
       Caption = 'Цвет сетки:'
       ParentColor = False
     end
     object LabelBack: TLabel
       Left = 190
-      Height = 13
+      Height = 14
       Top = 43
       Top = 43
-      Width = 57
+      Width = 66
       Caption = 'Цвет фона:'
       ParentColor = False
     end
       Caption = 'Цвет фона:'
       ParentColor = False
     end
@@ -62,9 +62,9 @@ object OptionsForm: TOptionsForm
     end
     object LabelPreview: TLabel
       Left = 190
     end
     object LabelPreview: TLabel
       Left = 190
-      Height = 13
+      Height = 14
       Top = 72
       Top = 72
-      Width = 216
+      Width = 252
       Caption = 'Цвет фона поля предпросмотра текстуры:'
       ParentColor = False
       WordWrap = True
       Caption = 'Цвет фона поля предпросмотра текстуры:'
       ParentColor = False
       WordWrap = True
@@ -78,49 +78,49 @@ object OptionsForm: TOptionsForm
     end
     object LabelMinimap: TLabel
       Left = 190
     end
     object LabelMinimap: TLabel
       Left = 190
-      Height = 13
+      Height = 14
       Top = 129
       Top = 129
-      Width = 112
+      Width = 129
       Caption = 'Масштаб мини-карты:'
       ParentColor = False
     end
     object LabelRecent: TLabel
       Left = 190
       Caption = 'Масштаб мини-карты:'
       ParentColor = False
     end
     object LabelRecent: TLabel
       Left = 190
-      Height = 13
+      Height = 14
       Top = 162
       Top = 162
-      Width = 199
+      Width = 233
       Caption = 'Запоминать последних открытых карт:'
       ParentColor = False
       WordWrap = True
     end
     object LabelLanguage: TLabel
       Left = 6
       Caption = 'Запоминать последних открытых карт:'
       ParentColor = False
       WordWrap = True
     end
     object LabelLanguage: TLabel
       Left = 6
-      Height = 13
+      Height = 14
       Top = 162
       Top = 162
-      Width = 31
+      Width = 34
       Caption = 'Язык:'
       ParentColor = False
     end
     object LabelGridSize: TLabel
       Left = 6
       Caption = 'Язык:'
       ParentColor = False
     end
     object LabelGridSize: TLabel
       Left = 6
-      Height = 13
+      Height = 14
       Top = 122
       Top = 122
-      Width = 105
+      Width = 121
       Caption = 'Размер точек сетки:'
       ParentColor = False
       WordWrap = True
     end
     object cbShowDots: TCheckBox
       Left = 6
       Caption = 'Размер точек сетки:'
       ParentColor = False
       WordWrap = True
     end
     object cbShowDots: TCheckBox
       Left = 6
-      Height = 17
+      Height = 21
       Top = 2
       Top = 2
-      Width = 112
+      Width = 130
       Caption = 'Показывать сетку'
       TabOrder = 0
     end
     object UpDown1: TUpDown
       Left = 143
       Caption = 'Показывать сетку'
       TabOrder = 0
     end
     object UpDown1: TUpDown
       Left = 143
-      Height = 21
+      Height = 26
       Top = 74
       Width = 12
       Associate = eDotStepOne
       Top = 74
       Width = 12
       Associate = eDotStepOne
@@ -132,7 +132,7 @@ object OptionsForm: TOptionsForm
     end
     object eDotStepOne: TEdit
       Left = 86
     end
     object eDotStepOne: TEdit
       Left = 86
-      Height = 21
+      Height = 26
       Top = 74
       Width = 57
       TabOrder = 3
       Top = 74
       Width = 57
       TabOrder = 3
@@ -167,10 +167,10 @@ object OptionsForm: TOptionsForm
     end
     object cbScale: TComboBox
       Left = 344
     end
     object cbScale: TComboBox
       Left = 344
-      Height = 21
+      Height = 27
       Top = 129
       Width = 70
       Top = 129
       Width = 70
-      ItemHeight = 13
+      ItemHeight = 0
       ItemIndex = 0
       Items.Strings = (
         '1x'
       ItemIndex = 0
       Items.Strings = (
         '1x'
@@ -182,23 +182,23 @@ object OptionsForm: TOptionsForm
     end
     object cbShowTexture: TCheckBox
       Left = 6
     end
     object cbShowTexture: TCheckBox
       Left = 6
-      Height = 17
+      Height = 21
       Top = 18
       Top = 18
-      Width = 167
+      Width = 196
       Caption = 'Показывать текстуру панели'
       TabOrder = 1
     end
     object cbShowSize: TCheckBox
       Left = 6
       Caption = 'Показывать текстуру панели'
       TabOrder = 1
     end
     object cbShowSize: TCheckBox
       Left = 6
-      Height = 17
+      Height = 21
       Top = 34
       Top = 34
-      Width = 169
+      Width = 194
       Caption = 'Показывать размеры панели'
       TabOrder = 2
     end
     object eRecent: TEdit
       Left = 344
       Caption = 'Показывать размеры панели'
       TabOrder = 2
     end
     object eRecent: TEdit
       Left = 344
-      Height = 21
+      Height = 26
       Top = 180
       Width = 57
       TabOrder = 15
       Top = 180
       Width = 57
       TabOrder = 15
@@ -206,7 +206,7 @@ object OptionsForm: TOptionsForm
     end
     object UpDown3: TUpDown
       Left = 401
     end
     object UpDown3: TUpDown
       Left = 401
-      Height = 21
+      Height = 26
       Top = 180
       Width = 12
       Associate = eRecent
       Top = 180
       Width = 12
       Associate = eRecent
@@ -218,7 +218,7 @@ object OptionsForm: TOptionsForm
     end
     object eDotStepTwo: TEdit
       Left = 86
     end
     object eDotStepTwo: TEdit
       Left = 86
-      Height = 21
+      Height = 26
       Top = 98
       Width = 57
       TabOrder = 5
       Top = 98
       Width = 57
       TabOrder = 5
@@ -226,7 +226,7 @@ object OptionsForm: TOptionsForm
     end
     object UpDown2: TUpDown
       Left = 143
     end
     object UpDown2: TUpDown
       Left = 143
-      Height = 21
+      Height = 26
       Top = 98
       Width = 12
       Associate = eDotStepTwo
       Top = 98
       Width = 12
       Associate = eDotStepTwo
@@ -238,9 +238,9 @@ object OptionsForm: TOptionsForm
     end
     object rbRussian: TRadioButton
       Left = 86
     end
     object rbRussian: TRadioButton
       Left = 86
-      Height = 17
+      Height = 21
       Top = 162
       Top = 162
-      Width = 60
+      Width = 71
       Caption = 'Русский'
       Checked = True
       TabOrder = 8
       Caption = 'Русский'
       Checked = True
       TabOrder = 8
@@ -248,18 +248,18 @@ object OptionsForm: TOptionsForm
     end
     object rbEnglish: TRadioButton
       Left = 86
     end
     object rbEnglish: TRadioButton
       Left = 86
-      Height = 17
+      Height = 21
       Top = 186
       Top = 186
-      Width = 52
+      Width = 64
       Caption = 'English'
       TabOrder = 9
     end
     object cbDotSize: TComboBox
       Left = 82
       Caption = 'English'
       TabOrder = 9
     end
     object cbDotSize: TComboBox
       Left = 82
-      Height = 21
+      Height = 27
       Top = 136
       Width = 73
       Top = 136
       Width = 73
-      ItemHeight = 13
+      ItemHeight = 0
       ItemIndex = 0
       Items.Strings = (
         '1'
       ItemIndex = 0
       Items.Strings = (
         '1'
@@ -270,19 +270,35 @@ object OptionsForm: TOptionsForm
     end
     object cbCheckerboard: TCheckBox
       Left = 190
     end
     object cbCheckerboard: TCheckBox
       Left = 190
-      Height = 17
+      Height = 21
       Top = 94
       Top = 94
-      Width = 145
+      Width = 166
       Caption = 'Использовать шахматку'
       Checked = True
       State = cbChecked
       TabOrder = 12
     end
       Caption = 'Использовать шахматку'
       Checked = True
       State = cbChecked
       TabOrder = 12
     end
+    object cbCompress: TCheckBox
+      Left = 190
+      Height = 21
+      Top = 208
+      Width = 212
+      Caption = 'Сжимать архив при сохранении'
+      TabOrder = 17
+    end
+    object cbBackup: TCheckBox
+      Left = 190
+      Height = 21
+      Top = 224
+      Width = 222
+      Caption = 'Резервная копия при сохранении'
+      TabOrder = 18
+    end
   end
   object bOK: TButton
     Left = 262
     Height = 25
   end
   object bOK: TButton
     Left = 262
     Height = 25
-    Top = 232
+    Top = 256
     Width = 75
     Caption = 'ОК'
     Default = True
     Width = 75
     Caption = 'ОК'
     Default = True
@@ -292,7 +308,7 @@ object OptionsForm: TOptionsForm
   object bCancel: TButton
     Left = 358
     Height = 25
   object bCancel: TButton
     Left = 358
     Height = 25
-    Top = 232
+    Top = 256
     Width = 75
     Cancel = True
     Caption = 'Отмена'
     Width = 75
     Cancel = True
     Caption = 'Отмена'
@@ -323,7 +339,7 @@ object OptionsForm: TOptionsForm
       'ColorS=F0FBFF'
       'ColorT=A4A0A0'
     )
       'ColorS=F0FBFF'
       'ColorT=A4A0A0'
     )
-    left = 200
-    top = 232
+    left = 96
+    top = 216
   end
 end
   end
 end
index 1f297ec217b0a6f7ba490f50f63a858f876d053b..8a77b180abf987c647abd3e97d36d7b7b9ae0c2c 100644 (file)
@@ -10,10 +10,15 @@ uses
   ExtCtrls, ComCtrls, Registry;
 
 type
   ExtCtrls, ComCtrls, Registry;
 
 type
+
+  { TOptionsForm }
+
   TOptionsForm = class (TForm)
     bOK: TButton;
     bCancel: TButton;
     cbCheckerboard: TCheckBox;
   TOptionsForm = class (TForm)
     bOK: TButton;
     bCancel: TButton;
     cbCheckerboard: TCheckBox;
+    cbCompress: TCheckBox;
+    cbBackup: TCheckBox;
     ColorDialog: TColorDialog;
     GroupBox1: TGroupBox;
   // Общие настройки:
     ColorDialog: TColorDialog;
     GroupBox1: TGroupBox;
   // Общие настройки:
@@ -72,7 +77,7 @@ procedure RegisterFileType(ext: String; FileName: String);
 implementation
 
 uses
 implementation
 
 uses
-  f_main, StdConvs, CONFIG, g_language;
+  f_main, StdConvs, CONFIG, g_language, g_resources;
 
 {$R *.lfm}
 
 
 {$R *.lfm}
 
@@ -117,6 +122,8 @@ begin
   sBackColor.Brush.Color := BackColor;
   sPreviewColor.Brush.Color := PreviewColor;
   cbCheckerboard.Checked := UseCheckerboard;
   sBackColor.Brush.Color := BackColor;
   sPreviewColor.Brush.Color := PreviewColor;
   cbCheckerboard.Checked := UseCheckerboard;
+  cbCompress.Checked := Compress;
+  cbBackup.Checked := Backup;
   if Scale = 2 then
     cbScale.ItemIndex := 1
   else
   if Scale = 2 then
     cbScale.ItemIndex := 1
   else
@@ -187,6 +194,8 @@ begin
   BackColor := sBackColor.Brush.Color;
   PreviewColor := sPreviewColor.Brush.Color;
   UseCheckerboard := cbCheckerboard.Checked;
   BackColor := sBackColor.Brush.Color;
   PreviewColor := sPreviewColor.Brush.Color;
   UseCheckerboard := cbCheckerboard.Checked;
+  Compress := cbCompress.Checked;
+  Backup := cbBackup.Checked;
 
   if cbScale.ItemIndex = 1 then
     Scale := 2
 
   if cbScale.ItemIndex = 1 then
     Scale := 2
@@ -214,6 +223,8 @@ begin
   config.WriteInt('Editor', 'Scale', cbScale.ItemIndex);
   config.WriteInt('Editor', 'RecentCount', re);
   config.WriteStr('Editor', 'Language', gLanguage);
   config.WriteInt('Editor', 'Scale', cbScale.ItemIndex);
   config.WriteInt('Editor', 'RecentCount', re);
   config.WriteStr('Editor', 'Language', gLanguage);
+  config.WriteBool('Editor', 'Compress', Compress);
+  config.WriteBool('Editor', 'Backup', Backup);
 
   if RecentCount <> re then
   begin
 
   if RecentCount <> re then
   begin
index 2a275ebfac3801352933a77a79652461c68b2d22..f5babdad9168822633e3f721f67db4dec7a193cf 100644 (file)
@@ -177,7 +177,7 @@ object PackMapForm: TPackMapForm
     TabOrder = 1
   end
   object SaveDialog: TSaveDialog
     TabOrder = 1
   end
   object SaveDialog: TSaveDialog
-    DefaultExt = '.wad'
+    DefaultExt = '.dfz'
     Filter = 'Карты Doom2D: Forever (*.wad)|*.wad|All files (*.*)|*.*'
     Options = [ofHideReadOnly, ofPathMustExist, ofEnableSizing, ofDontAddToRecent]
     left = 8
     Filter = 'Карты Doom2D: Forever (*.wad)|*.wad|All files (*.*)|*.*'
     Options = [ofHideReadOnly, ofPathMustExist, ofEnableSizing, ofDontAddToRecent]
     left = 8
index cdbe1056f9fde71dd1a11c5d2bfd53dac216faff..00e3dc0372b3984515df0b1068ee1fb9d6de1763 100644 (file)
@@ -133,15 +133,7 @@ begin
     Exit;
 
   if not cbAdd.Checked then
     Exit;
 
   if not cbAdd.Checked then
-  begin
-    (* Overwrite wad *)
-    if FileExists(eWAD.Text) then
-    begin
-      if FileExists(eWAD.Text + '.bak0') then
-        ASSERT(DeleteFile(eWAD.Text + '.bak0'));
-      ASSERT(RenameFile(eWAD.Text, eWAD.Text + '.bak0'))
-    end
-  end;
+    g_DeleteFile(eWAD.Text, '.bak0');
 
 // Читаем карту из памяти:
   mr := TMapReader_1.Create();
 
 // Читаем карту из памяти:
   mr := TMapReader_1.Create();
index 99a185545d64290def5c0c92fb1ce443d2ccf2ca..75d8787583f6dd9ae23e34dd4069d6bb3bf4dbf2 100644 (file)
@@ -543,6 +543,8 @@ Type
     I_LAB_ES_MINIMAP,
     I_LAB_ES_RECENT,
     I_LAB_ES_LANGUAGE,
     I_LAB_ES_MINIMAP,
     I_LAB_ES_RECENT,
     I_LAB_ES_LANGUAGE,
+    I_LAB_ES_COMPRESS,
+    I_LAB_ES_BACKUP,
 
     I_LAB_PACK_SAVE_TO,
     I_LAB_PACK_MAP_NAME,
 
     I_LAB_PACK_SAVE_TO,
     I_LAB_PACK_MAP_NAME,
@@ -1678,6 +1680,10 @@ Const
                                        'Запоминать последних открытых карт:'),
     ('LAB ES LANGUAGE',                'Language:',
                                        'Язык:'),
                                        'Запоминать последних открытых карт:'),
     ('LAB ES LANGUAGE',                'Language:',
                                        'Язык:'),
+    ('LAB ES COMPRESS',                'Compress archive when save',
+                                       'Сжимать архив при сохранении'),
+    ('LAB ES BACKUP',                  'Make backup before save',
+                                       'Резервная копия при сохранении'),
 
     ('LAB PACK SAVE TO',               'Save to:',
                                        'Сохранить в:'),
 
     ('LAB PACK SAVE TO',               'Save to:',
                                        'Сохранить в:'),
@@ -1796,10 +1802,10 @@ Const
     ('WAD SPECIAL TEXS',               '<EXTRA TEXTURES>',
                                        '<СПЕЦТЕКСТУРЫ>'),
 
     ('WAD SPECIAL TEXS',               '<EXTRA TEXTURES>',
                                        '<СПЕЦТЕКСТУРЫ>'),
 
-    ('FILE FILTER ALL',                'Doom 2D: Forever Maps (*.wad)|*.wad|Old Doom 2D: Forever 0.30 Maps (*.ini)|*.ini|All Files (*.*)|*.*',
-                                       'Карты Doom 2D: Forever (*.wad)|*.wad|Старые карты Doom 2D: Forever 0.30 (*.ini)|*.ini|Все файлы (*.*)|*.*'),
-    ('FILE FILTER WAD',                'Doom 2D: Forever Maps (*.wad)|*.wad|All Files (*.*)|*.*',
-                                       'Карты Doom 2D: Forever (*.wad)|*.wad|Все файлы (*.*)|*.*'),
+    ('FILE FILTER ALL',                'Doom 2D: Forever Maps (*.dfz, *.wad)|*.dfz;*.wad|Doom 2D: Forever 0.30 Maps (*.ini)|*.ini|Все файлы (*.*)|*.*',
+                                       'Карты Doom 2D: Forever (*.dfz, *.wad)|*.dfz;*.wad|Старые карты Doom 2D: Forever 0.30 (*.ini)|*.ini|Все файлы (*.*)|*.*'),
+    ('FILE FILTER WAD',                'Doom 2D: Forever Maps (*.dfz)|*.dfz|Doom 2D: Forever Maps (*.wad)|*.wad|Все файлы (*.*)|*.*',
+                                       'Карты Doom 2D: Forever (*.dfz)|*.dfz|Карты Doom 2D: Forever (*.wad)|*.wad|Все файлы (*.*)|*.*'),
 
     ('EDITOR TITLE',                   'Doom 2D: Forever Map Editor',
                                        'Редактор карт Doom 2D: Forever'),
 
     ('EDITOR TITLE',                   'Doom 2D: Forever Map Editor',
                                        'Редактор карт Doom 2D: Forever'),
@@ -2330,6 +2336,8 @@ begin
     cbShowTexture.Caption := _lc[I_CTRL_ES_TEXTURE];
     cbShowSize.Caption := _lc[I_CTRL_ES_PANEL_SIZE];
     cbCheckerboard.Caption := _lc[I_CTRL_ES_CHECKERBOARD];
     cbShowTexture.Caption := _lc[I_CTRL_ES_TEXTURE];
     cbShowSize.Caption := _lc[I_CTRL_ES_PANEL_SIZE];
     cbCheckerboard.Caption := _lc[I_CTRL_ES_CHECKERBOARD];
+    cbCompress.Caption := _lc[I_LAB_ES_COMPRESS];
+    cbBackup.Caption := _lc[I_LAB_ES_BACKUP];
     LabelGrid.Caption := _lc[I_LAB_ES_GRID];
     LabelGridCol.Caption := _lc[I_LAB_ES_GRID_COLOR];
     LabelGridSize.Caption := _lc[I_LAB_ES_GRID_SIZE];
     LabelGrid.Caption := _lc[I_LAB_ES_GRID];
     LabelGridCol.Caption := _lc[I_LAB_ES_GRID_COLOR];
     LabelGridSize.Caption := _lc[I_LAB_ES_GRID_SIZE];
index 9605b1a303361b5b85a3312ccfc02ab163845520..0e383c3a565d8317103f87a0170500f4945f7eff 100644 (file)
@@ -3,6 +3,13 @@ unit g_resources;
 interface
 
   (**
 interface
 
   (**
+    g_GetResourceSection
+      Parse path in form 'path/to/file.wad:some/section/resouce' to
+      wad = 'path/to/file.wa', section = 'some/section', name = 'resource'
+
+    g_DeleteFile
+      Delete file if it exists. Make backup if enabled.
+
     g_ReadResource
       Read whole file from wad
       (data <> nil) and (len > 0) when ok
     g_ReadResource
       Read whole file from wad
       (data <> nil) and (len > 0) when ok
@@ -26,7 +33,13 @@ interface
       res = 0 when ok
   **)
 
       res = 0 when ok
   **)
 
+  (* Editor options *)
+  var
+    Compress: Boolean;
+    Backup: Boolean;
+
   procedure g_GetResourceSection (path: String; out wad, section, name: String);
   procedure g_GetResourceSection (path: String; out wad, section, name: String);
+  procedure g_DeleteFile(wad: String; backupPostfix: String = '.bak');
 
   procedure g_ReadResource (wad, section, name: String; out data: PByte; out len: Integer);
   procedure g_ReadSubResource (wad, section0, name0, section1, name1: String; out data: PByte; out len: Integer);
 
   procedure g_ReadResource (wad, section, name: String; out data: PByte; out len: Integer);
   procedure g_ReadSubResource (wad, section0, name0, section1, name1: String; out data: PByte; out len: Integer);
@@ -84,6 +97,26 @@ implementation
     wad := Copy(path, 1, i - 1);
   end;
 
     wad := Copy(path, 1, i - 1);
   end;
 
+  procedure g_DeleteFile (wad: String; backupPostfix: String = '.bak');
+    var newwad: String;
+  begin
+    if Backup then
+    begin
+      if FileExists(wad) then
+      begin
+        newwad := wad + backupPostfix;
+        if FileExists(newwad) then
+          ASSERT(DeleteFile(newwad));
+        ASSERT(RenameFile(wad, newwad))
+      end
+    end
+    else
+    begin
+      if FileExists(wad) then
+        ASSERT(DeleteFile(wad))
+    end
+  end;
+
   procedure g_AddResourceToDFWAD (wad, section, name: String; const data: PByte; len: Integer; out res: Integer);
     var f: TWADEditor_1;
   begin
   procedure g_AddResourceToDFWAD (wad, section, name: String; const data: PByte; len: Integer; out res: Integer);
     var f: TWADEditor_1;
   begin
@@ -100,12 +133,7 @@ implementation
     f.CreateImage;
     f.RemoveResource(section, name);
     f.AddResource(data, len, name, section);
     f.CreateImage;
     f.RemoveResource(section, name);
     f.AddResource(data, len, name, section);
-    if FileExists(wad) then
-    begin
-      if FileExists(wad + '.bak') then
-        ASSERT(DeleteFile(wad + '.bak'));
-      ASSERT(RenameFile(wad, wad + '.bak'))
-    end;
+    g_DeleteFile(wad);
     f.SaveTo(wad);
     f.Free;
     res := 0
     f.SaveTo(wad);
     f.Free;
     res := 0
@@ -124,8 +152,8 @@ implementation
       var ds: TSFSMemoryChunkStream;
     begin
       SetLength(dir, n + 1);
       var ds: TSFSMemoryChunkStream;
     begin
       SetLength(dir, n + 1);
-      ds := TSFSMemoryChunkStream.Create(data, len, false);
-      dir[n] := dfzip.ZipOne(ts, name, ds);
+      ds := TSFSMemoryChunkStream.Create(data, len, False);
+      dir[n] := dfzip.ZipOne(ts, name, ds, Compress);
       ds.Free;
       INC(n);
     end;
       ds.Free;
       INC(n);
     end;
@@ -146,7 +174,7 @@ implementation
       for i := 0 to list.Count - 1 do
       begin
         path := NoTrailing(list.Files[i].path);
       for i := 0 to list.Count - 1 do
       begin
         path := NoTrailing(list.Files[i].path);
-        if (path <> section) or (list.Files[i].name <> section) then
+        if (path <> section) or (list.Files[i].name <> name) then
         begin
           g_ReadResource(wad, path, list.Files[i].name, data0, len0);
           ASSERT(data0 <> nil);
         begin
           g_ReadResource(wad, path, list.Files[i].name, data0, len0);
           ASSERT(data0 <> nil);
@@ -170,12 +198,7 @@ implementation
     dfzip.writeCentralDir(ts, dir);
     ts.Free;
 
     dfzip.writeCentralDir(ts, dir);
     ts.Free;
 
-    if FileExists(wad) then
-    begin
-      if FileExists(wad + '.bak') then
-        ASSERT(DeleteFile(wad + '.bak'));
-      ASSERT(RenameFile(wad, wad + '.bak'))
-    end;
+    g_DeleteFile(wad);
     ASSERT(RenameFile(tmp, wad));
     res := 0
   end;
     ASSERT(RenameFile(tmp, wad));
     res := 0
   end;
@@ -189,7 +212,7 @@ implementation
     e_WriteLog('g_AddResource "' + wad + '" "' + section + '" "' + name + '"', MSG_NOTIFY);
     if ext = '.wad' then
       g_AddResourceToDFWAD(wad, section, name, data, len, res)
     e_WriteLog('g_AddResource "' + wad + '" "' + section + '" "' + name + '"', MSG_NOTIFY);
     if ext = '.wad' then
       g_AddResourceToDFWAD(wad, section, name, data, len, res)
-    else if (ext = '.pk3') or (ext = '.zip') or (ext = '.dfzip') then
+    else
       g_AddResourceToZip(wad, section, name, data, len, res)
   end;
 
       g_AddResourceToZip(wad, section, name, data, len, res)
   end;
 
@@ -208,6 +231,7 @@ implementation
     end;
     f.CreateImage;
     f.RemoveResource(section, name);
     end;
     f.CreateImage;
     f.RemoveResource(section, name);
+    g_DeleteFile(wad);
     f.SaveTo(wad);
     f.Free;
     res := 0 (* ok *)
     f.SaveTo(wad);
     f.Free;
     res := 0 (* ok *)
@@ -226,8 +250,8 @@ implementation
       var ds: TSFSMemoryChunkStream;
     begin
       SetLength(dir, n + 1);
       var ds: TSFSMemoryChunkStream;
     begin
       SetLength(dir, n + 1);
-      ds := TSFSMemoryChunkStream.Create(data, len, false);
-      dir[n] := dfzip.ZipOne(ts, name, ds);
+      ds := TSFSMemoryChunkStream.Create(data, len, False);
+      dir[n] := dfzip.ZipOne(ts, name, ds, Compress);
       ds.Free;
       INC(n);
     end;
       ds.Free;
       INC(n);
     end;
@@ -248,7 +272,7 @@ implementation
       for i := 0 to list.Count - 1 do
       begin
         path := NoTrailing(list.Files[i].path);
       for i := 0 to list.Count - 1 do
       begin
         path := NoTrailing(list.Files[i].path);
-        if (path <> section) or (list.Files[i].name <> section) then
+        if (path <> section) or (list.Files[i].name <> name) then
         begin
           g_ReadResource(wad, path, list.Files[i].name, data0, len0);
           ASSERT(data0 <> nil);
         begin
           g_ReadResource(wad, path, list.Files[i].name, data0, len0);
           ASSERT(data0 <> nil);
@@ -266,12 +290,7 @@ implementation
     dfzip.writeCentralDir(ts, dir);
     ts.Free;
 
     dfzip.writeCentralDir(ts, dir);
     ts.Free;
 
-    if FileExists(wad) then
-    begin
-      if FileExists(wad + '.bak') then
-        ASSERT(DeleteFile(wad + '.bak'));
-      ASSERT(RenameFile(wad, wad + '.bak'))
-    end;
+    g_DeleteFile(wad);
     ASSERT(RenameFile(tmp, wad));
     res := 0
   end;
     ASSERT(RenameFile(tmp, wad));
     res := 0
   end;
@@ -284,7 +303,7 @@ implementation
     ext := LowerCase(SysUtils.ExtractFileExt(wad));
     if ext = '.wad' then
       g_DeleteResourceFromDFWAD(wad, section, name, res)
     ext := LowerCase(SysUtils.ExtractFileExt(wad));
     if ext = '.wad' then
       g_DeleteResourceFromDFWAD(wad, section, name, res)
-    else if (ext = '.dfz') or (ext = '.pk3') or (ext = '.zip') or (ext = '.dfzip') then
+    else
       g_DeleteResourceFromZip(wad, section, name, res)
   end;
 
       g_DeleteResourceFromZip(wad, section, name, res)
   end;
 
index 2cc9eff2e8f439d0f7ddad9be10081417650b721..e5e996841f803b4888dddd5a8467e5105ded8196 100644 (file)
@@ -417,6 +417,7 @@ begin
   result :=
     StrEquCI1251(prefix, 'zip') or
     StrEquCI1251(prefix, 'pk3') or
   result :=
     StrEquCI1251(prefix, 'zip') or
     StrEquCI1251(prefix, 'pk3') or
+    StrEquCI1251(prefix, 'dfz') or
     StrEquCI1251(prefix, 'dfwad') or
     StrEquCI1251(prefix, 'dfzip');
 end;
     StrEquCI1251(prefix, 'dfwad') or
     StrEquCI1251(prefix, 'dfzip');
 end;