Changeset 87 for oup/current


Ignore:
Timestamp:
Jan 14, 2007, 11:59:34 PM (18 years ago)
Author:
alloc
Message:
 
Location:
oup/current
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • oup/current/Code/DataStructures.pas

    r46 r87  
    33interface
    44
    5 uses SysUtils, Classes, Data, Dialogs, StrUtils;
     5uses SysUtils, Classes, Data, Dialogs, StrUtils, OniDataClass;
    66
    77type
     
    3434    Subs:   array of TStructDefSub;
    3535  end;
    36   THandler = function(fileid: LongWord): TRawList;
     36  THandler = function(connection: TOniData; fileid: LongWord): TRawList;
    3737
    3838  TRawListHandlers = record
     
    4747
    4848
    49 function LoadStructureDefinition(fileid: LongWord): TStructDef;
     49function LoadStructureDefinition(connection: TOniData; fileid: LongWord): TStructDef;
    5050function GetDataType(typeid: Word): String;
    5151function GetTypeDataLength(datatype: Word): Word;
     
    5353implementation
    5454
    55 uses Functions, OniDataClass, Forms, Template;
     55uses Functions, Forms, Template;
    5656
    5757
     
    120120
    121121
    122 function AGDB(fileid: LongWord): TRawList;
     122function AGDB(connection: TOniData; fileid: LongWord): TRawList;
    123123var
    124124  link:  LongWord;
     
    126126  i:     LongWord;
    127127begin
    128   if not OniDataConnection.OSisMac then
    129   begin
    130     OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @links);
     128  if not connection.OSisMac then
     129  begin
     130    connection.LoadDatFilePart(fileid, $1C, 4, @links);
    131131    links := links * 2;
    132132    SetLength(Result, links);
     
    134134    begin
    135135      Result[i].src_offset := $20 + i * 4;
    136       OniDataConnection.LoadDatFilePart(fileid, $20 + i * 4, 4, @link);
     136      connection.LoadDatFilePart(fileid, $20 + i * 4, 4, @link);
    137137      Result[i].raw_addr := link;
    138138      Result[i].raw_size := 0{????????????????????????????????};
     
    145145
    146146
    147 function AKVA(fileid: LongWord): TRawList;
     147function AKVA(connection: TOniData; fileid: LongWord): TRawList;
    148148var
    149149  link:  LongWord;
     
    151151  i:     LongWord;
    152152begin
    153   if not OniDataConnection.OSisMac then
    154   begin
    155     OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @links);
     153  if not connection.OSisMac then
     154  begin
     155    connection.LoadDatFilePart(fileid, $1C, 4, @links);
    156156    SetLength(Result, links);
    157157    for i := 0 to links - 1 do
    158158    begin
    159159      Result[i].src_offset := $20 + i * $74 + $24;
    160       OniDataConnection.LoadDatFilePart(fileid, $20 + i * $74 + $24, 4, @link);
     160      connection.LoadDatFilePart(fileid, $20 + i * $74 + $24, 4, @link);
    161161      Result[i].raw_addr := link;
    162       OniDataConnection.LoadDatFilePart(fileid, $20 + i * $74 + $28, 4, @link);
     162      connection.LoadDatFilePart(fileid, $20 + i * $74 + $28, 4, @link);
    163163      Result[i].raw_size := link;
    164164      Result[i].loc_sep  := False;
     
    170170
    171171
    172 function BINA(fileid: LongWord): TRawList;
     172function BINA(connection: TOniData; fileid: LongWord): TRawList;
    173173var
    174174  link:     LongWord;
    175175  datasize: LongWord;
    176176begin
    177   OniDataConnection.LoadDatFilePart(fileid, $0C, 4, @link);
    178   OniDataConnection.LoadDatFilePart(fileid, $08, 4, @datasize);
     177  connection.LoadDatFilePart(fileid, $0C, 4, @link);
     178  connection.LoadDatFilePart(fileid, $08, 4, @datasize);
     179  SetLength(Result, 1);
     180  Result[0].src_offset := $0C;
     181  Result[0].raw_addr   := link;
     182  Result[0].raw_size   := datasize;
     183  Result[0].loc_sep    := connection.OSisMac;
     184end;
     185
     186
     187
     188
     189function OSBD(connection: TOniData; fileid: LongWord): TRawList;
     190var
     191  link:     LongWord;
     192  datasize: LongWord;
     193begin
     194  connection.LoadDatFilePart(fileid, $08, 4, @datasize);
     195  connection.LoadDatFilePart(fileid, $0C, 4, @link);
    179196  SetLength(Result, 1);
    180197  Result[0].src_offset := $0C;
     
    187204
    188205
    189 function OSBD(fileid: LongWord): TRawList;
     206function SNDD(connection: TOniData; fileid: LongWord): TRawList;
    190207var
    191208  link:     LongWord;
    192209  datasize: LongWord;
    193210begin
    194   OniDataConnection.LoadDatFilePart(fileid, $08, 4, @datasize);
    195   OniDataConnection.LoadDatFilePart(fileid, $0C, 4, @link);
    196211  SetLength(Result, 1);
    197   Result[0].src_offset := $0C;
    198   Result[0].raw_addr   := link;
    199   Result[0].raw_size   := datasize;
    200   Result[0].loc_sep    := OniDataConnection.OSisMac;
    201 end;
    202 
    203 
    204 
    205 
    206 function SNDD(fileid: LongWord): TRawList;
    207 var
    208   link:     LongWord;
    209   datasize: LongWord;
    210 begin
    211   SetLength(Result, 1);
    212   if not OniDataConnection.OSisMac then
    213   begin
    214     OniDataConnection.LoadDatFilePart(fileid, $40, 4, @datasize);
    215     OniDataConnection.LoadDatFilePart(fileid, $44, 4, @link);
     212  if not connection.OSisMac then
     213  begin
     214    connection.LoadDatFilePart(fileid, $40, 4, @datasize);
     215    connection.LoadDatFilePart(fileid, $44, 4, @link);
    216216    Result[0].src_offset := $44;
    217217  end
    218218  else
    219219  begin
    220     OniDataConnection.LoadDatFilePart(fileid, $10, 4, @datasize);
    221     OniDataConnection.LoadDatFilePart(fileid, $14, 4, @link);
     220    connection.LoadDatFilePart(fileid, $10, 4, @datasize);
     221    connection.LoadDatFilePart(fileid, $14, 4, @link);
    222222    Result[0].src_offset := $14;
    223223  end;
     
    230230
    231231
    232 function SUBT(fileid: LongWord): TRawList;
     232function SUBT(connection: TOniData; fileid: LongWord): TRawList;
    233233var
    234234  baselink, lastlink: LongWord;
     
    237237  Data:  Tdata;
    238238begin
    239   OniDataConnection.LoadDatFilePart(fileid, $18, 4, @baselink);
    240   OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @links);
     239  connection.LoadDatFilePart(fileid, $18, 4, @baselink);
     240  connection.LoadDatFilePart(fileid, $1C, 4, @links);
    241241  if links > 0 then
    242242  begin
    243     OniDataConnection.LoadDatFilePart(fileid, $20 + (links - 1) * 4, 4, @lastlink);
     243    connection.LoadDatFilePart(fileid, $20 + (links - 1) * 4, 4, @lastlink);
    244244    SetLength(Data, lastlink + 1024);
    245     TOniDataDat(OniDataConnection).LoadRawOffset(False,
     245    TOniDataDat(connection).LoadRawOffset(False,
    246246      baselink, lastlink + 1024, Data);
    247247    //      OniDataConnection.LoadRawFile(fileid,$1C,baselink,lastlink+1024,False,@data[0]);
     
    274274
    275275
    276 function TRAM(fileid: LongWord): TRawList;
     276function TRAM(connection: TOniData; fileid: LongWord): TRawList;
    277277var
    278278  i:      Integer;
     
    287287begin
    288288  SetLength(Result, 13);
    289   OniDataConnection.LoadDatFilePart(fileid, $16C, 2, @frames);
     289  connection.LoadDatFilePart(fileid, $16C, 2, @frames);
    290290  {y-pos}
    291   OniDataConnection.LoadDatFilePart(fileid, $0C, 4, @link);
     291  connection.LoadDatFilePart(fileid, $0C, 4, @link);
    292292  Result[0].src_offset := $0C;
    293293  Result[0].raw_addr   := link;
    294294  Result[0].raw_size   := frames * 4;
    295295  {x-z-pos}
    296   OniDataConnection.LoadDatFilePart(fileid, $10, 4, @link);
     296  connection.LoadDatFilePart(fileid, $10, 4, @link);
    297297  Result[1].src_offset := $10;
    298298  Result[1].raw_addr   := link;
    299299  Result[1].raw_size   := frames * 8;
    300300  {attacks}
    301   OniDataConnection.LoadDatFilePart(fileid, $182, 1, @tempb);
    302   OniDataConnection.LoadDatFilePart(fileid, $14, 4, @link);
     301  connection.LoadDatFilePart(fileid, $182, 1, @tempb);
     302  connection.LoadDatFilePart(fileid, $14, 4, @link);
    303303  Result[2].src_offset := $14;
    304304  Result[2].raw_addr   := link;
    305305  Result[2].raw_size   := tempb * 32;
    306306  {damage}
    307   OniDataConnection.LoadDatFilePart(fileid, $183, 1, @tempb);
    308   OniDataConnection.LoadDatFilePart(fileid, $18, 4, @link);
     307  connection.LoadDatFilePart(fileid, $183, 1, @tempb);
     308  connection.LoadDatFilePart(fileid, $18, 4, @link);
    309309  Result[3].src_offset := $18;
    310310  Result[3].raw_addr   := link;
    311311  Result[3].raw_size   := tempb * 8;
    312312  {motionblur}
    313   OniDataConnection.LoadDatFilePart(fileid, $184, 1, @tempb);
    314   OniDataConnection.LoadDatFilePart(fileid, $1C, 4, @link);
     313  connection.LoadDatFilePart(fileid, $184, 1, @tempb);
     314  connection.LoadDatFilePart(fileid, $1C, 4, @link);
    315315  Result[4].src_offset := $1C;
    316316  Result[4].raw_addr   := link;
    317317  Result[4].raw_size   := tempb * 8;
    318318  {shortcut}
    319   OniDataConnection.LoadDatFilePart(fileid, $185, 1, @tempb);
    320   OniDataConnection.LoadDatFilePart(fileid, $20, 4, @link);
     319  connection.LoadDatFilePart(fileid, $185, 1, @tempb);
     320  connection.LoadDatFilePart(fileid, $20, 4, @link);
    321321  Result[5].src_offset := $20;
    322322  Result[5].raw_addr   := link;
    323323  Result[5].raw_size   := tempb * 8;
    324324  {throw}
    325   OniDataConnection.LoadDatFilePart(fileid, $24, 4, @link);
     325  connection.LoadDatFilePart(fileid, $24, 4, @link);
    326326  Result[6].src_offset := $24;
    327327  Result[6].raw_addr   := link;
     
    331331    Result[6].raw_size := 0;
    332332  {footstep}
    333   OniDataConnection.LoadDatFilePart(fileid, $186, 1, @tempb);
    334   OniDataConnection.LoadDatFilePart(fileid, $28, 4, @link);
     333  connection.LoadDatFilePart(fileid, $186, 1, @tempb);
     334  connection.LoadDatFilePart(fileid, $28, 4, @link);
    335335  Result[7].src_offset := $28;
    336336  Result[7].raw_addr   := link;
    337337  Result[7].raw_size   := tempb * 4;
    338338  {particle}
    339   OniDataConnection.LoadDatFilePart(fileid, $187, 1, @tempb);
    340   OniDataConnection.LoadDatFilePart(fileid, $2C, 4, @link);
     339  connection.LoadDatFilePart(fileid, $187, 1, @tempb);
     340  connection.LoadDatFilePart(fileid, $2C, 4, @link);
    341341  Result[8].src_offset := $2C;
    342342  Result[8].raw_addr   := link;
    343343  Result[8].raw_size   := tempb * 24;
    344344  {position}
    345   OniDataConnection.LoadDatFilePart(fileid, $30, 4, @link);
     345  connection.LoadDatFilePart(fileid, $30, 4, @link);
    346346  Result[9].src_offset := $30;
    347347  Result[9].raw_addr   := link;
    348348  Result[9].raw_size   := frames * 8;
    349349  {particle}
    350   OniDataConnection.LoadDatFilePart(fileid, $154, 2, @tempw);
    351   OniDataConnection.LoadDatFilePart(fileid, $38, 4, @link);
     350  connection.LoadDatFilePart(fileid, $154, 2, @tempw);
     351  connection.LoadDatFilePart(fileid, $38, 4, @link);
    352352  Result[11].src_offset := $38;
    353353  Result[11].raw_addr   := link;
    354354  Result[11].raw_size   := tempw * 34;
    355355  {extent}
    356   OniDataConnection.LoadDatFilePart(fileid, $138, 4, @templ);
    357   OniDataConnection.LoadDatFilePart(fileid, $13C, 4, @link);
     356  connection.LoadDatFilePart(fileid, $138, 4, @templ);
     357  connection.LoadDatFilePart(fileid, $13C, 4, @link);
    358358  Result[12].src_offset := $13C;
    359359  Result[12].raw_addr   := link;
    360360  Result[12].raw_size   := templ * 12;
    361361
    362   OniDataConnection.LoadDatFilePart(fileid, $34, 4, @link);
     362  connection.LoadDatFilePart(fileid, $34, 4, @link);
    363363  if link > 0 then
    364364  begin
    365     OniDataConnection.LoadDatFilePart(fileid, $160, 2, @tempw);
     365    connection.LoadDatFilePart(fileid, $160, 2, @tempw);
    366366    frame_count := 0;
    367367    i := 0;
    368368    SetLength(Data, $FFFF);
    369     TOniDataDat(OniDataConnection).LoadRawOffset(False, link, $FFFF, Data);
     369    TOniDataDat(connection).LoadRawOffset(False, link, $FFFF, Data);
    370370    offset := Data[$24] + Data[$25] * 256;
    371371    while (offset + i < Length(Data)) and (frame_count < frames - 1) do
     
    392392
    393393
    394 function TXMP(fileid: LongWord): TRawList;
     394function TXMP(connection: TOniData; fileid: LongWord): TRawList;
    395395var
    396396  link_pc:   LongWord;
     
    400400  datasize:  LongWord;
    401401begin
    402   OniDataConnection.LoadDatFilePart(fileid, $8C, SizeOf(x), @x);
    403   OniDataConnection.LoadDatFilePart(fileid, $8E, SizeOf(y), @y);
    404   OniDataConnection.LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype);
    405   OniDataConnection.LoadDatFilePart(fileid, $9C, 4, @link_pc);
    406   OniDataConnection.LoadDatFilePart(fileid, $A0, 4, @link_mac);
     402  connection.LoadDatFilePart(fileid, $8C, SizeOf(x), @x);
     403  connection.LoadDatFilePart(fileid, $8E, SizeOf(y), @y);
     404  connection.LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype);
     405  connection.LoadDatFilePart(fileid, $9C, 4, @link_pc);
     406  connection.LoadDatFilePart(fileid, $A0, 4, @link_mac);
    407407  case storetype of
    408408    0, 1, 2:
     
    414414  end;
    415415  SetLength(Result, 1);
    416   if not OniDataConnection.OSisMac then
     416  if not connection.OSisMac then
    417417  begin
    418418    Result[0].src_offset := $9C;
     
    425425  end;
    426426  Result[0].raw_size := datasize;
    427   Result[0].loc_sep  := OniDataConnection.OSisMac;
     427  Result[0].loc_sep  := connection.OSisMac;
    428428end;
    429429
     
    444444
    445445
    446 function LoadStructureDefinition(fileid: LongWord): TStructDef;
     446function LoadStructureDefinition(connection: TOniData; fileid: LongWord): TStructDef;
    447447var
    448448  i:      LongWord;
     
    461461  SetLength(Result.Subs, 0);
    462462  Result.Data := False;
    463   ext      := OniDataConnection.GetFileInfo(fileid).Extension;
     463  ext      := connection.GetFileInfo(fileid).Extension;
    464464  filename := ExtractFilePath(Application.ExeName) + '\StructDefs\' + ext + '.txt';
    465465  if FileExists(filename) then
    466466  begin
    467     Data := OniDataConnection.LoadDatFile(fileid);
     467    Data := connection.LoadDatFile(fileid);
    468468    AssignFile(deffile, filename);
    469469    Reset(deffile);
  • oup/current/Code/OniDataClass.pas

    r86 r87  
    11unit OniDataClass;
    22interface
    3 uses Data, DataStructures, Classes, SysUtils, StrUtils,
     3uses Data, Classes, SysUtils, StrUtils,
    44  Dialogs, ABSDecUtil, ABSMain, DB, Windows;
    55
     
    2121    procedure Close; virtual; abstract;
    2222
    23     function GetFileInfo(fileid: LongWord): TFileInfo; virtual; abstract;
     23    function GetFileInfo(fileid: Integer): TFileInfo; virtual;
    2424    function GetFilesList(ext: String; pattern: String;
    2525      NoEmptyFiles: Boolean; sort: TSortType): TStringArray; virtual; abstract;
     
    7373    procedure Close; override;
    7474
    75     function GetFileInfo(fileid: LongWord): TFileInfo; override;
     75    function GetFileInfo(fileid: Integer): TFileInfo; override;
    7676    function GetFilesList(ext: String; pattern: String;
    7777      NoEmptyFiles: Boolean; sort: TSortType): TStringArray; override;
     
    112112    procedure UpdateListCache;
    113113    //      function GetDatLinks(srcid:LongWord):TDatLinks;
    114     function GetFileInfo(fileid: LongWord): TFileInfo; override;
     114    function GetFileInfo(fileid: Integer): TFileInfo; override;
    115115    function GetFilesList(ext: String; pattern: String;
    116116      NoEmptyFiles: Boolean; sort: TSortType): TStringArray; override;
     
    142142    constructor Create(OLDBFilename: String; var Result: Boolean); override;
    143143    procedure Close; override;
    144 {
    145     procedure UpdateListCache;
    146     //      function GetDatLinks(srcid:LongWord):TDatLinks;
    147     function GetFileInfo(fileid: LongWord): TFileInfo; override;
    148     function GetFilesList(ext: String; pattern: String;
    149       NoEmptyFiles: Boolean; sort: TSortType): TStringArray; override;
    150     function GetFilesCount: LongWord; override;
    151     function GetExtensionsList: TStringArray; override;
    152     function GetExtendedExtensionsList: TExtensionsMap; override;
    153     function GetNamedFilesMap: TNamedFilesMap;
    154 
    155     function LoadDatFile(fileid: LongWord): Tdata; override;
    156     procedure UpdateDatFile(fileid: LongWord; Data: Tdata); override;
    157     procedure LoadDatFilePart(fileid, offset, size: LongWord; target: Pointer); override;
    158     procedure UpdateDatFilePart(fileid, offset, size: LongWord; target: Pointer); override;
    159 
    160     function GetRawList(fileid: LongWord): TRawList; override;
    161     procedure LoadRawFile(fileid, dat_offset: LongWord; target: Pointer); override;
    162     procedure UpdateRawFile(fileid, dat_offset: LongWord; size: LongWord;
    163       target: Pointer); override;
    164     procedure LoadRawFilePart(fileid, dat_offset: LongWord;
    165       offset, size: LongWord; target: Pointer); override;
    166     procedure UpdateRawFilePart(fileid, dat_offset: LongWord;
    167       offset, size: LongWord; target: Pointer); override;
    168 }  published
     144  published
    169145  end;
    170146
     
    181157function CreateDataConnection(filename: String; backend: Integer): TOniData;
    182158procedure CloseDataConnection(connection: TOniData);
     159function GetEmptyFileInfo: TFileInfo;
    183160
    184161
     
    187164
    188165implementation
    189 uses Functions;
     166uses DataStructures, Functions;
    190167
    191168
     
    252229
    253230
     231function TOniData.GetFileInfo(fileid: Integer): TFileInfo;
     232begin
     233  Result.ID := -1;
     234  Result.FileName := '';
     235  Result.FileNameHex := '';
     236  Result.Extension := '';
     237  Result.Name := '';
     238  Result.Size := 0;
     239  Result.FileType := 0;
     240  Result.DatAddr := 0;
     241  Result.opened := False;
     242end;
    254243
    255244
     
    378367
    379368
    380 function TOniDataDat.GetFileInfo(fileid: LongWord): TFileInfo;
    381 begin
     369function TOniDataDat.GetFileInfo(fileid: Integer): TFileInfo;
     370begin
     371  if fileid = -1 then
     372  begin
     373    Result := inherited GetFileInfo(fileid);
     374    Exit;
     375  end;
    382376  if fileid < Self.GetFilesCount then
    383377    Result    := Fdat_files[fileid]
     
    592586      if RawListHandlers[i].needed then
    593587      begin
    594         Result := RawListHandlers[i].Handler(fileid);
     588        Result := RawListHandlers[i].Handler(Self, fileid);
    595589        Break;
    596590      end
     
    961955
    962956
    963 function TOniDataADB.GetFileInfo(fileid: LongWord): TFileInfo;
     957function TOniDataADB.GetFileInfo(fileid: Integer): TFileInfo;
    964958var
    965959  i: Integer;
    966960begin
     961  if fileid = -1 then
     962  begin
     963    Result := inherited GetFileInfo(fileid);
     964    Exit;
     965  end;
    967966  if fileid < Self.GetFilesCount then
    968967  begin
     
    14841483        begin
    14851484          DataConnections[i].Close;
    1486           DataConnections[i].Free;
     1485//          DataConnections[i].Free;
    14871486          DataConnections[i] := nil;
    14881487          found := True;
     
    15001499
    15011500
     1501function GetEmptyFileInfo: TFileInfo;
     1502begin
     1503  Result.ID := -1;
     1504  Result.FileName := '';
     1505  Result.FileNameHex := '';
     1506  Result.Extension := '';
     1507  Result.Name := '';
     1508  Result.Size := 0;
     1509  Result.FileType := 0;
     1510  Result.DatAddr := 0;
     1511  Result.opened := False;
     1512end;
     1513
     1514
    15021515
    15031516
  • oup/current/Main.dfm

    r86 r87  
    202202          end
    203203        end
     204      end
     205      object menu_conns: TTBSubmenuItem
     206        Caption = 'Connections'
     207        Enabled = False
    204208      end
    205209      object menu_About: TTBItem
  • oup/current/Main.pas

    r86 r87  
    7575    tb_opendb: TTBItem;
    7676    Images_Close: TImageList;
     77    menu_conns: TTBSubmenuItem;
    7778    procedure UpdateConLists;
    7879    procedure LoadFile(typedb: Boolean);
     
    103104    procedure menu_view_statusbarClick(Sender: TObject);
    104105    procedure menu_view_toolbarClick(Sender: TObject);
     106    procedure menu_conns_itemClick(Sender: TObject);
    105107    procedure MDITabDrawTab(Control: TCustomTabControl; TabIndex: Integer;
    106108      const Rect: TRect; Active: Boolean);
     
    166168  end;
    167169  UpdateStatBar;
     170  UpdateConLists;
    168171end;
    169172
     
    226229  pt.Y := Y;
    227230  tabIndex := MDITab.GetTabAtPos(pt);
     231  hint := '';
    228232
    229233  if tabIndex >= 0 then
     
    231235    if MDITab.MDIChildren[tabIndex] is TForm_ToolTemplate then
    232236    begin
    233       hint := 'Window: ' + MDITab.MDIChildren[tabIndex].Caption + #13+#10 +
    234             'Selected File: ';
     237      if TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).Connection <> nil then
     238        hint := 'Connection: ' +
     239              ExtractFileName(TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).Connection.FileName) + #13+#10
     240      else
     241        hint := 'Connection: none' + #13+#10;
    235242      if TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.ID >= 0 then
    236         hint := hint + TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.FileName
     243        hint := hint + 'Selected File: ' +
     244              TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.FileName
    237245      else
    238         hint := hint + 'None';
     246        hint := hint + 'Selected File: none';
    239247    end
    240248    else
     
    320328  begin
    321329    Self.Caption      := 'Oni Un/Packer ' + version;
    322     statbar.Panels.Items[0].Text := 'Nothing loaded';
    323     statbar.Panels.Items[1].Text := 'Files: -';
    324     statbar.Panels.Items[2].Text := 'Extensions: -';
     330    statbar.Panels.Items[0].Text := '';
     331    statbar.Panels.Items[1].Text := 'Connections: -';
     332    statbar.Panels.Items[2].Text := '';
    325333    ActivateTools(False);
    326334  end;
     335  menu_conns.Enabled := Length(DataConnections) > 0;
    327336end;
    328337
     
    363372
    364373
     374procedure TForm_Main.menu_conns_itemClick(Sender: TObject);
     375var
     376  name: String;
     377  i: Integer;
     378begin
     379  name := TTBItem(Sender).Caption;
     380  if MessageBox(Handle, PChar('Do you really want to close data-connection to' +#13+#10+
     381        name + '?'), PChar('Close?'), MB_YESNO + MB_ICONQUESTION) = ID_YES then
     382  begin
     383    for i := 0 to High(DataConnections) do
     384      if ExtractFileName(DataConnections[i].FileName) = name then
     385      begin
     386        CloseDataConnection(DataConnections[i]);
     387        Break;
     388      end;
     389  end;
     390  UpdateConLists;
     391end;
     392
     393
    365394procedure TForm_Main.UpdateConLists;
    366395var
    367396  i: Integer;
    368 begin
    369   for i := 0 to MDITab.MDIChildCount - 1 do
    370     if MDITab.MDIChildren[i] is TForm_ToolTemplate then
    371       TForm_ToolTemplate(MDITab.MDIChildren[i]).UpdateList;
     397  entry: TTBItem;
     398begin
     399  if MDITab.MDIChildCount > 0 then
     400    for i := 0 to MDITab.MDIChildCount - 1 do
     401      if MDITab.MDIChildren[i] is TForm_ToolTemplate then
     402        TForm_ToolTemplate(MDITab.MDIChildren[i]).UpdateList;
     403
     404  menu_conns.Clear;
     405  if Length(DataConnections) > 0 then
     406  begin
     407    for i := 0 to High(DataConnections) do
     408    begin
     409      entry := TTBItem.Create(menu_conns);
     410      entry.Caption := ExtractFileName(DataConnections[i].FileName);
     411      entry.Name := 'menu_conn_' + IntToStr(i);
     412      entry.OnClick := menu_conns_itemClick;
     413      menu_conns.Add(entry);
     414      entry := nil;
     415    end;
     416  end;
    372417end;
    373418
  • oup/current/Tools/BinEdit.dfm

    r61 r87  
    44  OnCloseQuery = FormCloseQuery
    55  OnKeyUp = FormKeyUp
    6   ExplicitWidth = 500
    7   ExplicitHeight = 450
    86  PixelsPerInch = 96
    97  TextHeight = 13
     8  inherited panel_files: TPanel
     9    inherited filelist: TListBox
     10      ExplicitTop = 153
     11      ExplicitHeight = 270
     12    end
     13  end
    1014  inherited content: TPanel
    1115    object Splitter2: TSplitter
  • oup/current/Tools/BinEdit.pas

    r75 r87  
    5757    procedure value_viewer_contextPopup(Sender: TObject);
    5858  private
    59     fileid: LongWord;
     59    fileid: Integer;
    6060  public
    6161  end;
     
    291291  if VST.RootNodeCount = 0 then
    292292  begin
    293     structs := LoadStructureDefinition(fileid);
     293    structs := LoadStructureDefinition(Connection, fileid);
    294294    if structs.Data then
    295295    begin
  • oup/current/Tools/Preview.dfm

    r46 r87  
    33  PixelsPerInch = 96
    44  TextHeight = 13
     5  inherited panel_files: TPanel
     6    inherited filelist: TListBox
     7      ExplicitTop = 153
     8      ExplicitHeight = 270
     9    end
     10  end
    511  inherited content: TPanel
    612    object lbl_notpossible: TLabel
  • oup/current/Tools/Preview.pas

    r86 r87  
    3232    bitmaps:   array of TBitmap;
    3333    actualimg: Byte;
    34     _fileid:   LongWord;
     34    _fileid:   Integer;
    3535  public
    3636  end;
     
    5555begin
    5656  _fileid := fileinfo.ID;
    57   lbl_notpossible.Visible := False;
    58   Self.img.Visible := True;
    59   Self.timer.Enabled := False;
    60   Self.panel_buttons.Visible := False;
    61   ext     := fileinfo.Extension;
    62   if (ext = 'PSpc') or (ext = 'TXMB') or (ext = 'TXMP') then
    63     PreviewImage
    64   else if ext = 'TXAN' then
    65     PreviewTXAN
    66   else
    67   begin
    68     Self.lbl_notpossible.Visible := True;
     57  if _fileid >= 0 then
     58  begin
     59    lbl_notpossible.Visible := False;
     60    Self.img.Visible := True;
     61    Self.timer.Enabled := False;
     62    Self.panel_buttons.Visible := False;
     63    ext     := fileinfo.Extension;
     64    if (ext = 'PSpc') or (ext = 'TXMB') or (ext = 'TXMP') then
     65      PreviewImage
     66    else if ext = 'TXAN' then
     67      PreviewTXAN
     68    else
     69    begin
     70      Self.lbl_notpossible.Visible := True;
     71      Self.img.Visible := False;
     72    end;
     73  end
     74  else
     75  begin
    6976    Self.img.Visible := False;
     77    lbl_notpossible.Visible := False;
     78    Self.timer.Enabled := False;
     79    Self.panel_buttons.Visible := False;
    7080  end;
    7181end;
  • oup/current/Tools/Template.pas

    r86 r87  
    102102begin
    103103  oldcon := combo_connection.Items.Strings[combo_connection.ItemIndex];
     104  combo_connection.ItemIndex := -1;
    104105  combo_connection.Items.Clear;
    105   for i := 0 to High(DataConnections) do
    106   begin
    107     level := DataConnections[i].LevelInfo.LevelNumber;
    108     fn := ExtractFileName(DataConnections[i].FileName);
    109     if DataConnections[i].Backend = ODB_Dat then
    110       datatype := 'ONI-.dat: '
    111     else if DataConnections[i].Backend = ODB_ADB then
    112       datatype := 'OUP-DB: '
    113     else
    114       datatype := 'Unknown: ';
    115     boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ')';
    116     combo_connection.Items.Add(boxstring);
    117     if oldcon = boxstring then
    118       combo_connection.ItemIndex := combo_connection.Items.Count - 1;
     106  if Length(DataConnections) > 0 then
     107  begin
     108    for i := 0 to High(DataConnections) do
     109    begin
     110      level := DataConnections[i].LevelInfo.LevelNumber;
     111      fn := ExtractFileName(DataConnections[i].FileName);
     112      if DataConnections[i].Backend = ODB_Dat then
     113        datatype := 'ONI-.dat: '
     114      else if DataConnections[i].Backend = ODB_ADB then
     115        datatype := 'OUP-DB: '
     116      else
     117        datatype := 'Unknown: ';
     118      boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ')';
     119      combo_connection.Items.Add(boxstring);
     120      if oldcon = boxstring then
     121        combo_connection.ItemIndex := combo_connection.Items.Count - 1;
     122    end;
     123    if combo_connection.ItemIndex = -1 then
     124    begin
     125      combo_connection.ItemIndex := 0;
     126      combo_connectionChange(Self);
     127    end;
     128  end
     129  else
     130  begin
     131    FConnection := nil;
     132    filelist.Items.Clear;
     133    combo_extension.Items.Clear;
     134    combo_connectionChange(Self);
     135    FSelectedFile := GetEmptyFileInfo;
     136    if Assigned(FOnNewFileSelected) then
     137      FOnNewFileSelected(FSelectedFile);
    119138  end;
    120139end;
     
    127146begin
    128147  combo_connection.Items.Clear;
    129   for i := 0 to High(DataConnections) do
    130   begin
    131     level := DataConnections[i].LevelInfo.LevelNumber;
    132     fn := ExtractFileName(DataConnections[i].FileName);
    133     if DataConnections[i].Backend = ODB_Dat then
    134       datatype := 'ONI-.dat: '
    135     else if DataConnections[i].Backend = ODB_ADB then
    136       datatype := 'OUP-DB: '
    137     else
    138       datatype := 'Unknown: ';
    139     combo_connection.Items.Add(datatype + fn + ' (Level: ' + IntToStr(level) + ')');
    140   end;
    141   FConnection := DataConnections[0];
    142   combo_connection.ItemIndex := 0;
    143   combo_connectionChange(Self);
     148  if Length(DataConnections) > 0 then
     149  begin
     150    for i := 0 to High(DataConnections) do
     151    begin
     152      level := DataConnections[i].LevelInfo.LevelNumber;
     153      fn := ExtractFileName(DataConnections[i].FileName);
     154      if DataConnections[i].Backend = ODB_Dat then
     155        datatype := 'ONI-.dat: '
     156      else if DataConnections[i].Backend = ODB_ADB then
     157        datatype := 'OUP-DB: '
     158      else
     159        datatype := 'Unknown: ';
     160      combo_connection.Items.Add(datatype + fn + ' (Level: ' + IntToStr(level) + ')');
     161    end;
     162    FConnection := DataConnections[0];
     163    combo_connection.ItemIndex := 0;
     164    combo_connectionChange(Self);
     165  end
     166  else
     167  begin
     168    FConnection := nil;
     169    filelist.Items.Clear;
     170    combo_extension.Items.Clear;
     171    combo_connectionChange(Self);
     172  end;
    144173end;
    145174
     
    150179begin
    151180  combo_extension.Items.Clear;
    152   combo_extension.Items.Add('_All files_ (' +
    153     IntToStr(FConnection.GetFilesCount) + ')');
    154   exts := FConnection.GetExtensionsList;
    155   for i := 0 to High(exts) do
    156     if Length(FAllowedExts) > 0 then
    157     begin
    158       if Pos(MidStr(exts[i],1,4), FAllowedExts) > 0 then
     181  if FConnection <> nil then
     182  begin
     183    combo_extension.Items.Add('_All files_ (' +
     184      IntToStr(FConnection.GetFilesCount) + ')');
     185    exts := FConnection.GetExtensionsList;
     186    for i := 0 to High(exts) do
     187      if Length(FAllowedExts) > 0 then
    159188      begin
     189        if Pos(MidStr(exts[i],1,4), FAllowedExts) > 0 then
     190        begin
     191          combo_extension.Items.Add(exts[i]);
     192        end;
     193      end else
    160194        combo_extension.Items.Add(exts[i]);
    161       end;
    162     end else
    163       combo_extension.Items.Add(exts[i]);
    164   combo_extension.ItemIndex := 0;
    165   combo_extensionClick(Self);
     195    combo_extension.ItemIndex := 0;
     196    combo_extensionClick(Self);
     197  end;
    166198end;
    167199
     
    177209  i: LongWord;
    178210begin
    179   Extension := MidStr(combo_extension.Items.Strings[combo_extension.ItemIndex], 1, 4);
    180   no_zero_bytes := not check_zerobyte.Checked;
    181   pattern := '';
    182   if check_filtername.Checked then
    183     pattern := edit_filtername.Text;
    184   if Extension = '_All' then
    185     if Length(FAllowedExts) > 0 then
    186       Extension := FAllowedExts
    187     else
    188       Extension := '';
    189 
    190   files := FConnection.GetFilesList(extension, pattern, no_zero_bytes, FSortBy);
    191 
    192   filelist.Visible := False;
    193   filelist.Items.Clear;
    194   if Length(files) > 0 then
    195     for i := 0 to High(files) do
    196       filelist.Items.Add(files[i]);
    197   filelist.Visible := True;
     211  if FConnection <> nil then
     212  begin
     213    Extension := MidStr(combo_extension.Items.Strings[combo_extension.ItemIndex], 1, 4);
     214    no_zero_bytes := not check_zerobyte.Checked;
     215    pattern := '';
     216    if check_filtername.Checked then
     217      pattern := edit_filtername.Text;
     218    if Extension = '_All' then
     219      if Length(FAllowedExts) > 0 then
     220        Extension := FAllowedExts
     221      else
     222        Extension := '';
     223
     224    files := FConnection.GetFilesList(extension, pattern, no_zero_bytes, FSortBy);
     225
     226    filelist.Visible := False;
     227    filelist.Items.Clear;
     228    if Length(files) > 0 then
     229      for i := 0 to High(files) do
     230        filelist.Items.Add(files[i]);
     231    filelist.Visible := True;
     232  end;
    198233end;
    199234
     
    296331  inherited;
    297332  RecreateList;
    298   FConnection := nil;
    299   FSelectedFile.ID := -1;
    300   FSelectedFile.FileName := '';
    301   FSelectedFile.FileNameHex := '';
     333  FSelectedFile := GetEmptyFileInfo;
    302334  if Length(ToolList) > 0 then
    303335  begin
Note: See TracChangeset for help on using the changeset viewer.