Changeset 113 for oup/current/Helper
- Timestamp:
- Feb 25, 2007, 6:20:22 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Helper/LevelDB.pas
r112 r113 1 1 unit LevelDB; 2 3 2 interface 4 5 3 uses 6 4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, … … 28 26 29 27 implementation 30 31 28 {$R *.dfm} 32 33 29 uses ABSMain, ABSDecUtil, Main, 34 ConnectionManager, TypeDefs, DataAccess, OniImgClass ;30 ConnectionManager, TypeDefs, DataAccess, OniImgClass, Data; 35 31 36 32 type … … 70 66 Stream_Dat, Stream_Raw, Stream_Sep: TFileStream; 71 67 72 // FileCount: Integer;73 // temps, temps2: String;74 68 // Data, rawdata: Tdata; 75 69 BeginTime, FileTime: Double; 76 70 Step: Integer; 77 71 // rawlist: TRawDataList; 78 // extlist: TExtensionsMap;79 // fileinfo: TFileInfo;80 72 // datlinks: TDatLinks; 81 73 OniImage: TOniImage; … … 89 81 Strings: TStrings; 90 82 i, j: Integer; 83 temps: String; 84 FileInfo: TFileInfo; 85 86 DatFileStream, RawFileStream: TMemoryStream; 91 87 const 92 88 Steps: Byte = 3; … … 209 205 end; 210 206 211 212 extlist := OniDataConnection.GetExtendedExtensionsList; 213 for i := 0 to High(DatHeader.Ident) do 214 DatHeader.Ident[i] := OniDataConnection.LevelInfo.Ident[i]; 215 DatHeader.Files := OniDataConnection.GetFilesCount; 207 for i := 0 to High(DatHeader.OSIdent) do 208 case Connection.DataOS of 209 DOS_WIN: DatHeader.OSIdent[i] := HeaderOSIdentWin[i]; 210 DOS_MAC: DatHeader.OSIdent[i] := HeaderOSIdentMac[i]; 211 DOS_MACBETA: DatHeader.OSIdent[i] := HeaderOSIdentMacBeta[i]; 212 end; 213 for i := 0 to High(DatHeader.GlobalIdent) do 214 DatHeader.GlobalIdent[i] := HeaderGlobalIdent[i]; 215 DatHeader.Files := Connection.GetFileCount; 216 216 DatHeader.NamedFiles := Length(NamedFilesHeader); 217 DatHeader.Extensions := Length(extlist); 217 218 Strings := Connection.GetExtensionsList(EF_ExtCount); 219 220 DatHeader.Extensions := Strings.Count; 218 221 DatHeader.DataAddr := 0; 219 222 DatHeader.DataSize := 0; … … 227 230 228 231 DoStep('Writing extensions-header'); 229 progress.Max := Length(OniDataConnection.GetExtensionsList);232 progress.Max := Strings.Count; 230 233 Application.ProcessMessages; 231 232 for i := 0 to High(ExtensionsHeader) do 233 begin 234 ExtensionsHeader[i].Ident := extlist[i].Ident; 235 ExtensionsHeader[i].Extension := extlist[i].Extension; 236 SetLength(temps, 4); 234 for i := 0 to Strings.Count - 1 do 235 begin 236 temps := Strings.Strings[i]; 237 ExtensionsHeader[i].ExtCount := StrToInt( MidStr( 238 temps, 239 Pos('(', temps) + 1, 240 Pos(')', temps) - Pos('(', temps) - 1 ) ); 241 temps := MidStr(temps, 1, 4); 237 242 for j := 0 to 3 do 238 temps[j + 1] := ExtensionsHeader[i].Extension[3 - j]; 239 ExtensionsHeader[i].ExtCount := 240 Length(OniDataConnection.GetFilesList(temps, '', False, stIDAsc)); 243 ExtensionsHeader[i].Extension[j] := temps[4-j]; 244 for j := 0 to High(FileTypes) do 245 if FileTypes[j].Extension = temps then 246 Break; 247 if j < Length(FileTypes) then 248 begin 249 case Connection.DataOS of 250 DOS_WIN: ExtensionsHeader[i].Ident := FileTypes[j].IdentWin; 251 DOS_WINDEMO: ExtensionsHeader[i].Ident := FileTypes[j].IdentMac; 252 DOS_MAC: ExtensionsHeader[i].Ident := FileTypes[j].IdentMac; 253 DOS_MACBETA: ExtensionsHeader[i].Ident := FileTypes[j].IdentMac; 254 end; 255 end else begin 256 ShowMessage('Unknown Extension: ' + Strings.Strings[i]); 257 Exit; 258 end; 241 259 progress.Position := i + 1; 242 260 lbl_progress.Caption := 'Extensions done: ' + IntToStr(i + 1) + '/' + 243 IntToStr( Length(extlist));261 IntToStr(Strings.Count); 244 262 Application.ProcessMessages; 245 263 end; 246 247 264 248 265 DoStep('Storing files-data'); … … 253 270 Application.ProcessMessages; 254 271 255 begintime := Time;272 FileTime := Time; 256 273 for i := 0 to DatHeader.Files - 1 do 257 274 begin 258 fileinfo := OniDataConnection.GetFileInfo(i);275 FileInfo := Connection.GetFileInfo(i); 259 276 for j := 0 to 3 do 260 FilesHeader[i].Extension[j] := fileinfo.Extension[4 - j];261 if fileinfo.Size > 0 then277 FilesHeader[i].Extension[j] := FileInfo.Extension[4 - j]; 278 if FileInfo.Size > 0 then 262 279 begin 263 280 // DatLinks:=; 264 281 FilesHeader[i].DataAddr := Stream_Body.Size + 8; 265 Data := OniDataConnection.LoadDatFile(i); 266 Data[4] := (levelid) and $FF; 267 Data[5] := (levelid shr 8) and $FF; 268 Data[6] := (levelid shr 16) and $FF; 269 Data[7] := (levelid shr 24) and $FF; 282 DatFileStream := TMemoryStream.Create; 283 Connection.LoadDatFile(i, DatFileStream); 284 DatFileStream.Seek(4, soFromBeginning); 285 DatFileStream.Write(LevelID, 4); 270 286 271 287 if (Pos(UpperCase(fileinfo.Extension), UpperCase(raws)) mod 4) = 1 then … … 337 353 if ((i mod 10) = 0) and (i >= 100) then 338 354 lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr( 339 (Time - begintime) / i * (progress.Max - i + 1) * 1.1, timeformat );355 (Time - FileTime) / i * (progress.Max - i + 1) * 1.1, TimeFormat ); 340 356 progress.Position := i + 1; 341 357 lbl_progress.Caption := 'Files done: ' + IntToStr(i + 1) + '/' + IntToStr(progress.Max); … … 373 389 lbl_progress.Caption := 'Files done: ' + IntToStr(progress.Max) + '/' + 374 390 IntToStr(progress.Max); 375 lbl_estimation.Caption := 'FINISHED (duration: ' + TimeToStr(Time - absolutebegintime, timeformat) + ')';391 lbl_estimation.Caption := 'FINISHED (duration: ' + TimeToStr(Time - Begintime, TimeFormat) + ')'; 376 392 377 393 DoStep('FIN');
Note:
See TracChangeset
for help on using the changeset viewer.