Changeset 217 for oup


Ignore:
Timestamp:
Jun 15, 2007, 5:12:11 PM (17 years ago)
Author:
alloc
Message:
 
Location:
oup/current/Tools
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • oup/current/Tools/BinEdit.pas

    r204 r217  
    33uses
    44  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    5   Dialogs, Template, StdCtrls, ExtCtrls, VirtualTrees, Grids, Wrapgrid,
    6   MPHexEditor, VTHeaderPopup, Menus, StrUtils, Clipbrd,
    7   Data, TypeDefs, ConnectionManager, Buttons;
     5  Dialogs, VirtualTrees, Grids, Wrapgrid, MPHexEditor, StdCtrls,
     6  Menus, VTHeaderPopup, ExtCtrls, Buttons, StrUtils, Clipbrd,
     7  Data, TypeDefs, ConnectionManager, Template,
     8  _BaseTemplate, _TemplateFile, _TemplateFileList;
    89
    910type
     
    760761  nodedata: PNodeData;
    761762  rawinfo: TRawDataInfo;
    762   form: TForm_ToolTemplate;
     763  form: TForm_TemplateFileList;
    763764begin
    764765  if VST.FocusedColumn = 3 then
     
    781782        begin
    782783          form := nil;
    783           form := Form_Main.open_child('rawedit', ConID, fileid);
     784          form := TForm_TemplateFileList(Form_Main.open_child('rawedit', ConID, fileid));
    784785          if Assigned(form) then
    785786            TForm_RawEdit(form).LoadRaw(rawinfo);
     
    800801      if (nodedata.DataType >= 100) and (nodedata.DataType <= 300) then
    801802      begin
    802         form := Form_Main.open_child('binedit', ConID, -1);
     803        form := TForm_TemplateFileList(Form_Main.open_child('binedit', ConID));
    803804        if Assigned(form) then
    804805          form.SetFileFilters(nodedata.Value, '', False);
  • oup/current/Tools/MetaEditor.dfm

    r216 r217  
    1 object Form_Meta: TForm_Meta
    2   Left = 0
    3   Top = 0
     1inherited Form_Meta: TForm_Meta
    42  Caption = 'Form_Meta'
    5   ClientHeight = 393
    6   ClientWidth = 472
    7   Color = clBtnFace
    8   Constraints.MinHeight = 100
    9   Constraints.MinWidth = 200
    10   Font.Charset = DEFAULT_CHARSET
    11   Font.Color = clWindowText
    12   Font.Height = -11
    13   Font.Name = 'Tahoma'
    14   Font.Style = []
    15   FormStyle = fsMDIChild
    16   OldCreateOrder = False
    17   Visible = True
    18   WindowState = wsMaximized
    19   OnClose = FormClose
    203  OnCreate = FormCreate
    214  PixelsPerInch = 96
    225  TextHeight = 13
    23   object Splitter1: TSplitter
    24     Left = 384
    25     Top = 29
    26     Width = 8
    27     Height = 364
    28     Align = alRight
    29     AutoSnap = False
    30     Beveled = True
    31     MinSize = 75
    32     ExplicitLeft = 301
    33     ExplicitHeight = 336
    34   end
    35   object VST: TVirtualStringTree
    36     Left = 0
    37     Top = 29
    38     Width = 384
    39     Height = 364
    40     Align = alClient
    41     AnimationDuration = 0
    42     Header.AutoSizeIndex = 0
    43     Header.Font.Charset = DEFAULT_CHARSET
    44     Header.Font.Color = clWindowText
    45     Header.Font.Height = -11
    46     Header.Font.Name = 'Tahoma'
    47     Header.Font.Style = []
    48     Header.Options = [hoColumnResize, hoDrag, hoVisible]
    49     TabOrder = 0
    50     TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScrollOnExpand, toAutoDeleteMovedNodes]
    51     TreeOptions.MiscOptions = [toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
    52     OnFocusChanged = VSTFocusChanged
    53     OnFocusChanging = VSTFocusChanging
    54     OnGetText = VSTGetText
    55     OnPaintText = VSTPaintText
    56     OnInitChildren = VSTInitChildren
    57     Columns = <
    58       item
    59         Position = 0
    60         Width = 250
    61         WideText = 'FName'
    62       end
    63       item
    64         Position = 1
    65         WideText = 'FType'
    66       end
    67       item
    68         Position = 2
    69         WideText = 'FID'
    70       end
    71       item
    72         Position = 3
    73         WideText = 'Data'
    74       end>
    75   end
    76   object Panel1: TPanel
    77     Left = 0
    78     Top = 0
    79     Width = 472
    80     Height = 29
    81     Align = alTop
    82     BevelOuter = bvNone
    83     TabOrder = 1
    84     ExplicitWidth = 446
    85     DesignSize = (
    86       472
    87       29)
    88     object Label3: TLabel
    89       Left = 3
    90       Top = 6
    91       Width = 61
    92       Height = 13
    93       Caption = 'Connection: '
    94     end
    95     object Button1: TButton
    96       Left = 379
    97       Top = 1
    98       Width = 75
    99       Height = 25
    100       Anchors = [akTop, akRight]
    101       Caption = 'Load'
    102       Default = True
    103       TabOrder = 0
    104       OnClick = Button1Click
    105       ExplicitLeft = 196
    106     end
    107     object combo_connection: TComboBox
    108       Left = 64
    109       Top = 3
    110       Width = 309
    111       Height = 21
    112       Style = csDropDownList
    113       Anchors = [akLeft, akTop, akRight]
    114       DropDownCount = 12
    115       ItemHeight = 13
    116       TabOrder = 1
    117       ExplicitWidth = 126
     6  inherited panel_connection: TPanel
     7    ExplicitWidth = 598
     8    inherited combo_connection: TComboBox
     9      ExplicitWidth = 532
    11810    end
    11911  end
    120   object Panel2: TPanel
    121     Left = 392
    122     Top = 29
    123     Width = 80
    124     Height = 364
    125     Align = alRight
    126     BevelOuter = bvNone
    127     Caption = 'Panel2'
    128     TabOrder = 2
    129     ExplicitLeft = 329
    130     ExplicitHeight = 336
     12  inherited panel_basecontent: TPanel
     13    ExplicitLeft = 0
     14    ExplicitTop = 25
     15    ExplicitWidth = 598
     16    ExplicitHeight = 532
     17    object splitter: TSplitter
     18      Left = 502
     19      Top = 0
     20      Width = 8
     21      Height = 532
     22      Align = alRight
     23      AutoSnap = False
     24      Beveled = True
     25      MinSize = 200
     26      ExplicitLeft = 353
     27    end
     28    object VST: TVirtualStringTree
     29      Left = 0
     30      Top = 0
     31      Width = 502
     32      Height = 532
     33      Align = alClient
     34      AnimationDuration = 0
     35      Header.AutoSizeIndex = 0
     36      Header.Font.Charset = DEFAULT_CHARSET
     37      Header.Font.Color = clWindowText
     38      Header.Font.Height = -11
     39      Header.Font.Name = 'Tahoma'
     40      Header.Font.Style = []
     41      Header.Options = [hoColumnResize, hoDrag, hoVisible]
     42      TabOrder = 0
     43      TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScrollOnExpand, toAutoDeleteMovedNodes]
     44      TreeOptions.MiscOptions = [toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
     45      OnFocusChanged = VSTFocusChanged
     46      OnFocusChanging = VSTFocusChanging
     47      OnGetText = VSTGetText
     48      OnPaintText = VSTPaintText
     49      OnInitChildren = VSTInitChildren
     50      ExplicitLeft = 8
     51      ExplicitTop = 60
     52      ExplicitWidth = 353
     53      ExplicitHeight = 325
     54      Columns = <
     55        item
     56          Position = 0
     57          Width = 250
     58          WideText = 'FName'
     59        end
     60        item
     61          Position = 1
     62          WideText = 'FType'
     63        end
     64        item
     65          Position = 2
     66          WideText = 'FID'
     67        end
     68        item
     69          Position = 3
     70          WideText = 'Data'
     71        end>
     72    end
     73    object Panel2: TPanel
     74      Left = 510
     75      Top = 0
     76      Width = 88
     77      Height = 532
     78      Align = alRight
     79      BevelOuter = bvNone
     80      Caption = 'Panel2'
     81      TabOrder = 1
     82      ExplicitLeft = 376
     83      ExplicitTop = 92
     84      ExplicitHeight = 285
     85    end
    13186  end
    13287end
  • oup/current/Tools/MetaEditor.pas

    r214 r217  
    11unit MetaEditor;
     2
    23interface
     4
    35uses
    46  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    5   Dialogs, VirtualTrees, _MetaManager, StdCtrls, ExtCtrls;
     7  Dialogs, _BaseTemplate, ExtCtrls, VirtualTrees, StdCtrls;
    68
    79type
    8   TForm_Meta = class(TForm)
     10  TForm_Meta = class(TForm_BaseTemplate)
    911    VST: TVirtualStringTree;
    10     Panel1: TPanel;
    11     Button1: TButton;
    12     combo_connection: TComboBox;
    13     Label3: TLabel;
    14     Splitter1: TSplitter;
    1512    Panel2: TPanel;
    16     procedure FormClose(Sender: TObject; var Action: TCloseAction);
     13    splitter: TSplitter;
    1714    procedure FormCreate(Sender: TObject);
    18     procedure VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
    19       Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString);
    20     procedure Button1Click(Sender: TObject);
    2115    procedure VSTInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode;
    2216      var ChildCount: Cardinal);
    23     procedure VSTPaintText(Sender: TBaseVirtualTree;
    24       const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
    25       TextType: TVSTTextType);
     17    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    2618    procedure VSTFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode;
    2719      Column: TColumnIndex);
     
    2921      NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex;
    3022      var Allowed: Boolean);
     23    procedure VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
     24      Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString);
     25    procedure VSTPaintText(Sender: TBaseVirtualTree;
     26      const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
     27      TextType: TVSTTextType);
    3128  private
     29    procedure NewCon(ID: Integer);
    3230  public
    3331  end;
     
    3735
    3836implementation
    39 uses
    40   Data, _DataTypes, _FileTypes, ConnectionManager, TypeDefs, StrUtils;
    4137{$R *.dfm}
     38uses _MetaManager, _FileTypes, Data;
    4239
    4340type
     
    6057
    6158
    62 
    63 procedure TForm_Meta.VSTInitChildren(Sender: TBaseVirtualTree;
    64   Node: PVirtualNode; var ChildCount: Cardinal);
    65 var
    66   data: PNodeData;
    67   newdata: TNodeData;
    68   newnode: PVirtualNode;
    69   i: Integer;
    70   id: Integer;
    71 begin
    72   data := VST.GetNodeData(node);
    73   for i := 0 to Meta.FileById[TFile(data.Field).FileID].ChildCount - 1 do
    74   begin
    75     id := Meta.FileById[TFile(data.Field).FileID].LinkByIndex[i].DestID;
    76     Meta.InitFile(id);
    77     newdata.Field := Meta.FileById[id];
    78     newnode := AddVSTEntry(VST, Node, newdata);
    79     if Meta.FileById[id].ChildCount > 0 then
    80       VST.HasChildren[newnode] := True;
    81   end;
    82   ChildCount := Meta.FileById[TFile(data.Field).FileID].ChildCount;
    83 end;
    84 
    85 
    86 procedure TForm_Meta.Button1Click(Sender: TObject);
    87 var
    88   name: String;
    89   conid: Integer;
    90 
     59procedure TForm_Meta.NewCon(ID: Integer);
     60var
    9161  a,b,c: Int64;
    9262  i: Integer;
     
    9464  node: PVirtualNode;
    9565begin
    96   if combo_connection.ItemIndex >= 0 then
    97   begin
    98     name := combo_connection.Items.Strings[combo_connection.ItemIndex];
    99     conid := StrToInt(MidStr(name, Pos('[', name) + 1, Pos(']', name) - Pos('[', name)  - 1));
    100 
     66  if ID >= 0 then
     67  begin
    10168    QueryPerformanceFrequency(c);
    10269    QueryPerformanceCounter(a);
    10370    if not Assigned(Meta) then
    104       Meta := TMetaManager.Create(conid);
     71      Meta := TMetaManager.Create(ID);
    10572    QueryPerformanceCounter(b);
    10673    ShowMessage('Loading Done - ' + FloatToStr((b-a)/c) + 's');
     
    12289end;
    12390
    124 procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction);
    125 begin
    126   Meta.Free;
    127   Action := caFree;
    128 end;
    129 
    130 
    131 procedure TForm_Meta.FormCreate(Sender: TObject);
    132 var
     91
     92procedure TForm_Meta.VSTInitChildren(Sender: TBaseVirtualTree;
     93  Node: PVirtualNode; var ChildCount: Cardinal);
     94var
     95  data: PNodeData;
     96  newdata: TNodeData;
     97  newnode: PVirtualNode;
    13398  i: Integer;
    134 
    135   fn, datatype, boxstring: String;
    136   level: Integer;
    137 begin
    138   combo_connection.ItemIndex := -1;
    139   combo_connection.Items.Clear;
    140   if ConManager.Count > 0 then
    141   begin
    142     for i := 0 to ConManager.Count - 1 do
    143     begin
    144       level := ConManager.ConnectionByIndex[i].LevelNumber;
    145       fn := ExtractFileName(ConManager.ConnectionByIndex[i].FileName);
    146       if ConManager.ConnectionByIndex[i].Backend = DB_ONI then
    147         datatype := 'ONI-.dat: '
    148       else if ConManager.ConnectionByIndex[i].Backend = DB_ADB then
    149         datatype := 'OUP-DB: '
    150       else
    151         datatype := 'Unknown: ';
    152       boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ') [' + IntToStr(ConManager.ConnectionByIndex[i].ConnectionID) + ']';
    153       combo_connection.Items.Add(boxstring);
    154     end;
    155     if combo_connection.ItemIndex = -1 then
    156     begin
    157       combo_connection.ItemIndex := 0;
    158     end;
    159   end;
    160 
    161 
    162   VST.NodeDataSize := SizeOf(TNodeData);
    163   VST.Font.Charset := AppSettings.CharSet;
    164   VST.Clear;
    165 end;
    166 
     99  id: Integer;
     100begin
     101  data := VST.GetNodeData(node);
     102  for i := 0 to Meta.FileById[TFile(data.Field).FileID].ChildCount - 1 do
     103  begin
     104    id := Meta.FileById[TFile(data.Field).FileID].LinkByIndex[i].DestID;
     105    Meta.InitFile(id);
     106    newdata.Field := Meta.FileById[id];
     107    newnode := AddVSTEntry(VST, Node, newdata);
     108    if Meta.FileById[id].ChildCount > 0 then
     109      VST.HasChildren[newnode] := True;
     110  end;
     111  ChildCount := Meta.FileById[TFile(data.Field).FileID].ChildCount;
     112end;
    167113
    168114
     
    183129  end;
    184130end;
     131
    185132
    186133procedure TForm_Meta.VSTFocusChanging(Sender: TBaseVirtualTree; OldNode,
     
    216163end;
    217164
     165
    218166procedure TForm_Meta.VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
    219167  Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString);
     
    248196  end;
    249197end;
     198
    250199
    251200procedure TForm_Meta.VSTPaintText(Sender: TBaseVirtualTree;
     
    273222end;
    274223
    275 {
    276 
    277 procedure WriteStructureInfos;
    278 var
    279   i, j:    Integer;
    280   pdata:   PNodeData;
    281   Data:    TNodeData;
    282   node:    PVirtualNode;
    283 begin
    284   VST.BeginUpdate;
    285   if VST.RootNodeCount = 0 then
    286   begin
    287     structs := LoadStructureDefinition(ConID, fileid);
    288     if structs.Data then
    289     begin
    290       if Length(structs.Global) > 0 then
    291       begin
    292         for i := 0 to High(structs.Global) do
    293         begin
    294           Data.Caption  := structs.Global[i].Name;
    295           Data.Offset   := structs.Global[i].offset;
    296           Data.DataType := structs.Global[i].datatype;
    297           Data.Value    := GetValue(structs.Global[i].datatype, structs.Global[i].offset);
    298           Data.Description := structs.Global[i].description;
    299           AddVSTEntry(VST, nil, Data);
    300         end;
    301       end;
    302       if Length(structs.Subs) > 0 then
    303       begin
    304         for i := 0 to High(structs.Subs) do
    305         begin
    306           with structs.Subs[i] do
    307           begin
    308             if Length(Entries) > 0 then
    309             begin
    310               if Pos('#', SubName) > 0 then
    311               begin
    312                 Data.Offset  := StrToInt('$'+MidStr(SubName, Pos('#', SubName) + 1, 8));
    313                 Data.Value   := '$' +
    314                   MidStr(SubName, PosEx('#', SubName, Pos('#', SubName) + 1) + 1, 8);
    315                 Data.Caption := MidStr(SubName, 1, Pos('#', SubName) - 1);
    316                 Data.Description := SubDesc;
    317               end
    318               else
    319               begin
    320                 Data.Caption := SubName;
    321                 Data.Description := SubDesc;
    322                 Data.Offset := 0;
    323                 Data.Value := '';
    324               end;
    325               Data.DataType := 0;
    326               node := AddVSTEntry(VST, nil, Data);
    327               Data.Description := '';
    328               for j := 0 to High(Entries) do
    329               begin
    330                 Data.Caption  := Entries[j].Name;
    331                 Data.Offset   := Entries[j].offset;
    332                 Data.DataType := Entries[j].datatype;
    333                 Data.Value    := GetValue(Entries[j].datatype, Entries[j].offset);
    334                 Data.Description := Entries[j].description;
    335                 AddVSTEntry(VST, node, Data);
    336               end;
    337             end;
    338           end;
    339         end;
    340       end;
    341     end;
    342     if VST.RootNodeCount > 0 then
    343       VST.FocusedNode := VST.GetFirst;
    344   end
    345   else
    346   begin
    347     Node := VST.GetFirst;
    348     while Assigned(Node) do
    349     begin
    350       pdata := VST.GetNodeData(Node);
    351       if pdata.DataType > 0 then
    352         pdata.Value := GetValue(pdata.Datatype, pdata.Offset);
    353       Node := VST.GetNext(Node);
    354     end;
    355   end;
    356   VST.EndUpdate;
    357 end;
    358 }
     224
     225
     226procedure TForm_Meta.FormClose(Sender: TObject; var Action: TCloseAction);
     227begin
     228  Meta.Free;
     229  inherited;
     230end;
     231
     232procedure TForm_Meta.FormCreate(Sender: TObject);
     233begin
     234  inherited;
     235  OnNewConnection := NewCon;
     236  FConnectionID := -1;
     237
     238  VST.NodeDataSize := SizeOf(TNodeData);
     239  VST.Font.Charset := AppSettings.CharSet;
     240  VST.Clear;
     241
     242  UpdateConList;
     243end;
     244
    359245end.
  • oup/current/Tools/Template.pas

    r117 r217  
    266266  Form_WhatLinksHere.ConID := FConnectionID;
    267267  Form_WhatLinksHere.FileID := FSelectedFile.ID;
    268   Form_WhatLinksHere.SenderForm := Self;
     268//  Form_WhatLinksHere.SenderForm := Self;
    269269  Form_WhatLinksHere.Show;
    270270end;
Note: See TracChangeset for help on using the changeset viewer.