| 1 |
|
unit LevelDB; |
| 2 |
– |
|
| 2 |
|
interface |
| 4 |
– |
|
| 3 |
|
uses |
| 4 |
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
| 5 |
|
Dialogs, ComCtrls, StdCtrls, StrUtils; |
| 25 |
|
Form_LevelDB: TForm_LevelDB; |
| 26 |
|
|
| 27 |
|
implementation |
| 30 |
– |
|
| 28 |
|
{$R *.dfm} |
| 32 |
– |
|
| 29 |
|
uses ABSMain, ABSDecUtil, Main, |
| 30 |
< |
ConnectionManager, TypeDefs, DataAccess, OniImgClass; |
| 30 |
> |
ConnectionManager, TypeDefs, DataAccess, OniImgClass, Data; |
| 31 |
|
|
| 32 |
|
type |
| 33 |
|
THandler = procedure(FileID: Integer); |
| 65 |
|
Stream_Body, Stream_Names: TMemoryStream; |
| 66 |
|
Stream_Dat, Stream_Raw, Stream_Sep: TFileStream; |
| 67 |
|
|
| 72 |
– |
// FileCount: Integer; |
| 73 |
– |
// temps, temps2: String; |
| 68 |
|
// Data, rawdata: Tdata; |
| 69 |
|
BeginTime, FileTime: Double; |
| 70 |
|
Step: Integer; |
| 71 |
|
// rawlist: TRawDataList; |
| 78 |
– |
// extlist: TExtensionsMap; |
| 79 |
– |
// fileinfo: TFileInfo; |
| 72 |
|
// datlinks: TDatLinks; |
| 73 |
|
OniImage: TOniImage; |
| 74 |
|
LevelID: Integer; |
| 80 |
|
|
| 81 |
|
Strings: TStrings; |
| 82 |
|
i, j: Integer; |
| 83 |
+ |
temps: String; |
| 84 |
+ |
FileInfo: TFileInfo; |
| 85 |
+ |
|
| 86 |
+ |
DatFileStream, RawFileStream: TMemoryStream; |
| 87 |
|
const |
| 88 |
|
Steps: Byte = 3; |
| 89 |
|
|
| 204 |
|
end; |
| 205 |
|
end; |
| 206 |
|
|
| 207 |
< |
|
| 208 |
< |
extlist := OniDataConnection.GetExtendedExtensionsList; |
| 209 |
< |
for i := 0 to High(DatHeader.Ident) do |
| 210 |
< |
DatHeader.Ident[i] := OniDataConnection.LevelInfo.Ident[i]; |
| 211 |
< |
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 |
|
DatHeader.NamedFiles := Length(NamedFilesHeader); |
| 217 |
< |
DatHeader.Extensions := Length(extlist); |
| 217 |
> |
|
| 218 |
> |
Strings := Connection.GetExtensionsList(EF_ExtCount); |
| 219 |
> |
|
| 220 |
> |
DatHeader.Extensions := Strings.Count; |
| 221 |
|
DatHeader.DataAddr := 0; |
| 222 |
|
DatHeader.DataSize := 0; |
| 223 |
|
DatHeader.NamesAddr := 0; |
| 229 |
|
|
| 230 |
|
|
| 231 |
|
DoStep('Writing extensions-header'); |
| 232 |
< |
progress.Max := Length(OniDataConnection.GetExtensionsList); |
| 232 |
> |
progress.Max := Strings.Count; |
| 233 |
|
Application.ProcessMessages; |
| 234 |
< |
|
| 232 |
< |
for i := 0 to High(ExtensionsHeader) do |
| 234 |
> |
for i := 0 to Strings.Count - 1 do |
| 235 |
|
begin |
| 236 |
< |
ExtensionsHeader[i].Ident := extlist[i].Ident; |
| 237 |
< |
ExtensionsHeader[i].Extension := extlist[i].Extension; |
| 238 |
< |
SetLength(temps, 4); |
| 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); |
| 242 |
|
for j := 0 to 3 do |
| 243 |
< |
temps[j + 1] := ExtensionsHeader[i].Extension[3 - j]; |
| 244 |
< |
ExtensionsHeader[i].ExtCount := |
| 245 |
< |
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; |
| 259 |
|
progress.Position := i + 1; |
| 260 |
|
lbl_progress.Caption := 'Extensions done: ' + IntToStr(i + 1) + '/' + |
| 261 |
< |
IntToStr(Length(extlist)); |
| 261 |
> |
IntToStr(Strings.Count); |
| 262 |
|
Application.ProcessMessages; |
| 263 |
|
end; |
| 264 |
|
|
| 247 |
– |
|
| 265 |
|
DoStep('Storing files-data'); |
| 266 |
|
progress.Position := 0; |
| 267 |
|
progress.Max := DatHeader.Files; |
| 269 |
|
lbl_estimation.Caption := 'Estimated finishing time: unknown'; |
| 270 |
|
Application.ProcessMessages; |
| 271 |
|
|
| 272 |
< |
begintime := Time; |
| 272 |
> |
FileTime := Time; |
| 273 |
|
for i := 0 to DatHeader.Files - 1 do |
| 274 |
|
begin |
| 275 |
< |
fileinfo := OniDataConnection.GetFileInfo(i); |
| 275 |
> |
FileInfo := Connection.GetFileInfo(i); |
| 276 |
|
for j := 0 to 3 do |
| 277 |
< |
FilesHeader[i].Extension[j] := fileinfo.Extension[4 - j]; |
| 278 |
< |
if fileinfo.Size > 0 then |
| 277 |
> |
FilesHeader[i].Extension[j] := FileInfo.Extension[4 - j]; |
| 278 |
> |
if FileInfo.Size > 0 then |
| 279 |
|
begin |
| 280 |
|
// DatLinks:=; |
| 281 |
|
FilesHeader[i].DataAddr := Stream_Body.Size + 8; |
| 282 |
< |
Data := OniDataConnection.LoadDatFile(i); |
| 283 |
< |
Data[4] := (levelid) and $FF; |
| 284 |
< |
Data[5] := (levelid shr 8) and $FF; |
| 285 |
< |
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); |
| 286 |
|
|
| 287 |
|
if (Pos(UpperCase(fileinfo.Extension), UpperCase(raws)) mod 4) = 1 then |
| 288 |
|
begin |
| 352 |
|
|
| 353 |
|
if ((i mod 10) = 0) and (i >= 100) then |
| 354 |
|
lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr( |
| 355 |
< |
(Time - begintime) / i * (progress.Max - i + 1) * 1.1, timeformat ); |
| 355 |
> |
(Time - FileTime) / i * (progress.Max - i + 1) * 1.1, TimeFormat ); |
| 356 |
|
progress.Position := i + 1; |
| 357 |
|
lbl_progress.Caption := 'Files done: ' + IntToStr(i + 1) + '/' + IntToStr(progress.Max); |
| 358 |
|
Application.ProcessMessages; |
| 388 |
|
progress.Position := progress.Max; |
| 389 |
|
lbl_progress.Caption := 'Files done: ' + IntToStr(progress.Max) + '/' + |
| 390 |
|
IntToStr(progress.Max); |
| 391 |
< |
lbl_estimation.Caption := 'FINISHED (duration: ' + TimeToStr(Time - absolutebegintime, timeformat) + ')'; |
| 391 |
> |
lbl_estimation.Caption := 'FINISHED (duration: ' + TimeToStr(Time - Begintime, TimeFormat) + ')'; |
| 392 |
|
|
| 393 |
|
DoStep('FIN'); |
| 394 |
|
btn_abortok.Caption := '&OK'; |