- Timestamp:
- Jan 11, 2007, 11:45:20 PM (18 years ago)
- Location:
- oup/current
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Code/Exporters.pas
r46 r74 6 6 7 7 procedure ExportDatFile(fileid: LongWord; filename: String); 8 procedure ExportRawFiles(fileid: LongWord; filename: String); 8 9 procedure ExportRawFile(fileid: LongWord; dat_offset: LongWord; filename: String); 9 10 function ExportSNDD(fileid: LongWord; filename: String; convert: Boolean): Integer; 11 function Export TRAC(fileid: LongWord; filename: String; convert: Boolean): Integer;12 function ExportT XAN(fileid: LongWord; filename: String; convert: Boolean): Integer;13 function ExportTX MB(fileid: LongWord; filename: String; convert: Boolean): Integer;14 function Export TXMP(fileid: LongWord; filename: String; convert: Boolean): Integer;15 16 var 17 ExportHandlers: array[1.. 1] of TExportHandlers = (18 19 //(Ext:'AGDB'; needed:False),20 (Ext: 'SNDD'; needed: True; Handler: ExportSNDD) 21 {(Ext:'TRAC'; needed:True; Handler:ExportTRAC),22 (Ext:'TXAN'; needed:True; Handler:ExportTXAN),23 (Ext:'TXMB'; needed:True; Handler:Export TXMB),24 (Ext:'TXMP'; needed:True; Handler:Export TXMP)25 });10 function ExportConverted(fileid: LongWord; filename: String): Integer; 11 12 function ExportSNDD(fileid: LongWord; filename: String): Integer; 13 function ExportTRAC(fileid: LongWord; filename: String): Integer; 14 function ExportTXAN(fileid: LongWord; filename: String): Integer; 15 function ExportImage(fileid: LongWord; filename: String): Integer; 16 17 var 18 ExportHandlers: array[1..3] of TExportHandlers = ( 19 // (Ext:'ABNA'; needed:False), 20 // (Ext:'AGDB'; needed:False), 21 (Ext: 'SNDD'; needed: True; Handler: ExportSNDD), 22 // (Ext:'TRAC'; needed:True; Handler:ExportTRAC), 23 // (Ext:'TXAN'; needed:True; Handler:ExportTXAN), 24 (Ext:'TXMB'; needed:True; Handler:ExportImage), 25 (Ext:'TXMP'; needed:True; Handler:ExportImage) 26 ); 26 27 27 28 … … 30 31 31 32 uses Functions, DataStructures, OniDataClass; 32 33 33 34 34 … … 54 54 55 55 56 56 procedure ExportRawFiles(fileid: LongWord; filename: String); 57 var 58 i: Integer; 59 rawlist: TRawList; 60 begin 61 rawlist := OniDataConnection.GetRawList(fileid); 62 if Length(rawlist) > 0 then 63 for i := 0 to High(rawlist) do 64 ExportRawFile(fileid, rawlist[i].src_offset, filename); 65 end; 57 66 58 67 procedure ExportRawFile(fileid: LongWord; dat_offset: LongWord; filename: String); … … 77 86 end; 78 87 88 function ExportConverted(fileid: LongWord; filename: String): Integer; 89 var 90 i: Integer; 91 fileinfo: TFileInfo; 92 begin 93 fileinfo := OniDataConnection.GetFileInfo(fileid); 94 if Length(ExportHandlers) > 0 then 95 for i := 0 to High(ExportHandlers) do 96 if ExportHandlers[i].Ext = fileinfo.Extension then 97 ExportHandlers[i].Handler(fileid, filename); 98 end; 99 79 100 80 101 81 102 82 103 function ExportSNDD; 83 { CONST 84 WAVheader:Array[0..0] OF Byte=( 85 Ord('R'),Ord('I'),Ord('F'),Ord('F'),0,0,0,0,Ord('W'),Ord('A'),Ord('V'),Ord('E'), 86 Ord('f'),Ord('m'),Ord('t'),Ord(' '),24,0,0,0, 87 ); 88 } type 89 TDatData = record 104 type 105 TDatData = packed record 90 106 {0x00} 91 _fileid: LongWord;92 level: LongWord;93 F lag: LongWord;94 FormatTag:Word;95 ChanNo:Word;107 _fileid: LongWord; 108 level: LongWord; 109 FormatSize: LongWord; 110 AudioFormat: Word; 111 NumChannels: Word; 96 112 {0x10} 97 SampleRate: LongWord; 98 BytesPSec: LongWord; 99 BPSample: LongWord; 100 BitsPS: LongWord; 101 {0x20} 102 Unknown: array[1..7] of LongWord; 103 Unknown2: Word; 113 SampleRate: LongWord; 114 ByteRate: LongWord; 115 BlockAlign: Word; 116 BitsPerSample: Word; 117 {0x1C} 118 SizeExtHeader: Word; 119 SamplesPerBlock: Word; 120 NumCoefficients: Word; 121 Coefficients: array[0..6] of LongWord; 122 {0x3E} 123 Duration: Word; 104 124 {0x40} 105 RawSize: LongWord; 106 RawPos: LongWord; 107 end; 108 var 109 filestream: TFileStream; 110 125 RawSize: LongWord; 126 RawPos: LongWord; 127 end; 128 var 129 filestream: TFileStream; 111 130 DatData: TDatData; 131 i: Integer; 132 Data: Tdata; 133 112 134 //Wave Header Stuff 113 ASCII_Group: LongWord; //"RIFF" 114 WAV_Len: LongWord; 115 ASCII_WAV: LongWord; //"WAVE" 116 ASCII_FMT: LongWord; //"fmt " 117 WAV_FMT_Len: LongWord; 118 ASCII_DATA: LongWord; //"data" 119 WAV_FolLen: LongWord; 120 121 Data: Tdata; 135 ASCII_RIFF: LongWord; //"RIFF" 136 WAVE_Len: LongWord; 137 ASCII_WAVE: LongWord; //"WAVE" 138 ASCII_FMT: LongWord; //"fmt " 139 WAVE_FMT_Len: LongWord; 140 ASCII_DATA: LongWord; //"data" 141 WAVE_DataLen: LongWord; 122 142 begin 123 143 Result := export_noerror; … … 126 146 begin 127 147 //Initializing Header vars 128 ASCII_ Group:= 1179011410; // 'RIFF'129 WAV _Len := RAWSize + 70;130 ASCII_WAV := 1163280727; // 'WAVE'131 ASCII_FMT := 544501094; // 'fmt '132 WAV _FMT_Len := 50; // 50 bytes133 ASCII_DATA := 1635017060; // 'data'134 WAV _FolLen:= RAWSize;148 ASCII_RIFF := 1179011410; // 'RIFF' 149 WAVE_Len := RAWSize + 70; 150 ASCII_WAVE := 1163280727; // 'WAVE' 151 ASCII_FMT := 544501094; // 'fmt ' 152 WAVE_FMT_Len := 50; // 50 bytes 153 ASCII_DATA := 1635017060; // 'data' 154 WAVE_DataLen := RAWSize; 135 155 SetLength(Data, RAWSize); 136 156 OniDataConnection.LoadRawFile(fileid, $44, Data); 137 157 138 filestream := TFileStream.Create(filename + '.raw', fmCreate); 158 //Now start packing this into a neat wave... 159 filestream := TFileStream.Create(filename + '.wav', fmCreate); 160 filestream.Write(ASCII_RIFF, SizeOf(ASCII_RIFF)); 161 filestream.Write(WAVE_Len, SizeOf(WAVE_Len)); 162 filestream.Write(ASCII_WAVE, SizeOf(ASCII_WAVE)); 163 filestream.Write(ASCII_FMT, SizeOf(ASCII_FMT)); 164 filestream.Write(WAVE_FMT_Len, SizeOf(WAVE_FMT_Len)); 165 filestream.Write(AudioFormat, SizeOf(AudioFormat)); 166 filestream.Write(NumChannels, SizeOf(NumChannels)); 167 filestream.Write(Samplerate, SizeOf(Samplerate)); 168 filestream.Write(ByteRate, SizeOf(ByteRate)); 169 filestream.Write(BlockAlign, SizeOf(BlockAlign)); 170 filestream.Write(BitsPerSample, SizeOf(BitsPerSample)); 171 filestream.Write(SizeExtHeader, SizeOf(SizeExtHeader)); 172 filestream.Write(SamplesPerBlock, SizeOf(SamplesPerBlock)); 173 filestream.Write(NumCoefficients, SizeOf(NumCoefficients)); 174 for i := 0 to High(Coefficients) do 175 filestream.Write(Coefficients[i], SizeOf(Coefficients[i])); 176 filestream.Write(ASCII_DATA, SizeOf(ASCII_DATA)); 177 filestream.Write(WAVE_DataLen, SizeOf(WAVE_DataLen)); 139 178 filestream.Write(Data[0], Length(Data)); 140 179 filestream.Free; 141 142 if convert then143 begin144 //Now start packing this into a neat wave...145 filestream := TFileStream.Create(filename + '.wav', fmCreate);146 filestream.Write(ASCII_Group, SizeOf(ASCII_Group));147 filestream.Write(WAV_Len, SizeOf(WAV_Len));148 filestream.Write(ASCII_WAV, SizeOf(ASCII_WAV));149 filestream.Write(ASCII_FMT, SizeOf(ASCII_FMT));150 filestream.Write(WAV_FMT_Len, SizeOf(WAV_FMT_Len));151 filestream.Write(ChanNo, SizeOf(ChanNo));152 filestream.Write(Samplerate, SizeOf(Samplerate));153 filestream.Write(BytesPSec, SizeOf(BytesPSec));154 filestream.Write(BPSample, SizeOf(BPSample));155 filestream.Write(BitsPS, SizeOf(BitsPS));156 filestream.Write(Unknown[1], SizeOf(Unknown));157 filestream.Write(Unknown2, SizeOf(Unknown2));158 filestream.Write(ASCII_DATA, SizeOf(ASCII_DATA));159 filestream.Write(WAV_FolLen, SizeOf(WAV_FolLen));160 filestream.Write(Data[0], Length(Data));161 filestream.Free;162 end;163 180 end; 164 181 end; … … 214 231 215 232 216 function ExportTXMB; 217 var 218 filestream: TFileStream; 219 // img:TImgPackage; 220 Data: Tdata; 221 begin 222 Result := export_noerror; 223 if convert then 224 begin 225 { img:=LoadTXMBconnected(fileid); 226 data:=ImgdataToBmp(img.imgx,img.imgy,img.imgdepth,img.storetype,img.imgdata); 227 filestream:=TFileStream.Create(filename+'.bmp',fmCreate); 228 filestream.Write(data[0],Length(data)); 229 filestream.Free; 230 } end; 231 end; 232 233 234 235 236 function ExportTXMP; 237 var 238 filestream: TFileStream; 239 // img:TImgPackage; 240 begin 241 Result := export_noerror; 242 { img:=LoadImgData(fileid); 243 244 filestream:=TFileStream.Create(filename+'.raw',fmCreate); 245 filestream.Write(img.imgdata[0],Length(img.imgdata)); 246 filestream.Free; 247 248 IF convert THEN BEGIN 249 img.imgdata:=ImgdataToBMP(img.imgx,img.imgy,img.imgdepth,img.storetype,img.imgdata); 250 filestream:=TFileStream.Create(filename+'.bmp',fmCreate); 251 filestream.Write(img.imgdata[0],Length(img.imgdata)); 252 filestream.Free; 253 END; 254 } end; 233 function ExportImage; 234 var 235 filestream: TFileStream; 236 img: TOniImage; 237 data: Tdata; 238 begin 239 Result := export_noerror; 240 241 img := TOniImage.Create; 242 img.Load(fileid); 243 data := img.GetAsBMP; 244 img.Free; 245 246 filestream:=TFileStream.Create(filename+'.bmp',fmCreate); 247 filestream.Write(data[0],Length(data)); 248 filestream.Free; 249 end; 255 250 256 251 end. -
oup/current/Code/Functions.pas
r46 r74 4 4 5 5 uses Classes, Dialogs, SysUtils, StrUtils, Math, Data; 6 7 type8 TExportSet = set of (DO_dat, DO_raw, DO_convert, DO_toone);9 6 10 7 function BoolToStr(bool: Boolean): String; … … 16 13 function DataToBin(Data: Tdata): String; 17 14 function BinToInt(bin: String): Byte; 18 19 function ExportFile(fileid: LongWord; filename: String; settings: TExportSet;20 path: String): Integer;21 15 22 16 function StringSmaller(string1, string2: String): Boolean; … … 324 318 325 319 326 327 function ExportFile(fileid: LongWord; filename: String; settings: TExportSet;328 path: String): Integer;329 var330 i: Byte;331 extension: String;332 rawlist: TRawList;333 begin334 Result := export_noerror;335 extension := RightStr(filename, 4);336 if DO_toone in settings then337 begin338 ExportDatFile(fileid, path + '\' + GetWinFileName(filename));339 end340 else341 begin342 if DO_dat in settings then343 ExportDatFile(fileid, path + '\' + GetWinFileName(filename));344 if DO_raw in settings then345 begin346 rawlist := OniDataConnection.GetRawList(fileid);347 if Length(rawlist) > 0 then348 begin349 for i := 0 to High(rawlist) do350 begin351 ExportRawFile(fileid, rawlist[i].src_offset, path + '\' +352 GetWinFileName(filename));353 end;354 end;355 end;356 end;357 end;358 359 360 361 362 320 function Explode(_string: String; delimiter: Char): TStringArray; 363 321 var -
oup/current/Data.pas
r46 r74 71 71 Ext: String[4]; 72 72 needed: Boolean; 73 Handler: function(fileid: LongWord; filename: String ; convert: Boolean): Integer;73 Handler: function(fileid: LongWord; filename: String): Integer; 74 74 end; 75 75 -
oup/current/OniUnPacker.dpr
r56 r74 19 19 Extractor in 'Tools\Extractor.pas' {Form_ToolTemplate3}, 20 20 RawEdit in 'Tools\RawEdit.pas' {Form_ToolTemplate4}, 21 TxmpReplace in 'Tools\TxmpReplace.pas' {Form_ToolTemplate5}; 21 TxmpReplace in 'Tools\TxmpReplace.pas' {Form_ToolTemplate5}, 22 FolderBrowser in 'Code\FolderBrowser.pas'; 22 23 23 24 {$R *.res} -
oup/current/Tools/Extractor.dfm
r46 r74 1 1 inherited Form_Extractor: TForm_Extractor 2 2 Caption = 'Extractor' 3 ClientHeight = 491 4 ExplicitWidth = 500 5 ExplicitHeight = 518 3 6 PixelsPerInch = 96 4 7 TextHeight = 13 5 8 inherited Splitter1: TSplitter 6 9 Left = 483 10 Height = 491 7 11 Align = alRight 8 12 Visible = False … … 12 16 end 13 17 inherited panel_files: TPanel 14 Width = 184 15 Align = alClient 16 ExplicitWidth = 184 18 Width = 333 19 Height = 491 20 ExplicitWidth = 333 21 ExplicitHeight = 491 17 22 inherited filelist: TListBox 18 Width = 184 19 ExplicitWidth = 184 23 Width = 333 24 Height = 362 25 ExplicitWidth = 333 26 ExplicitHeight = 362 20 27 end 21 28 inherited panel_extension: TPanel 22 Width = 18423 ExplicitWidth = 18429 Width = 333 30 ExplicitWidth = 333 24 31 inherited combo_extension: TComboBox 25 Width = 176 26 ExplicitWidth = 176 32 Width = 325 33 ExplicitWidth = 325 34 end 35 inherited check_zerobyte: TCheckBox 36 Visible = False 27 37 end 28 38 inherited edit_filtername: TEdit 29 Width = 17630 ExplicitWidth = 17639 Width = 325 40 ExplicitWidth = 325 31 41 end 32 42 end 33 43 end 34 44 inherited content: TPanel 35 Left = 184 36 Width = 299 37 Align = alRight 38 ExplicitLeft = 184 39 ExplicitWidth = 299 45 Left = 333 46 Width = 150 47 Height = 491 48 ExplicitLeft = 333 49 ExplicitWidth = 150 50 ExplicitHeight = 491 40 51 object group_extract: TGroupBox 41 Left = 3 42 Top = 0 43 Width = 296 44 Height = 423 45 Align = alRight 52 AlignWithMargins = True 53 Left = 6 54 Top = 3 55 Width = 138 56 Height = 374 57 Margins.Left = 6 58 Margins.Right = 6 59 Align = alClient 46 60 Caption = '2. Select extract-method' 47 61 TabOrder = 0 48 object group_singlefiles: TGroupBox 49 AlignWithMargins = True 62 DesignSize = ( 63 138 64 374) 65 object label_export_sel: TLabel 66 Left = 7 67 Top = 18 68 Width = 62 69 Height = 20 70 AutoSize = False 71 Caption = 'Export ...' 72 end 73 object label_path: TLabel 74 Left = 7 75 Top = 136 76 Width = 30 77 Height = 18 78 AutoSize = False 79 Caption = 'Path:' 80 end 81 object check_dat: TCheckBox 82 Left = 7 83 Top = 75 84 Width = 121 85 Height = 18 86 Anchors = [akLeft, akTop, akRight] 87 Caption = 'Export .dat-entries' 88 Checked = True 89 State = cbChecked 90 TabOrder = 0 91 end 92 object check_raw: TCheckBox 93 Left = 7 94 Top = 94 95 Width = 121 96 Height = 18 97 Anchors = [akLeft, akTop, akRight] 98 Caption = 'Export .raw-entries' 99 TabOrder = 1 100 end 101 object check_convert: TCheckBox 102 Left = 7 103 Top = 112 104 Width = 121 105 Height = 18 106 Anchors = [akLeft, akTop, akRight] 107 Caption = 'Convert files' 108 TabOrder = 2 109 end 110 object radio_selected: TRadioButton 111 Left = 7 112 Top = 36 113 Width = 113 114 Height = 17 115 Caption = 'selected files' 116 Checked = True 117 TabOrder = 3 118 TabStop = True 119 end 120 object radio_all: TRadioButton 121 Left = 7 122 Top = 52 123 Width = 113 124 Height = 17 125 Caption = 'all files in list' 126 TabOrder = 4 127 end 128 object edit_path: TEdit 129 Left = 36 130 Top = 133 131 Width = 28 132 Height = 21 133 Anchors = [akLeft, akTop, akRight] 134 ReadOnly = True 135 TabOrder = 5 136 Text = 'C:\' 137 OnClick = btn_pathClick 138 end 139 object btn_path: TButton 140 Left = 70 141 Top = 133 142 Width = 62 143 Height = 21 144 Anchors = [akTop, akRight] 145 Caption = 'Select...' 146 TabOrder = 6 147 OnClick = btn_pathClick 148 end 149 object btn_export: TButton 150 Left = 7 151 Top = 180 152 Width = 75 153 Height = 25 154 Caption = 'Export!' 155 TabOrder = 7 156 OnClick = btn_exportClick 157 end 158 end 159 object group_progress: TGroupBox 160 AlignWithMargins = True 161 Left = 6 162 Top = 381 163 Width = 138 164 Height = 104 165 Margins.Left = 6 166 Margins.Top = 1 167 Margins.Right = 6 168 Margins.Bottom = 6 169 Align = alBottom 170 Caption = 'Progress ...' 171 TabOrder = 1 172 Visible = False 173 DesignSize = ( 174 138 175 104) 176 object lbl_progress: TLabel 177 Left = 8 178 Top = 40 179 Width = 265 180 Height = 17 181 AutoSize = False 182 Caption = 'Files done: 0/0' 183 end 184 object lbl_estimated: TLabel 185 Left = 8 186 Top = 56 187 Width = 265 188 Height = 17 189 AutoSize = False 190 Caption = 'Estimated finishing time: 00:00:00' 191 end 192 object progress: TProgressBar 50 193 Left = 8 51 194 Top = 16 52 Width = 280 53 Height = 185 54 Margins.Left = 6 55 Margins.Top = 1 56 Margins.Right = 6 57 Align = alTop 58 Caption = 'Write data into single files' 195 Width = 122 196 Height = 17 197 Anchors = [akLeft, akTop, akRight] 198 Smooth = True 59 199 TabOrder = 0 60 object btn_sel_dat: TButton 61 Left = 8 62 Top = 16 63 Width = 129 64 Height = 49 65 Caption = 'Selected files (dat contents only)' 66 TabOrder = 0 67 WordWrap = True 68 OnClick = Extract 69 end 70 object btn_sel_datraw: TButton 71 Left = 8 72 Top = 72 73 Width = 129 74 Height = 49 75 Caption = 'Selected files (dat+raw)' 76 TabOrder = 1 77 WordWrap = True 78 OnClick = Extract 79 end 80 object btn_sel_datraw_convert: TButton 81 Left = 8 82 Top = 128 83 Width = 129 84 Height = 49 85 Caption = 'Selected files (dat+raw) (with convert if possible)' 86 TabOrder = 2 87 WordWrap = True 88 OnClick = Extract 89 end 90 object btn_all_dat: TButton 91 Left = 144 92 Top = 16 93 Width = 129 94 Height = 49 95 Caption = 'All files in list (dat contents only)' 96 TabOrder = 3 97 WordWrap = True 98 OnClick = Extract 99 end 100 object btn_all_datraw: TButton 101 Left = 144 102 Top = 72 103 Width = 129 104 Height = 49 105 Caption = 'All files in list (dat+raw)' 106 TabOrder = 4 107 WordWrap = True 108 OnClick = Extract 109 end 110 object btn_all_datraw_convert: TButton 111 Left = 144 112 Top = 128 113 Width = 129 114 Height = 49 115 BiDiMode = bdLeftToRight 116 Caption = 'All files in list (dat+raw) (with convert if possible)' 117 ParentBiDiMode = False 118 TabOrder = 5 119 WordWrap = True 120 OnClick = Extract 121 end 122 end 123 object group_onefile: TGroupBox 124 AlignWithMargins = True 125 Left = 8 126 Top = 205 127 Width = 280 128 Height = 73 129 Margins.Left = 6 130 Margins.Top = 1 131 Margins.Right = 6 132 Align = alTop 133 Caption = 'Write data into one file' 200 end 201 object btn_abort: TButton 202 Left = 8 203 Top = 72 204 Width = 97 205 Height = 23 206 Caption = 'Abort' 207 Enabled = False 134 208 TabOrder = 1 135 object btn_sel_files_toone: TButton 136 Left = 8 137 Top = 16 138 Width = 129 139 Height = 49 140 Caption = 'Selected files (dat contents only)' 141 TabOrder = 0 142 WordWrap = True 143 OnClick = Extract 144 end 145 object btn_all_files_toone: TButton 146 Left = 144 147 Top = 16 148 Width = 129 149 Height = 49 150 Caption = 'All files in list (dat contents only)' 151 TabOrder = 1 152 WordWrap = True 153 OnClick = Extract 154 end 155 end 156 object group_progress: TGroupBox 157 AlignWithMargins = True 158 Left = 8 159 Top = 282 160 Width = 280 161 Height = 132 162 Margins.Left = 6 163 Margins.Top = 1 164 Margins.Right = 6 165 Margins.Bottom = 7 166 Align = alClient 167 Caption = 'Progress ...' 168 TabOrder = 2 169 Visible = False 170 object lbl_progress: TLabel 171 Left = 8 172 Top = 40 173 Width = 265 174 Height = 17 175 AutoSize = False 176 Caption = 'Files done: 0/0' 177 end 178 object lbl_estimated: TLabel 179 Left = 8 180 Top = 56 181 Width = 265 182 Height = 17 183 AutoSize = False 184 Caption = 'Estimated finishing time: 00:00:00' 185 end 186 object progress: TProgressBar 187 Left = 8 188 Top = 16 189 Width = 265 190 Height = 17 191 Smooth = True 192 TabOrder = 0 193 end 194 object btn_abort: TButton 195 Left = 8 196 Top = 72 197 Width = 97 198 Height = 23 199 Caption = 'Abort' 200 Enabled = False 201 TabOrder = 1 202 OnClick = btn_abortClick 203 end 204 end 205 end 206 end 207 object saved: TSaveDialog [3] 208 Left = 448 209 Top = 328 209 OnClick = btn_abortClick 210 end 211 end 210 212 end 211 213 end -
oup/current/Tools/Extractor.pas
r46 r74 3 3 uses 4 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 6 7 7 type 8 8 TForm_Extractor = class(TForm_ToolTemplate) 9 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 20 group_progress: TGroupBox; 21 21 lbl_progress: TLabel; … … 23 23 progress: TProgressBar; 24 24 btn_abort: TButton; 25 saved: TSaveDialog;26 25 procedure FormCreate(Sender: TObject); 27 procedure Extract(Sender: TObject);28 26 procedure btn_abortClick(Sender: TObject); 27 procedure btn_pathClick(Sender: TObject); 28 procedure btn_exportClick(Sender: TObject); 29 29 private 30 30 public … … 36 36 implementation 37 37 {$R *.dfm} 38 uses Main, Functions, Data, OniDataClass; 38 uses Main, Functions, Data, OniDataClass, FolderBrowser, Exporters; 39 39 40 40 41 procedure TForm_Extractor.FormCreate(Sender: TObject); … … 42 43 inherited; 43 44 Self.AllowMultiSelect := True; 44 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; 55 46 end; 56 47 … … 60 51 end; 61 52 62 procedure TForm_Extractor. Extract(Sender: TObject);53 procedure TForm_Extractor.btn_pathClick(Sender: TObject); 63 54 var 64 sel_only: Boolean; 65 dat_only: Boolean; 66 convert: Boolean; 67 one_file: Boolean; 68 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; 69 72 files: LongWord; 70 73 i, done: LongWord; 71 begintime: Double; 74 selonly: Boolean; 75 fileid: LongWord; 76 filename: String; 77 path: String; 72 78 begin 73 sel_only := Pos('sel', TButton(Sender).Name) > 0; 74 dat_only := not (Pos('datraw', TButton(Sender).Name) > 0); 75 convert := Pos('convert', TButton(Sender).Name) > 0; 76 one_file := Pos('toone', TButton(Sender).Name) > 0; 77 if dat_only then 78 settings := [DO_dat] 79 else 80 settings := [DO_dat, DO_raw]; 81 if convert then 82 settings := settings + [DO_convert]; 83 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'; 85 90 progress.Position := 0; 86 91 87 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 88 104 begin 89 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 96 106 begin 97 if FileExists(saved.FileName) then 98 begin 99 if MessageBox(Self.Handle, PChar( 100 'File already exists. Do you want to overwrite it?'), PChar('Warning!'), MB_YESNO) = 101 ID_YES then 102 begin 103 DeleteFile(saved.FileName); 104 end 105 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); 117 116 end; 118 if sel_only then 119 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( 143 119 (Time - begintime) / done * files + begintime); 144 if (i mod 10) = 0 then 145 begin 146 progress.Position := done; 147 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; 185 124 end; 125 126 panel_files.Enabled := True; 127 group_extract.Enabled := True; 128 group_progress.Visible := False; 186 129 end; 130 187 131 188 132 begin
Note:
See TracChangeset
for help on using the changeset viewer.