installer/UnitInstall.pas
changeset 169 314eb459448e
parent 126 b072ae770357
child 171 543d38a38bda
     1.1 --- a/installer/UnitInstall.pas	Wed Dec 28 00:08:15 2005 +0000
     1.2 +++ b/installer/UnitInstall.pas	Wed Dec 28 00:09:55 2005 +0000
     1.3 @@ -13,7 +13,7 @@
     1.4  procedure AddNotFound;
     1.5  procedure DownloadFile(eFile: String; eDestination: String);
     1.6  
     1.7 -procedure BasicInstallation(ePath: String; SteamInstall: Boolean; OS: TOS);
     1.8 +procedure BasicInstallation(ePath: String; SteamInstall, ListenInstall: Boolean; OS: TOS);
     1.9  procedure InstallDedicated(eModPath: String; UseSteam: Boolean);
    1.10  procedure InstallListen(ePath: String);
    1.11  procedure InstallCustom(ePath: String; eOS: TOS);
    1.12 @@ -218,13 +218,13 @@
    1.13  
    1.14  { Basic Installation }   
    1.15  
    1.16 -procedure BasicInstallation(ePath: String; SteamInstall: Boolean; OS: TOS);
    1.17 +procedure BasicInstallation(ePath: String; SteamInstall, ListenInstall: Boolean; OS: TOS);
    1.18  var eStr: TStringList;
    1.19      i: integer;
    1.20      CopyConfig: Boolean;
    1.21      eFound: Boolean;
    1.22  begin
    1.23 -  frmMain.ggeAll.MaxValue := 7;
    1.24 +  frmMain.ggeAll.MaxValue := 8;
    1.25    frmMain.ggeAll.Progress := 0;
    1.26    frmMain.ggeItem.MaxValue := 1;
    1.27    frmMain.ggeItem.Progress := 0;
    1.28 @@ -257,8 +257,9 @@
    1.29    AddDone;
    1.30    frmMain.ggeAll.Progress := 2;
    1.31    frmMain.ggeItem.Progress := 1;
    1.32 -  { Check for installation }
    1.33 +  { Check for installation / Create directories }
    1.34    CopyConfig := True;
    1.35 +  AddStatus('Creating directories...', clBlack);
    1.36    if DirectoryExists(ePath + 'addons\metamod\bin') then begin
    1.37      case MessageBox(frmMain.Handle, 'A Metamod:Source installation was already detected. If you choose to reinstall, your configuration files will be erased. Click Yes to continue, No to Upgrade, or Cancel to abort the install.', PChar(frmMain.Caption), MB_ICONQUESTION + MB_YESNOCANCEL) of
    1.38        mrNo: CopyConfig := False;
    1.39 @@ -267,16 +268,13 @@
    1.40          exit;
    1.41        end;
    1.42      end;
    1.43 -  end;
    1.44 -  AddStatus('Creating directories...', clBlack);
    1.45 -  if not eFound then begin
    1.46 -    { Create directories }
    1.47 +    AddSkipped;
    1.48 +  end
    1.49 +  else begin
    1.50      frmMain.ggeItem.Progress := 0;
    1.51      ForceDirectories(ePath + 'addons\metamod\bin');
    1.52      AddDone;
    1.53 -  end
    1.54 -  else
    1.55 -    AddSkipped;
    1.56 +  end;
    1.57    frmMain.ggeItem.Progress := 1;
    1.58    frmMain.ggeAll.Progress := 3;
    1.59  
    1.60 @@ -322,9 +320,9 @@
    1.61            break;
    1.62          end;
    1.63        end;
    1.64 -      FileSetAttr(ePath + 'gameinfo.txt', 0);
    1.65 +      SetFileAttributes(PChar(ePath + 'gameinfo.txt'), 0);
    1.66        eStr.SaveToFile(ePath + 'gameinfo.txt');
    1.67 -      FileSetAttr(ePath + 'gameinfo.txt', faReadOnly); // important for listen servers
    1.68 +      SetFileAttributes(PChar(ePath + 'gameinfo.txt'), faReadOnly); // important for listen servers
    1.69        AddDone;
    1.70      end
    1.71      else
    1.72 @@ -340,21 +338,30 @@
    1.73    AddDone;
    1.74    frmMain.ggeItem.Progress := 1;
    1.75    frmMain.ggeAll.Progress := 6;
    1.76 +  if ListenInstall then begin
    1.77 +    ePath := ExtractFilePath(Copy(ePath, 1, Length(ePath)-1));
    1.78 +    AddStatus('Copying hl2launch.exe...', clBlack);
    1.79 +    CopyFile(PChar(ExtractFilePath(ParamStr(0)) + 'hl2launch.exe'), PChar(ePath + 'hl2launch.exe'), False);
    1.80 +    AddDone;
    1.81 +  end;
    1.82    { Remove files }
    1.83    frmMain.ggeItem.Progress := 0;
    1.84    AddStatus('Removing temporary files...', clBlack);
    1.85 +  DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'hl2launch.exe'));
    1.86    DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'server.dll'));
    1.87    DeleteFile(PChar(ExtractFilePath(ParamStr(0)) + 'server_i486.so'));
    1.88    AddDone;
    1.89    frmMain.ggeItem.Progress := 1;
    1.90 -  frmMain.ggeAll.Progress := 7;
    1.91 +  frmMain.ggeAll.Progress := 8;
    1.92    { Finish }
    1.93    AddStatus('', clBlack, False);
    1.94    AddStatus('Finished installation!', clBlack, False);
    1.95    frmMain.cmdNext.Enabled := True;
    1.96    frmMain.cmdCancel.Hide;
    1.97 +  Screen.Cursor := crDefault;
    1.98  
    1.99 -  Screen.Cursor := crDefault;
   1.100 +  if ListenInstall then
   1.101 +    MessageBox(frmMain.Handle, PChar('hl2launch.exe has been copied to ' + ePath + '. Start it if you want to use Metamod:Source on your listen server, default starts won''t work.'), PChar(Application.Title), MB_ICONINFORMATION); 
   1.102  end;
   1.103  
   1.104  { Dedicated Server }
   1.105 @@ -364,7 +371,7 @@
   1.106    StartTime := Now;
   1.107    Screen.Cursor := crHourGlass;
   1.108    AddStatus('Starting Metamod:Source installation on dedicated server...', clBlack, False);
   1.109 -  BasicInstallation(eModPath, UseSteam, osWindows);
   1.110 +  BasicInstallation(eModPath, UseSteam, False, osWindows);
   1.111  end;
   1.112  
   1.113  { Listen Server }
   1.114 @@ -374,7 +381,7 @@
   1.115    StartTime := Now;
   1.116    Screen.Cursor := crHourGlass;
   1.117    AddStatus('Starting Metamod:Source installation on the listen server...', clBlack);
   1.118 -  BasicInstallation(ePath, True, osWindows);
   1.119 +  BasicInstallation(ePath, True, True, osWindows);
   1.120  end;
   1.121  
   1.122  { Custom mod }
   1.123 @@ -384,7 +391,7 @@
   1.124    StartTime := Now;
   1.125    Screen.Cursor := crHourGlass;
   1.126    AddStatus('Starting Metamod:Source installation...', clBlack);
   1.127 -  BasicInstallation(ePath, False, eOS);
   1.128 +  BasicInstallation(ePath, False, False, eOS);
   1.129  end;
   1.130  
   1.131  { FTP }
   1.132 @@ -407,10 +414,7 @@
   1.133  label UploadAgain;
   1.134  var eStr: TStringList;
   1.135      i: integer;
   1.136 -    ePath: String;
   1.137 -    CurNode: TTreeNode;
   1.138      CopyConfig, eFound: Boolean;
   1.139 -    eGoBack: Boolean;
   1.140  begin
   1.141    frmMain.cmdCancel.Show;
   1.142    frmMain.cmdNext.Hide;