Ignore:
Timestamp:
Dec 23, 2006, 1:03:50 AM (18 years ago)
Author:
alloc
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • oup/current/Tool_Extractor.pas

    r43 r45  
    11unit Tool_Extractor;
    2 
    32interface
    4 
    53uses
    64  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    7   Dialogs, StdCtrls, ExtCtrls, StrUtils, ComCtrls;
     5  Dialogs, Tool_Template, StdCtrls, ExtCtrls, ComCtrls, Menus;
    86
    97type
    10   TForm_Extractor = class(TForm)
    11     group_select: TGroupBox;
     8  TForm_Extractor = class(TForm_ToolTemplate)
    129    group_extract: TGroupBox;
    1310    group_singlefiles: TGroupBox;
     
    1815    btn_all_datraw: TButton;
    1916    btn_all_datraw_convert: TButton;
    20     group_onefile: TGroupBox;
    2117    btn_sel_files_toone: TButton;
    2218    btn_all_files_toone: TButton;
     19    group_onefile: TGroupBox;
    2320    group_progress: TGroupBox;
    24     progress: TProgressBar;
    2521    lbl_progress: TLabel;
    2622    lbl_estimated: TLabel;
     23    progress: TProgressBar;
    2724    btn_abort: TButton;
    2825    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 
    4326    procedure FormCreate(Sender: TObject);
    44     procedure FormClose(Sender: TObject; var Action: TCloseAction);
    45     procedure FormResize(Sender: TObject);
    4627    procedure Extract(Sender: TObject);
     28    procedure btn_abortClick(Sender: TObject);
    4729  private
    4830  public
     
    5335
    5436implementation
    55 
    5637{$R *.dfm}
    57 
    5838uses Main, Code_Functions, Data, Code_OniDataClass;
    59 
    60 
    61 
    62 
    63 procedure TForm_Extractor.Recreatelist;
    64 var
    65   i:    LongWord;
    66   exts: TStringArray;
    67 begin
    68   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) do
    73     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 var
    83   Extension: String[4];
    84   no_zero_bytes: Boolean;
    85   pattern: String;
    86   files: TStringArray;
    87   i: LongWord;
    88 begin
    89   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 then
    93     pattern := edit_filtername.Text;
    94   if Extension = '_All' then
    95     Extension := '';
    96 
    97   files := OniDataConnection.GetFilesList(extension, pattern, no_zero_bytes);
    98   list.Items.Clear;
    99   if Length(files) > 0 then
    100     for i := 0 to High(files) do
    101       list.Items.Add(files[i]);
    102 end;
    103 
    104 
    105 
    106 
    107 procedure TForm_Extractor.panel_extensionResize(Sender: TObject);
    108 begin
    109   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 begin
    118   LoadFileNames;
    119 end;
    120 
    121 
    122 
    123 
    124 procedure TForm_Extractor.check_zerobyteClick(Sender: TObject);
    125 var
    126   i: Byte;
    127 begin
    128   LoadFileNames;
    129 end;
    130 
    131 
    132 
    133 
    134 procedure TForm_Extractor.check_filternameClick(Sender: TObject);
    135 begin
    136   edit_filtername.Enabled := not check_filtername.Checked;
    137   LoadFileNames;
    138 end;
    139 
    140 
    141 
    142 
    143 procedure TForm_Extractor.FormResize(Sender: TObject);
    144 begin
    145   if Self.Width >= 450 then
    146   begin
    147   end
    148   else
    149     Self.Width := 450;
    150   if Self.Height >= 400 then
    151   begin
    152     group_progress.Height := group_extract.Height - 293;
    153   end
    154   else
    155     Self.Height := 400;
    156 end;
    157 
    158 
    159 
    160 
    161 procedure TForm_Extractor.FormClose(Sender: TObject; var Action: TCloseAction);
    162 begin
    163   Action := caFree;
    164 end;
    165 
    166 
    167 
    16839
    16940procedure TForm_Extractor.FormCreate(Sender: TObject);
    17041begin
     42  inherited;
     43  Self.AllowMultiSelect := True;
     44
    17145  btn_sel_dat.Caption    := 'Selected files' + CrLf + '(dat contents only)';
    17246  btn_sel_datraw.Caption := 'Selected files' + CrLf + '(dat+raw contents)';
     
    18155end;
    18256
    183 
    184 
     57procedure TForm_Extractor.btn_abortClick(Sender: TObject);
     58begin
     59  ShowMessage('X');
     60end;
    18561
    18662procedure TForm_Extractor.Extract(Sender: TObject);
     
    21389    begintime := Time;
    21490    group_progress.Visible := True;
    215     group_select.Enabled := False;
     91    panel_files.Enabled := False;
    21692    group_singlefiles.Enabled := False;
    21793    group_onefile.Enabled := False;
     
    230106        begin
    231107          group_progress.Visible    := False;
    232           group_select.Enabled      := True;
     108          panel_files.Enabled      := True;
    233109          group_singlefiles.Enabled := True;
    234110          group_onefile.Enabled     := True;
     
    242118    if sel_only then
    243119    begin
    244       files := list.SelCount;
     120      files := filelist.SelCount;
    245121      lbl_progress.Caption := 'Files done: 0/' + IntToStr(files);
    246122      progress.Max := files;
    247123      done  := 0;
    248       for i := 0 to list.Count - 1 do
     124      for i := 0 to filelist.Count - 1 do
    249125      begin
    250         if list.Selected[i] then
     126        if filelist.Selected[i] then
    251127        begin
    252128          if one_file then
    253129          begin
    254130            ExportFile(OniDataConnection.ExtractFileID(
    255               list.Items.Strings[list.ItemIndex]), ExtractFileName(saved.FileName),
     131              filelist.Items.Strings[filelist.ItemIndex]), ExtractFileName(saved.FileName),
    256132              settings, ExtractFileDir(saved.FileName));
    257133          end
     
    259135          begin
    260136            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:');
    262138          end;
    263139          Inc(done);
     
    276152    else
    277153    begin
    278       files := list.Count;
     154      files := filelist.Count;
    279155      lbl_progress.Caption := 'Files done: 0/' + IntToStr(files);
    280156      progress.Max := files;
    281       for i := 0 to list.Count - 1 do
     157      for i := 0 to filelist.Count - 1 do
    282158      begin
    283159        if one_file then
    284160        begin
    285161          ExportFile(OniDataConnection.ExtractFileID(
    286             list.Items.Strings[list.ItemIndex]), ExtractFileName(saved.FileName),
     162            filelist.Items.Strings[filelist.ItemIndex]), ExtractFileName(saved.FileName),
    287163            settings, ExtractFileDir(saved.FileName));
    288164        end
     
    290166        begin
    291167          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:');
    293169        end;
    294170        if ((i mod 10) = 0) and (i >= 50) then
     
    304180    end;
    305181    group_progress.Visible    := False;
    306     group_select.Enabled      := True;
     182    panel_files.Enabled      := True;
    307183    group_singlefiles.Enabled := True;
    308184    group_onefile.Enabled     := True;
     
    310186end;
    311187
     188begin
     189  AddToolListEntry('extractor', 'Extractor', '');
    312190end.
Note: See TracChangeset for help on using the changeset viewer.