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 111 by alloc, Wed Feb 21 03:28:48 2007 UTC vs.
Revision 217 by alloc, Fri Jun 15 15:12:11 2007 UTC

# Line 2 | Line 2 | unit BinEdit;
2   interface
3   uses
4    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
5 <  Dialogs, Template, StdCtrls, ExtCtrls, VirtualTrees, Grids, Wrapgrid,
6 <  MPHexEditor, VTHeaderPopup, Menus, StrUtils, Clipbrd,
7 <  Data, TypeDefs, ConnectionManager, Buttons;
5 >  Dialogs, VirtualTrees, Grids, Wrapgrid, MPHexEditor, StdCtrls,
6 >  Menus, VTHeaderPopup, ExtCtrls, Buttons, StrUtils, Clipbrd,
7 >  Data, TypeDefs, ConnectionManager, Template,
8 >  _BaseTemplate, _TemplateFile, _TemplateFileList;
9  
10   type
11    TForm_BinEdit = class(TForm_ToolTemplate)
# Line 21 | Line 22 | type
22      value_viewer_context_copyasstring: TMenuItem;
23      value_viewer_context_copyashex: TMenuItem;
24      VTHPopup: TVTHeaderPopupMenu;
25 +    panel_imexport: TPanel;
26 +    btn_export: TButton;
27 +    btn_import: TButton;
28      procedure FormCreate(Sender: TObject);
29      procedure NewFile(fileinfo: TFileInfo);
30  
# Line 58 | Line 62 | type
62    private
63      fileid: Integer;
64      ConID: Integer;
65 +    rawlist: TRawDataList;
66    public
67    end;
68  
# Line 66 | Line 71 | var
71  
72   implementation
73  
74 < uses ValueEdit, Main, Functions, DatStructureLoader{, RawEdit};
74 > uses ValueEdit, Main, Functions, DatStructureLoader, RawEdit;
75   {$R *.dfm}
76  
77   type
# Line 139 | Line 144 | end;
144   procedure TForm_BinEdit.LoadDat(_fileid: Integer);
145   var
146    mem:  TMemoryStream;
142  Data: TByteData;
147   begin
148    if ConID <> -1 then
149    begin
# Line 161 | Line 165 | begin
165      Self.ClearStructViewer;
166      mem := nil;
167      ConManager.Connection[ConID].LoadDatFile(fileid, TStream(mem));
168 +    rawlist := ConManager.Connection[ConID].GetRawList(fileid);
169      hex.LoadFromStream(mem);
170      mem.Free;
171      ClearValues;
# Line 173 | Line 178 | begin
178      Self.ClearStructViewer;
179      ClearValues;
180      hex.DataSize := 0;
181 +    SetLength(rawlist, 0);
182    end;
183   end;
184  
# Line 181 | Line 187 | end;
187   function TForm_BinEdit.GetValue(datatype: Word; offset: Integer): String;
188   var
189    Data: TByteData;
190 <  i:    Word;
190 >  i:    Integer;
191    floatformat: TFormatSettings;
192   begin
193    floatformat.DecimalSeparator := '.';
# Line 217 | Line 223 | begin
223      10:
224        Result := IntToBin(hex.Data[offset]);
225      11:
226 <      Result := '0x' + IntToHex(ConManager.Connection[ConID].GetRawInfo(fileid, offset).RawAddr, 8);
226 >    begin
227 >      if Length(rawlist) > 0 then
228 >      begin
229 >        for i := 0 to High(rawlist) do
230 >          if rawlist[i].SrcOffset = offset then
231 >          begin
232 >            if rawlist[i].RawAddr > 0 then
233 >              Result := '0x' + IntToHex(rawlist[i].RawAddr, 8)
234 >            else
235 >              Result := 'unused';
236 >            Break;
237 >          end;
238 >        if i > High(rawlist) then
239 >          Result := 'unused';
240 >      end;
241 >    end;
242      12:
243 <      Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 +
244 <        hex.Data[offset + 3] * 256 * 256, 5, '0');
243 >      if hex.Data[offset] = 1 then
244 >        Result := FormatNumber(hex.Data[offset + 1] + hex.Data[offset + 2] * 256 +
245 >          hex.Data[offset + 3] * 256 * 256, 5, '0')
246 >      else
247 >        Result := 'no link';
248      13:
249        Result := IntToStr(hex.Data[offset]);
250      14:
# Line 307 | Line 331 | begin
331              begin
332                if Pos('#', SubName) > 0 then
333                begin
334 <                Data.Offset  := HexToLong(MidStr(SubName, Pos('#', SubName) + 1, 8));
335 <                Data.Value   :=
334 >                Data.Offset  := StrToInt('$'+MidStr(SubName, Pos('#', SubName) + 1, 8));
335 >                Data.Value   := '$' +
336                    MidStr(SubName, PosEx('#', SubName, Pos('#', SubName) + 1) + 1, 8);
337                  Data.Caption := MidStr(SubName, 1, Pos('#', SubName) - 1);
338                  Data.Description := SubDesc;
# Line 458 | Line 482 | begin
482        str := '';
483        if hex.SelCount = 0 then
484        begin
485 <        while (hex.Data[hex.SelStart + j] > 0) and ((hex.SelStart + j) < hex.DataSize) do
485 >        while (hex.SelStart + j) < hex.DataSize do
486          begin
487 +          if hex.Data[hex.SelStart + j] = 0 then
488 +            Break;
489            if hex.Data[hex.selstart + j] >= 32 then
490              str := str + Char(hex.Data[hex.SelStart + j])
491            else
# Line 733 | Line 759 | procedure TForm_BinEdit.VSTDblClick(Send
759   var
760    node: PVirtualNode;
761    nodedata: PNodeData;
762 <  form: TForm_ToolTemplate;
762 >  rawinfo: TRawDataInfo;
763 >  form: TForm_TemplateFileList;
764   begin
765    if VST.FocusedColumn = 3 then
766    begin
# Line 748 | Line 775 | begin
775      end
776      else
777      begin
778 <      if nodedata.DataType = 11 then
778 >      if (nodedata.DataType = 11) and (nodedata.Value <> 'unused') then
779        begin
780 <        if ConManager.Connection[ConID].GetRawInfo(fileid, nodedata.offset).RawSize > 0 then
781 <          Form_Main.open_child('rawedit', ConID, fileid);
780 >        rawinfo := ConManager.Connection[ConID].GetRawInfo(fileid, nodedata.offset);
781 >        if rawinfo.RawSize > 0 then
782 >        begin
783 >          form := nil;
784 >          form := TForm_TemplateFileList(Form_Main.open_child('rawedit', ConID, fileid));
785 >          if Assigned(form) then
786 >            TForm_RawEdit(form).LoadRaw(rawinfo);
787 >        end;
788        end;
789 <      if nodedata.DataType = 12 then
789 >      if (nodedata.DataType = 12) and (nodedata.Value <> 'no link') then
790        begin
791          if (StrToInt(nodedata.Value) < ConManager.Connection[ConID].GetFileCount) and
792            (StrToInt(nodedata.Value) > 0) and
# Line 767 | Line 800 | begin
800        end;
801        if (nodedata.DataType >= 100) and (nodedata.DataType <= 300) then
802        begin
803 <        form := Form_Main.open_child('binedit', ConID, -1);
803 >        form := TForm_TemplateFileList(Form_Main.open_child('binedit', ConID));
804          if Assigned(form) then
805            form.SetFileFilters(nodedata.Value, '', False);
806        end;
# Line 793 | Line 826 | begin
826    else
827    begin
828      hex.SelStart := Data.Offset;
829 <    hex.SelEnd   := Data.Offset + HexToLong(Data.Value) - 1;
829 >    hex.SelEnd   := Data.Offset + StrToInt(Data.Value) - 1;
830    end;
831   end;
832  
# Line 824 | Line 857 | begin
857          if Data.DataType > 0 then
858            CellText := Data.Value //GetValue(data.DataType, data.Offset)
859          else if Length(Data.Value) > 0 then
860 <          CellText := IntToStr(HexToLong(Data.Value)) + ' Bytes';
860 >          CellText := IntToStr(StrToInt(Data.Value)) + ' Bytes';
861        4:
862          CellText := Data.Description;
863      end;

Diff Legend

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