Changeset 86 for oup/current/Main.pas


Ignore:
Timestamp:
Jan 14, 2007, 9:19:08 PM (18 years ago)
Author:
alloc
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • oup/current/Main.pas

    r84 r86  
    7575    tb_opendb: TTBItem;
    7676    Images_Close: TImageList;
     77    procedure UpdateConLists;
    7778    procedure LoadFile(typedb: Boolean);
    7879    function TryCloseAll: Boolean;
     
    154155  else if MidStr(ParamStr(1), 1, 4) = 'oldb' then
    155156  begin
    156     if not CreateDataConnection(ParamStr(2), ODB_ADB) then
     157    if CreateDataConnection(ParamStr(2), ODB_ADB) = nil then
    157158      ShowMessage('Error while loading the file:' + CrLf + ParamStr(
    158159        2) + CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?');
     
    160161  else if MidStr(ParamStr(1), 1, 3) = 'dat' then
    161162  begin
    162     if not CreateDataConnection(ParamStr(2), ODB_Dat) then
     163    if CreateDataConnection(ParamStr(2), ODB_Dat) = nil then
    163164      ShowMessage('Error while loading the file:' + CrLf + ParamStr(
    164165        2) + CrLf + 'Perhaps not an Oni-.dat-file?');
     
    263264  pt.Y := Y;
    264265  tabIndex := MDITab.GetTabAtPos(pt);
    265   if (Button = mbRight) and (tabIndex >= 0) then
    266     MDITab.MDIChildren[tabIndex].Close;
     266
     267//  if (Button = mbRight) and (tabIndex >= 0) then
     268//    MDITab.MDIChildren[tabIndex].Close;
    267269
    268270  if (Button = mbLeft) and (tabIndex >= 0) then
     
    309311procedure TForm_Main.UpdateStatBar;
    310312begin
    311   if Assigned(OniDataConnection) then
    312   begin
    313     Self.Caption      := 'Oni Un/Packer ' + version + ' (' + ExtractFileName(
    314       OniDataConnection.FileName) + ')';
     313  if Length(DataConnections) > 0 then
     314  begin
     315    Self.Caption      := 'Oni Un/Packer ' + version;
    315316    ActivateTools(True);
    316     statbar.Panels.Items[1].Text := 'Files: ' + IntToStr(OniDataConnection.GetFilesCount);
    317     statbar.Panels.Items[2].Text :=
    318       'Extensions: ' + IntToStr(Length(OniDataConnection.GetExtensionsList));
    319     case OniDataConnection.Backend of
    320       ODB_Dat:
    321         begin
    322           statbar.Panels.Items[0].Text := '.dat loaded: ' + OniDataConnection.FileName;
    323         end;
    324       ODB_ADB:
    325         begin
    326           statbar.Panels.Items[0].Text := 'OLDB loaded: ' + OniDataConnection.FileName;
    327         end;
    328     else
    329       Self.Caption      := 'Oni Un/Packer ' + version;
    330       statbar.Panels.Items[0].Text := 'Nothing loaded';
    331       statbar.Panels.Items[1].Text := 'Files: -';
    332       statbar.Panels.Items[2].Text := 'Extensions: -';
    333       ActivateTools(False);
    334     end;
     317    statbar.Panels.Items[1].Text := 'Connections: ' + IntToStr(Length(DataConnections));
    335318  end
    336319  else
     
    380363
    381364
     365procedure TForm_Main.UpdateConLists;
     366var
     367  i: Integer;
     368begin
     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;
     372end;
     373
    382374
    383375procedure TForm_Main.LoadFile(typedb: Boolean);
     
    385377  ext: String;
    386378begin
    387   if TryCloseAll then
    388   begin
    389     CloseDataConnection;
    390     opend.InitialDir := AppSettings.DatPath;
    391     opend.Filter     := 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP level database (*.oldb)|*.oldb|Any (*.*)|*';
    392     if typedb then
    393       opend.FilterIndex := 3
    394     else
    395       opend.FilterIndex := 2;
    396     if opend.Execute then
     379  opend.InitialDir := AppSettings.DatPath;
     380  opend.Filter     := 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP level database (*.oldb)|*.oldb|Any (*.*)|*';
     381  if typedb then
     382    opend.FilterIndex := 3
     383  else
     384    opend.FilterIndex := 2;
     385  if opend.Execute then
     386  begin
     387    ext := ExtractFileExt(opend.FileName);
     388    if ext = '.dat' then
    397389    begin
    398       ext := ExtractFileExt(opend.FileName);
    399       if ext = '.dat' then
    400       begin
    401         if not CreateDataConnection(opend.FileName, ODB_Dat) then
    402           ShowMessage('Error while loading the file:' + CrLf + opend.FileName +
    403             CrLf + 'Perhaps not an Oni-.dat-file?');
    404       end else if ext = '.oldb' then
    405       begin
    406         if not CreateDataConnection(opend.FileName, ODB_ADB) then
    407           ShowMessage('Error while loading the file:' + CrLf + opend.FileName +
    408             CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?');
    409       end else
    410         ShowMessage('Incompatible file');
    411       AppSettings.DatPath := ExtractFilepath(opend.FileName);
    412     end;
     390      if CreateDataConnection(opend.FileName, ODB_Dat) <> nil then
     391        UpdateConLists;
     392    end else if ext = '.oldb' then
     393    begin
     394      if CreateDataConnection(opend.FileName, ODB_ADB) <> nil then
     395        UpdateConLists;
     396    end else
     397      ShowMessage('Incompatible file');
     398    AppSettings.DatPath := ExtractFilepath(opend.FileName);
    413399  end;
    414400  UpdateStatBar;
     
    451437procedure TForm_Main.menu_createdbClick(Sender: TObject);
    452438begin
    453   if Assigned(OniDataConnection) then
     439{  if Assigned(OniDataConnection) then
    454440    if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' +
    455441          'Do you want to close it to continue?'), PChar('Close file?'),
     
    470456    if saved.Execute then
    471457      Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName);
    472 end;
     458}end;
    473459
    474460
     
    477463procedure TForm_Main.menu_createlvlClick(Sender: TObject);
    478464begin
    479   if Assigned(OniDataConnection) then
     465{  if Assigned(OniDataConnection) then
    480466    if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' +
    481467          'Do you want to close it to continue?'), PChar('Close file?'),
     
    496482    if saved.Execute then
    497483      Form_LevelDB.CreateLevel(opend.FileName, saved.FileName);
    498 end;
     484}end;
    499485
    500486 {#################################}
Note: See TracChangeset for help on using the changeset viewer.