Changeset 105


Ignore:
Timestamp:
Feb 21, 2007, 1:29:27 AM (15 years ago)
Author:
alloc
Message:
 
Location:
oup/rewrite
Files:
22 edited
2 moved

Legend:

Unmodified
Added
Removed
  • oup/rewrite/DataAccess/Access_OUP_ADB.pas

    r101 r105  
    103103  FBackend := DB_ADB;
    104104
     105  FConnectionID := ConnectionID;
    105106  FChangeRights := [CR_EditDat, CR_EditRaw, CR_ResizeDat, CR_ResizeRaw];
    106107
  • oup/rewrite/DataAccess/Access_OniArchive.pas

    r101 r105  
    4343    procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TStream); overload; override;
    4444
    45     function AppendRawFile(LocSep: Boolean; Size: Integer; Src: TStream): Integer; overload; override;
     45    function AppendRawFile(LocSep: Boolean; Src: TStream): Integer; overload; override;
    4646  published
    4747  end;
     
    184184  Msg := SM_OK;
    185185  FBackend := DB_ONI;
     186  FConnectionID := ConnectionID;
    186187  FChangeRights := [CR_EditDat, CR_EditRaw, CR_AppendRaw];
    187188end;
     
    616617end;
    617618
    618 function TAccess_OniArchive.AppendRawFile(LocSep: Boolean; Size: Integer; Src: TStream): Integer;
     619function TAccess_OniArchive.AppendRawFile(LocSep: Boolean; Src: TStream): Integer;
    619620begin
    620621  if not LocSep then
     
    625626    Result := Fraw_file.Size;
    626627    Fraw_file.Seek(0, soFromEnd);
    627     Fraw_file.CopyFrom(Src, Size);
     628    Fraw_file.CopyFrom(Src, Src.Size);
    628629    if UnloadWhenUnused then
    629630    begin
     
    641642    Result := Fsep_file.Size;
    642643    Fsep_file.Seek(0, soFromEnd);
    643     Fsep_file.CopyFrom(Src, Size);
     644    Fsep_file.CopyFrom(Src, Src.Size);
    644645    if UnloadWhenUnused then
    645646    begin
  • oup/rewrite/DataAccess/DataAccess.pas

    r101 r105  
    4242    procedure LoadDatFilePart(FileID, Offset, Size: Integer; Target: Pointer); overload;
    4343    procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TStream); overload; virtual; abstract;
    44     procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TByteData); overload;
    4544    procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: Pointer); overload;
    4645
     
    5655    procedure LoadRawFilePart(FileID, DatOffset, Offset, Size: Integer; Target: Pointer); overload;
    5756    procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TStream); overload; virtual; abstract;
    58     procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TByteData); overload;
    5957    procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: Pointer); overload;
    6058
    61     function AppendRawFile(LocSep: Boolean; Size: Integer; Src: TStream): Integer; overload; virtual;
    62     function AppendRawFile(LocSep: Boolean; Size: Integer; Src: TByteData): Integer; overload;
     59    function AppendRawFile(LocSep: Boolean; Src: TStream): Integer; overload; virtual;
     60    function AppendRawFile(LocSep: Boolean; Src: TByteData): Integer; overload;
    6361    function AppendRawFile(LocSep: Boolean; Size: Integer; Src: Pointer): Integer; overload;
    6462  published
     
    173171end;
    174172
    175 procedure TDataAccess.UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TByteData);
    176 var
    177   data: TStream;
    178 begin
    179   if fileid < GetFileCount then
    180   begin
    181     data := TMemoryStream.Create;
    182     data.Write(Src[0], Size);
    183     data.Seek(0, soFromBeginning);
    184     UpdateDatFilePart(FileID, offset, size, data);
    185     data.Free;
    186   end;
    187 end;
    188 
    189173procedure TDataAccess.UpdateDatFilePart(FileID, Offset, Size: Integer; Src: Pointer);
    190174var
     
    260244end;
    261245
    262 procedure TDataAccess.UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TByteData);
    263 var
    264   data: TStream;
    265 begin
    266   if fileid < GetFileCount then
    267   begin
    268     data := TMemoryStream.Create;
    269     data.Write(Src[0], Size);
     246procedure TDataAccess.UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: Pointer);
     247var
     248  data: TStream;
     249begin
     250  if fileid < GetFileCount then
     251  begin
     252    data := TMemoryStream.Create;
     253    data.Write(Src^, Size);
    270254    data.Seek(0, soFromBeginning);
    271255    UpdateRawFilePart(FileID, DatOffset, Offset, Size, data);
     
    274258end;
    275259
    276 procedure TDataAccess.UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: Pointer);
    277 var
    278   data: TStream;
    279 begin
    280   if fileid < GetFileCount then
    281   begin
    282     data := TMemoryStream.Create;
    283     data.Write(Src^, Size);
    284     data.Seek(0, soFromBeginning);
    285     UpdateRawFilePart(FileID, DatOffset, Offset, Size, data);
    286     data.Free;
    287   end;
    288 end;
    289 
    290 
    291 function TDataAccess.AppendRawFile(LocSep: Boolean; Size: Integer; Src: TStream): Integer;
     260
     261function TDataAccess.AppendRawFile(LocSep: Boolean; Src: TStream): Integer;
    292262begin
    293263  raise ENotImplemented.Create('ERROR: AppendRawFile not implemented here!!!');
     
    295265
    296266
    297 function TDataAccess.AppendRawFile(LocSep: Boolean; Size: Integer; Src: TByteData): Integer;
     267function TDataAccess.AppendRawFile(LocSep: Boolean; Src: TByteData): Integer;
    298268var
    299269  data: TStream;
    300270begin
    301271  data := TMemoryStream.Create;
    302   data.Write(Src[0], Size);
    303   AppendRawFile(LocSep, Size, data);
     272  data.Write(Src[0], Length(Src));
     273  data.Seek(0, soFromBeginning);
     274  AppendRawFile(LocSep, data);
    304275  data.Free;
    305276end;
     
    311282  data := TMemoryStream.Create;
    312283  data.Write(Src^, Size);
    313   AppendRawFile(LocSep, Size, data);
     284  data.Seek(0, soFromBeginning);
     285  AppendRawFile(LocSep, data);
    314286  data.Free;
    315287end;
  • oup/rewrite/Global/Functions.pas

    r97 r105  
    1111function Decode_Float(buffer: TByteData): Single;
    1212function Encode_Float(input: Single): TByteData;
     13function IntToBin(Value: Byte): String;
    1314function DataToBin(Data: TByteData): String;
    1415function BinToInt(bin: String): Byte;
     
    3940
    4041
    41 
    4242function BoolToStr(bool: Boolean): String;
    4343begin
     
    4949
    5050
    51 
    52 
    5351function HexToLong(hex: String): LongWord;
    5452
     
    7674begin
    7775  if NormalizeHexString(hex) then
    78   begin
    79     Result := StrToInt(hex);
    80 {
    81     hex    := UpperCase(hex);
     76    Result := StrToInt(hex)
     77  else
    8278    Result := 0;
    83     for i := 1 to Length(hex) do
    84     begin
    85       Result := Result shl 4;
    86       case hex[i] of
    87         '0'..'9':
    88           Result := Result + Ord(hex[i]) - 48;
    89         'A'..'F':
    90           Result := Result + Ord(hex[i]) - 55;
    91         else
    92           Result := 0;
    93           Exit;
    94       end;
    95     end;
    96 }
    97   end
    98   else
    99   begin
    100     Result := 0;
    101   end;
    102 end;
    103 
    104 
     79end;
    10580
    10681
     
    10984  Result := buffer[0] + buffer[1] * 256 + buffer[2] * 256 * 256 + buffer[3] * 256 * 256 * 256;
    11085end;
    111 
    112 
    11386
    11487
     
    12699
    127100
    128 
    129 
    130101function Decode_Float(buffer: TByteData): Single;
    131102var
     
    139110
    140111
    141 
    142 
    143112function Encode_Float(input: Single): TByteData;
    144113var
     
    150119
    151120
     121function IntToBin(Value: Byte): String;
     122var
     123  i: Byte;
     124begin
     125  Result := '';
     126  for i := 7 downto 0 do
     127    Result := Result + IntToStr((Value shr i) and $01);
     128end;
    152129
    153130
     
    171148  end;
    172149end;
    173 
    174 
    175150
    176151
     
    193168  end;
    194169end;
    195 
    196170
    197171
  • oup/rewrite/Global/OniImgClass.pas

    r101 r105  
    3939    function GetImageDataSize(fading: Boolean): Integer;
    4040
    41     function GetAsData: TByteData;
    42     function GetAs32bit: TByteData;
     41    procedure GetAsData(var Target: TStream); overload;
     42    procedure GetAsData(var Target: TByteData); overload;
     43    procedure GetAs32bit(var Target: TStream); overload;
     44    procedure GetAs32bit(var Target: TByteData); overload;
     45    procedure GetAsBMP(var Target: TStream); overload;
    4346    procedure GetAsBMP(var Target: TByteData); overload;
    44     procedure GetAsBMP(var Target: TStream); overload;
    4547    function LoadFromBMP(filename: String): Boolean;
    4648    function WriteToBMP(filename: String): Boolean;
    47     function GetMipMappedImage(var faded: TByteData): Boolean;
     49    function GetMipMappedImage(var Target: TStream): Boolean; overload;
     50    function GetMipMappedImage(var Target: TByteData): Boolean; overload;
    4851  published
    4952  end;
     
    369372  txmpimg.DecodeImage;
    370373//  txmpimg.WriteToBMP('C:\file.bmp');
    371   txmpdata := txmpimg.GetAs32bit;
     374  txmpimg.GetAs32bit(txmpdata);
    372375{    ShowMessage(IntToStr(txmpimg.Width)+'x'+IntToStr(txmpimg.Height));
    373376    for i:=0 to High(txmpdata) do
     
    615618
    616619
    617 function TOniImage.GetAsData: TByteData;
     620procedure TOniImage.GetAsData(var Target: TStream);
    618621var
    619622  i:      Integer;
     
    629632  else
    630633    revert := False;
    631   SetLength(Result, Length(Self.FData));
    632   for i := 0 to High(Result) do
    633     Result[i] := Self.FData[i];
     634  if not Assigned(Target) then
     635    Target := TMemoryStream.Create;
     636  Target.Write(FData[0], Length(FData));
     637  Target.Seek(0, soFromBeginning);
    634638  if revert then
    635639    Self.RevertImage;
    636640end;
    637641
    638 
    639 
    640 
    641 function TOniImage.GetAs32bit: TByteData;
    642 var
    643   i: Integer;
     642procedure TOniImage.GetAsData(var Target: TByteData);
     643var
     644  mem: TStream;
     645begin
     646  mem := TMemoryStream.Create;
     647  GetAsData(mem);
     648  SetLength(Target, mem.Size);
     649  mem.Read(Target[0], mem.Size);
     650  mem.Free;
     651end;
     652
     653
     654procedure TOniImage.GetAs32bit(var Target: TStream);
    644655begin
    645656  if not (DT_Decoded32 in Self.FDataType) then
    646657    Self.DecodeImage;
    647   SetLength(Result, Length(Self.FData));
    648   for i := 0 to High(Result) do
    649     Result[i] := Self.FData[i];
    650 end;
    651 
    652 
     658  if not Assigned(Target) then
     659    Target := TMemoryStream.Create;
     660  Target.Write(FData[0], Length(FData));
     661  Target.Seek(0, soFromBeginning);
     662end;
     663
     664procedure TOniImage.GetAs32bit(var Target: TByteData);
     665var
     666  mem: TStream;
     667begin
     668  mem := TMemoryStream.Create;
     669  GetAs32bit(mem);
     670  SetLength(Target, mem.Size);
     671  mem.Read(Target[0], mem.Size);
     672  mem.Free;
     673end;
    653674
    654675
     
    786807
    787808
    788 
    789 function TOniImage.GetMipMappedImage(var faded: TByteData): Boolean;
     809function TOniImage.GetMipMappedImage(var Target: TByteData): Boolean;
    790810var
    791811  i:      Integer;
     
    810830  x := Self.FWidth;
    811831  y := Self.FHeight;
    812   SetLength(faded, x * y * Self.FDepth div 8);
     832  SetLength(Target, x * y * Self.FDepth div 8);
    813833  SetLength(fadelvldata, x * y * Self.FDepth div 8);
    814   for i := 0 to Length(faded) - 1 do
    815   begin
    816     faded[i] := Self.FData[i];
     834  for i := 0 to Length(Target) - 1 do
     835  begin
     836    Target[i] := Self.FData[i];
    817837    fadelvldata[i] := Self.FData[i];
    818838  end;
     
    821841    x := x div 2;
    822842    y := y div 2;
    823     SetLength(faded, Length(faded) + x * y * Self.FDepth div 8);
     843    SetLength(Target, Length(Target) + x * y * Self.FDepth div 8);
    824844    for i := 0 to Length(fadelvldata) - 1 do
    825       faded[Length(faded) - x * y * Self.FDepth div 8 + i] := fadelvldata[i];
     845      Target[Length(Target) - x * y * Self.FDepth div 8 + i] := fadelvldata[i];
    826846  until (x = 1) or (y = 1) or ((x mod 2) = 1) or ((y mod 2) = 1);
    827847  if (x > 1) and (y > 1) then
     
    834854
    835855
     856function TOniImage.GetMipMappedImage(var Target: TStream): Boolean;
     857var
     858  data: TByteData;
     859  streampos: Integer;
     860begin
     861  Result := GetMipMappedImage(data);
     862  if not Assigned(Target) then
     863    Target := TMemoryStream.Create;
     864  streampos := Target.Position;
     865  Target.Write(data[0], Length(data));
     866  Target.Seek(streampos, soFromBeginning);
     867end;
     868
     869
    836870end.
  • oup/rewrite/Global/RawList.pas

    r101 r105  
    1818      FRawListHandlers: TRawListHandlers;
    1919    public
     20      property RawListHandlers: TRawListHandlers read FRawListHandlers;
    2021      procedure InsertRawListHandler(ext: String; needed: Boolean; handler: THandler);
    2122      function GetRawList(ConnectionID, FileID: Integer): TRawDataList;
  • oup/rewrite/Helper/ValueEdit.pas

    r104 r105  
    3333implementation
    3434
    35 uses BinEdit, {RawEdit, }DatStructureLoader, Main;
     35uses BinEdit, RawEdit, DatStructureLoader, Main;
    3636
    3737{$R *.dfm}
  • oup/rewrite/Main.dfm

    r97 r105  
    370370      'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP ' +
    371371      'level database (*.oldb)|*.oldb|Any (*.*)|*'
    372     Options = [ofPathMustExist, ofFileMustExist, ofEnableSizing]
     372    Options = [ofAllowMultiSelect, ofPathMustExist, ofFileMustExist, ofEnableSizing]
    373373    Left = 32
    374374    Top = 64
  • oup/rewrite/Main.pas

    r97 r105  
    1111  Settings, {Helper_LevelDB, }
    1212  Template,
    13   Preview;
    14 //  BinEdit, Extractor, RawEdit, TxmpReplace;
     13  RawEdit, BinEdit, Extractor, Preview, TxmpReplace;
    1514
    1615type
     
    162161  begin
    163162    UpdateStatBar;
     163    UpdateConLists;
    164164  end;
    165165end;
     
    497497procedure TForm_Main.LoadFile(typedb: Boolean);
    498498var
    499   ext: String;
     499  i: Integer;
    500500begin
    501501  opend.InitialDir := AppSettings.DatPath;
     
    507507  if opend.Execute then
    508508  begin
    509     ext := ExtractFileExt(opend.FileName);
    510     if ext = '.dat' then
    511     begin
    512       CreateConnection(opend.FileName);
    513     end else if ext = '.oldb' then
    514     begin
    515       CreateConnection(opend.FileName);
    516     end else
    517       ShowMessage('Incompatible file');
     509    if opend.Files.Count > 0 then
     510      for i := 0 to opend.Files.Count - 1 do
     511        CreateConnection(opend.Files.Strings[i]);
    518512    AppSettings.DatPath := ExtractFilepath(opend.FileName);
    519513  end;
     
    693687    CheckConnectionCloseable(index);
    694688    ConManager.CloseConnectionByIndex(index, RepMsg);
     689    ShowOpenMsg(RepMsg);
     690    UpdateConLists;
    695691  end;
    696692  UpdateStatBar;
     
    751747  if window_context = 'binedit' then
    752748  begin
    753 //    toolform         := TForm_BinEdit.Create(Self);
     749    toolform         := TForm_BinEdit.Create(Self);
    754750    toolform.Caption := 'Binary .dat-Editor ' + caption_end;
    755751    iconindex        := 5;
     
    757753  if window_context = 'extractor' then
    758754  begin
    759 //    toolform         := TForm_Extractor.Create(Self);
     755    toolform         := TForm_Extractor.Create(Self);
    760756    toolform.Caption := 'Extractor ' + caption_end;
    761757    iconindex        := 8;
     
    769765  if window_context = 'rawedit' then
    770766  begin
    771 //    toolform         := TForm_RawEdit.Create(Self);
     767    toolform         := TForm_RawEdit.Create(Self);
    772768    toolform.Caption := 'Binary .raw-Editor ' + caption_end;
    773769    iconindex        := 6;
     
    775771  if window_context = 'txmpreplace' then
    776772  begin
    777 //    toolform         := TForm_TxmpReplace.Create(Application);
     773    toolform         := TForm_TxmpReplace.Create(Self);
    778774    toolform.Caption := 'TXMP Replacer ' + caption_end;
    779775    iconindex        := 7;
  • oup/rewrite/OniUnPacker.bdsproj

    r104 r105  
    178178                </Language> 
    179179   
    180    
    181180    <Excluded_Packages>
    182181      <Excluded_Packages Name="d:\programme\borland\bds\3.0\Bin\dbwebxprt.bpl">Borland Web Wizard Package</Excluded_Packages>
  • oup/rewrite/OniUnPacker.dpr

    r104 r105  
    2323  ValueEdit in 'Helper\ValueEdit.pas' {Form_ValueEdit},
    2424  BinEdit in 'Tools\BinEdit.pas' {Form_BinEdit},
    25   RawEdit in 'Tools\RawEdit.pas' {Form_RawEdit};
     25  RawEdit in 'Tools\RawEdit.pas' {Form_RawEdit},
     26  Extractor in 'Tools\Extractor.pas' {Form_Extractor},
     27  TxmpReplace in 'Tools\TxmpReplace.pas' {Form_TxmpReplace};
    2628
    2729{$R *.res}
     
    3436  Application.CreateForm(TForm_Settings, Form_Settings);
    3537  Application.CreateForm(TForm_ValueEdit, Form_ValueEdit);
    36   Application.CreateForm(TForm_RawEdit, Form_RawEdit);
    3738  Application.Run;
    3839end.
  • oup/rewrite/Tools/BinEdit.dfm

    r104 r105  
    33  KeyPreview = True
    44  OnCloseQuery = FormCloseQuery
     5  OnCreate = FormCreate
    56  OnKeyUp = FormKeyUp
    67  ExplicitWidth = 500
  • oup/rewrite/Tools/BinEdit.pas

    r104 r105  
    176176  end;
    177177end;
    178 
    179 
    180 
    181 
    182 function IntToBin(Value: Byte): String;
    183 var
    184   i: Byte;
    185 begin
    186   Result := '';
    187   for i := 7 downto 0 do
    188     Result := Result + IntToStr((Value shr i) and $01);
    189 end;
    190 
    191178
    192179
  • oup/rewrite/Tools/Extractor.dfm

    r93 r105  
    2222      Width = 333
    2323      Height = 338
     24      MultiSelect = True
    2425      ExplicitWidth = 333
    2526      ExplicitHeight = 338
  • oup/rewrite/Tools/Extractor.pas

    r93 r105  
    3636implementation
    3737{$R *.dfm}
    38 uses Main, Functions, Data, OniDataClass, FolderBrowser, Exporters;
     38uses Main, Functions, Data, ConnectionManager, FolderBrowser, Exporters;
    3939
    4040
     
    105105    if (selonly and filelist.Selected[i]) or not selonly then
    106106    begin
    107       fileid := Connection.ExtractFileID(filelist.Items.Strings[i]);
     107      fileid := ConManager.Connection[ConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]);
    108108      filename := GetWinFilename(filelist.Items.Strings[i]);
    109109      if check_dat.Checked then
    110         ExportDatFile(Connection, fileid, path + filename);
     110        ExportDatFile(ConnectionID, fileid, path + filename);
    111111      if check_raw.Checked then
    112         ExportRawFiles(Connection, fileid, path + filename);
     112        ExportRawFiles(ConnectionID, fileid, path + filename);
    113113      if check_convert.Checked then
    114         ExportConverted(Connection, fileid, path + filename);
     114        ExportConverted(ConnectionID, fileid, path + filename);
    115115      Inc(done);
    116116    end;
  • oup/rewrite/Tools/RawEdit.dfm

    r104 r105  
    33  KeyPreview = True
    44  OnCloseQuery = FormCloseQuery
     5  OnCreate = FormCreate
    56  OnKeyUp = FormKeyUp
    67  ExplicitWidth = 500
  • oup/rewrite/Tools/RawEdit.pas

    r104 r105  
    6363implementation
    6464{$R *.dfm}
    65 uses Main, ValueEdit;
     65uses Main, ValueEdit, RawList;
    6666
    6767procedure TForm_RawEdit.NewFile(fileinfo: TFileInfo);
     
    115115    for i := 0 to filelist.Count - 1 do
    116116    begin
    117       if ConManager.Connection[ConID].ExtractFileIDOfName(filelist.Items.Strings[i]) = RawInfo.SrcID then
     117      if ConManager.Connection[ConID].ExtractFileIDOfName(filelist.Items.Strings[i]) = Raw_Info.SrcID then
    118118      begin
    119119        filelist.ItemIndex := i;
     
    132132  end;
    133133  mem := nil;
    134   ConManager.Connection[ConID].LoadRawFile(raw_info.SrcID, raw_info.SrcOffset, mem);
     134  ConManager.Connection[ConID].LoadRawFile(raw_info.SrcID, raw_info.SrcOffset, TStream(mem));
    135135  hex.LoadFromStream(mem);
    136136  ClearValues;
     
    146146begin
    147147  ClearValues;
    148   dat_offset := StrToInt('$' + MidStr(
     148  datoffset := StrToInt('$' + MidStr(
    149149    list_offset.Items.Strings[list_offset.ItemIndex], 3, 8));
    150   LoadRaw(Connection.GetRawInfo(fileid, dat_offset));
    151 end;
    152 
    153 
    154 
    155 
    156 function IntToBin(Value: Byte): String;
    157 var
    158   i: Byte;
    159 begin
    160   Result := '';
    161   for i := 7 downto 0 do
    162   begin
    163     Result := Result + IntToStr((Value shr i) and $01);
    164   end;
     150  LoadRaw(ConManager.Connection[ConID].GetRawInfo(fileid, datoffset));
    165151end;
    166152
     
    170156function TForm_RawEdit.GetValue(datatype: Word; offset: LongWord): String;
    171157var
    172   Data: Tdata;
     158  Data: TByteData;
    173159  i:    Word;
    174160  floatformat: TFormatSettings;
     
    231217begin
    232218  for i := 1 to value_viewer.RowCount - 1 do
    233   begin
    234219    value_viewer.Cells[1, i] := '';
    235   end;
    236220end;
    237221
     
    242226var
    243227  i, j:  Integer;
    244   Data:  Tdata;
     228  Data:  TByteData;
    245229  str:   String;
    246230  Value: LongWord;
     
    363347
    364348  exts := '';
    365   if Length(RawListHandlers) > 0 then
    366   begin
    367     for i := 0 to High(RawListHandlers) do
     349  if Length(RawLists.RawListHandlers) > 0 then
     350  begin
     351    for i := 0 to High(RawLists.RawListHandlers) do
    368352      if Length(exts) > 0 then
    369         exts := exts + ',' + RawListHandlers[i].Ext
     353        exts := exts + ',' + RawLists.RawListHandlers[i].Ext
    370354      else
    371         exts := RawListHandlers[i].Ext;
     355        exts := RawLists.RawListHandlers[i].Ext;
    372356  end;
    373357  Self.AllowedExts := exts;
     
    404388var
    405389  mem:  TMemoryStream;
    406   Data: Tdata;
    407390  i:    LongWord;
    408391begin
    409392  case MessageBox(Self.Handle, PChar('Save changes to .raw-part of file ' +
    410       Connection.GetFileInfo(fileid).FileName + '?'), PChar('Data changed...'),
     393      ConManager.Connection[ConID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'),
    411394      MB_YESNOCANCEL) of
    412395    idYes:
     
    415398      hex.SaveToStream(mem);
    416399      mem.Seek(0, soFromBeginning);
    417       SetLength(Data, mem.Size);
    418       mem.Read(Data[0], mem.Size);
     400      ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, mem);
    419401      mem.Free;
    420       Connection.UpdateRawFile(fileid_opened, dat_offset_opened,
    421         Length(Data), @Data[0]);
    422402      hex.Modified := False;
    423403      for i := 0 to hex.Datasize - 1 do
     
    428408      Result := True;
    429409    idCancel:
    430     begin
    431410      Result := False;
    432     end;
    433411  end;
    434412end;
     
    440418begin
    441419  if hex.Modified then
    442   begin
    443420    if not Save then
    444421      CanClose := False;
    445   end;
    446422end;
    447423
     
    529505  fs: TFileStream;
    530506begin
    531   saved.Filter     := 'Files of matching extension (*.' + Connection.GetFileInfo(
    532     fileid).Extension + ')|*.' + Connection.GetFileInfo(fileid).Extension +
     507  saved.Filter     := 'Files of matching extension (*.' +
     508    ConManager.Connection[ConID].GetFileInfo(fileid).Extension + ')|*.' +
     509    ConManager.Connection[ConID].GetFileInfo(fileid).Extension +
    533510    '|All files|*.*';
    534   saved.DefaultExt := Connection.GetFileInfo(fileid).Extension;
     511  saved.DefaultExt := ConManager.Connection[ConID].GetFileInfo(fileid).Extension;
    535512  if saved.Execute then
    536513  begin
     
    548525//  Data: Tdata;
    549526  fs:   TFileStream;
    550 begin
    551   opend.Filter := 'Files of matching extension (*.' + Connection.GetFileInfo(
    552     fileid).Extension + ')|*.' + Connection.GetFileInfo(fileid).Extension +
     527  data: TByteData;
     528  i: Integer;
     529  rawinfo: TRawDataInfo;
     530begin
     531  opend.Filter := 'Files of matching extension (*.' +
     532    ConManager.Connection[ConID].GetFileInfo(fileid).Extension + ')|*.' +
     533    ConManager.Connection[ConID].GetFileInfo(fileid).Extension +
    553534    '|All files|*.*';
    554535  if opend.Execute then
     
    557538    if fs.Size <> hex.DataSize then
    558539    begin
    559       ShowMessage('Can''t import ' + ExtractFilename(opend.FileName) +
    560         ', file has to have same size as file in .dat.' + CrLf +
    561         'Size of file in .dat: ' + FormatFileSize(hex.datasize) + CrLf +
    562         'Size of chosen file: ' + FormatFileSize(fs.Size));
    563     end
    564     else
    565     begin
    566       hex.LoadFromStream(fs);
    567       hex.Modified := True;
    568     end;
     540      if (not (CR_ResizeRaw in ConManager.Connection[ConID].ChangeRights)) and (not (CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights)) then
     541      begin
     542        ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) +
     543            ', file has to have same size as file in .raw with this backend.' + CrLf +
     544            'Size of file in .raw: ' + FormatFileSize(hex.DataSize) + CrLf +
     545            'Size of chosen file: ' + FormatFileSize(fs.Size));
     546        Exit;
     547      end else begin
     548        if MessageBox(Self.Handle,
     549              PChar('File has different size from the file in the .raw.' + CrLf +
     550                    'Size of file in .dat: ' + FormatFileSize(hex.DataSize) + CrLf +
     551                    'Size of chosen file: ' + FormatFileSize(fs.Size) + CrLf +
     552                    'Replace anyway?' + CrLf +
     553                    'WARNING: This only replaces the raw-data. It doesn''t' + CrLf +
     554                    'do the according changes in the .dat. Oni probably' + CrLf +
     555                    'won''t be able to use the data correctly!'), PChar('Different size'), MB_YESNO + MB_ICONWARNING) = ID_NO then
     556        begin
     557          Exit;
     558        end;
     559      end;
     560      rawinfo := ConManager.Connection[ConID].GetRawInfo(fileid, datoffset);
     561      if CR_ResizeRaw in ConManager.Connection[ConID].ChangeRights then
     562        ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, fs)
     563      else if CR_AppendRaw in ConManager.Connection[ConID].ChangeRights then
     564        i := ConManager.Connection[ConID].AppendRawFile(rawinfo.LocSep, fs);
     565        ConManager.Connection[ConID].UpdateDatFilePart(fileid, datoffset, 4, @i);
     566    end else begin
     567      ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, fs);
     568    end;
     569    fs.Seek(0, soFromBeginning);
     570    hex.LoadFromStream(fs);
     571    hex.Modified := False;
     572    for i := 0 to hex.Datasize - 1 do
     573      hex.ByteChanged[i] := False;
    569574    fs.Free;
    570575  end;
     
    691696procedure TForm_RawEdit.SetNewValue(datatype: Word; offset: LongWord; Value: String);
    692697var
    693   Data: Tdata;
     698  Data: TByteData;
    694699  value_int: LongWord;
    695700  value_float: Single;
  • oup/rewrite/Tools/Template.dfm

    r101 r105  
    242242        Style = csDropDownList
    243243        Anchors = [akLeft, akTop, akRight]
    244         DropDownCount = 12
     244        DropDownCount = 20
    245245        Font.Charset = DEFAULT_CHARSET
    246246        Font.Color = clWindowText
     
    288288        Style = csDropDownList
    289289        Anchors = [akLeft, akTop, akRight]
     290        DropDownCount = 12
    290291        ItemHeight = 13
    291292        TabOrder = 4
  • oup/rewrite/Tools/Template.pas

    r101 r105  
    117117      else
    118118        datatype := 'Unknown: ';
    119       boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ')';
     119      boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ') [' + IntToStr(ConManager.ConnectionByIndex[i].ConnectionID) + ']';
    120120      combo_connection.Items.Add(boxstring);
    121121      if ConManager.ConnectionByIndex[i].ConnectionID = FConnectionID then
     
    276276begin
    277277  if combo_connection.ItemIndex >= 0 then
    278     FConnectionID := combo_connection.ItemIndex
     278  begin
     279    name := combo_connection.Items.Strings[combo_connection.ItemIndex];
     280    FConnectionID := StrToInt(MidStr(name, Pos('[', name) + 1, Pos(']', name) - Pos('[', name)  - 1));
     281  end
    279282  else
    280283    FConnectionID := -1;
  • oup/rewrite/Tools/TxmpReplace.dfm

    r93 r105  
    11inherited Form_TxmpReplace: TForm_TxmpReplace
    22  Caption = 'TxmpReplace'
     3  OnCreate = FormCreate
    34  PixelsPerInch = 96
    45  TextHeight = 13
  • oup/rewrite/Tools/TxmpReplace.pas

    r97 r105  
    4747procedure TForm_TxmpReplace.SelectFile(fileinfo: TFileInfo);
    4848var
    49   Data: TByteData;
    5049  mem:  TMemoryStream;
    5150  fadingbyte, depthbyte, storebyte: Byte;
    5251begin
    5352  fileid := fileinfo.ID;
    54   Connection.LoadDatFilePart(fileid, $88, SizeOf(fadingbyte), @fadingbyte);
    55   Connection.LoadDatFilePart(fileid, $89, SizeOf(depthbyte), @depthbyte);
    56   Connection.LoadDatFilePart(fileid, $90, SizeOf(storebyte), @storebyte);
     53  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(fadingbyte), @fadingbyte);
     54  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $89, SizeOf(depthbyte), @depthbyte);
     55  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storebyte), @storebyte);
    5756  check_fading.Checked := (fadingbyte and $01) > 0;
    5857  check_transparency.Checked := (depthbyte and $04) > 0;
    5958
    60   OniImage_Old.LoadFromTXMP(connection, fileid);
     59  OniImage_Old.LoadFromTXMP(ConnectionID, fileid);
    6160  old_size := OniImage_Old.GetImageDataSize((fadingbyte and $01) > 0);
    62   Data := OniImage_Old.GetAsBMP;
    6361  mem  := TMemoryStream.Create;
    64   mem.Write(Data[0], Length(Data));
     62  OniImage_Old.GetAsBMP(TStream(mem));
    6563  mem.Seek(0, soFromBeginning);
    6664  image_txmppreview.Picture.Bitmap.LoadFromStream(mem);
     
    7472var
    7573  mem:   TMemoryStream;
    76   tempd: Tdata;
    7774begin
    7875  if opend.Execute then
    7976  begin
    8077    OniImage_New.LoadFromBMP(opend.FileName);
    81     tempd := OniImage_New.GetAsBMP;
    8278    mem   := TMemoryStream.Create;
    83     mem.Write(tempd[0], Length(tempd));
     79    OniImage_New.GetAsBMP(TStream(mem));
    8480    mem.Seek(0, soFromBeginning);
    8581    image_bmppreview.Picture.Bitmap.LoadFromStream(mem);
     
    9793  old_rawaddr, new_rawaddr: LongWord;
    9894  oldfading: Byte;
    99   tempd:     Tdata;
    100 
    10195  datbyte: Word;
     96  mem: TMemoryStream;
    10297begin
    10398  if filelist.ItemIndex >= 0 then
    10499  begin
    105     Connection.LoadDatFilePart(fileid, $88, 1, @oldfading);
    106     if Connection.OSisMac then
    107       Connection.UpdateDatFilePart(fileid, $A0, 4, @old_rawaddr)
     100    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, 1, @oldfading);
     101    if not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN) then
     102      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @old_rawaddr)
    108103    else
    109       Connection.LoadDatFilePart(fileid, $9C, 4, @old_rawaddr);
     104      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @old_rawaddr);
    110105
    111106    if (OniImage_Old.Width <> OniImage_New.Width) or
    112107      (OniImage_Old.Height <> OniImage_New.Height) then
    113108    begin
    114       if MessageBox(Self.Handle, PChar(
    115         'Current image and new image have different size' + CrLf +
    116         '(Current: ' + IntToStr(OniImage_Old.Width) +
    117         'x' + IntToStr(OniImage_Old.Height) + ' - New: ' +
    118         IntToStr(OniImage_New.Width) + 'x' + IntToStr(OniImage_New.Height) + ')' + CrLf +
    119         'Replace anyways?'),
    120         PChar(filelist.Items.Strings[filelist.ItemIndex]),
    121         MB_YESNO) = idNo then
     109      if MessageBox(Self.Handle,
     110            PChar(
     111              'Current image and new image have different size' + CrLf +
     112              '(Current: ' + IntToStr(OniImage_Old.Width) + 'x' +
     113              IntToStr(OniImage_Old.Height) + ' - New: ' +
     114              IntToStr(OniImage_New.Width) + 'x' + IntToStr(OniImage_New.Height) +
     115              ')' + CrLf + 'Replace anyway?'),
     116            PChar(filelist.Items.Strings[filelist.ItemIndex]), MB_YESNO) = idNo then
    122117        Exit;
    123118    end;
    124119
     120    mem := TMemoryStream.Create;
     121
    125122    if check_fading.Checked then
    126       if not OniImage_New.GetMipMappedImage(tempd) then
     123      if not OniImage_New.GetMipMappedImage(TStream(mem)) then
    127124        if MessageBox(Self.Handle,
    128           PChar('Can not create a MipMapped-image (probably because of a wrong dimension).' +
    129           #13 + #10 + 'Do you want to continue without MipMapping?'), PChar('Warning'),
    130           MB_YESNO) = ID_YES then
     125              PChar('Can not create a MipMapped-image (probably because of a wrong dimension).' +
     126                #13 + #10 + 'Do you want to continue without MipMapping?'), PChar('Warning'),
     127                MB_YESNO) = ID_YES then
    131128          check_fading.Checked := False
    132129        else
     
    134131
    135132    if not check_fading.Checked then
    136       tempd := OniImage_New.GetAsData;
     133    begin
     134      mem.Clear;
     135      OniImage_New.GetAsData(TStream(mem));
     136    end;
    137137
    138138    newsize := OniImage_New.GetImageDataSize(check_fading.Checked);
    139139
    140     if (newsize > old_size) and (Connection.Backend = ODB_Dat) then
    141       new_rawaddr := Connection.AppendRawFile(
    142         Connection.OSisMac, Length(tempd), tempd)
     140    if (newsize > old_size) and (ConManager.Connection[ConnectionID].Backend = DB_ONI) then
     141      new_rawaddr := ConManager.Connection[ConnectionID].AppendRawFile(
     142        not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN), mem.Size, mem)
    143143    else
    144144    begin
    145145      new_rawaddr := old_rawaddr;
    146       Connection.UpdateRawFile(fileid, $9C, Length(tempd), tempd);
     146      ConManager.Connection[ConnectionID].UpdateRawFile(fileid, $9C, mem);
    147147    end;
    148148
     
    150150    if check_fading.Checked then
    151151      datbyte := datbyte or $01;
    152     Connection.UpdateDatFilePart(fileid, $88, 1, @datbyte);
     152    ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $88, 1, @datbyte);
    153153    datbyte := $10;
    154154    if check_transparency.Checked then
    155155      datbyte := datbyte or $04;
    156     Connection.UpdateDatFilePart(fileid, $89, 1, @datbyte);
    157     Connection.UpdateDatFilePart(fileid, $8C, 2, @OniImage_New.Width);
    158     Connection.UpdateDatFilePart(fileid, $8E, 2, @OniImage_New.Height);
     156    ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $89, 1, @datbyte);
     157    ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8C, 2, @OniImage_New.Width);
     158    ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8E, 2, @OniImage_New.Height);
    159159    datbyte := $08;
    160     Connection.UpdateDatFilePart(fileid, $90, 1, @datbyte);
    161     if Connection.OSisMac then
    162       Connection.UpdateDatFilePart(fileid, $A0, 4, @new_rawaddr)
     160    ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $90, 1, @datbyte);
     161    if not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN) then
     162      ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $A0, 4, @new_rawaddr)
    163163    else
    164       Connection.UpdateDatFilePart(fileid, $9C, 4, @new_rawaddr);
     164      ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $9C, 4, @new_rawaddr);
    165165
    166166    ShowMessage('TXMP-image replaced');
Note: See TracChangeset for help on using the changeset viewer.