2 |
|
interface |
3 |
|
uses |
4 |
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
5 |
< |
Dialogs, Template, StdCtrls, ExtCtrls, ComCtrls, Menus, Buttons; |
5 |
> |
Dialogs, Template, StdCtrls, ExtCtrls, ComCtrls, Menus, Buttons, StrUtils; |
6 |
|
|
7 |
|
type |
8 |
|
TForm_Extractor = class(TForm_ToolTemplate) |
9 |
|
group_extract: TGroupBox; |
10 |
< |
group_singlefiles: TGroupBox; |
11 |
< |
btn_sel_dat: TButton; |
12 |
< |
btn_sel_datraw: TButton; |
13 |
< |
btn_sel_datraw_convert: TButton; |
14 |
< |
btn_all_dat: TButton; |
15 |
< |
btn_all_datraw: TButton; |
16 |
< |
btn_all_datraw_convert: TButton; |
17 |
< |
btn_sel_files_toone: TButton; |
18 |
< |
btn_all_files_toone: TButton; |
19 |
< |
group_onefile: TGroupBox; |
10 |
> |
check_dat: TCheckBox; |
11 |
> |
check_raw: TCheckBox; |
12 |
> |
check_convert: TCheckBox; |
13 |
> |
radio_selected: TRadioButton; |
14 |
> |
label_export_sel: TLabel; |
15 |
> |
radio_all: TRadioButton; |
16 |
> |
label_path: TLabel; |
17 |
> |
edit_path: TEdit; |
18 |
> |
btn_path: TButton; |
19 |
> |
btn_export: TButton; |
20 |
|
group_progress: TGroupBox; |
21 |
|
lbl_progress: TLabel; |
22 |
|
lbl_estimated: TLabel; |
23 |
|
progress: TProgressBar; |
24 |
|
btn_abort: TButton; |
25 |
– |
saved: TSaveDialog; |
25 |
|
procedure FormCreate(Sender: TObject); |
27 |
– |
procedure Extract(Sender: TObject); |
26 |
|
procedure btn_abortClick(Sender: TObject); |
27 |
+ |
procedure btn_pathClick(Sender: TObject); |
28 |
+ |
procedure btn_exportClick(Sender: TObject); |
29 |
|
private |
30 |
|
public |
31 |
|
end; |
35 |
|
|
36 |
|
implementation |
37 |
|
{$R *.dfm} |
38 |
< |
uses Main, Functions, Data, OniDataClass; |
38 |
> |
uses Main, Functions, Data, OniDataClass, FolderBrowser, Exporters; |
39 |
> |
|
40 |
|
|
41 |
|
procedure TForm_Extractor.FormCreate(Sender: TObject); |
42 |
|
begin |
43 |
|
inherited; |
44 |
|
Self.AllowMultiSelect := True; |
45 |
< |
|
45 |
< |
btn_sel_dat.Caption := 'Selected files' + CrLf + '(dat contents only)'; |
46 |
< |
btn_sel_datraw.Caption := 'Selected files' + CrLf + '(dat+raw contents)'; |
47 |
< |
btn_sel_datraw_convert.Caption := |
48 |
< |
'Selected files' + CrLf + '(dat+raw contents)' + CrLf + '(with convert if possible)'; |
49 |
< |
btn_all_dat.Caption := 'All files in list' + CrLf + '(dat contents only)'; |
50 |
< |
btn_all_datraw.Caption := 'All files in list' + CrLf + '(dat+raw contents)'; |
51 |
< |
btn_all_datraw_convert.Caption := |
52 |
< |
'All files in list' + CrLf + '(dat+raw contents)' + CrLf + '(with convert if possible)'; |
53 |
< |
btn_sel_files_toone.Caption := 'Selected files' + CrLf + '(dat contents only)'; |
54 |
< |
btn_all_files_toone.Caption := 'All files in list' + CrLf + '(dat contents only)'; |
45 |
> |
edit_path.Text := AppSettings.ExtractPath; |
46 |
|
end; |
47 |
|
|
48 |
|
procedure TForm_Extractor.btn_abortClick(Sender: TObject); |
50 |
|
ShowMessage('X'); |
51 |
|
end; |
52 |
|
|
53 |
< |
procedure TForm_Extractor.Extract(Sender: TObject); |
53 |
> |
procedure TForm_Extractor.btn_pathClick(Sender: TObject); |
54 |
|
var |
55 |
< |
sel_only: Boolean; |
56 |
< |
dat_only: Boolean; |
57 |
< |
convert: Boolean; |
58 |
< |
one_file: Boolean; |
59 |
< |
settings: TExportSet; |
55 |
> |
fb: TFolderBrowser; |
56 |
> |
begin |
57 |
> |
inherited; |
58 |
> |
|
59 |
> |
fb := TFolderBrowser.Create(Handle, 'Please select a folder where you want ' + |
60 |
> |
'the files to be stored...', edit_path.Text, False, True); |
61 |
> |
if fb.Execute then |
62 |
> |
begin |
63 |
> |
edit_path.Text := fb.SelectedItem; |
64 |
> |
AppSettings.ExtractPath := edit_path.Text; |
65 |
> |
end; |
66 |
> |
fb.Free; |
67 |
> |
end; |
68 |
> |
|
69 |
> |
procedure TForm_Extractor.btn_exportClick(Sender: TObject); |
70 |
> |
var |
71 |
> |
begintime: Double; |
72 |
|
files: LongWord; |
73 |
|
i, done: LongWord; |
74 |
< |
begintime: Double; |
74 |
> |
selonly: Boolean; |
75 |
> |
fileid: LongWord; |
76 |
> |
filename: String; |
77 |
> |
path: String; |
78 |
|
begin |
79 |
< |
sel_only := Pos('sel', TButton(Sender).Name) > 0; |
80 |
< |
dat_only := not (Pos('datraw', TButton(Sender).Name) > 0); |
81 |
< |
convert := Pos('convert', TButton(Sender).Name) > 0; |
82 |
< |
one_file := Pos('toone', TButton(Sender).Name) > 0; |
83 |
< |
if dat_only then |
84 |
< |
settings := [DO_dat] |
85 |
< |
else |
86 |
< |
settings := [DO_dat, DO_raw]; |
87 |
< |
if convert then |
88 |
< |
settings := settings + [DO_convert]; |
89 |
< |
if one_file then |
84 |
< |
settings := settings + [DO_toone]; |
79 |
> |
inherited; |
80 |
> |
panel_files.Enabled := False; |
81 |
> |
group_extract.Enabled := False; |
82 |
> |
group_progress.Visible := True; |
83 |
> |
|
84 |
> |
path := edit_path.Text; |
85 |
> |
if not EndsText('\', path) then |
86 |
> |
path := path + '\'; |
87 |
> |
|
88 |
> |
begintime := Time; |
89 |
> |
lbl_estimated.Caption := 'Estimated finishing time: unknown'; |
90 |
|
progress.Position := 0; |
91 |
|
|
92 |
< |
if saved.Execute then |
92 |
> |
selonly := radio_selected.Checked; |
93 |
> |
|
94 |
> |
if selonly then |
95 |
> |
files := filelist.SelCount |
96 |
> |
else |
97 |
> |
files := filelist.Count; |
98 |
> |
|
99 |
> |
lbl_progress.Caption := 'Files done: 0/' + IntToStr(files); |
100 |
> |
progress.Max := files; |
101 |
> |
done := 0; |
102 |
> |
|
103 |
> |
for i := 0 to filelist.Count - 1 do |
104 |
|
begin |
105 |
< |
begintime := Time; |
90 |
< |
group_progress.Visible := True; |
91 |
< |
panel_files.Enabled := False; |
92 |
< |
group_singlefiles.Enabled := False; |
93 |
< |
group_onefile.Enabled := False; |
94 |
< |
lbl_estimated.Caption := 'Estimated finishing time: unknown'; |
95 |
< |
if one_file then |
105 |
> |
if (selonly and filelist.Selected[i]) or not selonly then |
106 |
|
begin |
107 |
< |
if FileExists(saved.FileName) then |
108 |
< |
begin |
109 |
< |
if MessageBox(Self.Handle, PChar( |
110 |
< |
'File already exists. Do you want to overwrite it?'), PChar('Warning!'), MB_YESNO) = |
111 |
< |
ID_YES then |
112 |
< |
begin |
113 |
< |
DeleteFile(saved.FileName); |
114 |
< |
end |
115 |
< |
else |
106 |
< |
begin |
107 |
< |
group_progress.Visible := False; |
108 |
< |
panel_files.Enabled := True; |
109 |
< |
group_singlefiles.Enabled := True; |
110 |
< |
group_onefile.Enabled := True; |
111 |
< |
Exit; |
112 |
< |
end; |
113 |
< |
end; |
114 |
< |
i := FileCreate(saved.FileName); |
115 |
< |
FileClose(i); |
116 |
< |
i := 0; |
107 |
> |
fileid := OniDataConnection.ExtractFileID(filelist.Items.Strings[i]); |
108 |
> |
filename := GetWinFilename(filelist.Items.Strings[i]); |
109 |
> |
if check_dat.Checked then |
110 |
> |
ExportDatFile(fileid, path + filename); |
111 |
> |
if check_raw.Checked then |
112 |
> |
ExportRawFiles(fileid, path + filename); |
113 |
> |
if check_convert.Checked then |
114 |
> |
ExportConverted(fileid, path + filename); |
115 |
> |
Inc(done); |
116 |
|
end; |
117 |
< |
if sel_only then |
118 |
< |
begin |
120 |
< |
files := filelist.SelCount; |
121 |
< |
lbl_progress.Caption := 'Files done: 0/' + IntToStr(files); |
122 |
< |
progress.Max := files; |
123 |
< |
done := 0; |
124 |
< |
for i := 0 to filelist.Count - 1 do |
125 |
< |
begin |
126 |
< |
if filelist.Selected[i] then |
127 |
< |
begin |
128 |
< |
if one_file then |
129 |
< |
begin |
130 |
< |
ExportFile(OniDataConnection.ExtractFileID( |
131 |
< |
filelist.Items.Strings[filelist.ItemIndex]), ExtractFileName(saved.FileName), |
132 |
< |
settings, ExtractFileDir(saved.FileName)); |
133 |
< |
end |
134 |
< |
else |
135 |
< |
begin |
136 |
< |
ExportFile(OniDataConnection.ExtractFileID( |
137 |
< |
filelist.Items.Strings[filelist.ItemIndex]), filelist.Items.Strings[i], settings, 'D:'); |
138 |
< |
end; |
139 |
< |
Inc(done); |
140 |
< |
end; |
141 |
< |
if ((done mod 10) = 0) and (done >= 50) then |
142 |
< |
lbl_estimated.Caption := 'Estimated finishing time: ' + TimeToStr( |
117 |
> |
if ((done mod 10) = 0) and (done >= 50) then |
118 |
> |
lbl_estimated.Caption := 'Estimated finishing time: ' + TimeToStr( |
119 |
|
(Time - begintime) / done * files + begintime); |
120 |
< |
if (i mod 10) = 0 then |
121 |
< |
begin |
122 |
< |
progress.Position := done; |
123 |
< |
lbl_progress.Caption := 'Files done: ' + IntToStr(done) + '/' + IntToStr(files); |
148 |
< |
Application.ProcessMessages; |
149 |
< |
end; |
150 |
< |
end; |
151 |
< |
end |
152 |
< |
else |
153 |
< |
begin |
154 |
< |
files := filelist.Count; |
155 |
< |
lbl_progress.Caption := 'Files done: 0/' + IntToStr(files); |
156 |
< |
progress.Max := files; |
157 |
< |
for i := 0 to filelist.Count - 1 do |
158 |
< |
begin |
159 |
< |
if one_file then |
160 |
< |
begin |
161 |
< |
ExportFile(OniDataConnection.ExtractFileID( |
162 |
< |
filelist.Items.Strings[filelist.ItemIndex]), ExtractFileName(saved.FileName), |
163 |
< |
settings, ExtractFileDir(saved.FileName)); |
164 |
< |
end |
165 |
< |
else |
166 |
< |
begin |
167 |
< |
ExportFile(OniDataConnection.ExtractFileID( |
168 |
< |
filelist.Items.Strings[filelist.ItemIndex]), filelist.Items.Strings[i], settings, 'D:'); |
169 |
< |
end; |
170 |
< |
if ((i mod 10) = 0) and (i >= 50) then |
171 |
< |
lbl_estimated.Caption := 'Estimated finishing time: ' + TimeToStr( |
172 |
< |
(Time - begintime) / i * files + begintime); |
173 |
< |
if (i mod 5) = 0 then |
174 |
< |
begin |
175 |
< |
progress.Position := i; |
176 |
< |
lbl_progress.Caption := 'Files done: ' + IntToStr(i) + '/' + IntToStr(files); |
177 |
< |
Application.ProcessMessages; |
178 |
< |
end; |
179 |
< |
end; |
180 |
< |
end; |
181 |
< |
group_progress.Visible := False; |
182 |
< |
panel_files.Enabled := True; |
183 |
< |
group_singlefiles.Enabled := True; |
184 |
< |
group_onefile.Enabled := True; |
120 |
> |
|
121 |
> |
progress.Position := done; |
122 |
> |
lbl_progress.Caption := 'Files done: ' + IntToStr(done) + '/' + IntToStr(files); |
123 |
> |
Application.ProcessMessages; |
124 |
|
end; |
125 |
+ |
|
126 |
+ |
panel_files.Enabled := True; |
127 |
+ |
group_extract.Enabled := True; |
128 |
+ |
group_progress.Visible := False; |
129 |
|
end; |
130 |
|
|
131 |
+ |
|
132 |
|
begin |
133 |
|
AddToolListEntry('extractor', 'Extractor', ''); |
134 |
|
end. |