Changeset 45 for oup/current/Tool_Extractor.pas
- Timestamp:
- Dec 23, 2006, 1:03:50 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Tool_Extractor.pas
r43 r45 1 1 unit Tool_Extractor; 2 3 2 interface 4 5 3 uses 6 4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 7 Dialogs, StdCtrls, ExtCtrls, StrUtils, ComCtrls;5 Dialogs, Tool_Template, StdCtrls, ExtCtrls, ComCtrls, Menus; 8 6 9 7 type 10 TForm_Extractor = class(TForm) 11 group_select: TGroupBox; 8 TForm_Extractor = class(TForm_ToolTemplate) 12 9 group_extract: TGroupBox; 13 10 group_singlefiles: TGroupBox; … … 18 15 btn_all_datraw: TButton; 19 16 btn_all_datraw_convert: TButton; 20 group_onefile: TGroupBox;21 17 btn_sel_files_toone: TButton; 22 18 btn_all_files_toone: TButton; 19 group_onefile: TGroupBox; 23 20 group_progress: TGroupBox; 24 progress: TProgressBar;25 21 lbl_progress: TLabel; 26 22 lbl_estimated: TLabel; 23 progress: TProgressBar; 27 24 btn_abort: TButton; 28 25 saved: TSaveDialog; 29 panel_extension: TPanel;30 lbl_filter: TLabel;31 combo_extension: TComboBox;32 check_zerobyte: TCheckBox;33 edit_filtername: TEdit;34 check_filtername: TCheckBox;35 list: TListBox;36 procedure LoadFileNames;37 procedure check_filternameClick(Sender: TObject);38 procedure check_zerobyteClick(Sender: TObject);39 procedure combo_extensionClick(Sender: TObject);40 procedure panel_extensionResize(Sender: TObject);41 procedure Recreatelist;42 43 26 procedure FormCreate(Sender: TObject); 44 procedure FormClose(Sender: TObject; var Action: TCloseAction);45 procedure FormResize(Sender: TObject);46 27 procedure Extract(Sender: TObject); 28 procedure btn_abortClick(Sender: TObject); 47 29 private 48 30 public … … 53 35 54 36 implementation 55 56 37 {$R *.dfm} 57 58 38 uses Main, Code_Functions, Data, Code_OniDataClass; 59 60 61 62 63 procedure TForm_Extractor.Recreatelist;64 var65 i: LongWord;66 exts: TStringArray;67 begin68 combo_extension.Items.Clear;69 combo_extension.Items.Add('_All files_ (' + IntToStr(70 OniDataConnection.GetFilesCount) + ')');71 exts := OniDataConnection.GetExtensionsList;72 for i := 0 to High(exts) do73 combo_extension.Items.Add(exts[i]);74 combo_extension.ItemIndex := 0;75 combo_extensionClick(Self);76 end;77 78 79 80 81 procedure TForm_Extractor.LoadFileNames;82 var83 Extension: String[4];84 no_zero_bytes: Boolean;85 pattern: String;86 files: TStringArray;87 i: LongWord;88 begin89 Extension := MidStr(combo_extension.Items.Strings[combo_extension.ItemIndex], 1, 4);90 no_zero_bytes := not check_zerobyte.Checked;91 pattern := '';92 if check_filtername.Checked then93 pattern := edit_filtername.Text;94 if Extension = '_All' then95 Extension := '';96 97 files := OniDataConnection.GetFilesList(extension, pattern, no_zero_bytes);98 list.Items.Clear;99 if Length(files) > 0 then100 for i := 0 to High(files) do101 list.Items.Add(files[i]);102 end;103 104 105 106 107 procedure TForm_Extractor.panel_extensionResize(Sender: TObject);108 begin109 combo_extension.Width := panel_extension.Width - 5;110 edit_filtername.Width := panel_extension.Width - 5;111 end;112 113 114 115 116 procedure TForm_Extractor.combo_extensionClick(Sender: TObject);117 begin118 LoadFileNames;119 end;120 121 122 123 124 procedure TForm_Extractor.check_zerobyteClick(Sender: TObject);125 var126 i: Byte;127 begin128 LoadFileNames;129 end;130 131 132 133 134 procedure TForm_Extractor.check_filternameClick(Sender: TObject);135 begin136 edit_filtername.Enabled := not check_filtername.Checked;137 LoadFileNames;138 end;139 140 141 142 143 procedure TForm_Extractor.FormResize(Sender: TObject);144 begin145 if Self.Width >= 450 then146 begin147 end148 else149 Self.Width := 450;150 if Self.Height >= 400 then151 begin152 group_progress.Height := group_extract.Height - 293;153 end154 else155 Self.Height := 400;156 end;157 158 159 160 161 procedure TForm_Extractor.FormClose(Sender: TObject; var Action: TCloseAction);162 begin163 Action := caFree;164 end;165 166 167 168 39 169 40 procedure TForm_Extractor.FormCreate(Sender: TObject); 170 41 begin 42 inherited; 43 Self.AllowMultiSelect := True; 44 171 45 btn_sel_dat.Caption := 'Selected files' + CrLf + '(dat contents only)'; 172 46 btn_sel_datraw.Caption := 'Selected files' + CrLf + '(dat+raw contents)'; … … 181 55 end; 182 56 183 184 57 procedure TForm_Extractor.btn_abortClick(Sender: TObject); 58 begin 59 ShowMessage('X'); 60 end; 185 61 186 62 procedure TForm_Extractor.Extract(Sender: TObject); … … 213 89 begintime := Time; 214 90 group_progress.Visible := True; 215 group_select.Enabled := False;91 panel_files.Enabled := False; 216 92 group_singlefiles.Enabled := False; 217 93 group_onefile.Enabled := False; … … 230 106 begin 231 107 group_progress.Visible := False; 232 group_select.Enabled := True;108 panel_files.Enabled := True; 233 109 group_singlefiles.Enabled := True; 234 110 group_onefile.Enabled := True; … … 242 118 if sel_only then 243 119 begin 244 files := list.SelCount;120 files := filelist.SelCount; 245 121 lbl_progress.Caption := 'Files done: 0/' + IntToStr(files); 246 122 progress.Max := files; 247 123 done := 0; 248 for i := 0 to list.Count - 1 do124 for i := 0 to filelist.Count - 1 do 249 125 begin 250 if list.Selected[i] then126 if filelist.Selected[i] then 251 127 begin 252 128 if one_file then 253 129 begin 254 130 ExportFile(OniDataConnection.ExtractFileID( 255 list.Items.Strings[list.ItemIndex]), ExtractFileName(saved.FileName),131 filelist.Items.Strings[filelist.ItemIndex]), ExtractFileName(saved.FileName), 256 132 settings, ExtractFileDir(saved.FileName)); 257 133 end … … 259 135 begin 260 136 ExportFile(OniDataConnection.ExtractFileID( 261 list.Items.Strings[list.ItemIndex]),list.Items.Strings[i], settings, 'D:');137 filelist.Items.Strings[filelist.ItemIndex]), filelist.Items.Strings[i], settings, 'D:'); 262 138 end; 263 139 Inc(done); … … 276 152 else 277 153 begin 278 files := list.Count;154 files := filelist.Count; 279 155 lbl_progress.Caption := 'Files done: 0/' + IntToStr(files); 280 156 progress.Max := files; 281 for i := 0 to list.Count - 1 do157 for i := 0 to filelist.Count - 1 do 282 158 begin 283 159 if one_file then 284 160 begin 285 161 ExportFile(OniDataConnection.ExtractFileID( 286 list.Items.Strings[list.ItemIndex]), ExtractFileName(saved.FileName),162 filelist.Items.Strings[filelist.ItemIndex]), ExtractFileName(saved.FileName), 287 163 settings, ExtractFileDir(saved.FileName)); 288 164 end … … 290 166 begin 291 167 ExportFile(OniDataConnection.ExtractFileID( 292 list.Items.Strings[list.ItemIndex]),list.Items.Strings[i], settings, 'D:');168 filelist.Items.Strings[filelist.ItemIndex]), filelist.Items.Strings[i], settings, 'D:'); 293 169 end; 294 170 if ((i mod 10) = 0) and (i >= 50) then … … 304 180 end; 305 181 group_progress.Visible := False; 306 group_select.Enabled := True;182 panel_files.Enabled := True; 307 183 group_singlefiles.Enabled := True; 308 184 group_onefile.Enabled := True; … … 310 186 end; 311 187 188 begin 189 AddToolListEntry('extractor', 'Extractor', ''); 312 190 end.
Note:
See TracChangeset
for help on using the changeset viewer.