--- oup/current/Tools/RawEdit.pas 2007/05/02 15:16:58 175 +++ oup/current/Tools/RawEdit.pas 2007/06/18 14:23:58 223 @@ -1,22 +1,25 @@ unit RawEdit; + interface + uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, Template, StdCtrls, ExtCtrls, Menus, Grids, Wrapgrid, - MPHexEditor, Clipbrd, StrUtils, TypeDefs, - Data, Functions, DatStructureLoader, ConnectionManager, Buttons; + Dialogs, _TemplateFileList, Menus, StdCtrls, ExtCtrls, Buttons, ComCtrls, + TypeDefs, Grids, Wrapgrid, MPHexEditor; type - TForm_RawEdit = class(TForm_ToolTemplate) - Splitter4: TSplitter; + TForm_RawEdit = class(TForm_TemplateFileList) panel_imexport: TPanel; btn_export: TButton; btn_import: TButton; GroupBox1: TGroupBox; list_offset: TListBox; + Splitter4: TSplitter; + opend: TOpenDialog; + saved: TSaveDialog; hex: TMPHexEditor; - Splitter2: TSplitter; value_viewer: TWrapGrid; + Splitter2: TSplitter; value_viewer_context: TPopupMenu; value_viewer_context_copy: TMenuItem; value_viewer_context_copyasdec: TMenuItem; @@ -24,8 +27,6 @@ type value_viewer_context_copyasbitset: TMenuItem; value_viewer_context_copyasstring: TMenuItem; value_viewer_context_copyashex: TMenuItem; - opend: TOpenDialog; - saved: TSaveDialog; procedure list_offsetClick(Sender: TObject); procedure NewFile(fileinfo: TFileInfo); procedure LoadRaw(raw_info: TRawDataInfo); @@ -57,12 +58,12 @@ type public end; -var - Form_RawEdit: TForm_RawEdit; implementation {$R *.dfm} -uses Main, ValueEdit, RawList; +uses + _TemplateFile, ValueEdit, ConnectionManager, StrUtils, Functions, RawList, + Data, Clipbrd; procedure TForm_RawEdit.NewFile(fileinfo: TFileInfo); var @@ -101,7 +102,6 @@ end; procedure TForm_RawEdit.LoadRaw(raw_info: TRawDataInfo); var i: Integer; - mem: TMemoryStream; begin if hex.Modified then begin @@ -110,31 +110,24 @@ begin Exit; end; end; - if list_offset.Count = 0 then + for i := 0 to filelist.Count - 1 do begin - for i := 0 to filelist.Count - 1 do + if ConManager.Connection[ConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]) = Raw_Info.SrcID then begin - if ConManager.Connection[ConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]) = Raw_Info.SrcID then - begin - filelist.ItemIndex := i; - listClick(Self); - Break; - end; + filelist.ItemIndex := i; + listClick(Self); + Break; end; - for i := 0 to list_offset.Count - 1 do + end; + for i := 0 to list_offset.Count - 1 do + begin + if MidStr(list_offset.Items.Strings[i], 3, 8) = IntToHex(raw_info.SrcOffset, 8) then begin - if MidStr(list_offset.Items.Strings[i], 3, 8) = IntToHex(raw_info.SrcOffset, 8) then - begin - list_offset.ItemIndex := i; - Break; - end; + list_offset.ItemIndex := i; + list_offsetClick(Self); + Break; end; end; - mem := nil; - ConManager.Connection[ConnectionID].LoadRawFile(raw_info.SrcID, raw_info.SrcOffset, TStream(mem)); - hex.LoadFromStream(mem); - ClearValues; - hexSelectionChanged(Self); end; @@ -143,11 +136,28 @@ end; procedure TForm_RawEdit.list_offsetClick(Sender: TObject); +var + mem: TMemoryStream; + rawinfo: TRawDataInfo; begin - ClearValues; datoffset := StrToInt('$' + MidStr( list_offset.Items.Strings[list_offset.ItemIndex], 3, 8)); - LoadRaw(ConManager.Connection[ConnectionID].GetRawInfo(fileid, datoffset)); + + rawinfo := ConManager.Connection[ConnectionID].GetRawInfo(fileid, datoffset); + + if rawinfo.RawSize > 0 then + begin + mem := nil; + ConManager.Connection[ConnectionID].LoadRawFile(rawinfo.SrcID, rawinfo.SrcOffset, TStream(mem)); + hex.LoadFromStream(mem); + ClearValues; + hexSelectionChanged(Self); + end + else + begin + hex.DataSize := 0; + ClearValues; + end; end; @@ -538,7 +548,10 @@ begin fs := TFileStream.Create(opend.FileName, fmOpenRead); if fs.Size <> hex.DataSize then begin - if (not (CR_ResizeRaw in ConManager.Connection[ConnectionID].ChangeRights)) and (not (CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights)) then + if + (not (CR_ResizeRaw in ConManager.Connection[ConnectionID].ChangeRights)) + and (not (CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights)) + then begin ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) + ', file has to have same size as file in .raw with this backend.' + CrLf + @@ -807,4 +820,6 @@ end; begin AddToolListEntry('rawedit', 'Binary .raw-Editor', ''); -end. \ No newline at end of file +end. + +