Changeset 97 for oup


Ignore:
Timestamp:
Jan 23, 2007, 12:05:45 AM (18 years ago)
Author:
alloc
Message:
 
Location:
oup/rewrite
Files:
6 added
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • oup/rewrite/DataAccess/ConnectionManager.pas

    r93 r97  
    1818    function GetConnection(ConnectionID: Integer): TDataAccess;
    1919    function GetConnectionByIndex(Index: Integer): TDataAccess;
     20    function GetConnectionIndex(ConnectionID: Integer): Integer;
    2021    procedure RemoveConnection(ArrayIndex: Integer);
    2122  protected
     
    2425    property Connection[ConnectionID: Integer]: TDataAccess read GetConnection;
    2526    property ConnectionByIndex[Index: Integer]: TDataAccess read GetConnectionByIndex;
     27    property ConnectionIndexByID[ConnectionID: Integer]: Integer read GetConnectionIndex;
    2628    property OnCoonnectionListChanged: TConnectionListChangedEvent read FConnectionListChanged write FConnectionListChanged;
    2729
     
    3739
    3840
     41var
     42  ConManager: TConnectionManager;
     43
     44
    3945implementation
    4046uses
     
    4955begin
    5056  Result := Length(FConnections);
     57end;
     58
     59function TConnectionManager.GetConnectionIndex(ConnectionID: Integer): Integer;
     60var
     61  i: Integer;
     62begin
     63  Result := -1;
     64  if Count > 0 then
     65    for i := 0 to Count - 1 do
     66      if ConnectionByIndex[i].ConnectionID = ConnectionID then
     67      begin
     68        Result := i;
     69        Break;
     70      end;
    5171end;
    5272
     
    240260
    241261
     262initialization
     263  ConManager := TConnectionManager.Create;
     264finalization
     265  ConManager.Free;
    242266end.
  • oup/rewrite/DataAccess/DataAccess.pas

    r93 r97  
    1313    FFileName:      String;
    1414    FBackend:       TDataBackend;
     15    FDataOS:        TDataOS;
    1516    FLevelNumber:   Integer;
    1617    FChangeRights:  TChangeRights;
     18    procedure SetDataOS(DataOS: TDataOS);
    1719  protected
    1820  public
    1921    property ConnectionID: Integer      read FConnectionID;
    20     property FileName:    String        read FFileName;
    21     property Backend:     TDataBackend  read FBackend;
    22     property LevelNumber: Integer       read FLevelNumber;
     22    property FileName:     String       read FFileName;
     23    property Backend:      TDataBackend read FBackend;
     24    property DataOS:       TDataOS      read FDataOS write SetDataOS;
     25    property LevelNumber:  Integer      read FLevelNumber;
    2326
    2427    constructor Create(FileName: String; ConnectionID: Integer; var Msg: TStatusMessages); virtual; abstract;
     
    3437
    3538    procedure LoadDatFile(FileID: Integer; var Target: TStream); overload; virtual; abstract;
    36     procedure LoadDatFile(FileID: Integer; var Target: TByteArray); overload; virtual; abstract;
     39    procedure LoadDatFile(FileID: Integer; var Target: TByteData); overload; virtual; abstract;
    3740    procedure UpdateDatFile(FileID: Integer; Src: TStream); overload; virtual; abstract;
    38     procedure UpdateDatFile(FileID: Integer; Src: TByteArray); overload; virtual; abstract;
     41    procedure UpdateDatFile(FileID: Integer; Src: TByteData); overload; virtual; abstract;
    3942    procedure LoadDatFilePart(FileID, Offset, Size: Integer; var Target: TStream); overload; virtual; abstract;
    40     procedure LoadDatFilePart(FileID, Offset, Size: Integer; var Target: TByteArray); overload; virtual; abstract;
     43    procedure LoadDatFilePart(FileID, Offset, Size: Integer; var Target: TByteData); overload; virtual; abstract;
    4144    procedure LoadDatFilePart(FileID, Offset, Size: Integer; Target: Pointer); overload; virtual; abstract;
    4245    procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TStream); overload; virtual; abstract;
    43     procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TByteArray); overload; virtual; abstract;
     46    procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TByteData); overload; virtual; abstract;
    4447    procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: Pointer); overload; virtual; abstract;
    4548
     
    4851
    4952    procedure LoadRawFile(FileID, DatOffset: Integer; var Target: TStream); overload; virtual; abstract;
    50     procedure LoadRawFile(FileID, DatOffset: Integer; var Target: TByteArray); overload; virtual; abstract;
     53    procedure LoadRawFile(FileID, DatOffset: Integer; var Target: TByteData); overload; virtual; abstract;
    5154    procedure UpdateRawFile(FileID, DatOffset, Size: Integer; Src: TStream); overload; virtual; abstract;
    52     procedure UpdateRawFile(FileID, DatOffset, Size: Integer; Src: TByteArray); overload; virtual; abstract;
     55    procedure UpdateRawFile(FileID, DatOffset, Size: Integer; Src: TByteData); overload; virtual; abstract;
    5356    procedure LoadRawFilePart(FileID, DatOffset, Offset, Size: Integer; var Target: TStream); overload; virtual; abstract;
    54     procedure LoadRawFilePart(FileID, DatOffset, Offset, Size: Integer; var Target: TByteArray); overload; virtual; abstract;
     57    procedure LoadRawFilePart(FileID, DatOffset, Offset, Size: Integer; var Target: TByteData); overload; virtual; abstract;
    5558    procedure LoadRawFilePart(FileID, DatOffset, Offset, Size: Integer; Target: Pointer); overload; virtual; abstract;
    5659    procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TStream); overload; virtual; abstract;
    57     procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TByteArray); overload; virtual; abstract;
     60    procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TByteData); overload; virtual; abstract;
    5861    procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: Pointer); overload; virtual; abstract;
    5962
    6063    function AppendRawFile(LocSep: Boolean; Size: Integer; Src: TStream): Integer; overload; virtual; abstract;
    61     function AppendRawFile(LocSep: Boolean; Size: Integer; Src: TByteArray): Integer; overload; virtual; abstract;
     64    function AppendRawFile(LocSep: Boolean; Size: Integer; Src: TByteData): Integer; overload; virtual; abstract;
    6265    function AppendRawFile(LocSep: Boolean; Size: Integer; Src: Pointer): Integer; overload; virtual; abstract;
    6366  published
    6467  end;
    6568
    66 
    67 
    68 
    69 
    70 {
    71 var
    72   DataConnections: array of TOniData;
    73 
    74 function CreateDataConnection(filename: String; backend: Integer): TOniData;
    75 function ConnectionExists(filename: String): TOniData;
    76 procedure CloseDataConnection(connection: TOniData);
    77 function GetEmptyFileInfo: TFileInfo;
    78 }
    7969
    8070
     
    158148
    159149
     150procedure TDataAccess.SetDataOS(DataOS: TDataOS);
     151begin
     152  raise ENotImplemented.Create('TDataAccess.SetDataOS: TBD!');
     153end;
    160154
    161155end.
  • oup/rewrite/Global/TypeDefs.pas

    r93 r97  
    33
    44uses
    5   Graphics;
     5  Graphics, SysUtils;
    66
    77type
     8  ENotImplemented = class(Exception);
     9
    810  TDataBackend = (DB_ONI, DB_ADB);
     11  TDataOS = (DOS_WIN, DOS_MAC);
    912
    1013  TChangeRights = set of (CR_EditDat, CR_EditRaw, CR_ResizeDat, CR_ResizeRaw);
     
    5154  );
    5255
    53   TByteArray = array of Byte;
     56  TByteData = array of Byte;
    5457
    5558  TAppSettings = record
     
    7982}
    8083
     84const
     85  CrLf: String[2] = #13#10;
     86
    8187implementation
    8288
  • oup/rewrite/Helper/Helper_LevelDB.pas

    r93 r97  
    1616    procedure btn_abortokClick(Sender: TObject);
    1717  private
    18     procedure HandleFile(ext: String; fileid: LongWord; dir_dat2db: Boolean);
     18    procedure HandleFile(ext: String; fileid: Integer; dir_dat2db: Boolean);
    1919    procedure stop_convert;
    2020  public
    21     procedure CreateDatabase(Source, target: String);
    22     procedure CreateLevel(Source, target: String);
     21    procedure CreateDatabase(Source, Target: String);
     22    procedure CreateLevel(Source, Target: String);
    2323  end;
    2424
     
    3131{$R *.dfm}
    3232
    33 uses ABSMain, ABSDecUtil, Main, Functions, Data,
    34   OniImgClass, DataStructures, OniDataClass;
     33uses ABSMain, ABSDecUtil, Main, Functions, Data, OniImgClass, DataStructures, ConnectionManager;
    3534
    3635type
  • oup/rewrite/Main.dfm

    r93 r97  
    656656      0000000000000000000000000000000000000000000000000000000000000000
    657657      00000000000000000000000000000000000000FFFF0000000000000000000000
    658       00000000000000C1C100009A9A00008585000085850000000000000000000000
     658      00000000000000FFFF0000FFFF0000FFFF0000FFFF0000000000000000000000
    659659      00000000000000FFFF0000FFFF0000FFFF000000000000000000292018002920
    660660      20005252520039313100DEDEDE00A4A4A40039313100DEDEDE00A4A4A4000000
     
    664664      0000000000000000000000000000000000000000000000000000000000000000
    665665      0000000000000000FF00000000000000FF0000FFFF0000FFFF00000000000000
    666       0000000B0B000032320000707000007C7C00007C7C000070700000323200000B
    667       0B00000000000000000000FFFF0000FFFF000000000000000000292018002920
     666      0000000000000000000000000000000000000000000000000000000000000000
     667      0000000000000000000000FFFF0000FFFF000000000000000000292018002920
    668668      20005252520039313100DEDEDE00A4A4A40039313100DEDEDE00A4A4A4000000
    669669      000029202000292020000000000000000000FF00000000000000FF000000FF00
     
    671671      0000FF000000FF00000000000000FF0000000000FF00000000000000FF000000
    672672      FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000
    673       FF000000FF000000FF00000000000000FF0000FFFF0000FFFF0000D9D9000016
    674       16000060600000B1B10000E0E00000F9F90000F9F90000E0E00000B1B1000060
    675       600000161600000000000000000000FFFF000000000000000000292029003129
     673      FF000000FF000000FF00000000000000FF0000FFFF0000FFFF0000FFFF000000
     674      0000000000000000000000FFFF0000FFFF0000FFFF0000FFFF00000000000000
     675      000000000000000000000000000000FFFF000000000000000000292029003129
    676676      2900525252003931310039313100A4A4A4003931310039313100A4A4A4000000
    677677      000031292900312929000000000000000000FF00000000000000FF0000000000
     
    679679      0000FF000000FF00000000000000FF0000000000FF00000000000000FF000000
    680680      0000000000000000000000000000000000000000000000000000000000000000
    681       00000000FF000000FF00000000000000FF0000FFFF0000EDED00008C8C000070
    682       700000D5D50000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000D5
    683       D50000606000000B0B0000000000000000000000000000000000525252005252
     681      00000000FF000000FF00000000000000FF0000FFFF0000FFFF0000FFFF000000
     682      000000FFFF0000FFFF0000FFFF00000000000000000000FFFF0000FFFF0000FF
     683      FF00000000000000000000000000000000000000000000000000525252005252
    684684      5200525252005252520052525200525252005252520052525200525252005252
    685685      520052525200525252000000000000000000FF00000000000000FF0000000000
     
    687687      0000FF000000FF00000000000000FF0000000000FF00000000000000FF000000
    688688      0000000000000000000000000000000000000000000000000000000000000000
    689       00000000FF000000FF00000000000000FF000000000000C2C2000067670000B1
    690       B10000FFFF0000C9C90000414100002C2C00002C2C00002C2C0000EAEA0000FF
    691       FF0000B1B1000032320000000000000000000000000000000000000000000000
     689      00000000FF000000FF00000000000000FF000000000000FFFF0000FFFF000000
     690      000000FFFF0000FFFF00000000000000FF000000FF000000000000FFFF0000FF
     691      FF00000000000000000000000000000000000000000000000000000000000000
    692692      0000000000000000000000000000000000000000000000000000000000000000
    693693      000000000000000000000000000000000000FF00000000000000FF000000FF00
     
    695695      0000FF000000FF00000000000000FF0000000000FF00000000000000FF000000
    696696      FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000
    697       FF000000FF000000FF00000000000000FF0000000000000000000070700000E0
    698       E00000C0C000002D2D00002B2B000062620000373700002121000039390000C9
    699       C90000E0E00000707000000000000000000000000000000000000000FF000000
     697      FF000000FF000000FF00000000000000FF0000000000000000000000000000FF
     698      FF0000FFFF0000000000000000000000000000000000000000000000000000FF
     699      FF0000FFFF0000000000000000000000000000000000000000000000FF000000
    700700      FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000
    701701      FF000000FF000000FF000000000000000000FF00000000000000FF0000000000
     
    703703      0000FF000000FF00000000000000FF0000000000FF00000000000000FF000000
    704704      0000000000000000000000000000000000000000000000000000000000000000
    705       FF000000FF000000FF00000000000000FF0000000000000000000079790000F8
    706       F80000929200003C3C0000C9C90000FFFF0000FFFF0000FFFF0000464600006A
    707       6A0000F8F800007C7C00008585000000000000000000000000000000FF000000
     705      FF000000FF000000FF00000000000000FF0000000000000000000000000000FF
     706      FF000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF000000
     707      000000FFFF000000000000FFFF000000000000000000000000000000FF000000
    708708      FF000000FF000000000000000000000000000000000000000000000000000000
    709709      FF000000FF000000FF000000000000000000FF00000000000000FF0000000000
     
    711711      0000FF000000FF00000000000000FF0000000000FF00000000000000FF000000
    712712      0000000000000000000000000000000000000000000000000000000000000000
    713       FF000000FF000000FF00000000000000FF0000000000000000000079790000F8
    714       F80000F4F40000F4F40000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FF
    715       FF0000F8F800007C7C000085850000FFFF0000000000000000000000FF000000
     713      FF000000FF000000FF00000000000000FF0000000000000000000000000000FF
     714      FF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FF
     715      FF0000FFFF000000000000FFFF0000FFFF0000000000000000000000FF000000
    716716      FF000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00000000000000
    717717      00000000FF000000FF000000000000000000FF00000000000000FF000000FF00
     
    719719      0000FF000000FF00000000000000FF0000000000FF00000000000000FF000000
    720720      FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000
    721       FF000000FF000000FF00000000000000FF0000FFFF00000000000060600000E0
    722       E00000FFFF0000424200002A2A0000FFFF0000FFFF00003B3B000052520000FF
    723       FF0000E0E00000707000009A9A0000FFFF0000000000000000000000FF000000
     721      FF000000FF000000FF00000000000000FF0000FFFF00000000000000000000FF
     722      FF0000FFFF00000000000000000000FFFF0000FFFF00000000000000000000FF
     723      FF0000FFFF000000000000FFFF0000FFFF0000000000000000000000FF000000
    724724      000000000000FFFFFF00FFFFFF000000000000000000FFFFFF00FFFFFF000000
    725725      0000000000000000FF000000000000000000FF00000000000000FF0000000000
     
    727727      0000FF000000FF00000000000000FF0000000000FF00000000000000FF000000
    728728      00000000000000000000000000000000000000000000000000000000FF000000
    729       FF000000FF000000FF00000000000000FF0000FFFF0000C2C2000032320000B1
    730       B10000C9C900005858000045450000FFFF0000FFFF0000434300005E5E0000FF
    731       FF0000B1B1000032320000C2C20000FFFF0000000000000000000000FF000000
     729      FF000000FF000000FF00000000000000FF0000FFFF0000FFFF00000000000000
     730      000000FFFF00000000000000000000FFFF0000FFFF00000000000000000000FF
     731      FF00000000000000000000FFFF0000FFFF0000000000000000000000FF000000
    732732      0000FFFFFF00FFFFFF00000000006A00BD006A00BD0000000000FFFFFF00FFFF
    733733      FF00000000000000FF000000000000000000FF00000000000000FF0000000000
     
    735735      0000FF000000FF00000000000000FF0000000000FF00000000000000FF000000
    736736      00000000000000000000000000000000000000000000000000000000FF000000
    737       FF000000FF000000FF00000000000000FF0000FFFF0000EDED00008C8C000060
    738       600000D5D50000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000D5
    739       D50000606000000B0B000000000000FFFF0000000000000000000000FF000000
     737      FF000000FF000000FF00000000000000FF0000FFFF0000FFFF0000FFFF000000
     738      000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FF
     739      FF0000000000000000000000000000FFFF0000000000000000000000FF000000
    740740      0000000000000000000000000000000000000000000000000000000000000000
    741741      0000000000000000FF000000000000000000FF00000000000000FF000000FF00
     
    743743      0000FF000000FF00000000000000FF0000000000FF00000000000000FF000000
    744744      FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000
    745       FF000000FF000000FF00000000000000FF0000FFFF0000FFFF0000D9D900007F
    746       7F000060600000B1B10000E0E00000F8F80000F8F80000E0E00000B1B1000070
    747       70000016160000000000000000000000000000000000000000000000FF000000
     745      FF000000FF000000FF00000000000000FF0000FFFF0000FFFF0000FFFF0000FF
     746      FF00000000000000000000FFFF0000FFFF0000FFFF0000FFFF00000000000000
     747      00000000000000000000000000000000000000000000000000000000FF000000
    748748      FF00000000000000000000000000000000000000000000000000000000000000
    749749      00000000FF000000FF000000000000000000FF00000000000000FF0000000000
     
    751751      0000FF000000FF00000000000000FF0000000000FF00000000000000FF000000
    752752      000000000000000000000000000000000000000000000000FF000000FF000000
    753       FF000000FF000000FF00000000000000FF000000000000FFFF0000FFFF0000D9
    754       D900008C8C00003232000060600000797900007979000070700000676700008C
    755       8C0000D9D90000000000000000000000000000000000000000000000FF000000
     753      FF000000FF000000FF00000000000000FF000000000000FFFF0000FFFF0000FF
     754      FF0000FFFF00000000000000000000000000000000000000000000FFFF0000FF
     755      FF0000FFFF0000000000000000000000000000000000000000000000FF000000
    756756      FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000
    757757      FF000000FF000000FF0000000000000000000000000000000000000000000000
     
    760760      0000000000000000000000000000000000000000000000000000000000000000
    761761      000000000000000000000000000000000000000000000000000000FFFF0000FF
    762       FF0000EDED0000C2C2000000000000000000000000000000000000C2C20000ED
    763       ED0000FFFF0000FFFF0000000000000000000000000000000000000000000000
     762      FF0000FFFF0000FFFF000000000000000000000000000000000000FFFF0000FF
     763      FF0000FFFF0000FFFF0000000000000000000000000000000000000000000000
    764764      0000000000000000000000000000000000000000000000000000000000000000
    765765      0000000000000000000000000000000000000000000000000000000000000000
  • oup/rewrite/Main.pas

    r93 r97  
    88  Data, TypeDefs, ConnectionManager,
    99//  Functions, Exporters, DataStructures,
     10  Functions,
    1011  Settings, {Helper_LevelDB, }
    11   Template, BinEdit, Extractor, Preview, RawEdit, TxmpReplace;
     12  Template,
     13  Preview;
     14//  BinEdit, Extractor, RawEdit, TxmpReplace;
    1215
    1316type
     
    9295    procedure ToolbarDockChanged(Sender: TObject);
    9396    procedure CreateConnection(filename: String);
     97    function CheckConnectionCloseable(index: Integer): Boolean;
    9498
    9599    procedure menu_loadfileClick(Sender: TObject);
     
    126130    procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;
    127131  private
    128     ConnectionManager: TConnectionManager;
    129132  public
    130133    procedure DefaultHandler(var Message); override;
     
    154157  RepMsg: TStatusMessages;
    155158begin
    156   ConnectionManager.OpenConnection(filename, RepMsg);
     159  ConManager.OpenConnection(filename, RepMsg);
    157160  ShowOpenMsg(RepMsg);
    158161  if RepMsg = SM_OK then
     
    161164  end;
    162165end;
     166
     167function TForm_Main.CheckConnectionCloseable(index: Integer): Boolean;
     168var
     169  i: Integer;
     170  toolform: TForm_ToolTemplate;
     171begin
     172  if MDITab.MDIChildCount > 0 then
     173  begin
     174    for i := 0 to MDITab.MDIChildCount - 1 do
     175    begin
     176      if MDITab.MDIChildren[i] is TForm_ToolTemplate then
     177      begin
     178        toolform := TForm_ToolTemplate(MDITab.MDIChildren[i]);
     179        if toolform.ConnectionID = ConManager.ConnectionByIndex[index].ConnectionID then
     180        begin
     181          if not toolform.Closeable then
     182            ShowMessage('Can not close toolwindow: ' + toolform.Caption);
     183        end;
     184      end;
     185    end;
     186  end;
     187end;
     188
    163189
    164190{ Eine zweite Instanz hat uns ihre Kommandozeilenparameter geschickt }
     
    215241  Self.FormResize(Self);
    216242
    217   ConnectionManager := TConnectionManager.Create;
    218   ConnectionManager.OnCoonnectionListChanged := UpdateConLists;
     243  ConManager.OnCoonnectionListChanged := UpdateConLists;
    219244
    220245  if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
     
    293318  tabIndex: Integer;
    294319  hint: String;
     320  tool: TForm_ToolTemplate;
    295321begin
    296322  pt.X := X;
     
    303329    if MDITab.MDIChildren[tabIndex] is TForm_ToolTemplate then
    304330    begin
    305       if TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).Connection <> nil then
     331      tool := TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]);
     332      if tool.ConnectionID > -1 then
    306333        hint := 'Connection: ' +
    307               ExtractFileName(TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).Connection.FileName) + #13+#10
     334              ExtractFileName(ConManager.Connection[tool.ConnectionID].FileName) + #13+#10
    308335      else
    309336        hint := 'Connection: none' + #13+#10;
    310       if TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.ID >= 0 then
     337      if tool.SelectedFile.ID > -1 then
    311338        hint := hint + 'Selected File: ' +
    312               TForm_ToolTemplate(MDITab.MDIChildren[tabIndex]).SelectedFile.FileName
     339              FormatNumber(tool.SelectedFile.ID, 5, '0') + '-' +
     340              tool.SelectedFile.Name + '.' +
     341              tool.SelectedFile.Extension
    313342      else
    314343        hint := hint + 'Selected File: none';
     
    387416procedure TForm_Main.UpdateStatBar;
    388417begin
    389   if Length(DataConnections) > 0 then
     418  if ConManager.Count > 0 then
    390419  begin
    391420    Self.Caption      := 'Oni Un/Packer ' + version;
    392421    ActivateTools(True);
    393     statbar.Panels.Items[1].Text := 'Connections: ' + IntToStr(Length(DataConnections));
     422    statbar.Panels.Items[1].Text := 'Connections: ' + IntToStr(ConManager.Count);
    394423  end
    395424  else
     
    401430    ActivateTools(False);
    402431  end;
    403   menu_conns.Enabled := Length(DataConnections) > 0;
     432  menu_conns.Enabled := ConManager.Count > 0;
    404433end;
    405434
     
    451480
    452481  menu_conns.Clear;
    453   if ConnectionManager.Count > 0 then
    454   begin
    455     for i := 0 to ConnectionManager.Count - 1 do
     482  if ConManager.Count > 0 then
     483  begin
     484    for i := 0 to ConManager.Count - 1 do
    456485    begin
    457486      entry := TTBItem.Create(menu_conns);
    458       entry.Caption := ExtractFileName(DataConnections[i].FileName);
     487      entry.Caption := ExtractFileName(ConManager.ConnectionByIndex[i].FileName);
    459488      entry.Name := 'menu_conn_' + IntToStr(i);
    460489      entry.OnClick := menu_conns_itemClick;
     
    556585procedure TForm_Main.menu_previewClick(Sender: TObject);
    557586begin
    558   open_child('preview', nil, -1);
     587  open_child('preview', -1, -1);
    559588end;
    560589
    561590procedure TForm_Main.menu_bineditClick(Sender: TObject);
    562591begin
    563   open_child('binedit', nil, -1);
     592  open_child('binedit', -1, -1);
    564593end;
    565594
    566595procedure TForm_Main.menu_raweditClick(Sender: TObject);
    567596begin
    568   open_child('rawedit', nil, -1);
     597  open_child('rawedit', -1, -1);
    569598end;
    570599
    571600procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject);
    572601begin
    573   open_child('txmpreplace', nil, -1);
     602  open_child('txmpreplace', -1, -1);
    574603end;
    575604
    576605procedure TForm_Main.menu_extractorClick(Sender: TObject);
    577606begin
    578   open_child('extractor', nil, -1);
     607  open_child('extractor', -1, -1);
    579608end;
    580609
     
    586615procedure TForm_Main.menu_filecompareClick(Sender: TObject);
    587616begin
    588   open_child('compare', nil, -1);
     617  open_child('compare', -1, -1);
    589618end;
    590619
     
    653682  name: String;
    654683  i: Integer;
    655 begin
    656   name := TTBItem(Sender).Caption;
     684  index: Integer;
     685  RepMsg: TStatusMessages;
     686begin
     687//  name := TTBItem(Sender).Caption;
     688  index := TTBItem(Sender).Parent.IndexOf(TTBItem(Sender));
     689  name := ExtractFileName(ConManager.ConnectionByIndex[index].FileName);
    657690  if MessageBox(Handle, PChar('Do you really want to close data-connection to' +#13+#10+
    658691        name + '?'), PChar('Close?'), MB_YESNO + MB_ICONQUESTION) = ID_YES then
    659692  begin
    660     for i := 0 to High(DataConnections) do
    661       if ExtractFileName(DataConnections[i].FileName) = name then
    662       begin
    663         CloseDataConnection(DataConnections[i]);
    664         Break;
    665       end;
     693    CheckConnectionCloseable(index);
     694    ConManager.CloseConnectionByIndex(index, RepMsg);
    666695  end;
    667696  UpdateStatBar;
     
    722751  if window_context = 'binedit' then
    723752  begin
    724     toolform         := TForm_BinEdit.Create(Self);
     753//    toolform         := TForm_BinEdit.Create(Self);
    725754    toolform.Caption := 'Binary .dat-Editor ' + caption_end;
    726755    iconindex        := 5;
     
    728757  if window_context = 'extractor' then
    729758  begin
    730     toolform         := TForm_Extractor.Create(Self);
     759//    toolform         := TForm_Extractor.Create(Self);
    731760    toolform.Caption := 'Extractor ' + caption_end;
    732761    iconindex        := 8;
     
    740769  if window_context = 'rawedit' then
    741770  begin
    742     toolform         := TForm_RawEdit.Create(Self);
     771//    toolform         := TForm_RawEdit.Create(Self);
    743772    toolform.Caption := 'Binary .raw-Editor ' + caption_end;
    744773    iconindex        := 6;
     
    746775  if window_context = 'txmpreplace' then
    747776  begin
    748     toolform         := TForm_TxmpReplace.Create(Application);
     777//    toolform         := TForm_TxmpReplace.Create(Application);
    749778    toolform.Caption := 'TXMP Replacer ' + caption_end;
    750779    iconindex        := 7;
     
    757786    MDITab.AddTab(TForm(toolform), iconindex);
    758787    toolform.Caption := AnsiReplaceStr(toolform.Caption, '       ', '');
    759     if (fileid > -1) and (connection <> nil) then
     788    if connection > -1 then
    760789    begin
    761       toolform.SelectFileID(connection, fileid);
     790      toolform.SelectConnection(connection);
     791      if fileid > -1 then
     792        toolform.SelectFileID(connection, fileid);
    762793    end;
    763794    Result := toolform;
  • oup/rewrite/OniUnPacker.bdsproj

    r93 r97  
    176176                        <Language Name="ProjectLang">$00000000</Language>
    177177                        <Language Name="RootDir"></Language>
    178                 </Language> 
    179    
    180    
    181    
    182     <Excluded_Packages>
     178                </Language>  <Excluded_Packages>
    183179      <Excluded_Packages Name="d:\programme\borland\bds\3.0\Bin\dbwebxprt.bpl">Borland Web Wizard Package</Excluded_Packages>
    184180    </Excluded_Packages>
  • oup/rewrite/OniUnPacker.dpr

    r93 r97  
    1919  Extractor in 'Tools\Extractor.pas' {Form_Extractor},
    2020  Preview in 'Tools\Preview.pas' {Form_Preview},
    21   RawEdit in 'Tools\RawEdit.pas' {Form_RawEdit};
     21  RawEdit in 'Tools\RawEdit.pas' {Form_RawEdit},
     22  OniImgClass in 'Global\OniImgClass.pas',
     23  Functions in 'Global\Functions.pas',
     24  Helper_ValueEdit in 'Helper\Helper_ValueEdit.pas' {Form_ValueEdit},
     25  RawList in 'Global\RawList.pas',
     26  DatStructureLoader in 'Global\DatStructureLoader.pas',
     27  Exporters in 'Global\Exporters.pas';
    2228
    2329{$R *.res}
     
    2935  Application.CreateForm(TForm_Main, Form_Main);
    3036  Application.CreateForm(TForm_Settings, Form_Settings);
     37  Application.CreateForm(TForm_ValueEdit, Form_ValueEdit);
    3138  Application.Run;
    3239end.
  • oup/rewrite/Tools/BinEdit.pas

    r93 r97  
    140140var
    141141  mem:  TMemoryStream;
    142   Data: Tdata;
     142  Data: TByteData;
    143143begin
    144144  if con <> nil then
     
    397397procedure TForm_BinEdit.WriteValues;
    398398var
    399   i, j:  Byte;
     399  i, j:  Integer;
    400400  Data:  Tdata;
    401401  str:   String;
  • oup/rewrite/Tools/Preview.pas

    r94 r97  
    44  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    55  Dialogs, StdCtrls, Template, ExtCtrls, Math, StrUtils,
    6   ConnectionManager, {OniImgClass,} Data, TypeDefs, Menus, Buttons;
     6  ConnectionManager, OniImgClass, Data, TypeDefs, Menus, Buttons;
    77
    88type
     
    8484procedure TForm_Preview.LoadImage(fileid, index: Integer);
    8585var
    86   Data:      TByteArray;
     86  Data:      TByteData;
    8787  memstream: TMemoryStream;
    8888  OniImage:  TOniImage;
     
    9090begin
    9191  OniImage := TOniImage.Create;
    92   OniImage.Load(Connection, fileid);
    93   Data := OniImage.GetAsBMP;
     92  OniImage.Load(ConnectionID, fileid);
     93  OniImage.GetAsBMP(Data);
    9494  OniImage.Free;
    9595
     
    147147  i:    Byte;
    148148begin
    149   Connection.LoadDatFilePart(_fileid, $14, SizeOf(loop_speed), @loop_speed);
    150   Connection.LoadDatFilePart(_fileid, $1C, SizeOf(linkcount), @linkcount);
     149  ConManager.Connection[ConnectionID].LoadDatFilePart(_fileid, $14, SizeOf(loop_speed), @loop_speed);
     150  ConManager.Connection[ConnectionID].LoadDatFilePart(_fileid, $1C, SizeOf(linkcount), @linkcount);
    151151  SetBitmapCount(linkcount);
    152152  for i := 0 to linkcount - 1 do
    153153  begin
    154     Connection.LoadDatFilePart(_fileid, $20 + i * 4, SizeOf(link), @link);
     154    ConManager.Connection[ConnectionID].LoadDatFilePart(_fileid, $20 + i * 4, SizeOf(link), @link);
    155155    link := link div 256;
    156156    if link = 0 then
     
    190190  else
    191191    actualimg := High(bitmaps);
    192   Self.Caption := 'Preview ' + Connection.GetFileInfo(_fileid).FileName +
     192  Self.Caption := 'Preview ' + ConManager.Connection[ConnectionID].GetFileInfo(_fileid).Name +
    193193    ' (' + IntToStr(actualimg + 1) + '/' + IntToStr(Length(bitmaps)) + ')';
    194194  DrawImage(actualimg);
     
    202202  else
    203203    actualimg := 0;
    204   Self.Caption := 'Preview ' + Connection.GetFileInfo(_fileid).FileName +
     204  Self.Caption := 'Preview ' + ConManager.Connection[ConnectionID].GetFileInfo(_fileid).Name +
    205205    ' (' + IntToStr(actualimg + 1) + '/' + IntToStr(Length(bitmaps)) + ')';
    206206  DrawImage(actualimg);
  • oup/rewrite/Tools/RawEdit.pas

    r93 r97  
    44  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    55  Dialogs, Template, StdCtrls, ExtCtrls, Menus, Grids, Wrapgrid,
    6   MPHexEditor, Clipbrd, StrUtils,
    7   Data, Functions, DataStructures, Exporters, OniDataClass, Buttons;
     6  MPHexEditor, Clipbrd, StrUtils, TypeDefs,
     7  Data, Functions, DatStructureLoader, ConnectionManager, Buttons;
    88
    99type
     
    2929    procedure list_offsetClick(Sender: TObject);
    3030    procedure NewFile(fileinfo: TFileInfo);
    31     procedure LoadRaw(raw_info: TRawInfo);
     31    procedure LoadRaw(raw_info: TRawDataInfo);
    3232    function Save: Boolean;
    3333
     
    259259procedure TForm_RawEdit.WriteValues;
    260260var
    261   i, j:  Byte;
     261  i, j:  Integer;
    262262  Data:  Tdata;
    263263  str:   String;
  • oup/rewrite/Tools/Template.dfm

    r93 r97  
    1919  OnActivate = FormActivate
    2020  OnClose = FormClose
    21   OnCreate = FormCreate
    2221  OnResize = FormResize
    2322  PixelsPerInch = 96
  • oup/rewrite/Tools/Template.pas

    r93 r97  
    66  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    77  Dialogs, ExtCtrls, StdCtrls, StrUtils,
    8   ConnectionManager, {Functions,} Data, TypeDefs, Menus, Buttons;
     8  Data, TypeDefs, Menus, Buttons;
    99
    1010type
    1111  TNewFileSelectedEvent = procedure(FileInfo: TFileInfo) of object;
    1212  TNewConnectionEvent = procedure(Connection: Integer) of object;
     13  TCheckCloseableEvent = function: Boolean of object;
    1314
    1415  TForm_ToolTemplate = class(TForm)
     
    4041    combo_connection: TComboBox;
    4142    Bevel1: TBevel;
    42     procedure RecreateList;
    43     procedure UpdateList;
    4443    procedure RecreateExtList;
     44    procedure UpdateConList;
    4545    procedure LoadFileNames;
    46     procedure SelectFileName(connection: Integer; FileName: String);
    47     procedure SelectFileID(connection: Integer; FileID: Integer);
     46    procedure SelectFileName(ConnectionID: Integer; FileName: String);
     47    procedure SelectFileID(ConnectionID, FileID: Integer);
     48    procedure SelectConnection(ConnectionID: Integer);
    4849    procedure check_filternameClick(Sender: TObject);
    4950    procedure check_zerobyteClick(Sender: TObject);
     
    5455
    5556    procedure FormResize(Sender: TObject);
    56     procedure FormCreate(Sender: TObject);
    5757    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    5858    procedure popup_importClick(Sender: TObject);
     
    6767    FOnNewFileSelected: TNewFileSelectedEvent;
    6868    FOnNewConnection: TNewConnectionEvent;
     69    FOnCheckCloseable: TCheckCloseableEvent;
    6970    FAllowedExts: String;
    7071    FAllowMultiSelect: Boolean;
    7172    FSelectedFile: TFileInfo;
    72     FConnection: Integer;
     73    FConnectionID: Integer;
    7374    procedure SetAllowedExts(exts: String);
    7475    procedure SetMultiSelect(allow: Boolean);
     76    function GetToolCloseable: Boolean;
    7577  public
    7678    constructor Create(AOwner: TComponent); override;
     
    7981    property OnNewFileSelected: TNewFileSelectedEvent read FOnNewFileSelected write FOnNewFileSelected;
    8082    property OnNewConnection: TNewConnectionEvent read FOnNewConnection write FOnNewConnection;
     83    property OnCheckCloseable: TCheckCloseableEvent read FOnCheckCloseable write FOnCheckCloseable;
    8184    property AllowedExts: String read FAllowedExts write SetAllowedExts;
    8285    property AllowMultiSelect: Boolean read FAllowMultiSelect write SetMultiSelect;
    8386    property SelectedFile: TFileInfo read FSelectedFile;
    84     property Connection: Integer read FConnection;
     87    property ConnectionID: Integer read FConnectionID;
     88    property Closeable: Boolean read GetToolCloseable;
    8589  end;
    8690
     
    9195implementation
    9296{$R *.dfm}
    93 uses Main, Exporters;
    94 
    95 
    96 procedure TForm_ToolTemplate.UpdateList;
     97uses Main, ConnectionManager, Exporters, Functions;
     98
     99
     100procedure TForm_ToolTemplate.UpdateConList;
    97101var
    98102  i: Integer;
    99103  fn, datatype, boxstring: String;
    100104  level: Integer;
    101   oldcon: String;
    102 begin
    103   oldcon := combo_connection.Items.Strings[combo_connection.ItemIndex];
     105begin
    104106  combo_connection.ItemIndex := -1;
    105107  combo_connection.Items.Clear;
    106   if Length(DataConnections) > 0 then
    107   begin
    108     for i := 0 to High(DataConnections) do
     108  if ConManager.Count > 0 then
     109  begin
     110    for i := 0 to ConManager.Count - 1 do
    109111    begin
    110       level := DataConnections[i].LevelInfo.LevelNumber;
    111       fn := ExtractFileName(DataConnections[i].FileName);
    112       if DataConnections[i].Backend = ODB_Dat then
     112      level := ConManager.ConnectionByIndex[i].LevelNumber;
     113      fn := ExtractFileName(ConManager.ConnectionByIndex[i].FileName);
     114      if ConManager.ConnectionByIndex[i].Backend = DB_ONI then
    113115        datatype := 'ONI-.dat: '
    114       else if DataConnections[i].Backend = ODB_ADB then
     116      else if ConManager.ConnectionByIndex[i].Backend = DB_ADB then
    115117        datatype := 'OUP-DB: '
    116118      else
     
    118120      boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ')';
    119121      combo_connection.Items.Add(boxstring);
    120       if oldcon = boxstring then
     122      if ConManager.ConnectionByIndex[i].ConnectionID = FConnectionID then
    121123        combo_connection.ItemIndex := combo_connection.Items.Count - 1;
    122124    end;
     
    129131  else
    130132  begin
    131     FConnection := nil;
     133    FConnectionID := 0;
    132134    filelist.Items.Clear;
    133135    combo_extension.Items.Clear;
    134136    combo_connectionChange(Self);
    135     FSelectedFile := GetEmptyFileInfo;
     137    FSelectedFile.ID := -1;
    136138    if Assigned(FOnNewFileSelected) then
    137139      FOnNewFileSelected(FSelectedFile);
     
    139141end;
    140142
    141 procedure TForm_ToolTemplate.RecreateList;
    142 var
    143   i: Integer;
    144   fn, datatype: String;
    145   level: Integer;
    146 begin
    147   combo_connection.Items.Clear;
    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;
    173 end;
    174 
    175143procedure TForm_ToolTemplate.RecreateExtList;
    176144var
    177   i:    LongWord;
    178   exts: TStringArray;
     145  i:    Integer;
     146  exts: TStrings;
    179147begin
    180148  combo_extension.Items.Clear;
    181   if FConnection <> nil then
     149  if FConnectionID > -1 then
    182150  begin
    183151    combo_extension.Items.Add('_All files_ (' +
    184       IntToStr(FConnection.GetFilesCount) + ')');
    185     exts := FConnection.GetExtensionsList;
    186     for i := 0 to High(exts) do
     152      IntToStr(ConManager.Connection[FConnectionID].GetFileCount) + ')');
     153    exts := ConManager.Connection[FConnectionID].GetExtensionsList(EF_ExtCount);
     154    for i := 0 to exts.Count - 1 do
    187155      if Length(FAllowedExts) > 0 then
    188156      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
    194         combo_extension.Items.Add(exts[i]);
     157        if Pos(MidStr(exts.Strings[i],1,4), FAllowedExts) > 0 then
     158          combo_extension.Items.Add(exts.Strings[i]);
     159      end
     160      else
     161        combo_extension.Items.Add(exts.Strings[i]);
    195162    combo_extension.ItemIndex := 0;
    196163    combo_extensionClick(Self);
     164    exts.Free;
    197165  end;
    198166end;
     
    206174  no_zero_bytes: Boolean;
    207175  pattern: String;
    208   files: TStringArray;
    209   i: LongWord;
    210 begin
    211   if FConnection <> nil then
     176  files: TStrings;
     177  i: Integer;
     178begin
     179  if FConnectionID > -1 then
    212180  begin
    213181    Extension := MidStr(combo_extension.Items.Strings[combo_extension.ItemIndex], 1, 4);
     
    222190        Extension := '';
    223191
    224     files := FConnection.GetFilesList(extension, pattern, no_zero_bytes, FSortBy);
     192    files := ConManager.Connection[FConnectionID].GetFilesList(extension, pattern, no_zero_bytes, FSortBy);
    225193
    226194    filelist.Visible := False;
    227195    filelist.Items.Clear;
    228     if Length(files) > 0 then
    229       for i := 0 to High(files) do
    230         filelist.Items.Add(files[i]);
     196    if files.Count > 0 then
     197      filelist.Items.AddStrings(files);
    231198    filelist.Visible := True;
    232199  end;
     
    239206  ext: String;
    240207begin
    241   id := FConnection.ExtractFileID(filelist.Items.Strings[filelist.ItemIndex]);
     208  id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]);
    242209  ext := RightStr(filelist.Items.Strings[filelist.ItemIndex], 4);
    243210  exportd.Filter := 'Files of matching extension (*.' + ext + ')|*.' + ext + '|All files|*.*';
    244211  exportd.DefaultExt := ext;
    245212  if exportd.Execute then
    246     ExportDatFile(FConnection, id, exportd.FileName);
     213    ExportDatFile(FConnectionID, id, exportd.FileName);
    247214end;
    248215
     
    252219  finfo: TFileInfo;
    253220  fs: TFileStream;
    254   data: TData;
    255 begin
    256   id := FConnection.ExtractFileID(filelist.Items.Strings[filelist.ItemIndex]);
    257   finfo := FConnection.GetFileInfo(id);
     221begin
     222  id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]);
     223  finfo := ConManager.Connection[FConnectionID].GetFileInfo(id);
    258224
    259225  importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' +
     
    268234        'Size of chosen file: ' + FormatFileSize(fs.Size))
    269235    else begin
    270       SetLength(data, fs.Size);
    271       fs.Read(data[0], fs.Size);
    272       FConnection.UpdateDatFile(id, data);
     236      ConManager.Connection[FConnectionID].UpdateDatFile(id, fs);
    273237      Self.listClick(Self);
    274238    end;
     
    283247begin
    284248  sender_name := TComponent(Sender).Name;
    285   id := FConnection.ExtractFileID(filelist.Items.Strings[filelist.ItemIndex]);
     249  id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]);
    286250  context := MidStr(sender_name, Pos('_', sender_name) + 1, Length(sender_name) - Pos('_', sender_name));
    287   Form_Main.open_child(context, FConnection, id);
     251  Form_Main.open_child(context, FConnectionID, id);
    288252end;
    289253
     
    295259begin
    296260  if combo_connection.ItemIndex >= 0 then
    297   begin
    298     name := combo_connection.Items.Strings[combo_connection.ItemIndex];
    299     nstart := Pos(' ', name) + 1;
    300     nend := Pos('(', name) - 1;
    301     name := MidStr(name, nstart, nend - nstart);
    302 
    303     for i := 0 to High(DataConnections) do
    304     begin
    305       if ExtractFileName(DataConnections[i].FileName) = name then
    306       begin
    307         FConnection := DataConnections[i];
    308         Break;
    309       end;
    310     end;
    311     if i = Length(DataConnections) then
    312       FConnection := nil;
    313 
    314     RecreateExtList;
    315     if Assigned(FOnNewConnection) then
    316       FOnNewConnection(FConnection);
    317   end;
     261    FConnectionID := combo_connection.ItemIndex
     262  else
     263    FConnectionID := -1;
     264  RecreateExtList;
     265  if Assigned(FOnNewConnection) then
     266    FOnNewConnection(FConnectionID);
    318267end;
    319268
     
    330279begin
    331280  inherited;
    332   RecreateList;
    333   FSelectedFile := GetEmptyFileInfo;
     281  Self.Width  := 260;
     282  Self.Height := 300;
     283  FAllowedExts := '';
     284  FAllowMultiSelect := False;
     285  FOnNewFileSelected := nil;
     286  FOnNewConnection := nil;
     287  FOnCheckCloseable := nil;
     288  FConnectionID := -1;
     289  FSelectedFile.ID := -1;
     290  UpdateConList;
    334291  if Length(ToolList) > 0 then
    335292  begin
     
    368325begin
    369326  if btn_sort_id_asc.Down then
    370     FSortBy := stIDAsc
     327    FSortBy := ST_IDAsc
    371328  else if btn_sort_id_desc.Down then
    372     FSortBy := stIDDesc
     329    FSortBy := ST_IDDesc
    373330  else if btn_sort_name_asc.Down then
    374     FSortBy := stNameAsc
     331    FSortBy := ST_NameAsc
    375332  else if btn_sort_name_desc.Down then
    376     FSortBy := stNameDesc
     333    FSortBy := ST_NameDesc
    377334  else if btn_sort_ext_asc.Down then
    378     FSortBy := stExtAsc
     335    FSortBy := ST_ExtAsc
    379336  else if btn_sort_ext_desc.Down then
    380     FSortBy := stExtDesc;
     337    FSortBy := ST_ExtDesc;
    381338  LoadFileNames;
    382339end;
     
    394351  if filelist.ItemIndex > -1 then
    395352  begin
    396     fileid := FConnection.ExtractFileID(
     353    fileid := ConManager.Connection[FConnectionID].ExtractFileIDOfName(
    397354          filelist.Items.Strings[filelist.ItemIndex]);
    398     FSelectedFile := FConnection.GetFileInfo(fileid);
     355    FSelectedFile := ConManager.Connection[FConnectionID].GetFileInfo(fileid);
    399356    if Assigned(FOnNewFileSelected) then
    400357      FOnNewFileSelected(FSelectedFile);
     
    415372
    416373
    417 procedure TForm_ToolTemplate.SelectFileID(connection: TOniData; id: Integer);
    418 var
    419   i: Integer;
    420   name: String;
    421   nstart, nend: Integer;
    422 begin
    423   for i := 0 to combo_connection.Items.Count - 1 do
    424   begin
    425     name := combo_connection.Items.Strings[i];
    426     nstart := Pos(' ', name) + 1;
    427     nend := Pos('(', name) - 1;
    428     name := MidStr(name, nstart, nend - nstart);
    429 
    430     if ExtractFileName(connection.FileName) = name then
    431     begin
    432       combo_connection.ItemIndex := i;
    433       combo_connectionChange(Self);
    434     end;
    435   end;
     374procedure TForm_ToolTemplate.SelectConnection(ConnectionID: Integer);
     375begin
     376  if FConnectionID <> ConnectionID then
     377  begin
     378    combo_connection.ItemIndex := ConManager.ConnectionIndexByID[ConnectionID];
     379    combo_connectionChange(Self);
     380  end;
     381end;
     382
     383procedure TForm_ToolTemplate.SelectFileID(ConnectionID, FileID: Integer);
     384var
     385  i: Integer;
     386begin
     387  if FConnectionID <> ConnectionID then
     388    SelectConnection(ConnectionID);
    436389
    437390  filelist.ItemIndex := -1;
    438391  if filelist.Items.Count > 0 then
    439392    for i := 0 to filelist.Items.Count - 1 do
    440       if FConnection.ExtractFileID(filelist.Items.Strings[i]) = id then
     393      if ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]) = FileID then
    441394      begin
    442395        filelist.ItemIndex := i;
     
    446399end;
    447400
    448 procedure TForm_ToolTemplate.SelectFileName(connection: TOniData; filename: String);
    449 var
    450   i: Integer;
    451   name: String;
    452   nstart, nend: Integer;
    453 begin
    454   for i := 0 to combo_connection.Items.Count - 1 do
    455   begin
    456     name := combo_connection.Items.Strings[i];
    457     nstart := Pos(' ', name) + 1;
    458     nend := Pos('(', name) - 1;
    459     name := MidStr(name, nstart, nend - nstart);
    460 
    461     if ExtractFileName(connection.FileName) = name then
    462     begin
    463       combo_connection.ItemIndex := i;
    464       combo_connectionChange(Self);
    465     end;
    466   end;
     401procedure TForm_ToolTemplate.SelectFileName(ConnectionID: Integer; filename: String);
     402var
     403  i: Integer;
     404begin
     405  if FConnectionID <> ConnectionID then
     406    SelectConnection(ConnectionID);
    467407
    468408  filelist.ItemIndex := -1;
     
    519459
    520460
    521 procedure TForm_ToolTemplate.FormCreate(Sender: TObject);
    522 begin
    523   Self.Width  := 260;
    524   Self.Height := 300;
    525   FOnNewFileSelected := nil;
    526   FOnNewConnection := nil;
    527   FAllowedExts := '';
    528   FAllowMultiSelect := False;
     461function TForm_ToolTemplate.GetToolCloseable: Boolean;
     462begin
     463  if Assigned(FOnCheckCloseable) then
     464    Result := FOnCheckCloseable
     465  else
     466    Result := True;
    529467end;
    530468
  • oup/rewrite/Tools/TxmpReplace.pas

    r93 r97  
    44  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    55  Dialogs, Template, StdCtrls, ExtCtrls,
    6   Functions, Data, OniImgClass, Menus, Buttons;
     6  Functions, Data, OniImgClass, Menus, Buttons, TypeDefs;
    77
    88type
     
    4141implementation
    4242{$R *.dfm}
    43 uses Main, OniDataClass;
     43uses Main, ConnectionManager;
    4444
    4545
     
    4747procedure TForm_TxmpReplace.SelectFile(fileinfo: TFileInfo);
    4848var
    49   Data: Tdata;
     49  Data: TByteData;
    5050  mem:  TMemoryStream;
    5151  fadingbyte, depthbyte, storebyte: Byte;
Note: See TracChangeset for help on using the changeset viewer.