Changeset 105 for oup/rewrite/Tools


Ignore:
Timestamp:
Feb 21, 2007, 1:29:27 AM (18 years ago)
Author:
alloc
Message:
 
Location:
oup/rewrite/Tools
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • 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.