ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/Tools/BinEdit.pas
(Generate patch)

Comparing oup/current/Tools/BinEdit.pas (file contents):
Revision 109 by alloc, Wed Feb 21 03:12:33 2007 UTC vs.
Revision 113 by alloc, Sun Feb 25 17:20:22 2007 UTC

# Line 33 | Line 33 | type
33  
34      procedure LoadDat(_fileid: Integer);
35      function Save: Boolean;
36 <    function GetValue(datatype: Word; offset: LongWord): String;
37 <    procedure SetNewValue(datatype: Word; offset: LongWord; Value: String);
36 >    function GetValue(datatype: Word; offset: Integer): String;
37 >    procedure SetNewValue(datatype: Word; offset: Integer; Value: String);
38  
39      procedure WriteStructureInfos;
40      procedure ClearStructViewer;
# Line 139 | Line 139 | end;
139   procedure TForm_BinEdit.LoadDat(_fileid: Integer);
140   var
141    mem:  TMemoryStream;
142  Data: TByteData;
142   begin
143    if ConID <> -1 then
144    begin
# Line 178 | Line 177 | end;
177  
178  
179  
180 < function TForm_BinEdit.GetValue(datatype: Word; offset: LongWord): String;
180 > function TForm_BinEdit.GetValue(datatype: Word; offset: Integer): String;
181   var
182    Data: TByteData;
183    i:    Word;
184 +  tempi: Integer;
185    floatformat: TFormatSettings;
186   begin
187    floatformat.DecimalSeparator := '.';
# Line 217 | Line 217 | begin
217      10:
218        Result := IntToBin(hex.Data[offset]);
219      11:
220 <      Result := '0x' + IntToHex(ConManager.Connection[ConID].GetRawInfo(fileid, offset).RawAddr, 8);
220 >    begin
221 >      tempi := ConManager.Connection[ConID].GetRawInfo(fileid, offset).RawAddr;
222 >      if tempi >= 0 then
223 >        Result := '0x' + IntToHex(tempi, 8)
224 >      else
225 >        Result := 'unused';
226 >    end;
227      12:
228 <      Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 +
229 <        hex.Data[offset + 3] * 256 * 256, 5, '0');
228 >      if hex.Data[offset] = 1 then
229 >        Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 +
230 >          hex.Data[offset + 3] * 256 * 256, 5, '0')
231 >      else
232 >        Result := 'no link';
233      13:
234        Result := IntToStr(hex.Data[offset]);
235      14:
# Line 273 | Line 282 | end;
282  
283   procedure TForm_BinEdit.WriteStructureInfos;
284   var
285 <  i, j:    LongWord;
285 >  i, j:    Integer;
286    pdata:   PNodeData;
287    Data:    TNodeData;
288    node:    PVirtualNode;
# Line 307 | Line 316 | begin
316              begin
317                if Pos('#', SubName) > 0 then
318                begin
319 <                Data.Offset  := HexToLong(MidStr(SubName, Pos('#', SubName) + 1, 8));
320 <                Data.Value   :=
319 >                Data.Offset  := StrToInt('$'+MidStr(SubName, Pos('#', SubName) + 1, 8));
320 >                Data.Value   := '$' +
321                    MidStr(SubName, PosEx('#', SubName, Pos('#', SubName) + 1) + 1, 8);
322                  Data.Caption := MidStr(SubName, 1, Pos('#', SubName) - 1);
323                  Data.Description := SubDesc;
# Line 375 | Line 384 | var
384    i, j:  Integer;
385    Data:  TByteData;
386    str:   String;
387 <  Value: LongWord;
387 >  Value: Integer;
388    floatformat: TFormatSettings;
389   begin
390    floatformat.DecimalSeparator := '.';
# Line 488 | Line 497 | end;
497   function TForm_BinEdit.Save: Boolean;
498   var
499    mem:  TMemoryStream;
500 <  i:    LongWord;
500 >  i:    Integer;
501   begin
502    case MessageBox(Self.Handle, PChar('Save changes to file ' +
503        ConManager.Connection[ConID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'),
# Line 670 | Line 679 | end;
679   procedure TForm_BinEdit.value_viewer_context_copyClick(Sender: TObject);
680   var
681    Name:  String;
682 <  Value: LongWord;
682 >  Value: Integer;
683   begin
684    Name := TMenuItem(Sender).Name;
685    if Pos('asstring', Name) > 0 then
# Line 748 | Line 757 | begin
757      end
758      else
759      begin
760 <      if nodedata.DataType = 11 then
760 >      if (nodedata.DataType = 11) and (nodedata.Value <> 'unused') then
761        begin
762          if ConManager.Connection[ConID].GetRawInfo(fileid, nodedata.offset).RawSize > 0 then
763            Form_Main.open_child('rawedit', ConID, fileid);
764        end;
765 <      if nodedata.DataType = 12 then
765 >      if (nodedata.DataType = 12) and (nodedata.Value <> 'no link') then
766        begin
767          if (StrToInt(nodedata.Value) < ConManager.Connection[ConID].GetFileCount) and
768            (StrToInt(nodedata.Value) > 0) and
# Line 793 | Line 802 | begin
802    else
803    begin
804      hex.SelStart := Data.Offset;
805 <    hex.SelEnd   := Data.Offset + HexToLong(Data.Value) - 1;
805 >    hex.SelEnd   := Data.Offset + StrToInt(Data.Value) - 1;
806    end;
807   end;
808  
# Line 824 | Line 833 | begin
833          if Data.DataType > 0 then
834            CellText := Data.Value //GetValue(data.DataType, data.Offset)
835          else if Length(Data.Value) > 0 then
836 <          CellText := IntToStr(HexToLong(Data.Value)) + ' Bytes';
836 >          CellText := IntToStr(StrToInt(Data.Value)) + ' Bytes';
837        4:
838          CellText := Data.Description;
839      end;
# Line 855 | Line 864 | end;
864  
865  
866  
867 < procedure TForm_BinEdit.SetNewValue(datatype: Word; offset: LongWord; Value: String);
867 > procedure TForm_BinEdit.SetNewValue(datatype: Word; offset: Integer; Value: String);
868   var
869    Data: TByteData;
870    value_int: LongWord;
# Line 922 | Line 931 | end;
931  
932   procedure TForm_BinEdit.value_viewerDblClick(Sender: TObject);
933   var
934 <  offset:     LongWord;
934 >  offset:     Integer;
935    datatype:   Word;
936    objectname: String;
937    Value:      String;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)