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 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 38 | Line 38 | type
38      procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
39      procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
40  
41 <    function GetValue(datatype: Word; offset: LongWord): String;
41 >    function GetValue(datatype: Word; offset: Integer): String;
42      procedure ClearValues;
43      procedure WriteValues;
44 <    procedure SetNewValue(datatype: Word; offset: LongWord; Value: String);
44 >    procedure SetNewValue(datatype: Word; offset: Integer; Value: String);
45  
46      procedure value_viewerDblClick(Sender: TObject);
47      procedure value_viewer_context_copyClick(Sender: TObject);
# Line 53 | Line 53 | type
53      procedure hexSelectionChanged(Sender: TObject);
54      procedure hexChange(Sender: TObject);
55    private
56 <    ConID, fileid, datoffset: Integer;
56 >    fileid, datoffset: Integer;
57    public
58    end;
59  
# Line 100 | Line 100 | end;
100  
101   procedure TForm_RawEdit.LoadRaw(raw_info: TRawDataInfo);
102   var
103 <  i:    LongWord;
103 >  i:    Integer;
104    mem: TMemoryStream;
105   begin
106    if hex.Modified then
# Line 114 | Line 114 | begin
114    begin
115      for i := 0 to filelist.Count - 1 do
116      begin
117 <      if ConManager.Connection[ConID].ExtractFileIDOfName(filelist.Items.Strings[i]) = Raw_Info.SrcID then
117 >      if ConManager.Connection[ConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]) = Raw_Info.SrcID then
118        begin
119          filelist.ItemIndex := i;
120          listClick(Self);
# Line 131 | Line 131 | begin
131      end;
132    end;
133    mem := nil;
134 <  ConManager.Connection[ConID].LoadRawFile(raw_info.SrcID, raw_info.SrcOffset, TStream(mem));
134 >  ConManager.Connection[ConnectionID].LoadRawFile(raw_info.SrcID, raw_info.SrcOffset, TStream(mem));
135    hex.LoadFromStream(mem);
136    ClearValues;
137    hexSelectionChanged(Self);
# Line 147 | Line 147 | begin
147    ClearValues;
148    datoffset := StrToInt('$' + MidStr(
149      list_offset.Items.Strings[list_offset.ItemIndex], 3, 8));
150 <  LoadRaw(ConManager.Connection[ConID].GetRawInfo(fileid, datoffset));
150 >  LoadRaw(ConManager.Connection[ConnectionID].GetRawInfo(fileid, datoffset));
151   end;
152  
153  
154  
155  
156 < function TForm_RawEdit.GetValue(datatype: Word; offset: LongWord): String;
156 > function TForm_RawEdit.GetValue(datatype: Word; offset: Integer): String;
157   var
158    Data: TByteData;
159    i:    Word;
# Line 227 | Line 227 | var
227    i, j:  Integer;
228    Data:  TByteData;
229    str:   String;
230 <  Value: LongWord;
230 >  Value: Integer;
231    floatformat: TFormatSettings;
232   begin
233    floatformat.DecimalSeparator := '.';
# Line 339 | Line 339 | end;
339  
340   procedure TForm_RawEdit.FormCreate(Sender: TObject);
341   var
342 <  i:     LongWord;
342 >  i:     Integer;
343    exts: String;
344   begin
345    inherited;
# Line 387 | Line 387 | end;
387   function TForm_RawEdit.Save: Boolean;
388   var
389    mem:  TMemoryStream;
390 <  i:    LongWord;
390 >  i:    Integer;
391   begin
392    case MessageBox(Self.Handle, PChar('Save changes to .raw-part of file ' +
393 <      ConManager.Connection[ConID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'),
393 >      ConManager.Connection[ConnectionID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'),
394        MB_YESNOCANCEL) of
395      idYes:
396      begin
397        mem := TMemoryStream.Create;
398        hex.SaveToStream(mem);
399        mem.Seek(0, soFromBeginning);
400 <      ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, mem);
400 >      ConManager.Connection[ConnectionID].UpdateRawFile(fileid, datoffset, mem);
401        mem.Free;
402        hex.Modified := False;
403        for i := 0 to hex.Datasize - 1 do
# Line 505 | Line 505 | var
505    fs: TFileStream;
506   begin
507    saved.Filter     := 'Files of matching extension (*.' +
508 <    ConManager.Connection[ConID].GetFileInfo(fileid).Extension + ')|*.' +
509 <    ConManager.Connection[ConID].GetFileInfo(fileid).Extension +
508 >    ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension + ')|*.' +
509 >    ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension +
510      '|All files|*.*';
511 <  saved.DefaultExt := ConManager.Connection[ConID].GetFileInfo(fileid).Extension;
511 >  saved.DefaultExt := ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension;
512    if saved.Execute then
513    begin
514      fs := TFileStream.Create(saved.FileName, fmCreate);
# Line 524 | Line 524 | procedure TForm_RawEdit.btn_importClick(
524   var
525   //  Data: Tdata;
526    fs:   TFileStream;
527  data: TByteData;
527    i: Integer;
528    rawinfo: TRawDataInfo;
529   begin
530    opend.Filter := 'Files of matching extension (*.' +
531 <    ConManager.Connection[ConID].GetFileInfo(fileid).Extension + ')|*.' +
532 <    ConManager.Connection[ConID].GetFileInfo(fileid).Extension +
531 >    ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension + ')|*.' +
532 >    ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension +
533      '|All files|*.*';
534    if opend.Execute then
535    begin
536      fs := TFileStream.Create(opend.FileName, fmOpenRead);
537      if fs.Size <> hex.DataSize then
538      begin
539 <      if (not (CR_ResizeRaw in ConManager.Connection[ConID].ChangeRights)) and (not (CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights)) then
539 >      if (not (CR_ResizeRaw in ConManager.Connection[ConnectionID].ChangeRights)) and (not (CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights)) then
540        begin
541          ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) +
542              ', file has to have same size as file in .raw with this backend.' + CrLf +
# Line 557 | Line 556 | begin
556            Exit;
557          end;
558        end;
559 <      rawinfo := ConManager.Connection[ConID].GetRawInfo(fileid, datoffset);
560 <      if CR_ResizeRaw in ConManager.Connection[ConID].ChangeRights then
561 <        ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, fs)
562 <      else if CR_AppendRaw in ConManager.Connection[ConID].ChangeRights then
563 <        i := ConManager.Connection[ConID].AppendRawFile(rawinfo.LocSep, fs);
564 <        ConManager.Connection[ConID].UpdateDatFilePart(fileid, datoffset, 4, @i);
559 >      rawinfo := ConManager.Connection[ConnectionID].GetRawInfo(fileid, datoffset);
560 >      if CR_ResizeRaw in ConManager.Connection[ConnectionID].ChangeRights then
561 >        ConManager.Connection[ConnectionID].UpdateRawFile(fileid, datoffset, fs)
562 >      else if CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights then
563 >        i := ConManager.Connection[ConnectionID].AppendRawFile(rawinfo.LocSep, fs);
564 >        ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, datoffset, 4, @i);
565      end else begin
566 <      ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, fs);
566 >      ConManager.Connection[ConnectionID].UpdateRawFile(fileid, datoffset, fs);
567      end;
568      fs.Seek(0, soFromBeginning);
569      hex.LoadFromStream(fs);
# Line 634 | Line 633 | procedure TForm_RawEdit.value_viewer_con
633   var
634   //  i:     Byte;
635    Name:  String;
636 <  Value: LongWord;
636 >  Value: Integer;
637   begin
638    Name := TMenuItem(Sender).Name;
639    if Pos('asstring', Name) > 0 then
# Line 693 | Line 692 | end;
692  
693  
694  
695 < procedure TForm_RawEdit.SetNewValue(datatype: Word; offset: LongWord; Value: String);
695 > procedure TForm_RawEdit.SetNewValue(datatype: Word; offset: Integer; Value: String);
696   var
697    Data: TByteData;
698    value_int: LongWord;
# Line 760 | Line 759 | end;
759  
760   procedure TForm_RawEdit.value_viewerDblClick(Sender: TObject);
761   var
762 <  offset:     LongWord;
762 >  offset:     Integer;
763    datatype:   Word;
764    objectname: String;
765    Value:      String;

Diff Legend

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