Changeset 86 for oup/current/Code
- Timestamp:
- Jan 14, 2007, 9:19:08 PM (18 years ago)
- Location:
- oup/current/Code
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Code/Exporters.pas
r74 r86 3 3 interface 4 4 5 uses Classes, Dialogs, StrUtils, SysUtils, Math, Data, OniImgClass; 6 7 procedure ExportDatFile(fileid: LongWord; filename: String); 8 procedure ExportRawFiles(fileid: LongWord; filename: String); 9 procedure ExportRawFile(fileid: LongWord; dat_offset: LongWord; filename: String); 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; 5 uses Classes, Dialogs, StrUtils, SysUtils, Math, Data, OniImgClass, OniDataClass; 6 7 type 8 TExportHandlers = record 9 Ext: String[4]; 10 needed: Boolean; 11 Handler: function(connection: TOniData; fileid: LongWord; filename: String): Integer; 12 end; 13 14 procedure ExportDatFile(connection: TOniData; fileid: LongWord; filename: String); 15 procedure ExportRawFiles(connection: TOniData; fileid: LongWord; filename: String); 16 procedure ExportRawFile(connection: TOniData; fileid: LongWord; dat_offset: LongWord; filename: String); 17 function ExportConverted(connection: TOniData; fileid: LongWord; filename: String): Integer; 18 19 function ExportSNDD(connection: TOniData; fileid: LongWord; filename: String): Integer; 20 function ExportTRAC(connection: TOniData; fileid: LongWord; filename: String): Integer; 21 function ExportTXAN(connection: TOniData; fileid: LongWord; filename: String): Integer; 22 function ExportImage(connection: TOniData; fileid: LongWord; filename: String): Integer; 16 23 17 24 var … … 30 37 implementation 31 38 32 uses Functions, DataStructures , OniDataClass;33 34 35 36 procedure ExportDatFile( fileid: LongWord; filename: String);39 uses Functions, DataStructures; 40 41 42 43 procedure ExportDatFile(connection: TOniData; fileid: LongWord; filename: String); 37 44 var 38 45 filestream: TFileStream; 39 46 Data: Tdata; 40 47 begin 41 Data := OniDataConnection.LoadDatFile(fileid);48 Data := connection.LoadDatFile(fileid); 42 49 if FileExists(filename) then 43 50 begin … … 54 61 55 62 56 procedure ExportRawFiles( fileid: LongWord; filename: String);63 procedure ExportRawFiles(connection: TOniData; fileid: LongWord; filename: String); 57 64 var 58 65 i: Integer; 59 66 rawlist: TRawList; 60 67 begin 61 rawlist := OniDataConnection.GetRawList(fileid);68 rawlist := connection.GetRawList(fileid); 62 69 if Length(rawlist) > 0 then 63 70 for i := 0 to High(rawlist) do 64 ExportRawFile( fileid, rawlist[i].src_offset, filename);65 end; 66 67 procedure ExportRawFile( fileid: LongWord; dat_offset: LongWord; filename: String);71 ExportRawFile(connection, fileid, rawlist[i].src_offset, filename); 72 end; 73 74 procedure ExportRawFile(connection: TOniData; fileid: LongWord; dat_offset: LongWord; filename: String); 68 75 var 69 76 filestream: TFileStream; 70 77 Data: Tdata; 71 78 begin 72 SetLength(Data, OniDataConnection.GetRawInfo(fileid, dat_offset).raw_size);73 OniDataConnection.LoadRawFile(fileid, dat_offset, @Data[0]);79 SetLength(Data, connection.GetRawInfo(fileid, dat_offset).raw_size); 80 connection.LoadRawFile(fileid, dat_offset, @Data[0]); 74 81 if FileExists(filename + '.raw0x' + IntToHex(dat_offset, 8)) then 75 82 begin … … 86 93 end; 87 94 88 function ExportConverted( fileid: LongWord; filename: String): Integer;95 function ExportConverted(connection: TOniData; fileid: LongWord; filename: String): Integer; 89 96 var 90 97 i: Integer; 91 98 fileinfo: TFileInfo; 92 99 begin 93 fileinfo := OniDataConnection.GetFileInfo(fileid);100 fileinfo := connection.GetFileInfo(fileid); 94 101 if Length(ExportHandlers) > 0 then 95 102 for i := 0 to High(ExportHandlers) do 96 103 if ExportHandlers[i].Ext = fileinfo.Extension then 97 ExportHandlers[i].Handler( fileid, filename);104 ExportHandlers[i].Handler(connection, fileid, filename); 98 105 end; 99 106 … … 142 149 begin 143 150 Result := export_noerror; 144 OniDataConnection.LoadDatFilePart(fileid, 0, SizeOf(DatData), @DatData);151 connection.LoadDatFilePart(fileid, 0, SizeOf(DatData), @DatData); 145 152 with DatData do 146 153 begin … … 154 161 WAVE_DataLen := RAWSize; 155 162 SetLength(Data, RAWSize); 156 OniDataConnection.LoadRawFile(fileid, $44, Data);163 connection.LoadRawFile(fileid, $44, Data); 157 164 158 165 //Now start packing this into a neat wave... … … 192 199 Result := export_noerror; 193 200 194 OniDataConnection.LoadDatFilePart(fileid, $18, SizeOf(link), @link);201 connection.LoadDatFilePart(fileid, $18, SizeOf(link), @link); 195 202 link := link div 256; 196 203 197 OniDataConnection.LoadDatFilePart(fileid, $1E, SizeOf(linkcount), @linkcount);204 connection.LoadDatFilePart(fileid, $1E, SizeOf(linkcount), @linkcount); 198 205 for i := 1 to linkcount do 199 206 begin 200 OniDataConnection.LoadDatFilePart(fileid, $20 + (i - 1) * 12 + 8, SizeOf(link), @link);207 connection.LoadDatFilePart(fileid, $20 + (i - 1) * 12 + 8, SizeOf(link), @link); 201 208 link := link div 256; 202 209 end; … … 215 222 Result := export_noerror; 216 223 217 OniDataConnection.LoadDatFilePart(fileid, $14, SizeOf(loop_speed), @loop_speed);218 OniDataConnection.LoadDatFilePart(fileid, $16, SizeOf(unknown), @unknown);219 220 OniDataConnection.LoadDatFilePart(fileid, $1C, SizeOf(linkcount), @linkcount);224 connection.LoadDatFilePart(fileid, $14, SizeOf(loop_speed), @loop_speed); 225 connection.LoadDatFilePart(fileid, $16, SizeOf(unknown), @unknown); 226 227 connection.LoadDatFilePart(fileid, $1C, SizeOf(linkcount), @linkcount); 221 228 for i := 0 to linkcount - 1 do 222 229 begin 223 OniDataConnection.LoadDatFilePart(fileid, $20 + i * 4, SizeOf(link), @link);230 connection.LoadDatFilePart(fileid, $20 + i * 4, SizeOf(link), @link); 224 231 link := link div 256; 225 232 if link = 0 then … … 240 247 241 248 img := TOniImage.Create; 242 img.Load( fileid);249 img.Load(connection, fileid); 243 250 data := img.GetAsBMP; 244 251 img.Free; -
oup/current/Code/Functions.pas
r75 r86 21 21 function DecodeHexString(hex: String): Tdata; 22 22 function GetWinFileName(Name: String): String; 23 function GetExtractPath: String;23 //function GetExtractPath: String; 24 24 25 25 function Explode(_string: String; delimiter: Char): TStringArray; … … 352 352 353 353 354 354 { 355 355 function GetExtractPath: String; 356 356 begin 357 Result := ExtractFilePath( OniDataConnection.FileName) + '\extracted_' +358 ExtractFileName( OniDataConnection.Filename);359 end; 360 357 Result := ExtractFilePath(DataConnections[i].FileName) + '\extracted_' + 358 ExtractFileName(DataConnections[i].Filename); 359 end; 360 } 361 361 362 362 end. -
oup/current/Code/OniDataClass.pas
r56 r86 136 136 end; 137 137 138 TOniDataEmpty = class(TOniData) 139 private 140 protected 141 public 142 constructor Create(OLDBFilename: String; var Result: Boolean); override; 143 procedure Close; override; 144 { 145 procedure UpdateListCache; 146 // function GetDatLinks(srcid:LongWord):TDatLinks; 147 function GetFileInfo(fileid: LongWord): TFileInfo; override; 148 function GetFilesList(ext: String; pattern: String; 149 NoEmptyFiles: Boolean; sort: TSortType): TStringArray; override; 150 function GetFilesCount: LongWord; override; 151 function GetExtensionsList: TStringArray; override; 152 function GetExtendedExtensionsList: TExtensionsMap; override; 153 function GetNamedFilesMap: TNamedFilesMap; 154 155 function LoadDatFile(fileid: LongWord): Tdata; override; 156 procedure UpdateDatFile(fileid: LongWord; Data: Tdata); override; 157 procedure LoadDatFilePart(fileid, offset, size: LongWord; target: Pointer); override; 158 procedure UpdateDatFilePart(fileid, offset, size: LongWord; target: Pointer); override; 159 160 function GetRawList(fileid: LongWord): TRawList; override; 161 procedure LoadRawFile(fileid, dat_offset: LongWord; target: Pointer); override; 162 procedure UpdateRawFile(fileid, dat_offset: LongWord; size: LongWord; 163 target: Pointer); override; 164 procedure LoadRawFilePart(fileid, dat_offset: LongWord; 165 offset, size: LongWord; target: Pointer); override; 166 procedure UpdateRawFilePart(fileid, dat_offset: LongWord; 167 offset, size: LongWord; target: Pointer); override; 168 } published 169 end; 138 170 139 171 const … … 143 175 144 176 var 177 // OniDataConnection: TOniData; 178 DataConnections: array of TOniData; 145 179 OniDataConnection: TOniData; 146 180 147 function CreateDataConnection(filename: String; backend: Integer): Boolean; 148 procedure CloseDataConnection; 181 function CreateDataConnection(filename: String; backend: Integer): TOniData; 182 procedure CloseDataConnection(connection: TOniData); 183 149 184 150 185 … … 1372 1407 1373 1408 1374 function CreateDataConnection(filename: String; backend: Integer): Boolean;1409 function CreateDataConnection(filename: String; backend: Integer): TOniData; 1375 1410 var 1376 1411 answer: Boolean; 1377 begin 1378 if Assigned(OniDataConnection) then 1379 begin 1380 OniDataConnection.Close; 1381 OniDataConnection.Free; 1382 OniDataConnection := nil; 1383 end; 1412 i: Integer; 1413 begin 1414 if Length(DataConnections) > 0 then 1415 begin 1416 for i := 0 to High(DataConnections) do 1417 begin 1418 if ExtractFileName(DataConnections[i].FFileName) = ExtractFileName(filename) then 1419 begin 1420 if DataConnections[i].FFileName <> filename then 1421 begin 1422 Result := nil; 1423 ShowMessage('You can not open two files with the same name at a time.'); 1424 end 1425 else 1426 Result := DataConnections[i]; 1427 Exit; 1428 end; 1429 end; 1430 end; 1431 1432 if not FileExists(filename) then 1433 begin 1434 ShowMessage('File "' + filename + '" does not exist!'); 1435 Result := nil; 1436 Exit; 1437 end; 1438 1439 SetLength(DataConnections, Length(DataConnections) + 1); 1440 i := High(DataConnections); 1384 1441 case backend of 1385 1442 ODB_Dat: 1386 OniDataConnection:= TOniDataDat.Create(filename, answer);1443 DataConnections[i] := TOniDataDat.Create(filename, answer); 1387 1444 ODB_ADB: 1388 OniDataConnection:= TOniDataADB.Create(filename, answer);1445 DataConnections[i] := TOniDataADB.Create(filename, answer); 1389 1446 else 1390 1447 ShowMessage('Unknown Backend'); 1391 Result := False;1448 Result := nil; 1392 1449 Exit; 1393 1450 end; … … 1395 1452 if answer then 1396 1453 begin 1397 // ShowMessage('file loaded'); 1398 // ShowMessage('Files: '+IntToStr(OniDataConnection.GetFilesCount)); 1399 Result := True; 1454 Result := DataConnections[i]; 1455 // Result := True; 1400 1456 end 1401 1457 else 1402 1458 begin 1403 1459 ShowMessage('File not loaded'); 1404 OniDataConnection.Close; 1405 OniDataConnection.Free; 1406 Result := False; 1407 end; 1408 end; 1409 1410 1411 1412 1413 procedure CloseDataConnection; 1414 begin 1415 if Assigned(OniDataConnection) then 1416 begin 1417 OniDataConnection.Close; 1418 OniDataConnection := nil; 1419 end; 1460 DataConnections[i].Close; 1461 DataConnections[i].Free; 1462 DataConnections[i] := nil; 1463 SetLength(DataConnections, Length(DataConnections) - 1); 1464 Result := nil; 1465 end; 1466 end; 1467 1468 1469 1470 1471 procedure CloseDataConnection(connection: TOniData); 1472 var 1473 i: Integer; 1474 found: Boolean; 1475 begin 1476 if Assigned(connection) then 1477 begin 1478 found := False; 1479 for i := 0 to High(DataConnections) do 1480 begin 1481 if not found then 1482 begin 1483 if DataConnections[i] = connection then 1484 begin 1485 DataConnections[i].Close; 1486 DataConnections[i].Free; 1487 DataConnections[i] := nil; 1488 found := True; 1489 end; 1490 end 1491 else 1492 begin 1493 DataConnections[i - 1] := DataConnections[i]; 1494 end; 1495 end; 1496 if found then 1497 SetLength(DataConnections, Length(DataConnections) - 1); 1498 end; 1499 end; 1500 1501 1502 1503 1504 constructor TOniDataEmpty.Create(OLDBFilename: String; var Result: Boolean); 1505 var 1506 i, j: Byte; 1507 temps: String; 1508 begin 1509 ShowMessage('OLD'); 1510 end; 1511 1512 procedure TOniDataEmpty.Close; 1513 begin 1514 ShowMessage('OLD'); 1420 1515 end; 1421 1516 -
oup/current/Code/OniImgClass.pas
r46 r86 33 33 34 34 constructor Create; 35 function Load( fileid: LongWord): Boolean;36 function LoadFromPSpc( fileid: LongWord): Boolean;37 function LoadFromTXMP( fileid: LongWord): Boolean;38 function LoadFromTXMB( fileid: LongWord): Boolean;35 function Load(connection: TOniData; fileid: Cardinal): Boolean; 36 function LoadFromPSpc(connection: TOniData; fileid: LongWord): Boolean; 37 function LoadFromTXMP(connection: TOniData; fileid: LongWord): Boolean; 38 function LoadFromTXMB(connection: TOniData; fileid: LongWord): Boolean; 39 39 function GetImageDataSize(fading: Boolean): LongWord; 40 40 … … 303 303 304 304 305 function TOniImage.Load( fileid: LongWord): Boolean;305 function TOniImage.Load(connection: TOniData; fileid: Cardinal): Boolean; 306 306 var 307 307 FileInfo: TFileInfo; 308 308 ext: String; 309 309 begin 310 FileInfo := OniDataConnection.GetFileInfo(fileid);310 FileInfo := connection.GetFileInfo(fileid); 311 311 if FileInfo.Extension = 'PSpc' then 312 Result := LoadFromPSpc( fileid)312 Result := LoadFromPSpc(connection, fileid) 313 313 else if FileInfo.Extension = 'TXMB' then 314 Result := LoadFromTXMB( fileid)314 Result := LoadFromTXMB(connection, fileid) 315 315 else if FileInfo.Extension = 'TXMP' then 316 Result := LoadFromTXMP( fileid)316 Result := LoadFromTXMP(connection, fileid) 317 317 else 318 318 Result := False; … … 322 322 323 323 324 function TOniImage.LoadFromPSpc( fileid: LongWord): Boolean;324 function TOniImage.LoadFromPSpc(connection: TOniData; fileid: LongWord): Boolean; 325 325 type 326 326 TPoint = packed record … … 357 357 col, row: Byte; 358 358 begin 359 OniDataConnection.LoadDatFilePart(fileid, $08, SizeOf(PSpc), @PSpc);359 connection.LoadDatFilePart(fileid, $08, SizeOf(PSpc), @PSpc); 360 360 PSpc.TXMP := PSpc.TXMP div 256; 361 361 if PSpc.TXMP = 0 then … … 365 365 end; 366 366 txmpimg := TOniImage.Create; 367 txmpimg.LoadFromTXMP( PSpc.TXMP);367 txmpimg.LoadFromTXMP(connection, PSpc.TXMP); 368 368 txmpimg.DecodeImage; 369 369 txmpimg.WriteToBMP('C:\file.bmp'); … … 464 464 465 465 466 function TOniImage.LoadFromTXMP( fileid: LongWord): Boolean;466 function TOniImage.LoadFromTXMP(connection: TOniData; fileid: LongWord): Boolean; 467 467 var 468 468 img_addr: LongWord; 469 469 begin 470 470 Result := True; 471 OniDataConnection.LoadDatFilePart(fileid, $8C, SizeOf(Self.FWidth), @Self.FWidth);472 OniDataConnection.LoadDatFilePart(fileid, $8E, SizeOf(Self.FHeight), @Self.FHeight);473 OniDataConnection.LoadDatFilePart(fileid, $90, SizeOf(Self.FStoreType),471 connection.LoadDatFilePart(fileid, $8C, SizeOf(Self.FWidth), @Self.FWidth); 472 connection.LoadDatFilePart(fileid, $8E, SizeOf(Self.FHeight), @Self.FHeight); 473 connection.LoadDatFilePart(fileid, $90, SizeOf(Self.FStoreType), 474 474 @Self.FStoreType); 475 if not OniDataConnection.OSisMac then476 OniDataConnection.LoadDatFilePart(fileid, $9C, SizeOf(img_addr), @img_addr)475 if not connection.OSisMac then 476 connection.LoadDatFilePart(fileid, $9C, SizeOf(img_addr), @img_addr) 477 477 else 478 OniDataConnection.LoadDatFilePart(fileid, $A0, SizeOf(img_addr), @img_addr);478 connection.LoadDatFilePart(fileid, $A0, SizeOf(img_addr), @img_addr); 479 479 480 480 case Self.FStoreType of … … 499 499 end; 500 500 501 if not OniDataConnection.OSisMac then502 OniDataConnection.LoadRawFile(fileid, $9C, @Self.FData[0])501 if not connection.OSisMac then 502 connection.LoadRawFile(fileid, $9C, @Self.FData[0]) 503 503 else 504 OniDataConnection.LoadRawFile(fileid, $A0, @Self.FData[0]);504 connection.LoadRawFile(fileid, $A0, @Self.FData[0]); 505 505 506 506 Self.FDataType := [DT_OniReverted, DT_Oni]; … … 510 510 511 511 512 function TOniImage.LoadFromTXMB( fileid: LongWord): Boolean;512 function TOniImage.LoadFromTXMB(connection: TOniData; fileid: LongWord): Boolean; 513 513 var 514 514 i, x, y, x2, y2, pixelid, imgid: LongWord; … … 519 519 x_start, y_start: LongWord; 520 520 begin 521 OniDataConnection.LoadDatFilePart(fileid, $10, SizeOf(Self.FWidth), @Self.FWidth);522 OniDataConnection.LoadDatFilePart(fileid, $12, SizeOf(Self.FHeight), @Self.FHeight);523 OniDataConnection.LoadDatFilePart(fileid, $18, SizeOf(cols), @cols);524 OniDataConnection.LoadDatFilePart(fileid, $1A, SizeOf(rows), @rows);525 OniDataConnection.LoadDatFilePart(fileid, $1C, SizeOf(linkcount), @linkcount);521 connection.LoadDatFilePart(fileid, $10, SizeOf(Self.FWidth), @Self.FWidth); 522 connection.LoadDatFilePart(fileid, $12, SizeOf(Self.FHeight), @Self.FHeight); 523 connection.LoadDatFilePart(fileid, $18, SizeOf(cols), @cols); 524 connection.LoadDatFilePart(fileid, $1A, SizeOf(rows), @rows); 525 connection.LoadDatFilePart(fileid, $1C, SizeOf(linkcount), @linkcount); 526 526 SetLength(images_decoded, linkcount); 527 527 for i := 0 to linkcount - 1 do 528 528 begin 529 OniDataConnection.LoadDatFilePart(fileid, $20 + i * 4, SizeOf(link), @link);529 connection.LoadDatFilePart(fileid, $20 + i * 4, SizeOf(link), @link); 530 530 link := link div 256; 531 531 images_decoded[i] := TOniImage.Create; 532 images_decoded[i].LoadFromTXMP( link);532 images_decoded[i].LoadFromTXMP(connection, link); 533 533 images_decoded[i].DecodeImage; 534 534 images_decoded[i].RevertImage;
Note:
See TracChangeset
for help on using the changeset viewer.