Ignore:
Timestamp:
Jan 16, 2007, 12:35:04 AM (18 years ago)
Author:
alloc
Message:

Rev86 was first after multi-cons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • oup/current/Tools/BinEdit.pas

    r87 r92  
    3232    procedure hexChange(Sender: TObject);
    3333
    34     procedure LoadDat(_fileid: LongWord);
     34    procedure LoadDat(_fileid: Integer);
    3535    function Save: Boolean;
    3636    function GetValue(datatype: Word; offset: LongWord): String;
     
    5757    procedure value_viewer_contextPopup(Sender: TObject);
    5858  private
     59    con: TOniData;
    5960    fileid: Integer;
    6061  public
     
    9394  value_viewer.RowCount := 8;
    9495  value_viewer.FixedRows := 1;
     96  value_viewer.FixedCols := 1;
    9597  value_viewer.Cells[0, 0] := 'Type';
    9698  value_viewer.Cells[1, 0] := 'Value';
     
    102104  value_viewer.Cells[0, 6] := 'String';
    103105  value_viewer.Cells[0, 7] := 'Selected length';
    104 //  value_viewer.ColWidths[0] := 100;
    105 //  value_viewer.ColWidths[1] := value_viewer.Width - 150;
     106  value_viewer.ColWidths[0] := 120;
     107  value_viewer.ColWidths[1] := 1000;
    106108//  hex.Height := content.Height - 215;
    107109  //
     
    135137
    136138
    137 procedure TForm_BinEdit.LoadDat(_fileid: LongWord);
     139procedure TForm_BinEdit.LoadDat(_fileid: Integer);
    138140var
    139141  mem:  TMemoryStream;
    140142  Data: Tdata;
    141143begin
    142   if hex.Modified then
    143   begin
    144     if not Save then
    145     begin
    146       Self.SelectFileID(fileid);
    147       Exit;
    148     end;
    149   end;
    150   fileid := _fileid;
    151   if OniDataConnection.ExtractFileID(
    152         filelist.Items.Strings[filelist.ItemIndex]) <> fileid then
    153     Self.SelectFileID(fileid);
    154   Self.ClearStructViewer;
    155   Data := OniDataConnection.LoadDatFile(fileid);
    156   if Length(Data) > 0 then
    157   begin
    158     mem := TMemoryStream.Create;
    159     mem.Write(Data[0], Length(Data));
    160     mem.Seek(0, soFromBeginning);
    161     hex.LoadFromStream(mem);
    162     mem.Free;
    163     WriteStructureInfos;
     144  if con <> nil then
     145  begin
     146    if hex.Modified then
     147    begin
     148      if not Save then
     149      begin
     150        Self.SelectFileID(Connection, fileid);
     151        Exit;
     152      end;
     153    end;
     154  end;
     155  if _fileid >= 0 then
     156  begin
     157    fileid := _fileid;
     158    con := Connection;
     159    if con.ExtractFileID(filelist.Items.Strings[filelist.ItemIndex]) <> fileid then
     160      Self.SelectFileID(Connection, fileid);
     161    Self.ClearStructViewer;
     162    Data := con.LoadDatFile(fileid);
     163    if Length(Data) > 0 then
     164    begin
     165      mem := TMemoryStream.Create;
     166      mem.Write(Data[0], Length(Data));
     167      mem.Seek(0, soFromBeginning);
     168      hex.LoadFromStream(mem);
     169      mem.Free;
     170      WriteStructureInfos;
     171    end
     172    else
     173    begin
     174      ClearValues;
     175      hex.DataSize := 0;
     176    end;
    164177  end
    165178  else
    166179  begin
     180    fileid := _fileid;
     181    con := nil;
     182    Self.ClearStructViewer;
    167183    ClearValues;
    168184    hex.DataSize := 0;
     
    226242      Result := IntToBin(hex.Data[offset]);
    227243    11:
    228       Result := '0x' + IntToHex(OniDataConnection.GetRawInfo(fileid, offset).raw_addr, 8);
     244      Result := '0x' + IntToHex(con.GetRawInfo(fileid, offset).raw_addr, 8);
    229245    12:
    230246      Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 +
     
    291307  if VST.RootNodeCount = 0 then
    292308  begin
    293     structs := LoadStructureDefinition(Connection, fileid);
     309    structs := LoadStructureDefinition(con, fileid);
    294310    if structs.Data then
    295311    begin
     
    501517begin
    502518  case MessageBox(Self.Handle, PChar('Save changes to file ' +
    503       OniDataConnection.GetFileInfo(fileid).FileName + '?'), PChar('Data changed...'),
     519      con.GetFileInfo(fileid).FileName + '?'), PChar('Data changed...'),
    504520      MB_YESNOCANCEL) of
    505521    idYes:
     
    511527      mem.Read(Data[0], mem.Size);
    512528      mem.Free;
    513       OniDataConnection.UpdateDatFile(fileid, Data);
     529      con.UpdateDatFile(fileid, Data);
    514530      hex.Modified := False;
    515531      for i := 0 to hex.Datasize - 1 do
     
    762778      if nodedata.DataType = 11 then
    763779      begin
    764         if OniDataConnection.GetRawInfo(fileid, nodedata.offset).raw_size > 0 then
    765           Form_Main.open_child('rawedit', fileid);
     780        if con.GetRawInfo(fileid, nodedata.offset).raw_size > 0 then
     781          Form_Main.open_child('rawedit', Connection, fileid);
    766782      end;
    767783      if nodedata.DataType = 12 then
    768784      begin
    769         if (StrToInt(nodedata.Value) < OniDataConnection.GetFilesCount) and
     785        if (StrToInt(nodedata.Value) < con.GetFilesCount) and
    770786          (StrToInt(nodedata.Value) > 0) and
    771787          (StrToInt(nodedata.Value) <> fileid) then
    772788        begin
    773           if OniDataConnection.GetFileInfo(StrToInt(nodedata.Value)).Size > 0 then
    774             Form_Main.open_child('binedit', StrToInt(nodedata.Value))
     789          if con.GetFileInfo(StrToInt(nodedata.Value)).Size > 0 then
     790            Form_Main.open_child('binedit', Connection, StrToInt(nodedata.Value))
    775791          else
    776792            ShowMessage('Linked filed is a zero-byte-file');
     
    779795      if (nodedata.DataType >= 100) and (nodedata.DataType <= 300) then
    780796      begin
    781         form := Form_Main.open_child('binedit', -1);
     797        form := Form_Main.open_child('binedit', Connection, -1);
    782798        if Assigned(form) then
    783799          form.SetFileFilters(nodedata.Value, '', False);
Note: See TracChangeset for help on using the changeset viewer.