summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a140ef8)
raw | patch | inline | side by side (parent: a140ef8)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 16 Jan 2019 14:45:07 +0000 (17:45 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 16 Jan 2019 14:45:07 +0000 (17:45 +0300) |
diff --git a/src/editor/f_main.lfm b/src/editor/f_main.lfm
index 344fefb0dac03850713cd2f0183a1e359ac9738e..4eae45a4aefda5f34bb7961ab5340e3200a312bf 100644 (file)
--- a/src/editor/f_main.lfm
+++ b/src/editor/f_main.lfm
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
}
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
diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas
index 5624e6a3def924542f32448cd3f59d6138b67cef..95d468df1917067c9c67c1b4bb77d8423009a1e8 100644 (file)
--- a/src/editor/f_main.pas
+++ b/src/editor/f_main.pas
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;
index b100ee3e6d2ac823a27912076782c6034189feea..3e6cc235e4b523aee0d1fc122379ad46e2be9171 100644 (file)
--- a/src/editor/f_options.lfm
+++ b/src/editor/f_options.lfm
object OptionsForm: TOptionsForm
Left = 202
- Height = 262
+ Height = 285
Top = 174
Width = 435
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = 'Настройки редактора'
- ClientHeight = 262
+ ClientHeight = 285
ClientWidth = 435
Color = clBtnFace
Font.Color = clWindowText
Font.Name = 'MS Sans Serif'
OnActivate = FormActivate
Position = poScreenCenter
- LCLVersion = '1.6.4.0'
+ LCLVersion = '1.8.4.0'
object GroupBox1: TGroupBox
Left = 8
- Height = 225
+ Height = 248
Top = 0
Width = 425
- ClientHeight = 207
- ClientWidth = 421
+ ClientHeight = 246
+ ClientWidth = 423
TabOrder = 0
object sDotColor: TShape
Left = 344
end
object LabelGrid: TLabel
Left = 6
- Height = 13
+ Height = 14
Top = 74
- Width = 61
+ Width = 73
Caption = 'Шаги сетки:'
ParentColor = False
end
object LabelGridCol: TLabel
Left = 190
- Height = 13
+ Height = 14
Top = 2
- Width = 60
+ Width = 69
Caption = 'Цвет сетки:'
ParentColor = False
end
object LabelBack: TLabel
Left = 190
- Height = 13
+ Height = 14
Top = 43
- Width = 57
+ Width = 66
Caption = 'Цвет фона:'
ParentColor = False
end
end
object LabelPreview: TLabel
Left = 190
- Height = 13
+ Height = 14
Top = 72
- Width = 216
+ Width = 252
Caption = 'Цвет фона поля предпросмотра текстуры:'
ParentColor = False
WordWrap = True
end
object LabelMinimap: TLabel
Left = 190
- Height = 13
+ Height = 14
Top = 129
- Width = 112
+ Width = 129
Caption = 'Масштаб мини-карты:'
ParentColor = False
end
object LabelRecent: TLabel
Left = 190
- Height = 13
+ Height = 14
Top = 162
- Width = 199
+ Width = 233
Caption = 'Запоминать последних открытых карт:'
ParentColor = False
WordWrap = True
end
object LabelLanguage: TLabel
Left = 6
- Height = 13
+ Height = 14
Top = 162
- Width = 31
+ Width = 34
Caption = 'Язык:'
ParentColor = False
end
object LabelGridSize: TLabel
Left = 6
- Height = 13
+ Height = 14
Top = 122
- Width = 105
+ Width = 121
Caption = 'Размер точек сетки:'
ParentColor = False
WordWrap = True
end
object cbShowDots: TCheckBox
Left = 6
- Height = 17
+ Height = 21
Top = 2
- Width = 112
+ Width = 130
Caption = 'Показывать сетку'
TabOrder = 0
end
object UpDown1: TUpDown
Left = 143
- Height = 21
+ Height = 26
Top = 74
Width = 12
Associate = eDotStepOne
end
object eDotStepOne: TEdit
Left = 86
- Height = 21
+ Height = 26
Top = 74
Width = 57
TabOrder = 3
end
object cbScale: TComboBox
Left = 344
- Height = 21
+ Height = 27
Top = 129
Width = 70
- ItemHeight = 13
+ ItemHeight = 0
ItemIndex = 0
Items.Strings = (
'1x'
end
object cbShowTexture: TCheckBox
Left = 6
- Height = 17
+ Height = 21
Top = 18
- Width = 167
+ Width = 196
Caption = 'Показывать текстуру панели'
TabOrder = 1
end
object cbShowSize: TCheckBox
Left = 6
- Height = 17
+ Height = 21
Top = 34
- Width = 169
+ Width = 194
Caption = 'Показывать размеры панели'
TabOrder = 2
end
object eRecent: TEdit
Left = 344
- Height = 21
+ Height = 26
Top = 180
Width = 57
TabOrder = 15
end
object UpDown3: TUpDown
Left = 401
- Height = 21
+ Height = 26
Top = 180
Width = 12
Associate = eRecent
end
object eDotStepTwo: TEdit
Left = 86
- Height = 21
+ Height = 26
Top = 98
Width = 57
TabOrder = 5
end
object UpDown2: TUpDown
Left = 143
- Height = 21
+ Height = 26
Top = 98
Width = 12
Associate = eDotStepTwo
end
object rbRussian: TRadioButton
Left = 86
- Height = 17
+ Height = 21
Top = 162
- Width = 60
+ Width = 71
Caption = 'Русский'
Checked = True
TabOrder = 8
end
object rbEnglish: TRadioButton
Left = 86
- Height = 17
+ Height = 21
Top = 186
- Width = 52
+ Width = 64
Caption = 'English'
TabOrder = 9
end
object cbDotSize: TComboBox
Left = 82
- Height = 21
+ Height = 27
Top = 136
Width = 73
- ItemHeight = 13
+ ItemHeight = 0
ItemIndex = 0
Items.Strings = (
'1'
end
object cbCheckerboard: TCheckBox
Left = 190
- Height = 17
+ Height = 21
Top = 94
- Width = 145
+ Width = 166
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
- Top = 232
+ Top = 256
Width = 75
Caption = 'ОК'
Default = True
object bCancel: TButton
Left = 358
Height = 25
- Top = 232
+ Top = 256
Width = 75
Cancel = True
Caption = 'Отмена'
'ColorS=F0FBFF'
'ColorT=A4A0A0'
)
- left = 200
- top = 232
+ left = 96
+ top = 216
end
end
index 1f297ec217b0a6f7ba490f50f63a858f876d053b..8a77b180abf987c647abd3e97d36d7b7b9ae0c2c 100644 (file)
--- a/src/editor/f_options.pas
+++ b/src/editor/f_options.pas
ExtCtrls, ComCtrls, Registry;
type
+
+ { TOptionsForm }
+
TOptionsForm = class (TForm)
bOK: TButton;
bCancel: TButton;
cbCheckerboard: TCheckBox;
+ cbCompress: TCheckBox;
+ cbBackup: TCheckBox;
ColorDialog: TColorDialog;
GroupBox1: TGroupBox;
// Общие настройки:
implementation
uses
- f_main, StdConvs, CONFIG, g_language;
+ f_main, StdConvs, CONFIG, g_language, g_resources;
{$R *.lfm}
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
BackColor := sBackColor.Brush.Color;
PreviewColor := sPreviewColor.Brush.Color;
UseCheckerboard := cbCheckerboard.Checked;
+ Compress := cbCompress.Checked;
+ Backup := cbBackup.Checked;
if cbScale.ItemIndex = 1 then
Scale := 2
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
index 2a275ebfac3801352933a77a79652461c68b2d22..f5babdad9168822633e3f721f67db4dec7a193cf 100644 (file)
--- a/src/editor/f_packmap.lfm
+++ b/src/editor/f_packmap.lfm
TabOrder = 1
end
object SaveDialog: TSaveDialog
- DefaultExt = '.wad'
+ DefaultExt = '.dfz'
Filter = 'Карты Doom2D: Forever (*.wad)|*.wad|All files (*.*)|*.*'
Options = [ofHideReadOnly, ofPathMustExist, ofEnableSizing, ofDontAddToRecent]
left = 8
index cdbe1056f9fde71dd1a11c5d2bfd53dac216faff..00e3dc0372b3984515df0b1068ee1fb9d6de1763 100644 (file)
--- a/src/editor/f_packmap.pas
+++ b/src/editor/f_packmap.pas
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();
index 99a185545d64290def5c0c92fb1ce443d2ccf2ca..75d8787583f6dd9ae23e34dd4069d6bb3bf4dbf2 100644 (file)
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,
'Запоминать последних открытых карт:'),
('LAB ES LANGUAGE', 'Language:',
'Язык:'),
+ ('LAB ES COMPRESS', 'Compress archive when save',
+ 'Сжимать архив при сохранении'),
+ ('LAB ES BACKUP', 'Make backup before save',
+ 'Резервная копия при сохранении'),
('LAB PACK SAVE TO', 'Save to:',
'Сохранить в:'),
('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'),
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];
index 9605b1a303361b5b85a3312ccfc02ab163845520..0e383c3a565d8317103f87a0170500f4945f7eff 100644 (file)
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
res = 0 when ok
**)
+ (* Editor options *)
+ var
+ Compress: Boolean;
+ Backup: Boolean;
+
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);
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
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
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;
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);
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;
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;
end;
f.CreateImage;
f.RemoveResource(section, name);
+ g_DeleteFile(wad);
f.SaveTo(wad);
f.Free;
res := 0 (* ok *)
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;
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);
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;
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;
diff --git a/src/sfs/sfsZipFS.pas b/src/sfs/sfsZipFS.pas
index 2cc9eff2e8f439d0f7ddad9be10081417650b721..e5e996841f803b4888dddd5a8467e5105ded8196 100644 (file)
--- a/src/sfs/sfsZipFS.pas
+++ b/src/sfs/sfsZipFS.pas
result :=
StrEquCI1251(prefix, 'zip') or
StrEquCI1251(prefix, 'pk3') or
+ StrEquCI1251(prefix, 'dfz') or
StrEquCI1251(prefix, 'dfwad') or
StrEquCI1251(prefix, 'dfzip');
end;