1 | UNIT Unit11_extractor;
|
---|
2 | INTERFACE
|
---|
3 | USES
|
---|
4 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
5 | Dialogs, StdCtrls, ExtCtrls, StrUtils, ComCtrls;
|
---|
6 | TYPE
|
---|
7 | TForm11 = Class(TForm)
|
---|
8 | group_select: TGroupBox;
|
---|
9 | panel_extension: TPanel;
|
---|
10 | combo_extension: TComboBox;
|
---|
11 | list: TListBox;
|
---|
12 | group_extract: TGroupBox;
|
---|
13 | group_singlefiles: TGroupBox;
|
---|
14 | btn_sel_dat: TButton;
|
---|
15 | btn_sel_datraw: TButton;
|
---|
16 | btn_sel_datraw_convert: TButton;
|
---|
17 | btn_all_dat: TButton;
|
---|
18 | btn_all_datraw: TButton;
|
---|
19 | btn_all_datraw_convert: TButton;
|
---|
20 | group_onefile: TGroupBox;
|
---|
21 | btn_sel_files_toone: TButton;
|
---|
22 | btn_all_files_toone: TButton;
|
---|
23 | group_progress: TGroupBox;
|
---|
24 | progress: TProgressBar;
|
---|
25 | lbl_progress: TLabel;
|
---|
26 | lbl_estimated: TLabel;
|
---|
27 | btn_abort: TButton;
|
---|
28 | saved: TSaveDialog;
|
---|
29 | PROCEDURE FormCreate(Sender: TObject);
|
---|
30 | PROCEDURE FormActivate(Sender: TObject);
|
---|
31 | PROCEDURE FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
32 | PROCEDURE FormResize(Sender: TObject);
|
---|
33 | PROCEDURE combo_extensionClick(Sender: TObject);
|
---|
34 | PROCEDURE panel_extensionResize(Sender: TObject);
|
---|
35 | PROCEDURE Extract(Sender: TObject);
|
---|
36 | PRIVATE
|
---|
37 | PUBLIC
|
---|
38 | PROCEDURE Recreatelist;
|
---|
39 | END;
|
---|
40 |
|
---|
41 | VAR
|
---|
42 | Form11: TForm11;
|
---|
43 |
|
---|
44 | IMPLEMENTATION
|
---|
45 | {$R *.dfm}
|
---|
46 | USES Unit1_main, Unit2_functions, Unit3_data;
|
---|
47 |
|
---|
48 | PROCEDURE TForm11.Recreatelist;
|
---|
49 | VAR
|
---|
50 | i:LongWord;
|
---|
51 | exts:TStringList;
|
---|
52 | BEGIN
|
---|
53 | combo_extension.Items.Clear;
|
---|
54 | combo_extension.Items.Add('_All files_ ('{+IntToStr(dat_header.Files)}+')');
|
---|
55 | exts:=GetExtensionsList;
|
---|
56 | FOR i:=0 TO High(exts) DO
|
---|
57 | combo_extension.Items.Add(exts[i]);
|
---|
58 | combo_extension.ItemIndex:=0;
|
---|
59 | combo_extensionClick(Self);
|
---|
60 | END;
|
---|
61 |
|
---|
62 | PROCEDURE TForm11.panel_extensionResize(Sender: TObject);
|
---|
63 | BEGIN
|
---|
64 | combo_extension.Width:=panel_extension.Width-5;
|
---|
65 | END;
|
---|
66 |
|
---|
67 | PROCEDURE TForm11.combo_extensionClick(Sender: TObject);
|
---|
68 | VAR
|
---|
69 | Extension:String[4];
|
---|
70 | files:TStringList;
|
---|
71 | i:LongWord;
|
---|
72 | BEGIN
|
---|
73 | Extension:=MidStr(combo_extension.Items.Strings[combo_extension.ItemIndex],1,4);
|
---|
74 | list.Items.Clear;
|
---|
75 | IF Extension='_All' THEN
|
---|
76 | files:=GetFilesList('','',True)
|
---|
77 | ELSE
|
---|
78 | files:=GetFilesList(extension,'',True);
|
---|
79 | IF Length(files)>0 THEN
|
---|
80 | FOR i:=0 TO High(files) DO
|
---|
81 | list.Items.Add(files[i]);
|
---|
82 | END;
|
---|
83 |
|
---|
84 | PROCEDURE TForm11.FormResize(Sender: TObject);
|
---|
85 | BEGIN
|
---|
86 | IF Self.Width>=450 THEN BEGIN
|
---|
87 | END ELSE Self.Width:=450;
|
---|
88 | IF Self.Height>=400 THEN BEGIN
|
---|
89 | group_progress.Height:=group_extract.Height-293;
|
---|
90 | END ELSE Self.Height:=400;
|
---|
91 | END;
|
---|
92 |
|
---|
93 | PROCEDURE TForm11.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
94 | BEGIN
|
---|
95 | Action:=caFree;
|
---|
96 | Form1.close_window(Self.Name);
|
---|
97 | END;
|
---|
98 |
|
---|
99 | PROCEDURE TForm11.FormActivate(Sender: TObject);
|
---|
100 | BEGIN
|
---|
101 | Form1.SetActiveWindow(Self.Name);
|
---|
102 | END;
|
---|
103 |
|
---|
104 | PROCEDURE TForm11.FormCreate(Sender: TObject);
|
---|
105 | BEGIN
|
---|
106 | btn_sel_dat.Caption:= 'Selected files'+CrLf+'(dat contents only)';
|
---|
107 | btn_sel_datraw.Caption:= 'Selected files'+CrLf+'(dat+raw contents)';
|
---|
108 | btn_sel_datraw_convert.Caption:='Selected files'+CrLf+'(dat+raw contents)'+CrLf+'(with convert if possible)';
|
---|
109 | btn_all_dat.Caption:= 'All files in list'+CrLf+'(dat contents only)';
|
---|
110 | btn_all_datraw.Caption:= 'All files in list'+CrLf+'(dat+raw contents)';
|
---|
111 | btn_all_datraw_convert.Caption:='All files in list'+CrLf+'(dat+raw contents)'+CrLf+'(with convert if possible)';
|
---|
112 | btn_sel_files_toone.Caption:= 'Selected files'+CrLf+'(dat contents only)';
|
---|
113 | btn_all_files_toone.Caption:= 'All files in list'+CrLf+'(dat contents only)';
|
---|
114 | END;
|
---|
115 |
|
---|
116 | PROCEDURE TForm11.Extract(Sender: TObject);
|
---|
117 | VAR
|
---|
118 | sel_only:Boolean;
|
---|
119 | dat_only:Boolean;
|
---|
120 | convert:Boolean;
|
---|
121 | one_file:Boolean;
|
---|
122 | settings:TExportSet;
|
---|
123 | files:LongWord;
|
---|
124 | i,done:LongWord;
|
---|
125 | begintime:Double;
|
---|
126 | BEGIN
|
---|
127 | sel_only:=Pos('sel',TButton(Sender).Name)>0;
|
---|
128 | dat_only:=NOT (Pos('datraw',TButton(Sender).Name)>0);
|
---|
129 | convert:=Pos('convert',TButton(Sender).Name)>0;
|
---|
130 | one_file:=Pos('toone',TButton(Sender).Name)>0;
|
---|
131 | IF dat_only THEN settings:=[DO_dat]
|
---|
132 | ELSE settings:=[DO_dat,DO_raw];
|
---|
133 | IF convert THEN settings:=settings+[DO_convert];
|
---|
134 | IF one_file THEN settings:=settings+[DO_toone];
|
---|
135 | progress.Position:=0;
|
---|
136 |
|
---|
137 | IF saved.Execute THEN BEGIN
|
---|
138 | begintime:=Time;
|
---|
139 | group_progress.Visible:=True;
|
---|
140 | group_select.Enabled:=False;
|
---|
141 | group_singlefiles.Enabled:=False;
|
---|
142 | group_onefile.Enabled:=False;
|
---|
143 | lbl_estimated.Caption:='Estimated finishing time: unknown';
|
---|
144 | IF sel_only THEN BEGIN
|
---|
145 | files:=list.SelCount;
|
---|
146 | lbl_progress.Caption:='Files done: 0/'+IntToStr(files);
|
---|
147 | progress.Max:=files;
|
---|
148 | done:=0;
|
---|
149 | FOR i:=0 TO list.Count-1 DO BEGIN
|
---|
150 | IF list.Selected[i] THEN BEGIN
|
---|
151 | ExportFile(StrToInt(MidStr(list.Items.Strings[i],1,5)),list.Items.Strings[i],settings,'D:');
|
---|
152 | Inc(done);
|
---|
153 | END;
|
---|
154 | IF ((done MOD 10)=0) AND (done>=50) THEN
|
---|
155 | lbl_estimated.Caption:='Estimated finishing time: '+TimeToStr((Time-begintime)/done*files+begintime);
|
---|
156 | IF (i MOD 10)=0 THEN BEGIN
|
---|
157 | progress.Position:=done;
|
---|
158 | lbl_progress.Caption:='Files done: '+IntToStr(done)+'/'+IntToStr(files);
|
---|
159 | Application.ProcessMessages;
|
---|
160 | END;
|
---|
161 | END;
|
---|
162 | END ELSE BEGIN
|
---|
163 | files:=list.Count;
|
---|
164 | lbl_progress.Caption:='Files done: 0/'+IntToStr(files);
|
---|
165 | progress.Max:=files;
|
---|
166 | FOR i:=0 TO list.Count-1 DO BEGIN
|
---|
167 | ExportFile(StrToInt(MidStr(list.Items.Strings[i],1,5)),list.Items.Strings[i],settings,'D:');
|
---|
168 | IF ((i MOD 10)=0) AND (i>=50) THEN
|
---|
169 | lbl_estimated.Caption:='Estimated finishing time: '+TimeToStr((Time-begintime)/i*files+begintime);
|
---|
170 | IF (i MOD 5)=0 THEN BEGIN
|
---|
171 | progress.Position:=done;
|
---|
172 | lbl_progress.Caption:='Files done: '+IntToStr(done)+'/'+IntToStr(files);
|
---|
173 | Application.ProcessMessages;
|
---|
174 | END;
|
---|
175 | END;
|
---|
176 | END;
|
---|
177 | group_progress.Visible:=False;
|
---|
178 | group_select.Enabled:=True;
|
---|
179 | group_singlefiles.Enabled:=True;
|
---|
180 | group_onefile.Enabled:=True;
|
---|
181 | END;
|
---|
182 | END;
|
---|
183 |
|
---|
184 | END.
|
---|