Changeset 92 for oup/current/Tools/BinEdit.pas
- Timestamp:
- Jan 16, 2007, 12:35:04 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Tools/BinEdit.pas
r87 r92 32 32 procedure hexChange(Sender: TObject); 33 33 34 procedure LoadDat(_fileid: LongWord);34 procedure LoadDat(_fileid: Integer); 35 35 function Save: Boolean; 36 36 function GetValue(datatype: Word; offset: LongWord): String; … … 57 57 procedure value_viewer_contextPopup(Sender: TObject); 58 58 private 59 con: TOniData; 59 60 fileid: Integer; 60 61 public … … 93 94 value_viewer.RowCount := 8; 94 95 value_viewer.FixedRows := 1; 96 value_viewer.FixedCols := 1; 95 97 value_viewer.Cells[0, 0] := 'Type'; 96 98 value_viewer.Cells[1, 0] := 'Value'; … … 102 104 value_viewer.Cells[0, 6] := 'String'; 103 105 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; 106 108 // hex.Height := content.Height - 215; 107 109 // … … 135 137 136 138 137 procedure TForm_BinEdit.LoadDat(_fileid: LongWord);139 procedure TForm_BinEdit.LoadDat(_fileid: Integer); 138 140 var 139 141 mem: TMemoryStream; 140 142 Data: Tdata; 141 143 begin 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; 164 177 end 165 178 else 166 179 begin 180 fileid := _fileid; 181 con := nil; 182 Self.ClearStructViewer; 167 183 ClearValues; 168 184 hex.DataSize := 0; … … 226 242 Result := IntToBin(hex.Data[offset]); 227 243 11: 228 Result := '0x' + IntToHex( OniDataConnection.GetRawInfo(fileid, offset).raw_addr, 8);244 Result := '0x' + IntToHex(con.GetRawInfo(fileid, offset).raw_addr, 8); 229 245 12: 230 246 Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 + … … 291 307 if VST.RootNodeCount = 0 then 292 308 begin 293 structs := LoadStructureDefinition( Connection, fileid);309 structs := LoadStructureDefinition(con, fileid); 294 310 if structs.Data then 295 311 begin … … 501 517 begin 502 518 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...'), 504 520 MB_YESNOCANCEL) of 505 521 idYes: … … 511 527 mem.Read(Data[0], mem.Size); 512 528 mem.Free; 513 OniDataConnection.UpdateDatFile(fileid, Data);529 con.UpdateDatFile(fileid, Data); 514 530 hex.Modified := False; 515 531 for i := 0 to hex.Datasize - 1 do … … 762 778 if nodedata.DataType = 11 then 763 779 begin 764 if OniDataConnection.GetRawInfo(fileid, nodedata.offset).raw_size > 0 then765 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); 766 782 end; 767 783 if nodedata.DataType = 12 then 768 784 begin 769 if (StrToInt(nodedata.Value) < OniDataConnection.GetFilesCount) and785 if (StrToInt(nodedata.Value) < con.GetFilesCount) and 770 786 (StrToInt(nodedata.Value) > 0) and 771 787 (StrToInt(nodedata.Value) <> fileid) then 772 788 begin 773 if OniDataConnection.GetFileInfo(StrToInt(nodedata.Value)).Size > 0 then774 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)) 775 791 else 776 792 ShowMessage('Linked filed is a zero-byte-file'); … … 779 795 if (nodedata.DataType >= 100) and (nodedata.DataType <= 300) then 780 796 begin 781 form := Form_Main.open_child('binedit', -1);797 form := Form_Main.open_child('binedit', Connection, -1); 782 798 if Assigned(form) then 783 799 form.SetFileFilters(nodedata.Value, '', False);
Note:
See TracChangeset
for help on using the changeset viewer.