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 111 by alloc, Wed Feb 21 03:28:48 2007 UTC vs.
Revision 175 by alloc, Wed May 2 15:16:58 2007 UTC

# 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 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  
# Line 310 | Line 310 | begin
310        str := '';
311        if hex.SelCount = 0 then
312        begin
313 <        while (hex.Data[hex.SelStart + j] > 0) and ((hex.SelStart + j) < hex.DataSize) do
313 >        while (hex.SelStart + j) < hex.DataSize do
314          begin
315 +          if hex.Data[hex.SelStart + j] = 0 then
316 +            Break;
317            if hex.Data[hex.selstart + j] >= 32 then
318              str := str + Char(hex.Data[hex.SelStart + j])
319            else
# Line 390 | Line 392 | var
392    i:    Integer;
393   begin
394    case MessageBox(Self.Handle, PChar('Save changes to .raw-part of file ' +
395 <      ConManager.Connection[ConID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'),
395 >      ConManager.Connection[ConnectionID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'),
396        MB_YESNOCANCEL) of
397      idYes:
398      begin
399        mem := TMemoryStream.Create;
400        hex.SaveToStream(mem);
401        mem.Seek(0, soFromBeginning);
402 <      ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, mem);
402 >      ConManager.Connection[ConnectionID].UpdateRawFile(fileid, datoffset, mem);
403        mem.Free;
404        hex.Modified := False;
405        for i := 0 to hex.Datasize - 1 do
# Line 505 | Line 507 | var
507    fs: TFileStream;
508   begin
509    saved.Filter     := 'Files of matching extension (*.' +
510 <    ConManager.Connection[ConID].GetFileInfo(fileid).Extension + ')|*.' +
511 <    ConManager.Connection[ConID].GetFileInfo(fileid).Extension +
510 >    ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension + ')|*.' +
511 >    ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension +
512      '|All files|*.*';
513 <  saved.DefaultExt := ConManager.Connection[ConID].GetFileInfo(fileid).Extension;
513 >  saved.DefaultExt := ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension;
514    if saved.Execute then
515    begin
516      fs := TFileStream.Create(saved.FileName, fmCreate);
# Line 524 | Line 526 | procedure TForm_RawEdit.btn_importClick(
526   var
527   //  Data: Tdata;
528    fs:   TFileStream;
527  data: TByteData;
529    i: Integer;
530    rawinfo: TRawDataInfo;
531   begin
532    opend.Filter := 'Files of matching extension (*.' +
533 <    ConManager.Connection[ConID].GetFileInfo(fileid).Extension + ')|*.' +
534 <    ConManager.Connection[ConID].GetFileInfo(fileid).Extension +
533 >    ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension + ')|*.' +
534 >    ConManager.Connection[ConnectionID].GetFileInfo(fileid).Extension +
535      '|All files|*.*';
536    if opend.Execute then
537    begin
538      fs := TFileStream.Create(opend.FileName, fmOpenRead);
539      if fs.Size <> hex.DataSize then
540      begin
541 <      if (not (CR_ResizeRaw in ConManager.Connection[ConID].ChangeRights)) and (not (CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights)) then
541 >      if (not (CR_ResizeRaw in ConManager.Connection[ConnectionID].ChangeRights)) and (not (CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights)) then
542        begin
543          ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) +
544              ', file has to have same size as file in .raw with this backend.' + CrLf +
# Line 557 | Line 558 | begin
558            Exit;
559          end;
560        end;
561 <      rawinfo := ConManager.Connection[ConID].GetRawInfo(fileid, datoffset);
562 <      if CR_ResizeRaw in ConManager.Connection[ConID].ChangeRights then
563 <        ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, fs)
564 <      else if CR_AppendRaw in ConManager.Connection[ConID].ChangeRights then
565 <        i := ConManager.Connection[ConID].AppendRawFile(rawinfo.LocSep, fs);
566 <        ConManager.Connection[ConID].UpdateDatFilePart(fileid, datoffset, 4, @i);
561 >      rawinfo := ConManager.Connection[ConnectionID].GetRawInfo(fileid, datoffset);
562 >      if CR_ResizeRaw in ConManager.Connection[ConnectionID].ChangeRights then
563 >        ConManager.Connection[ConnectionID].UpdateRawFile(fileid, datoffset, fs)
564 >      else if CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights then
565 >        i := ConManager.Connection[ConnectionID].AppendRawFile(rawinfo.LocSep, fs);
566 >        ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, datoffset, 4, @i);
567      end else begin
568 <      ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, fs);
568 >      ConManager.Connection[ConnectionID].UpdateRawFile(fileid, datoffset, fs);
569      end;
570      fs.Seek(0, soFromBeginning);
571      hex.LoadFromStream(fs);

Diff Legend

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