Changeset 231


Ignore:
Timestamp:
Jun 21, 2007, 12:24:04 AM (17 years ago)
Author:
alloc
Message:
 
Location:
oup/current
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • oup/current/DataAccess/Access_OniArchive.pas

    r229 r231  
    370370  if fileid < GetFileCount then
    371371  begin
    372     if not Assigned(Target) then
    373       Target := TMemoryStream.Create;
    374     if not FDatOpened then
    375       Fdat_file := TFileStream.Create(FFileName, fmOpenReadWrite);
    376     Fdat_file.Seek(Fdat_files[fileid].DatAddr, soFromBeginning);
    377     streampos := Target.Position;
    378     Target.CopyFrom(Fdat_file, Fdat_files[fileid].Size);
    379     Target.Seek(streampos, soFromBeginning);
    380     if UnloadWhenUnused then
    381     begin
    382       Fdat_file.Free;
    383       FDatOpened := False;
    384     end
    385     else
    386       FDatOpened := True;
     372    if GetFileInfo(FileID).Size > 0 then
     373    begin
     374      if not Assigned(Target) then
     375        Target := TMemoryStream.Create;
     376      if not FDatOpened then
     377        Fdat_file := TFileStream.Create(FFileName, fmOpenReadWrite);
     378      Fdat_file.Seek(Fdat_files[fileid].DatAddr, soFromBeginning);
     379      streampos := Target.Position;
     380      Target.CopyFrom(Fdat_file, Fdat_files[fileid].Size);
     381      Target.Seek(streampos, soFromBeginning);
     382      if UnloadWhenUnused then
     383      begin
     384        Fdat_file.Free;
     385        FDatOpened := False;
     386      end
     387      else
     388        FDatOpened := True;
     389    end;
    387390  end;
    388391end;
  • oup/current/FileClasses/_Extensions.pas

    r229 r231  
    22
    33interface
     4
     5uses
     6  _FileTypes;
    47
    58type
  • oup/current/FileClasses/_FileTypes.pas

    r216 r231  
    1111    protected
    1212      FConnectionID: Integer;
    13       FFileID: Integer;
    14       FFileName: String;
    15       FFileExt: String;
    16       FFileSize: Integer;
     13      FFileInfo: TFileInfo;
    1714      FFileStream: TMemoryStream;
    1815
     
    4542
    4643      property FileStream: TMemoryStream read FFileStream;
    47       property FileID: Integer read FFileID;
    48       property FileName: String read FFileName;
    49       property FileExt: String read FFileExt;
    50       property FileSize: Integer read FFileSize;
     44      property FileInfo: TFileInfo read FFileInfo;
    5145      property ConnectionID: Integer read FConnectionID;
    5246
     
    8478
    8579constructor TFile.Create(ConnectionID, FileID: Integer);
    86 var
    87   fileinfo: TFileInfo;
    8880begin
    8981  FConnectionID := ConnectionID;
    90   FFileID := FileID;
    91   fileinfo := ConManager.Connection[ConnectionID].GetFileInfo(FileID);
    92   FFileName := fileinfo.Name;
    93   FFileExt := fileinfo.Extension;
    94   FFileSize := fileinfo.Size;
     82  FFileInfo := ConManager.Connection[ConnectionID].GetFileInfo(FileID);
    9583
    9684  FCached := False;
     
    235223procedure TFile.InitDatLinks;
    236224begin
    237   FDatLinks := ConManager.Connection[FConnectionID].GetDatLinks(FFileID);
     225  FDatLinks := ConManager.Connection[FConnectionID].GetDatLinks(FFileInfo.ID);
    238226end;
    239227
     
    245233procedure TFile.InitRawList;
    246234begin
    247   FRawParts := ConManager.Connection[FConnectionID].GetRawList(FFileID);
     235  FRawParts := ConManager.Connection[FConnectionID].GetRawList(FFileInfo.ID);
    248236end;
    249237
  • oup/current/Tools/BinEdit.dfm

    r225 r231  
    44  OnCreate = FormCreate
    55  OnKeyUp = FormKeyUp
    6   ExplicitWidth = 320
    7   ExplicitHeight = 240
    86  PixelsPerInch = 96
    97  TextHeight = 13
     
    1917            ExplicitHeight = 318
    2018          end
     19        end
     20        inherited tab_meta: TTabSheet
     21          ExplicitLeft = 0
     22          ExplicitTop = 0
     23          ExplicitWidth = 0
     24          ExplicitHeight = 0
    2125        end
    2226      end
     
    133137        OnDblClick = value_viewerDblClick
    134138        OnMouseDown = value_viewerMouseDown
    135         ExplicitHeight = 218
    136139      end
    137140      object VST: TVirtualStringTree
  • oup/current/Tools/BinEdit.pas

    r225 r231  
    3030    procedure NewFile(fileinfo: TFileInfo);
    3131
    32     procedure LoadDat(_fileid: Integer);
    3332    function Save: Boolean;
    3433    function GetValue(datatype: Word; offset: Integer): String;
     
    121120
    122121procedure TForm_BinEdit.NewFile(fileinfo: TFileInfo);
    123 begin
    124   LoadDat(fileinfo.ID);
    125 end;
    126 
    127 
    128 
    129 
    130 function AddVSTEntry(AVST: TCustomVirtualStringTree; ANode: PVirtualNode;
    131   ARecord: TNodeData): PVirtualNode;
    132 var
    133   Data: PNodeData;
    134 begin
    135   Result := AVST.AddChild(ANode);
    136   Data   := AVST.GetNodeData(Result);
    137   AVST.ValidateNode(Result, False);
    138   Data^ := ARecord;
    139 end;
    140 
    141 
    142 
    143 
    144 procedure TForm_BinEdit.LoadDat(_fileid: Integer);
    145122var
    146123  mem:  TMemoryStream;
     
    157134    end;
    158135  end;
    159   if _fileid >= 0 then
    160   begin
    161     fileid := _fileid;
     136  if fileinfo.ID >= 0 then
     137  begin
     138    fileid := fileinfo.ID;
    162139    ConID := ConnectionID;
    163     if ConManager.Connection[ConID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]) <> fileid then
    164       Self.SelectFileID(ConnectionID, fileid);
     140//    if ConManager.Connection[ConID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]) <> fileid then
     141//      Self.SelectFileID(ConnectionID, fileid);
    165142    Self.ClearStructViewer;
    166143    mem := nil;
     
    174151  else
    175152  begin
    176     fileid := _fileid;
     153    fileid := -1;
    177154    ConID := -1;
    178155    Self.ClearStructViewer;
     
    182159  end;
    183160end;
     161
     162
     163
     164
     165function AddVSTEntry(AVST: TCustomVirtualStringTree; ANode: PVirtualNode;
     166  ARecord: TNodeData): PVirtualNode;
     167var
     168  Data: PNodeData;
     169begin
     170  Result := AVST.AddChild(ANode);
     171  Data   := AVST.GetNodeData(Result);
     172  AVST.ValidateNode(Result, False);
     173  Data^ := ARecord;
     174end;
     175
     176
    184177
    185178
  • oup/current/Tools/FileManager.dfm

    r228 r231  
    33  PixelsPerInch = 96
    44  TextHeight = 13
     5  inherited panel_basecontent: TPanel
     6    inherited panel_files: TPanel
     7      inherited FilePages: TPageControl
     8        inherited tab_files: TTabSheet
     9          Caption = 'File list'
     10        end
     11      end
     12    end
     13  end
    514end
  • oup/current/Tools/MetaEditor.pas

    r229 r231  
    3434implementation
    3535{$R *.dfm}
    36 uses _MetaManager, _FileTypes, Data;
     36uses _MetaManager, _MetaTypes, ConnectionManager, Data;
    3737
    3838type
     
    5757procedure TForm_Meta.NewCon(ID: Integer);
    5858var
    59   a,b,c: Int64;
    6059  i: Integer;
    6160  data: TNodeData;
    6261  node: PVirtualNode;
    63 begin
    64 {
     62  Meta: TMetaManager;
     63begin
    6564  if ID >= 0 then
    6665  begin
    67     QueryPerformanceFrequency(c);
    68     QueryPerformanceCounter(a);
    69     if not Assigned(Meta) then
    70       Meta := TMetaManager.Create(ID, Self);
    71     QueryPerformanceCounter(b);
    72     ShowMessage('Loading Done - ' + FloatToStr((b-a)/c) + 's');
    73 
    7466    VST.Clear;
    7567    VST.BeginUpdate;
     68    Meta := ConManager.Connection[ID].MetaData;
    7669    for i := 0 to Meta.FileCount - 1 do
    7770    begin
     
    8679    VST.EndUpdate;
    8780  end;
    88 }
    8981end;
    9082
     
    9890  i: Integer;
    9991  id: Integer;
    100 begin
    101 {
    102   data := VST.GetNodeData(node);
    103   for i := 0 to Meta.FileById[TFile(data.Field).FileID].ChildCount - 1 do
    104   begin
    105     id := Meta.FileById[TFile(data.Field).FileID].LinkByIndex[i].DestID;
     92  Meta: TMetaManager;
     93begin
     94  data := Sender.GetNodeData(node);
     95  Meta := ConManager.Connection[ID].MetaData;
     96  for i := 0 to TFile(data.Field).ChildCount - 1 do
     97  begin
     98    id := TFile(data.Field).LinkByIndex[i].DestID;
    10699    Meta.InitFile(id);
    107100    newdata.Field := Meta.FileById[id];
    108     newnode := AddVSTEntry(VST, Node, newdata);
     101    newnode := AddVSTEntry(TCustomVirtualStringTree(Sender), Node, newdata);
    109102    if Meta.FileById[id].ChildCount > 0 then
    110       VST.HasChildren[newnode] := True;
    111   end;
    112   ChildCount := Meta.FileById[TFile(data.Field).FileID].ChildCount;
    113 }
     103      Sender.HasChildren[newnode] := True;
     104  end;
     105  ChildCount := Sender.ChildCount[Node];
    114106end;
    115107
     
    180172          if Data.Field is TFile then
    181173          begin
    182             CellText := TFile(Data.Field).FileName;
     174            CellText := TFile(Data.Field).FileInfo.Name;
    183175            if CellText = '' then
    184176              CellText := 'Unnamed';
     
    188180        begin
    189181          if Data.Field is TFile then
    190             CellText := TFile(Data.Field).FileExt;
     182            CellText := TFile(Data.Field).FileInfo.Extension;
    191183        end;
    192184      2:
    193185        begin
    194186          if Data.Field is TFile then
    195             CellText := IntToStr(TFile(Data.Field).FileID);
     187            CellText := IntToStr(TFile(Data.Field).FileInfo.ID);
    196188        end;
    197189    end;
     
    214206          if Data.Field is TFile then
    215207          begin
    216             if Length(TFile(Data.Field).FileName) = 0 then
     208            if Length(TFile(Data.Field).FileInfo.Name) = 0 then
    217209              TargetCanvas.Font.Color := $C06060;
    218             if TFile(Data.Field).FileSize = 0 then
     210            if TFile(Data.Field).FileInfo.Size = 0 then
    219211              TargetCanvas.Font.Color := $2020A0;
    220212          end;
  • oup/current/Tools/_TemplateFileList.dfm

    r229 r231  
    3737        TabOrder = 0
    3838        object tab_files: TTabSheet
    39           Caption = 'Files'
     39          Caption = 'Filelist'
    4040          object panel_extension: TPanel
    4141            Left = 0
     
    267267        end
    268268        object tab_meta: TTabSheet
    269           Caption = 'Meta'
     269          Caption = 'Tree'
    270270          ImageIndex = 1
    271271          object filelist_meta: TVirtualStringTree
     
    284284            Header.Options = [hoColumnResize, hoDrag]
    285285            TabOrder = 0
     286            OnFocusChanged = filelist_metaFocusChanged
     287            OnFocusChanging = filelist_metaFocusChanging
    286288            OnGetText = filelist_metaGetText
    287289            OnPaintText = filelist_metaPaintText
  • oup/current/Tools/_TemplateFileList.pas

    r230 r231  
    99
    1010type
     11  TNewFileSelectingEvent = procedure(FileInfo: TFileInfo; var allowed: Boolean) of object;
     12
    1113  TForm_TemplateFileList = class(TForm_TemplateFile)
    1214    panel_files: TPanel;
     
    6264      const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
    6365      TextType: TVSTTextType);
     66    procedure filelist_metaFocusChanging(Sender: TBaseVirtualTree; OldNode,
     67      NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex;
     68      var Allowed: Boolean);
     69    procedure filelist_metaFocusChanged(Sender: TBaseVirtualTree;
     70      Node: PVirtualNode; Column: TColumnIndex);
    6471  private
    6572    FSortBy: TSortType;
    6673    FAllowedExts: String;
    6774    FAllowMultiSelect: Boolean;
     75    FOnNewFileSelecting: TNewFileSelectingEvent;
    6876    procedure SetAllowedExts(exts: String);
    6977    procedure SetMultiSelect(allow: Boolean);
     
    7583    property AllowedExts: String read FAllowedExts write SetAllowedExts;
    7684    property AllowMultiSelect: Boolean read FAllowMultiSelect write SetMultiSelect;
     85    property OnNewFileSelecting: TNewFileSelectingEvent read FOnNewFileSelecting write FOnNewFileSelecting;
    7786  end;
    7887
     
    404413
    405414
     415procedure TForm_TemplateFileList.filelist_metaFocusChanged(
     416  Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
     417var
     418  data: PNodeData;
     419begin
     420  inherited;
     421  data := Sender.GetNodeData(Node);
     422  if data.Field is TFile then
     423  begin
     424    if Assigned(FOnNewFileSelected) then
     425    begin
     426      FOnNewFileSelected(TFile(data.Field).FileInfo);
     427    end;
     428  end;
     429end;
     430
     431procedure TForm_TemplateFileList.filelist_metaFocusChanging(
     432  Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode; OldColumn,
     433  NewColumn: TColumnIndex; var Allowed: Boolean);
     434var
     435  data: PNodeData;
     436begin
     437  inherited;
     438  data := Sender.GetNodeData(NewNode);
     439  if data.Field is TFile then
     440  begin
     441    if Assigned(FOnNewFileSelecting) then
     442    begin
     443      FOnNewFileSelecting(TFile(data.Field).FileInfo, Allowed);
     444    end;
     445  end;
     446end;
     447
    406448procedure TForm_TemplateFileList.filelist_metaGetText(Sender: TBaseVirtualTree;
    407449  Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
     
    418460  if data.Field is TFile then
    419461  begin
    420     if TFile(data.Field).FileName = '' then
    421       CellText := TFile(data.Field).FileExt + ' (unnamed)'
     462    if TFile(data.Field).FileInfo.Name = '' then
     463      CellText := TFile(data.Field).FileInfo.Extension + ' (unnamed)'
    422464    else
    423       CellText := TFile(data.Field).FileExt + ': ' + TFile(data.Field).FileName;
     465      CellText := TFile(data.Field).FileInfo.Extension + ': ' + TFile(data.Field).FileInfo.Name;
    424466  end;
    425467end;
     
    479521  if Data.Field is TFile then
    480522  begin
    481     if Length(TFile(Data.Field).FileName) = 0 then
     523    if Length(TFile(Data.Field).FileInfo.Name) = 0 then
    482524      TargetCanvas.Font.Color := $C06060;
    483     if TFile(Data.Field).FileSize = 0 then
     525    if TFile(Data.Field).FileInfo.Size = 0 then
    484526      TargetCanvas.Font.Color := $2020A0;
    485527  end;
Note: See TracChangeset for help on using the changeset viewer.