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

Comparing oup/current/Tools/RawEdit.pas (file contents):
Revision 175 by alloc, Wed May 2 15:16:58 2007 UTC vs.
Revision 223 by alloc, Mon Jun 18 14:23:58 2007 UTC

# Line 1 | Line 1
1   unit RawEdit;
2 +
3   interface
4 +
5   uses
6    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 <  Dialogs, Template, StdCtrls, ExtCtrls, Menus, Grids, Wrapgrid,
8 <  MPHexEditor, Clipbrd, StrUtils, TypeDefs,
7 <  Data, Functions, DatStructureLoader, ConnectionManager, Buttons;
7 >  Dialogs, _TemplateFileList, Menus, StdCtrls, ExtCtrls, Buttons, ComCtrls,
8 >  TypeDefs, Grids, Wrapgrid, MPHexEditor;
9  
10   type
11 <  TForm_RawEdit = class(TForm_ToolTemplate)
11 <    Splitter4: TSplitter;
11 >  TForm_RawEdit = class(TForm_TemplateFileList)
12      panel_imexport: TPanel;
13      btn_export: TButton;
14      btn_import: TButton;
15      GroupBox1: TGroupBox;
16      list_offset: TListBox;
17 +    Splitter4: TSplitter;
18 +    opend: TOpenDialog;
19 +    saved: TSaveDialog;
20      hex: TMPHexEditor;
18    Splitter2: TSplitter;
21      value_viewer: TWrapGrid;
22 +    Splitter2: TSplitter;
23      value_viewer_context: TPopupMenu;
24      value_viewer_context_copy: TMenuItem;
25      value_viewer_context_copyasdec: TMenuItem;
# Line 24 | Line 27 | type
27      value_viewer_context_copyasbitset: TMenuItem;
28      value_viewer_context_copyasstring: TMenuItem;
29      value_viewer_context_copyashex: TMenuItem;
27    opend: TOpenDialog;
28    saved: TSaveDialog;
30      procedure list_offsetClick(Sender: TObject);
31      procedure NewFile(fileinfo: TFileInfo);
32      procedure LoadRaw(raw_info: TRawDataInfo);
# Line 57 | Line 58 | type
58    public
59    end;
60  
60 var
61  Form_RawEdit: TForm_RawEdit;
61  
62   implementation
63   {$R *.dfm}
64 < uses Main, ValueEdit, RawList;
64 > uses
65 >  _TemplateFile, ValueEdit, ConnectionManager, StrUtils, Functions, RawList,
66 >  Data, Clipbrd;
67  
68   procedure TForm_RawEdit.NewFile(fileinfo: TFileInfo);
69   var
# Line 101 | Line 102 | end;
102   procedure TForm_RawEdit.LoadRaw(raw_info: TRawDataInfo);
103   var
104    i:    Integer;
104  mem: TMemoryStream;
105   begin
106    if hex.Modified then
107    begin
# Line 110 | Line 110 | begin
110        Exit;
111      end;
112    end;
113 <  if list_offset.Count = 0 then
113 >  for i := 0 to filelist.Count - 1 do
114    begin
115 <    for i := 0 to filelist.Count - 1 do
115 >    if ConManager.Connection[ConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]) = Raw_Info.SrcID then
116      begin
117 <      if ConManager.Connection[ConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]) = Raw_Info.SrcID then
118 <      begin
119 <        filelist.ItemIndex := i;
120 <        listClick(Self);
121 <        Break;
122 <      end;
117 >      filelist.ItemIndex := i;
118 >      listClick(Self);
119 >      Break;
120      end;
121 <    for i := 0 to list_offset.Count - 1 do
121 >  end;
122 >  for i := 0 to list_offset.Count - 1 do
123 >  begin
124 >    if MidStr(list_offset.Items.Strings[i], 3, 8) = IntToHex(raw_info.SrcOffset, 8) then
125      begin
126 <      if MidStr(list_offset.Items.Strings[i], 3, 8) = IntToHex(raw_info.SrcOffset, 8) then
127 <      begin
128 <        list_offset.ItemIndex := i;
129 <        Break;
130 <      end;
126 >      list_offset.ItemIndex := i;
127 >      list_offsetClick(Self);
128 >      Break;
129      end;
130    end;
133  mem := nil;
134  ConManager.Connection[ConnectionID].LoadRawFile(raw_info.SrcID, raw_info.SrcOffset, TStream(mem));
135  hex.LoadFromStream(mem);
136  ClearValues;
137  hexSelectionChanged(Self);
131   end;
132  
133  
# Line 143 | Line 136 | end;
136  
137  
138   procedure TForm_RawEdit.list_offsetClick(Sender: TObject);
139 + var
140 +  mem: TMemoryStream;
141 +  rawinfo: TRawDataInfo;
142   begin
147  ClearValues;
143    datoffset := StrToInt('$' + MidStr(
144      list_offset.Items.Strings[list_offset.ItemIndex], 3, 8));
145 <  LoadRaw(ConManager.Connection[ConnectionID].GetRawInfo(fileid, datoffset));
145 >
146 >  rawinfo := ConManager.Connection[ConnectionID].GetRawInfo(fileid, datoffset);
147 >
148 >  if rawinfo.RawSize > 0 then
149 >  begin
150 >    mem := nil;
151 >    ConManager.Connection[ConnectionID].LoadRawFile(rawinfo.SrcID, rawinfo.SrcOffset, TStream(mem));
152 >    hex.LoadFromStream(mem);
153 >    ClearValues;
154 >    hexSelectionChanged(Self);
155 >  end
156 >  else
157 >  begin
158 >    hex.DataSize := 0;
159 >    ClearValues;
160 >  end;
161   end;
162  
163  
# Line 538 | Line 548 | begin
548      fs := TFileStream.Create(opend.FileName, fmOpenRead);
549      if fs.Size <> hex.DataSize then
550      begin
551 <      if (not (CR_ResizeRaw in ConManager.Connection[ConnectionID].ChangeRights)) and (not (CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights)) then
551 >      if
552 >        (not (CR_ResizeRaw in ConManager.Connection[ConnectionID].ChangeRights))
553 >        and (not (CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights))
554 >        then
555        begin
556          ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) +
557              ', file has to have same size as file in .raw with this backend.' + CrLf +
# Line 807 | Line 820 | end;
820  
821   begin
822    AddToolListEntry('rawedit', 'Binary .raw-Editor', '');
823 < end.
823 > end.
824 >
825 >

Diff Legend

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