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

Comparing:
oup/rewrite/Tools/BinEdit.pas (file contents), Revision 105 by alloc, Wed Feb 21 00:29:27 2007 UTC vs.
oup/current/Tools/BinEdit.pas (file contents), Revision 177 by alloc, Sat May 12 13:22:11 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 58 | Line 58 | type
58    private
59      fileid: Integer;
60      ConID: Integer;
61 +    rawlist: TRawDataList;
62    public
63    end;
64  
# Line 66 | Line 67 | var
67  
68   implementation
69  
70 < uses ValueEdit, Main, Functions, DatStructureLoader{, RawEdit};
70 > uses ValueEdit, Main, Functions, DatStructureLoader, RawEdit;
71   {$R *.dfm}
72  
73   type
# Line 139 | Line 140 | end;
140   procedure TForm_BinEdit.LoadDat(_fileid: Integer);
141   var
142    mem:  TMemoryStream;
142  Data: TByteData;
143   begin
144    if ConID <> -1 then
145    begin
# Line 161 | Line 161 | begin
161      Self.ClearStructViewer;
162      mem := nil;
163      ConManager.Connection[ConID].LoadDatFile(fileid, TStream(mem));
164 +    rawlist := ConManager.Connection[ConID].GetRawList(fileid);
165      hex.LoadFromStream(mem);
166      mem.Free;
167      ClearValues;
# Line 173 | Line 174 | begin
174      Self.ClearStructViewer;
175      ClearValues;
176      hex.DataSize := 0;
177 +    SetLength(rawlist, 0);
178    end;
179   end;
180  
181  
182  
183 < function TForm_BinEdit.GetValue(datatype: Word; offset: LongWord): String;
183 > function TForm_BinEdit.GetValue(datatype: Word; offset: Integer): String;
184   var
185    Data: TByteData;
186 <  i:    Word;
186 >  i:    Integer;
187 >  tempi: Integer;
188    floatformat: TFormatSettings;
189   begin
190    floatformat.DecimalSeparator := '.';
# Line 217 | Line 220 | begin
220      10:
221        Result := IntToBin(hex.Data[offset]);
222      11:
223 <      Result := '0x' + IntToHex(ConManager.Connection[ConID].GetRawInfo(fileid, offset).RawAddr, 8);
223 >    begin
224 >      if Length(rawlist) > 0 then
225 >        for i := 0 to High(rawlist) do
226 >          if rawlist[i].SrcOffset = offset then
227 >          begin
228 >            if rawlist[i].RawAddr > 0 then
229 >              Result := '0x' + IntToHex(rawlist[i].RawAddr, 8)
230 >            else
231 >              Result := 'unused';
232 >            Break;
233 >          end;
234 >    end;
235      12:
236 <      Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 +
237 <        hex.Data[offset + 3] * 256 * 256, 5, '0');
236 >      if hex.Data[offset] = 1 then
237 >        Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 +
238 >          hex.Data[offset + 3] * 256 * 256, 5, '0')
239 >      else
240 >        Result := 'no link';
241      13:
242        Result := IntToStr(hex.Data[offset]);
243      14:
# Line 273 | Line 290 | end;
290  
291   procedure TForm_BinEdit.WriteStructureInfos;
292   var
293 <  i, j:    LongWord;
293 >  i, j:    Integer;
294    pdata:   PNodeData;
295    Data:    TNodeData;
296    node:    PVirtualNode;
# Line 307 | Line 324 | begin
324              begin
325                if Pos('#', SubName) > 0 then
326                begin
327 <                Data.Offset  := HexToLong(MidStr(SubName, Pos('#', SubName) + 1, 8));
328 <                Data.Value   :=
327 >                Data.Offset  := StrToInt('$'+MidStr(SubName, Pos('#', SubName) + 1, 8));
328 >                Data.Value   := '$' +
329                    MidStr(SubName, PosEx('#', SubName, Pos('#', SubName) + 1) + 1, 8);
330                  Data.Caption := MidStr(SubName, 1, Pos('#', SubName) - 1);
331                  Data.Description := SubDesc;
# Line 375 | Line 392 | var
392    i, j:  Integer;
393    Data:  TByteData;
394    str:   String;
395 <  Value: LongWord;
395 >  Value: Integer;
396    floatformat: TFormatSettings;
397   begin
398    floatformat.DecimalSeparator := '.';
# Line 458 | Line 475 | begin
475        str := '';
476        if hex.SelCount = 0 then
477        begin
478 <        while (hex.Data[hex.SelStart + j] > 0) and ((hex.SelStart + j) < hex.DataSize) do
478 >        while (hex.SelStart + j) < hex.DataSize do
479          begin
480 +          if hex.Data[hex.SelStart + j] = 0 then
481 +            Break;
482            if hex.Data[hex.selstart + j] >= 32 then
483              str := str + Char(hex.Data[hex.SelStart + j])
484            else
# Line 488 | Line 507 | end;
507   function TForm_BinEdit.Save: Boolean;
508   var
509    mem:  TMemoryStream;
510 <  i:    LongWord;
510 >  i:    Integer;
511   begin
512    case MessageBox(Self.Handle, PChar('Save changes to file ' +
513        ConManager.Connection[ConID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'),
# Line 670 | Line 689 | end;
689   procedure TForm_BinEdit.value_viewer_context_copyClick(Sender: TObject);
690   var
691    Name:  String;
692 <  Value: LongWord;
692 >  Value: Integer;
693   begin
694    Name := TMenuItem(Sender).Name;
695    if Pos('asstring', Name) > 0 then
# Line 733 | Line 752 | procedure TForm_BinEdit.VSTDblClick(Send
752   var
753    node: PVirtualNode;
754    nodedata: PNodeData;
755 +  rawinfo: TRawDataInfo;
756    form: TForm_ToolTemplate;
757   begin
758    if VST.FocusedColumn = 3 then
# Line 748 | Line 768 | begin
768      end
769      else
770      begin
771 <      if nodedata.DataType = 11 then
771 >      if (nodedata.DataType = 11) and (nodedata.Value <> 'unused') then
772        begin
773 <        if ConManager.Connection[ConID].GetRawInfo(fileid, nodedata.offset).RawSize > 0 then
774 <          Form_Main.open_child('rawedit', ConID, fileid);
773 >        rawinfo := ConManager.Connection[ConID].GetRawInfo(fileid, nodedata.offset);
774 >        if rawinfo.RawSize > 0 then
775 >        begin
776 >          form := nil;
777 >          form := Form_Main.open_child('rawedit', ConID, fileid);
778 >          if Assigned(form) then
779 >            TForm_RawEdit(form).LoadRaw(rawinfo);
780 >        end;
781        end;
782 <      if nodedata.DataType = 12 then
782 >      if (nodedata.DataType = 12) and (nodedata.Value <> 'no link') then
783        begin
784          if (StrToInt(nodedata.Value) < ConManager.Connection[ConID].GetFileCount) and
785            (StrToInt(nodedata.Value) > 0) and
# Line 793 | Line 819 | begin
819    else
820    begin
821      hex.SelStart := Data.Offset;
822 <    hex.SelEnd   := Data.Offset + HexToLong(Data.Value) - 1;
822 >    hex.SelEnd   := Data.Offset + StrToInt(Data.Value) - 1;
823    end;
824   end;
825  
# Line 824 | Line 850 | begin
850          if Data.DataType > 0 then
851            CellText := Data.Value //GetValue(data.DataType, data.Offset)
852          else if Length(Data.Value) > 0 then
853 <          CellText := IntToStr(HexToLong(Data.Value)) + ' Bytes';
853 >          CellText := IntToStr(StrToInt(Data.Value)) + ' Bytes';
854        4:
855          CellText := Data.Description;
856      end;
# Line 855 | Line 881 | end;
881  
882  
883  
884 < procedure TForm_BinEdit.SetNewValue(datatype: Word; offset: LongWord; Value: String);
884 > procedure TForm_BinEdit.SetNewValue(datatype: Word; offset: Integer; Value: String);
885   var
886    Data: TByteData;
887    value_int: LongWord;
# Line 922 | Line 948 | end;
948  
949   procedure TForm_BinEdit.value_viewerDblClick(Sender: TObject);
950   var
951 <  offset:     LongWord;
951 >  offset:     Integer;
952    datatype:   Word;
953    objectname: String;
954    Value:      String;

Diff Legend

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