; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

[Setup]
AppName=Natural Selection
AppVerName=Natural Selection 3.1
AppPublisher=Unknown Worlds Entertainment
AppPublisherURL=http://www.unknownworlds.com
AppSupportURL=http://www.unknownworlds.com/ns/view?action=manual
AppUpdatesURL=http://www.unknownworlds.com/ns/view?action=files
DefaultDirName={code:MyDir}
DisableDirPage=no
DefaultGroupName=Natural Selection
DisableProgramGroupPage=yes
WizardImageFile=v:\install\images\LrgImage.bmp
WizardSmallImageFile=v:\install\images\SmlImage.bmp

[Files]
;Source: "v:\install\config\config.cfg"; DestDir: {app}\nsp\; Flags: confirmoverwrite
;Source: "v:\install\ns\*.*"; DestDir: "{app}\nsp"; Flags: ignoreversion recursesubdirs
Source: "v:\install\ns-diff\*.*"; DestDir: "{app}\nsp"; Flags: ignoreversion recursesubdirs
;Source: "E:\ns21install\fmod.dll"; DestDir: "{app}"; Flags: ignoreversion

[Run]
;Filename: "{app}\nsp\xfire_installer.exe"; Description: "Xfire is the Instant Messenger for gamers.  See when, where, and what games (Natural Selection and over 75 others) your friends are playing and join them with one click.  It's free.  Install now?"; Flags: postinstall

[Code]
function GetSteamDir(): String;
var
   sPrevPath: String;
begin
  sPrevPath := '';
  RegQueryStringValue( HKCU, 'Software\Valve\Steam','ModInstallPath', sPrevpath);
  Result := sPrevPath;
end;

function GetWonDir(): String;
var
   sPrevPath: String;
begin
  sPrevPath := '';
  RegQueryStringValue( HKCU, 'Software\Valve\Half-Life','InstallPath', sPrevpath);
  Result := sPrevPath;
end;

function MyDir(Default: String): String;
var
    sPath : String;
begin
  sPath := GetSteamDir();
  if (Length(sPath) < 1) then
  begin
    sPath := GetWonDir();
  end;
  Result := sPath;
end;

function InitializeSetup(): Boolean;
var
    sSteamPath: String;
    sWonPath: String;
    bResult: Boolean;
    mbResult: Integer;
begin
  bResult:=true;
  // if ( CheckForMutexes('__SteamBootstrapperApp__')) then
  //begin
  //  MsgBox( 'STEAM is currently running, please stop STEAM before running this setup.' , mbInformation, MB_OK );
  //  bResult := false;
  //end;
  sSteamPath := GetSteamDir();
  sWonPath := GetWonDir();
  if ((Length(sSteamPath) < 1) and (Length(sWonPath) < 1) and bResult) then
  begin
      mbResult := MsgBox( 'Setup has not detected a valid Steam or Half-Life (WON) install. Do you wish to continue?.' , mbConfirmation, MB_YESNO);
      if (mbResult = idNo) then
      begin
        bResult := false;
      end;
  end;
  Result := bResult;
end;