
////////////////////////////////////////////////////////////////////////////////
//
//  IIIIIII SSSSSS
//    II    SS                          InstallShield (R)
//    II    SSSSSS      (c) 1996-2000, InstallShield Software Corporation
//    II        SS      (c) 1990-1996, InstallShield Corporation
//  IIIIIII SSSSSS                     All Rights Reserved.
//
//
//  This code is generated as a starting setup template.  You should
//  modify it to provide all necessary steps for your setup.
//
//
//    File Name:  Setup.rul
//
//  Description:  InstallShield script
//
//     Comments:  This template script performs a basic setup. With minor
//                modifications, this template can be adapted to create
//                new, customized setups.
//
////////////////////////////////////////////////////////////////////////////////


// Include header files

#include "ifx.h" //DO NOT REMOVE

////////////////////// string defines ////////////////////////////

//////////////////// installation declarations ///////////////////

// ---- globals ----
// we don't need full/non-full information
// only the following are used for UI

NUMBER DO_CORE_BOOL;
NUMBER DO_NIGHTLY_BOOL;

// Q3
NUMBER DO_GAME_Q3_BOOL;
// per-game package global config
STRING  szDIR_GAME_Q3, szDIR_GAMETOOLS_Q3;

// Wolf
NUMBER DO_GAME_WOLF_BOOL;
STRING szDIR_GAME_WOLF, szDIR_GAMETOOLS_WOLF;

// JKII
NUMBER DO_GAME_JKII_BOOL;
STRING szDIR_GAME_JKII, szDIR_GAMETOOLS_JKII;

// STVEF
NUMBER DO_GAME_STVEF_BOOL;
STRING szDIR_GAME_STVEF, szDIR_GAMETOOLS_STVEF;

// SOF2
NUMBER DO_GAME_SOF2_BOOL;
STRING szDIR_GAME_SOF2, szDIR_GAMETOOLS_SOF2;

// Halflife
NUMBER DO_GAME_HALFLIFE_BOOL;
NUMBER DO_GAME_CSTRIKE_BOOL; // only used for .game generation
STRING szDIR_GAME_HALFLIFE, szDIR_GAMETOOLS_HALFLIFE;

// ET
NUMBER DO_GAME_ET_BOOL;
STRING szDIR_GAME_ET, szDIR_GAMETOOLS_ET;

// Quake
NUMBER DO_GAME_Q1_BOOL;
STRING szDIR_GAME_Q1, szDIR_GAMETOOLS_Q1;

// JA
NUMBER DO_GAME_JA_BOOL;
STRING szDIR_GAME_JA, szDIR_GAMETOOLS_JA;

// Q2
NUMBER DO_GAME_Q2_BOOL;
STRING szDIR_GAME_Q2, szDIR_GAMETOOLS_Q2;

// HER2
NUMBER DO_GAME_HER2_BOOL;
STRING szDIR_GAME_HER2, szDIR_GAMETOOLS_HER2;

// ---- script function prototypes -----


// your script function prototypes
prototype ReadInfoList(LIST);

function ReadInfoList(svInfoList)
	STRING svLine;
	NUMBER nFlag, nvFileHandle;

begin
	OpenFileMode(FILE_MODE_NORMAL);
	OpenFile(nvFileHandle, SUPPORTDIR, "infolist.txt");
	while (nFlag = 0)
		nFlag = GetLine(nvFileHandle, svLine);
		ListAddString(svInfoList, svLine, AFTER);
	endwhile;
	CloseFile(nvFileHandle);
end;



//////////////////////////////////////////////////////////////////////////////
//
//  FUNCTION:   OnFirstUIBefore
//
//  EVENT:      FirstUIBefore event is sent when installation is run for the first
//              time on given machine. In the handler installation usually displays
//              UI allowing end user to specify installation parameters. After this
//              function returns, ComponentTransferData is called to perform file
//              transfer.
//
///////////////////////////////////////////////////////////////////////////////
function OnFirstUIBefore()
    NUMBER  nRegKey,nRegKeySize,nKeyType;
    STRING  szRegKey, szQuake3, szJKII, szSTVEF, szSOF2, szRTCW, szHL, szCStrike, szET, szQ1, szJA, szQ2, szHER2;
    NUMBER  nResult,nSetupType;
    STRING  szTitle, szMsg;
    STRING  szLicenseFile, szQuestion;
    STRING  szTargetPath;
    STRING  szDir, szSubDir;
    STRING  szfolder;
    STRING  szComponents, szTargetdir;
    STRING  svSetupType;
    NUMBER  nLevel;
    LIST    listStartCopy, listInfoList;
    NUMBER  nvSize;
    STRING  DEFAULTJKIIDIR;
    STRING  DEFAULTSTVEFDIR;
    STRING  DEFAULTSOF2DIR;
    STRING  DEFAULTRTCWDIR;
    STRING  DEFAULTHALFLIFEDIR;
    STRING  DEFAULTETDIR;
    STRING  DEFAULTQ1DIR;
    STRING  DEFAULTJADIR;
begin

// config
// some defaults
szSubDir = "Radiant-1.<<RADIANT_MAJOR>>";

// template
DO_CORE_BOOL = <<DO_CORE_BOOL>>;
DO_NIGHTLY_BOOL = <<DO_NIGHTLY_BOOL>>;
DO_GAME_Q3_BOOL = <<DO_GAME_Q3_BOOL>>;
DO_GAME_WOLF_BOOL = <<DO_GAME_WOLF_BOOL>>;
DO_GAME_JKII_BOOL = <<DO_GAME_JKII_BOOL>>;
DO_GAME_STVEF_BOOL = <<DO_GAME_STVEF_BOOL>>;
DO_GAME_SOF2_BOOL = <<DO_GAME_SOF2_BOOL>>;
DO_GAME_HALFLIFE_BOOL = <<DO_GAME_HALFLIFE_BOOL>>;
DO_GAME_ET_BOOL = <<DO_GAME_ET_BOOL>>;
DO_GAME_Q1_BOOL = <<DO_GAME_Q1_BOOL>>;
DO_GAME_JA_BOOL = <<DO_GAME_JA_BOOL>>;
DO_GAME_Q2_BOOL = <<DO_GAME_Q2_BOOL>>;
DO_GAME_HER2_BOOL = <<DO_GAME_HER2_BOOL>>;
// common stuff

  // TO DO: if you want to enable background, window title, and caption bar title
  // SetTitle( @TITLE_MAIN, 24, WHITE );
  // SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION );
  // Enable( FULLWINDOWMODE );
  // Enable( BACKGROUND );
  // SetColor(BACKGROUND,RGB (0, 128, 128);

Dlg_Start:
  // beginning of dialogs label

Dlg_SdWelcome:
  szTitle = "";
  szMsg   = "";
  nResult = SdWelcome( szTitle, szMsg );
  if (nResult = BACK) goto Dlg_Start;

Dlg_SdLicense:
  szLicenseFile = SUPPORTDIR ^ "license.txt";
  szTitle    = "";
  szMsg      = "";
  szQuestion = "";
  nResult    = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile );
  if (nResult = BACK) goto Dlg_SdWelcome;

Dlg_SdShowInfoList:
  szTitle		= "Information\nLatest " + @PRODUCT_NAME + " project information.";
  szMsg		= "";
  listInfoList = ListCreate( STRINGLIST );
  ReadInfoList(listInfoList);
  // sdShowInfoList dialog customised in _IsUser.dll
  nResult     = SdShowInfoList( szTitle, szMsg, listInfoList );
  if (nResult = BACK) goto Dlg_SdLicense;

  // TODO TTimo: prompt for what is in the setup and what the user wants to install?
  // i.e. by component

  // core
  if (DO_CORE_BOOL == 1) then
Dlg_SdAskCorePath:
    szDir   = "C:\\Program Files\\GtkRadiant-1.<<RADIANT_MAJOR>>";
    szTitle = "Installation of " + @PRODUCT_NAME + " core files.";
    szMsg   = "Select the installation path for " + @PRODUCT_NAME + " core files.";
    nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );
    // FIXME TTimo if a setup doesn't hold the core, it prolly needs to default that
    // reading from registry for instance (if TARGETDIR init is required)
    TARGETDIR = szDir;
    ComponentSetTarget (MEDIA, "<DIR_CORE>", TARGETDIR);
    if (nResult = BACK) goto Dlg_SdShowInfoList;

  endif;

  if (DO_NIGHTLY_BOOL == 1) then
  	MessageBox ("IMPORTANT NOTE ABOUT UPDATE SETUPS:\n" + 
  	"You may be prompted about games that are not installed. This setup is a single update to all the games we support.\n" +
  	"Let the setup select the default paths, and in 'Setup Type' dialog, select custom setup and disable the updates for the games you don't have.", WARNING);
  endif;

  // ---------------------------------------------------------------------------------
  // game pack #1
  if (DO_GAME_Q3_BOOL == 1) then
Dlg_SdAskGamePath_Q3:
    // guess the default game path
    nKeyType = REGDB_STRING;
    RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
    nRegKey = RegDBGetKeyValueEx ("SOFTWARE\\Id\\Quake III Arena\\", "INSTALLPATH", nKeyType, szRegKey, nRegKeySize);
    if (nRegKey = 0) then
	  FindFile (szRegKey, "quake3.exe", szQuake3);
	  if (szQuake3 = "quake3.exe") then
	    szDIR_GAME_Q3 = szRegKey;
      else
        szDIR_GAME_Q3 = @DEFAULTQUAKE3DIR;
      endif;
    else
      szDIR_GAME_Q3 = @DEFAULTQUAKE3DIR;
    endif;

    // prompt user for game path
    szTitle = "Quake III Arena / Quake III: Team Arena and mods game package";
    szMsg   = "Select the folder where Quake III Arena is installed.\nNOTE: For compatibility purposes, your Quake III Arena folder name must contain the word \"quake\" in the top level. eg. C:\\Program Files\\Quake III Arena\n\nTo continue, click Next.";
    nResult = SdAskDestPath( szTitle, szMsg, szDIR_GAME_Q3, 0 );
    if (nResult = BACK) then
      if (DO_CORE_BOOL == 1) then
      	goto Dlg_SdAskCorePath;
      else
        goto Dlg_SdShowInfoList;
      endif;
    endif;

    // prompt user for game subdir
Dlg_SdShowDlgEdit1_Q3:
    szTitle = "Choose Folder\nEnter a folder name.";
    szMsg   = "Please enter the folder name for " + @PRODUCT_NAME + " Quake III Arena game pack in the edit field below.\nNOTE: This is for installation of the game specific files.";
    nResult = SdShowDlgEdit1 (szTitle, szMsg, "Folder", szSubDir);
    szDIR_GAMETOOLS_Q3 = szDIR_GAME_Q3 ^ szSubDir;
    if (nResult = BACK) goto Dlg_SdAskGamePath_Q3;

    // set values in components
    ComponentSetTarget (MEDIA, "<DIR_GAME_Q3>", szDIR_GAME_Q3);
    ComponentSetTarget (MEDIA, "<DIR_GAMETOOLS_Q3>", szDIR_GAMETOOLS_Q3);

  endif;

  // ---------------------------------------------------------------------------------
  // game pack #2
  if (DO_GAME_WOLF_BOOL == 1) then
Dlg_SdAskGamePath_Wolf:

    nKeyType = REGDB_STRING;
    RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
    nRegKey = RegDBGetKeyValueEx ("SOFTWARE\\Activision\\Return to Castle Wolfenstein - Game of The Year Edition\\", "INSTALLPATH", nKeyType, szRegKey, nRegKeySize);
    if (nRegKey = 0) then
      FindFile (szRegKey, "wolfmp.exe", szRTCW);
      if (szRTCW = "wolfmp.exe") then
        szDIR_GAME_WOLF = szRegKey;
      else
        szDIR_GAME_WOLF = @DEFAULTRTCWDIR;
      endif;
    else
      szDIR_GAME_WOLF = @DEFAULTRTCWDIR;
    endif;

    // prompt user for game path
    // NOTE TTimo: only required in full setup actually?
    szTitle = "Return To Castle Wolfenstein game package";
    szMsg   = "Select the folder where Return To Castle Wolfenstein is installed.";
    nResult = SdAskDestPath( szTitle, szMsg, szDIR_GAME_WOLF, 0 );
    if (nResult = BACK) then
      if (DO_GAME_Q3_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Q3;
      elseif (DO_CORE_BOOL == 1) then
      	goto Dlg_SdAskCorePath;
      else
        goto Dlg_SdShowInfoList;
      endif;
    endif;

    // prompt user for game subdir
Dlg_SdShowDlgEdit1_Wolf:
    szTitle = "Choose Folder\nEnter a folder name.";
    szMsg   = "Please enter the folder name for " + @PRODUCT_NAME + " Return to Castle Wolfenstein game pack in the edit field below.\nNOTE: This is for installation of the game specific files.";
    nResult = SdShowDlgEdit1 (szTitle, szMsg, "Folder", szSubDir);
    szDIR_GAMETOOLS_WOLF = szDIR_GAME_WOLF ^ szSubDir;
    if (nResult = BACK) goto Dlg_SdAskGamePath_Wolf;

    // set values in components
    ComponentSetTarget (MEDIA, "<DIR_GAME_WOLF>", szDIR_GAME_WOLF);
    ComponentSetTarget (MEDIA, "<DIR_GAMETOOLS_WOLF>", szDIR_GAMETOOLS_WOLF);

  endif;

  // ---------------------------------------------------------------------------------
  // game pack #3
  if (DO_GAME_JKII_BOOL == 1) then
Dlg_SdAskGamePath_JKII:

    // guess the default game path from registry
    DEFAULTJKIIDIR = "C:\\Program Files\\LucasArts\\Star Wars JK II Jedi Outcast\\GameData";
    nKeyType = REGDB_STRING;
    RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
    nRegKey = RegDBGetKeyValueEx ("SOFTWARE\\LucasArts Entertainment Company LLC\\Star Wars JK II Jedi Outcast\\1.0\\", "Install Path", nKeyType, szRegKey, nRegKeySize);
    if (nRegKey = 0) then
	  FindFile (szRegKey + "GameData", "jk2sp.exe", szJKII);
	  if (szJKII = "jk2sp.exe") then
	    szDIR_GAME_JKII = szRegKey;
      else
        szDIR_GAME_JKII = DEFAULTJKIIDIR;
      endif;
    else
      szDIR_GAME_JKII = DEFAULTJKIIDIR;
    endif;

    // prompt user for game path
    szTitle = "Jedi Knight II: Jedi Outcast game package";
    szMsg   = "Select the folder where Jedi Knight II: Jedi Outcast is installed.";
    nResult = SdAskDestPath( szTitle, szMsg, szDIR_GAME_JKII, 0 );
    if (nResult = BACK) then
      if (DO_GAME_WOLF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Wolf;
      elseif (DO_GAME_Q3_BOOL == 1) then
      	goto Dlg_SdShowDlgEdit1_Q3;
      elseif (DO_CORE_BOOL == 1) then
      	goto Dlg_SdAskCorePath;
      else
        goto Dlg_SdShowInfoList;
      endif;
    endif;

    // prompt user for game subdir
Dlg_SdShowDlgEdit1_JKII:
    szTitle = "Choose Folder\nEnter a folder name.";
    szMsg   = "Please enter the folder name for " + @PRODUCT_NAME + " Jedi Knight II: Jedi Outcast game pack in the edit field below.\nNOTE: This is for installation of the game specific files.";
    nResult = SdShowDlgEdit1 (szTitle, szMsg, "Folder", szSubDir);
    szDIR_GAMETOOLS_JKII = szDIR_GAME_JKII ^ szSubDir;
    if (nResult = BACK) goto Dlg_SdAskGamePath_JKII;

    // set values in components
    ComponentSetTarget (MEDIA, "<DIR_GAME_JKII>", szDIR_GAME_JKII);
    ComponentSetTarget (MEDIA, "<DIR_GAMETOOLS_JKII>", szDIR_GAMETOOLS_JKII);

  endif;

  // ---------------------------------------------------------------------------------
  // game pack #4
  if (DO_GAME_STVEF_BOOL == 1) then
Dlg_SdAskGamePath_STVEF:

    // guess the default game path from registry
    DEFAULTSTVEFDIR = "C:\\Program Files\\Raven\\Star Trek Voyager Elite Force\\";
    nKeyType = REGDB_STRING;
    RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
    nRegKey = RegDBGetKeyValueEx ("SOFTWARE\\Activision\\Star Trek: Voyager - Elite Force\\1.0\\", "Install Path", nKeyType, szRegKey, nRegKeySize);
    if (nRegKey = 0) then
	  FindFile (szRegKey + "GameData", "stvoy.exe", szSTVEF);
	  if (szSTVEF = "stvoy.exe") then
	    szDIR_GAME_STVEF = szRegKey;
      else
        szDIR_GAME_STVEF = DEFAULTSTVEFDIR;
      endif;
    else
      szDIR_GAME_STVEF = DEFAULTSTVEFDIR;
    endif;

    // prompt user for game path
    szTitle = "Star Trek Voyage : Elite Force game package";
    szMsg   = "Select the folder where Star Trek Voyage : Elite Force is installed.";
    nResult = SdAskDestPath( szTitle, szMsg, szDIR_GAME_STVEF, 0 );
    if (nResult = BACK) then
      if (DO_GAME_JKII_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_JKII;
      elseif (DO_GAME_WOLF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Wolf;
      elseif (DO_GAME_Q3_BOOL == 1) then
      	goto Dlg_SdShowDlgEdit1_Q3;
      elseif (DO_CORE_BOOL == 1) then
      	goto Dlg_SdAskCorePath;
      else
        goto Dlg_SdShowInfoList;
      endif;
    endif;

    // prompt user for game subdir
Dlg_SdShowDlgEdit1_STVEF:
    szTitle = "Choose Folder\nEnter a folder name.";
    szMsg   = "Please enter the folder name for " + @PRODUCT_NAME + " Star Trek Voyage : Elite Force game pack in the edit field below.\nNOTE: This is for installation of the game specific files.";
    nResult = SdShowDlgEdit1 (szTitle, szMsg, "Folder", szSubDir);
    szDIR_GAMETOOLS_STVEF = szDIR_GAME_STVEF ^ szSubDir;
    if (nResult = BACK) goto Dlg_SdAskGamePath_STVEF;

    // set values in components
    ComponentSetTarget (MEDIA, "<DIR_GAME_STVEF>", szDIR_GAME_STVEF);
    ComponentSetTarget (MEDIA, "<DIR_GAMETOOLS_STVEF>", szDIR_GAMETOOLS_STVEF);

  endif;

  // ---------------------------------------------------------------------------------  
  // game pack #5, SofII
  // ---------------------------------------------------------------------------------
  if (DO_GAME_SOF2_BOOL == 1) then
Dlg_SdAskGamePath_SOF2:
    
    // guess the default game path from registry
    DEFAULTSOF2DIR = "C:\\Program Files\\Soldier of Fortune II - Double Helix\\";
    nKeyType = REGDB_STRING;
    RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
    nRegKey = RegDBGetKeyValueEx ("SOFTWARE\\Activision\\Soldier of Fortune II - Double Helix\\", "InstallPath", nKeyType, szRegKey, nRegKeySize);
    if (nRegKey = 0) then
	  FindFile (szRegKey + "GameData", "sof2.exe", szSOF2);
	  if (szSOF2 = "sof2.exe") then
	    szDIR_GAME_SOF2 = szRegKey;
      else
        szDIR_GAME_SOF2 = DEFAULTSOF2DIR; 
      endif;
    else
      szDIR_GAME_SOF2 = DEFAULTSOF2DIR; 
    endif;
    
    // prompt user for game path
    szTitle = "Soldier of Fortune II - Double Helix game package";
    szMsg   = "Select the folder where Soldier of Fortune II - Double Helix is installed.";
    nResult = SdAskDestPath( szTitle, szMsg, szDIR_GAME_SOF2, 0 );
    if (nResult = BACK) then
      if (DO_GAME_STVEF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_STVEF;
      elseif (DO_GAME_JKII_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_JKII;
      elseif (DO_GAME_WOLF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Wolf;
      elseif (DO_GAME_Q3_BOOL == 1) then
      	goto Dlg_SdShowDlgEdit1_Q3;
      elseif (DO_CORE_BOOL == 1) then
      	goto Dlg_SdAskCorePath;
      else
        goto Dlg_SdShowInfoList;
      endif;
    endif;
    
    // prompt user for game subdir
Dlg_SdShowDlgEdit1_SOF2:
    szTitle = "Choose Folder\nEnter a folder name.";
    szMsg   = "Please enter the folder name for " + @PRODUCT_NAME + " Soldier of Fortune II - Double Helix game pack in the edit field below.\nNOTE: This is for installation of the game specific files.";
    nResult = SdShowDlgEdit1 (szTitle, szMsg, "Folder", szSubDir);
    szDIR_GAMETOOLS_SOF2 = szDIR_GAME_SOF2 ^ szSubDir;
    if (nResult = BACK) goto Dlg_SdAskGamePath_SOF2;
    
    // set values in components
    ComponentSetTarget (MEDIA, "<DIR_GAME_SOF2>", szDIR_GAME_SOF2);
    ComponentSetTarget (MEDIA, "<DIR_GAMETOOLS_SOF2>", szDIR_GAMETOOLS_SOF2);
    
  endif;

  // ---------------------------------------------------------------------------------
  // game pack #6
  // Hydra: note, for addition game packs, do NOT copy this one.
  if (DO_GAME_HALFLIFE_BOOL == 1) then
Dlg_SdAskGamePath_HALFLIFE:

    // for halflife/cs put the default in first, then override
    DEFAULTHALFLIFEDIR = "C:\\Sierra\\Half-Life\\";
    szDIR_GAME_HALFLIFE = DEFAULTHALFLIFEDIR;
    // for the .game file generation we need a flag.
    DO_GAME_CSTRIKE_BOOL = 0;

    // guess the default game path (Counter Strike Retail)
    nKeyType = REGDB_STRING;
    RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
    nRegKey = RegDBGetKeyValueEx ("SOFTWARE\\Sierra OnLine\\Setup\\CSTRIKE\\", "Directory", nKeyType, szRegKey, nRegKeySize);
    if (nRegKey = 0) then
	  FindFile (szRegKey, "cstrike.exe", szCStrike);
	  if (szCStrike = "cstrike.exe") then
	    szDIR_GAME_HALFLIFE = szRegKey;
	    DO_GAME_CSTRIKE_BOOL = 1; // set the flag
	  endif;
    endif;

	if (szDIR_GAME_HALFLIFE = DEFAULTHALFLIFEDIR) then
	  // guess the default game path (HalfLife)
	  nKeyType = REGDB_STRING;
	  RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
	  nRegKey = RegDBGetKeyValueEx ("SOFTWARE\\Sierra OnLine\\Setup\\HALFLIFE\\", "Directory", nKeyType, szRegKey, nRegKeySize);
	  if (nRegKey = 0) then
	    FindFile (szRegKey, "hl.exe", szHL);
		if (szHL = "hl.exe") then
		  szDIR_GAME_HALFLIFE = szRegKey;
     	endif;
	  endif;
	endif;

    // prompt user for game path
    szTitle = "Halflife / Counterstrike-Retail and mods game package";
    szMsg   = "Select the folder where Halflife or Counterstrike-Retail is installed.\nclick Next.";
    nResult = SdAskDestPath( szTitle, szMsg, szDIR_GAME_HALFLIFE, 0 );
    if (nResult = BACK) then
      if (DO_GAME_SOF2_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_SOF2;
      elseif (DO_GAME_STVEF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_STVEF;
      elseif (DO_GAME_JKII_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_JKII;
      elseif (DO_GAME_WOLF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Wolf;
      elseif (DO_GAME_Q3_BOOL == 1) then
      	goto Dlg_SdShowDlgEdit1_Q3;
      elseif (DO_CORE_BOOL == 1) then
      	goto Dlg_SdAskCorePath;
      else
        goto Dlg_SdShowInfoList;
      endif;
    endif;

    // prompt user for game subdir
Dlg_SdShowDlgEdit1_HALFLIFE:
    szTitle = "Choose Folder\nEnter a folder name.";
    szMsg   = "Please enter the folder name for " + @PRODUCT_NAME + " Halflife game pack in the edit field below.\nNOTE: This is for installation of the game specific files.";
    nResult = SdShowDlgEdit1 (szTitle, szMsg, "Folder", szSubDir);
    szDIR_GAMETOOLS_HALFLIFE = szDIR_GAME_HALFLIFE ^ szSubDir;
    if (nResult = BACK) goto Dlg_SdAskGamePath_HALFLIFE;

    // set values in components
    ComponentSetTarget (MEDIA, "<DIR_GAME_HALFLIFE>", szDIR_GAME_HALFLIFE);
    ComponentSetTarget (MEDIA, "<DIR_GAMETOOLS_HALFLIFE>", szDIR_GAMETOOLS_HALFLIFE);

  endif;

  // ---------------------------------------------------------------------------------  
  // game pack #7, ET
  // ---------------------------------------------------------------------------------
  if (DO_GAME_ET_BOOL == 1) then
Dlg_SdAskGamePath_ET:
    
    // guess the default game path from registry
    DEFAULTETDIR = "C:\\Program Files\\Wolfenstein - Enemy Territory\\";
    nKeyType = REGDB_STRING;
    RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
    nRegKey = RegDBGetKeyValueEx ("SOFTWARE\\Activision\\Wolfenstein - Enemy Territory\\", "InstallPath", nKeyType, szRegKey, nRegKeySize);
    if (nRegKey = 0) then
	  FindFile (szRegKey + "GameData", "ET.exe", szET);
	  if (szET = "ET.exe") then
	    szDIR_GAME_ET = szRegKey;
      else
        szDIR_GAME_ET = DEFAULTETDIR; 
      endif;
    else
      szDIR_GAME_ET = DEFAULTETDIR; 
    endif;
    
    // prompt user for game path
    szTitle = "Wolfenstein: Enemy Territory game package";
    szMsg   = "Select the folder where Wolfenstein: Enemy Territory is installed.";
    nResult = SdAskDestPath( szTitle, szMsg, szDIR_GAME_ET, 0 );
    if (nResult = BACK) then
      if (DO_GAME_HALFLIFE_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_HALFLIFE;
      elseif (DO_GAME_STVEF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_STVEF;
      elseif (DO_GAME_JKII_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_JKII;
      elseif (DO_GAME_WOLF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Wolf;
      elseif (DO_GAME_Q3_BOOL == 1) then
      	goto Dlg_SdShowDlgEdit1_Q3;
      elseif (DO_CORE_BOOL == 1) then
      	goto Dlg_SdAskCorePath;
      else
        goto Dlg_SdShowInfoList;
      endif;
    endif;
    
    // prompt user for game subdir
Dlg_SdShowDlgEdit1_ET:
    szTitle = "Choose Folder\nEnter a folder name.";
    szMsg   = "Please enter the folder name for " + @PRODUCT_NAME + " Wolfenstein: Enemy Territory game pack in the edit field below.\nNOTE: This is for installation of the game specific files.";
    nResult = SdShowDlgEdit1 (szTitle, szMsg, "Folder", szSubDir);
    szDIR_GAMETOOLS_ET = szDIR_GAME_ET ^ szSubDir;
    if (nResult = BACK) goto Dlg_SdAskGamePath_ET;
    
    // set values in components
    ComponentSetTarget (MEDIA, "<DIR_GAME_ET>", szDIR_GAME_ET);
    ComponentSetTarget (MEDIA, "<DIR_GAMETOOLS_ET>", szDIR_GAMETOOLS_ET);
    
  endif;

  // ---------------------------------------------------------------------------------  
  // game pack #8, Quake
  // ---------------------------------------------------------------------------------
  if (DO_GAME_Q1_BOOL == 1) then
Dlg_SdAskGamePath_Q1:
    
    // guess the default game path from registry
    DEFAULTQ1DIR = "C:\\quake\\";

	FindFile (szRegKey + "GameData", "quake.exe", szQ1);
	if (szQ1 = "quake.exe") then
	  szDIR_GAME_Q1 = szRegKey;
    else
      szDIR_GAME_Q1 = DEFAULTQ1DIR; 
    endif;
    
    // prompt user for game path
    szTitle = "Quake game package";
    szMsg   = "Select the folder where Quake is installed.";
    nResult = SdAskDestPath( szTitle, szMsg, szDIR_GAME_Q1, 0 );
    if (nResult = BACK) then
      if (DO_GAME_ET_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_ET;
      elseif (DO_GAME_HALFLIFE_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_HALFLIFE;
      elseif (DO_GAME_SOF2_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_SOF2;
      elseif (DO_GAME_STVEF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_STVEF;
      elseif (DO_GAME_JKII_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_JKII;
      elseif (DO_GAME_WOLF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Wolf;
      elseif (DO_GAME_Q3_BOOL == 1) then
      	goto Dlg_SdShowDlgEdit1_Q3;
      elseif (DO_CORE_BOOL == 1) then
      	goto Dlg_SdAskCorePath;
      else
        goto Dlg_SdShowInfoList;
      endif;
    endif;
    
    // prompt user for game subdir
Dlg_SdShowDlgEdit1_Q1:
    szTitle = "Choose Folder\nEnter a folder name.";
    szMsg   = "Please enter the folder name for " + @PRODUCT_NAME + " Quake game pack in the edit field below.\nNOTE: This is for installation of the game specific files.";
    nResult = SdShowDlgEdit1 (szTitle, szMsg, "Folder", szSubDir);
    szDIR_GAMETOOLS_Q1 = szDIR_GAME_Q1 ^ szSubDir;
    if (nResult = BACK) goto Dlg_SdAskGamePath_Q1;
    
    // set values in components
    ComponentSetTarget (MEDIA, "<DIR_GAME_Q1>", szDIR_GAME_Q1);
    ComponentSetTarget (MEDIA, "<DIR_GAMETOOLS_Q1>", szDIR_GAMETOOLS_Q1);
    
  endif;

  // ---------------------------------------------------------------------------------  
  // game pack #8, JA
  if (DO_GAME_JA_BOOL == 1) then
Dlg_SdAskGamePath_JA:
    
    // guess the default game path from registry
    DEFAULTJADIR = "C:\\Program Files\\LucasArts\\Star Wars Jedi Knight Jedi Academy\\GameData";
    nKeyType = REGDB_STRING;
    RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
    nRegKey = RegDBGetKeyValueEx ("SOFTWARE\\LucasArts\\Star Wars Jedi Knight Jedi Academy\\1.0\\", "Install Path", nKeyType, szRegKey, nRegKeySize);
    if (nRegKey = 0) then
	  FindFile (szRegKey + "GameData", "jasp.exe", szJKII);
	  if (szJKII = "jasp.exe") then
	    szDIR_GAME_JA = szRegKey;
      else
        szDIR_GAME_JA = DEFAULTJADIR;
      endif;
    else
      szDIR_GAME_JA = DEFAULTJADIR;
    endif;
    
    // prompt user for game path
    szTitle = "Star Wars Jedi Knight Jedi Academy";
    szMsg   = "Select the folder where Star Wars Jedi Knight Jedi Academy is installed.";
    nResult = SdAskDestPath( szTitle, szMsg, szDIR_GAME_JA, 0 );
    if (nResult = BACK) then
      if (DO_GAME_Q1_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Q1;
      elseif (DO_GAME_ET_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_ET;
      elseif (DO_GAME_HALFLIFE_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_HALFLIFE;
      elseif (DO_GAME_SOF2_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_SOF2;
      elseif (DO_GAME_STVEF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_STVEF;
      elseif (DO_GAME_JKII_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_JKII;
      elseif (DO_GAME_WOLF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Wolf;
      elseif (DO_GAME_Q3_BOOL == 1) then
      	goto Dlg_SdShowDlgEdit1_Q3;
      elseif (DO_CORE_BOOL == 1) then
      	goto Dlg_SdAskCorePath;
      else
        goto Dlg_SdShowInfoList;
      endif;
    endif;
    
    // prompt user for game subdir
Dlg_SdShowDlgEdit1_JA:
    szTitle = "Choose Folder\nEnter a folder name.";
    szMsg   = "Please enter the folder name for " + @PRODUCT_NAME + " Star Wars Jedi Knight Jedi Academy game pack in the edit field below.\nNOTE: This is for installation of the game specific files.";
    nResult = SdShowDlgEdit1 (szTitle, szMsg, "Folder", szSubDir);
    szDIR_GAMETOOLS_JA = szDIR_GAME_JA ^ szSubDir;
    if (nResult = BACK) goto Dlg_SdAskGamePath_JA;
    
    // set values in components
    ComponentSetTarget (MEDIA, "<DIR_GAME_JA>", szDIR_GAME_JA);
    ComponentSetTarget (MEDIA, "<DIR_GAMETOOLS_JA>", szDIR_GAMETOOLS_JA);
    
  endif;

  // ---------------------------------------------------------------------------------  
  // game pack #9, Q2
  // ---------------------------------------------------------------------------------
  if (DO_GAME_Q2_BOOL == 1) then
Dlg_SdAskGamePath_Q2:
    
    // guess the default game path from registry
    szDIR_GAME_Q2 = "C:\\Quake2\\";
    
    // prompt user for game path
    szTitle = "Quake II";
    szMsg   = "Select the folder where Quake II is installed.";
    nResult = SdAskDestPath( szTitle, szMsg, szDIR_GAME_Q2, 0 );
    if (nResult = BACK) then
      if (DO_GAME_JA_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_JA;
      elseif (DO_GAME_Q1_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Q1;
      elseif (DO_GAME_ET_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_ET;
      elseif (DO_GAME_HALFLIFE_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_HALFLIFE;
      elseif (DO_GAME_STVEF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_STVEF;
      elseif (DO_GAME_JKII_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_JKII;
      elseif (DO_GAME_WOLF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Wolf;
      elseif (DO_GAME_Q3_BOOL == 1) then
      	goto Dlg_SdShowDlgEdit1_Q3;
      elseif (DO_CORE_BOOL == 1) then
      	goto Dlg_SdAskCorePath;
      else
        goto Dlg_SdShowInfoList;
      endif;
    endif;
    
    // prompt user for game subdir
Dlg_SdShowDlgEdit1_Q2:
    szTitle = "Choose Folder\nEnter a folder name.";
    szMsg   = "Please enter the folder name for " + @PRODUCT_NAME + " Quake II game pack in the edit field below.\nNOTE: This is for installation of the game specific files.";
    nResult = SdShowDlgEdit1 (szTitle, szMsg, "Folder", szSubDir);
    szDIR_GAMETOOLS_Q2 = szDIR_GAME_Q2 ^ szSubDir;
    if (nResult = BACK) goto Dlg_SdAskGamePath_Q2;
    
    // set values in components
    ComponentSetTarget (MEDIA, "<DIR_GAME_Q2>", szDIR_GAME_Q2);
    ComponentSetTarget (MEDIA, "<DIR_GAMETOOLS_Q2>", szDIR_GAMETOOLS_Q2);
    
  endif;

  // ---------------------------------------------------------------------------------  
  // game pack #10, HER2
  // ---------------------------------------------------------------------------------
  if (DO_GAME_HER2_BOOL == 1) then
Dlg_SdAskGamePath_HER2:
    
    // guess the default game path from registry
    szDIR_GAME_HER2 = "C:\\Heretic2\\";
    
    // prompt user for game path
    szTitle = "Heretic II";
    szMsg   = "Select the folder where Heretic II is installed.";
    nResult = SdAskDestPath( szTitle, szMsg, szDIR_GAME_HER2, 0 );
    if (nResult = BACK) then
      if (DO_GAME_Q2_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Q2;
      elseif (DO_GAME_JA_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_JA;
      elseif (DO_GAME_Q1_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Q1;
      elseif (DO_GAME_ET_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_ET;
      elseif (DO_GAME_HALFLIFE_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_HALFLIFE;
      elseif (DO_GAME_STVEF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_STVEF;
      elseif (DO_GAME_JKII_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_JKII;
      elseif (DO_GAME_WOLF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Wolf;
      elseif (DO_GAME_Q3_BOOL == 1) then
      	goto Dlg_SdShowDlgEdit1_Q3;
      elseif (DO_CORE_BOOL == 1) then
      	goto Dlg_SdAskCorePath;
      else
        goto Dlg_SdShowInfoList;
      endif;
    endif;
    
    // prompt user for game subdir
Dlg_SdShowDlgEdit1_HER2:
    szTitle = "Choose Folder\nEnter a folder name.";
    szMsg   = "Please enter the folder name for " + @PRODUCT_NAME + " Heretic II game pack in the edit field below.\nNOTE: This is for installation of the game specific files.";
    nResult = SdShowDlgEdit1 (szTitle, szMsg, "Folder", szSubDir);
    szDIR_GAMETOOLS_HER2 = szDIR_GAME_HER2 ^ szSubDir;
    if (nResult = BACK) goto Dlg_SdAskGamePath_HER2;
    
    // set values in components
    ComponentSetTarget (MEDIA, "<DIR_GAME_HER2>", szDIR_GAME_HER2);
    ComponentSetTarget (MEDIA, "<DIR_GAMETOOLS_HER2>", szDIR_GAMETOOLS_HER2);
    
  endif;

  // ---------------------------------------------------------------------------------
  // game pack #11, 'TODO: add your game pack here'
  // ---------------------------------------------------------------------------------

  // prompt for typical, custom etc. install
Dlg_SetupType:
    szTitle    = "";
    szMsg      = "";
    nResult = SdSetupTypeEx (szTitle, szMsg, "", svSetupType, 0);
    if (nResult = BACK) then
      // FIXME TTimo wish we could stick labels into variables instead?
      if (DO_GAME_HER2_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_HER2;
      elseif (DO_GAME_Q2_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Q2;
      elseif (DO_GAME_JA_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_JA;
      elseif (DO_GAME_Q1_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Q1;
      elseif (DO_GAME_ET_BOOL == 1) then
      	goto Dlg_SdShowDlgEdit1_ET;
      elseif (DO_GAME_HALFLIFE_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_HALFLIFE;
      elseif (DO_GAME_SOF2_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_SOF2;
      elseif (DO_GAME_STVEF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_STVEF;
      elseif (DO_GAME_JKII_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_JKII;
      elseif (DO_GAME_WOLF_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Wolf;
      elseif (DO_GAME_Q3_BOOL == 1) then
        goto Dlg_SdShowDlgEdit1_Q3;
      elseif (DO_CORE_BOOL == 1) then
        goto Dlg_SdAskCorePath;
      else
        goto Dlg_SdShowInfoList;
      endif;
    endif;
    if (svSetupType = "custom") then
    	nResult = CUSTOM;
    endif;
    nSetupType = nResult;

Dlg_SdComponentTree:
    if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType;
    szTitle    = "";
    szMsg      = "";
    szTargetdir = TARGETDIR;
    szComponents = "";
    nLevel = 2;
    if (nSetupType = CUSTOM) then
		    nResult = SdComponentTree(szTitle, szMsg, szTargetdir, szComponents, nLevel);
		    if (nResult = BACK) goto Dlg_SetupType;
    endif;

Dlg_ObjDialogs:
    nResult = ShowObjWizardPages(nResult);
    if (nResult = BACK) goto Dlg_SdComponentTree;

Dlg_SdSelectFolder:
    szfolder = @FOLDER_NAME;
    szTitle    = "";
    szMsg      = "";
    nResult    = SdSelectFolder( szTitle, szMsg, szfolder );
    SHELL_OBJECT_FOLDER = szfolder;
    if (nResult = BACK) goto Dlg_ObjDialogs;

  // push the list of stuff
Dlg_SdStartCopy:
    szTitle = "";
    szMsg   = "";
    listStartCopy = ListCreate( STRINGLIST );
    if (DO_CORE_BOOL == 1) then
      ListAddString(listStartCopy,@PRODUCT_NAME + " core installation directory:",AFTER);
      ListAddString(listStartCopy,"     " + TARGETDIR,AFTER);
    endif;
    if (DO_GAME_Q3_BOOL == 1) then
      ListAddString(listStartCopy,"Quake III Arena folder:",AFTER);
      ListAddString(listStartCopy,"		" + szDIR_GAME_Q3,AFTER);
      ListAddString(listStartCopy,"Quake III Arena mapping package folder:",AFTER);
      ListAddString(listStartCopy,"		" + szDIR_GAMETOOLS_Q3,AFTER);
    endif;
    if (DO_GAME_WOLF_BOOL == 1) then
      ListAddString(listStartCopy,"Return To Castle Wolfenstein folder:",AFTER);
      ListAddString(listStartCopy,"		" + szDIR_GAME_WOLF,AFTER);
      ListAddString(listStartCopy,"Return To Castle Wolfenstein mapping package folder:",AFTER);
      ListAddString(listStartCopy,"		" + szDIR_GAMETOOLS_WOLF,AFTER);
    endif;
    if (DO_GAME_JKII_BOOL == 1) then
      ListAddString(listStartCopy,"Jedi Knight II: Jedi Outcast folder:",AFTER);
      ListAddString(listStartCopy,"		" + szDIR_GAME_JKII,AFTER);
      ListAddString(listStartCopy,"Jedi Knight II: Jedi Outcast mapping package folder:",AFTER);
      ListAddString(listStartCopy,"		" + szDIR_GAMETOOLS_JKII,AFTER);
    endif;
    if (DO_GAME_STVEF_BOOL == 1) then
      ListAddString(listStartCopy,"Star Trek Voyager : Elite Force folder:",AFTER);
      ListAddString(listStartCopy,"		" + szDIR_GAME_STVEF,AFTER);
      ListAddString(listStartCopy,"Star Trek Voyager : Elite Force mapping package folder:",AFTER);
      ListAddString(listStartCopy,"		" + szDIR_GAMETOOLS_STVEF,AFTER);
    endif;
    if (DO_GAME_SOF2_BOOL == 1) then
      ListAddString(listStartCopy,"Soldier of Fortune II - Double Helix folder:",AFTER);
      ListAddString(listStartCopy,"		" + szDIR_GAME_SOF2,AFTER);
      ListAddString(listStartCopy,"Soldier of Fortune II - Double Helix mapping package folder:",AFTER);
      ListAddString(listStartCopy,"		" + szDIR_GAMETOOLS_SOF2,AFTER);
    endif;
    if (DO_GAME_HALFLIFE_BOOL == 1) then
      ListAddString(listStartCopy,"Halflife or CounterStrike-Retail folder:",AFTER);
      ListAddString(listStartCopy,"		" + szDIR_GAME_HALFLIFE,AFTER);
      ListAddString(listStartCopy,"Halflife or CounterStrike-Retail mapping package folder:",AFTER);
      ListAddString(listStartCopy,"		" + szDIR_GAMETOOLS_HALFLIFE,AFTER);
    endif;
    if (DO_GAME_ET_BOOL == 1) then
      ListAddString(listStartCopy,"Wolfenstein: Enemy Territory folder:",AFTER);
      ListAddString(listStartCopy,"     " + szDIR_GAME_ET,AFTER);
      ListAddString(listStartCopy,"Wolfenstein: Enemy Territory mapping package folder:",AFTER);
      ListAddString(listStartCopy,"     " + szDIR_GAMETOOLS_ET,AFTER);
    endif;
    if (DO_GAME_Q1_BOOL == 1) then
      ListAddString(listStartCopy,"Quake folder:",AFTER);
      ListAddString(listStartCopy,"     " + szDIR_GAME_Q1,AFTER);
      ListAddString(listStartCopy,"Quake mapping package folder:",AFTER);
      ListAddString(listStartCopy,"     " + szDIR_GAMETOOLS_Q1,AFTER);
    endif;
    if (DO_GAME_JA_BOOL == 1) then
      ListAddString(listStartCopy,"Star Wars Jedi Knight Jedi Academy folder:",AFTER);
      ListAddString(listStartCopy,"     " + szDIR_GAME_JA,AFTER);
      ListAddString(listStartCopy,"Star Wars Jedi Knight Jedi Academy mapping package folder:",AFTER);
      ListAddString(listStartCopy,"     " + szDIR_GAMETOOLS_JA,AFTER);
    endif;
    if (DO_GAME_Q2_BOOL == 1) then
      ListAddString(listStartCopy,"Quake II folder:",AFTER);
      ListAddString(listStartCopy,"     " + szDIR_GAME_Q2,AFTER);
      ListAddString(listStartCopy,"Quake II mapping package folder:",AFTER);
      ListAddString(listStartCopy,"     " + szDIR_GAMETOOLS_Q2,AFTER);
    endif;
    if (DO_GAME_HER2_BOOL == 1) then
      ListAddString(listStartCopy,"Heretic II folder:",AFTER);
      ListAddString(listStartCopy,"     " + szDIR_GAME_HER2,AFTER);
      ListAddString(listStartCopy,"Heretic II mapping package folder:",AFTER);
      ListAddString(listStartCopy,"     " + szDIR_GAMETOOLS_HER2,AFTER);
    endif;
    ListAddString(listStartCopy,"Setup type: ",AFTER);
    ListAddString(listStartCopy,"		" + svSetupType,AFTER);
    nResult = SdStartCopy( szTitle, szMsg, listStartCopy );
    ListDestroy(listStartCopy);
    if (nResult = BACK) goto Dlg_SdSelectFolder;

    // setup default status
    SetStatusWindow(0, "");
    Enable(STATUSEX);
    StatusUpdate(ON, 100);


  return 0;
end;

///////////////////////////////////////////////////////////////////////////////
//
//  FUNCTION:   OnMoving
//
//  EVENT:      Moving event is sent when file transfer is started as a result of
//              ComponentTransferData call, before any file transfer operations
//              are performed.
//
///////////////////////////////////////////////////////////////////////////////
function OnMoving()
    STRING szAppPath;
begin
    // Set LOGO Compliance Application Path
    // NOTE TTimo
    // doc on RegDBSetItem says before calling you must call the InstallationInfo
    // function, which provides information used to create the key
    szAppPath = TARGETDIR;
    RegDBSetItem(REGDB_APPPATH, szAppPath);
    RegDBSetItem(REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY);
end;

/////////////////////////////////////////////////////////////////////////////////
// The OnMoved event handler responds to the Moved event that is generated just
// after all selected components have been installed or uninstalled on the
// target computer.
/////////////////////////////////////////////////////////////////////////////////

function OnMoved()
  NUMBER nvFileHandle;
begin
  if !MAINTENANCE then
    // generate RADIANT_MAJOR and RADIANT_MINOR file items
    if (CreateFile(nvFileHandle, TARGETDIR, "RADIANT_MAJOR")< 0) then
      MessageBox ("CreateFile " + TARGETDIR + "\\RADIANT_MAJOR failed.", SEVERE);
      abort;
    endif;
    // template
    WriteLine(nvFileHandle, "<<RADIANT_MAJOR>>");
    CloseFile(nvFileHandle);
    if (CreateFile(nvFileHandle, TARGETDIR, "RADIANT_MINOR")< 0) then
      MessageBox ("CreateFile " + TARGETDIR + "\\RADIANT_MINOR failed.", SEVERE);
      abort;
    endif;
    // template
    WriteLine(nvFileHandle, "<<RADIANT_MINOR>>");
    CloseFile(nvFileHandle);
    // generate the config files for the game packages
    // NOTE: we are directly creating them, not using XCopyFile
    //   that means those won't be uninstalled, doesn't look like a big problem to me
    if (DO_GAME_Q3_BOOL == 1) then
      if (CreateDir(TARGETDIR ^ "games")< 0) then
         // Report the error; then abort.
         MessageBox ("Unable to create directory " + TARGETDIR ^ "games", SEVERE);
         abort;
      endif;
      if (CreateFile(nvFileHandle, TARGETDIR ^ "games", "q3.game")< 0) then
        // Report the error.
        MessageBox ("CreateFile " + TARGETDIR ^ "games" + "\\q3.game failed.", SEVERE);
        abort;
      endif;
      WriteLine(nvFileHandle, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>");
      WriteLine(nvFileHandle, "<!-- generated by Radiant setup, modify at your own risks -->");
      WriteLine(nvFileHandle, "<game");
      WriteLine(nvFileHandle, "  name=\"Quake III Arena / Quake III: Team Arena and modifications\"");
      WriteLine(nvFileHandle, "  enginepath =\"" + szDIR_GAME_Q3 + "/\"");
      WriteLine(nvFileHandle, "  gametools=\"" + szDIR_GAMETOOLS_Q3 + "/\"");
      WriteLine(nvFileHandle, "  gamename=\"quake3\"");
      WriteLine(nvFileHandle, "/>");
      CloseFile(nvFileHandle);
    endif;
    if (DO_GAME_WOLF_BOOL == 1) then
      if (CreateDir(TARGETDIR ^ "games")< 0) then
         // Report the error; then abort.
         MessageBox ("Unable to create directory " + TARGETDIR ^ "games", SEVERE);
         abort;
      endif;
      if (CreateFile(nvFileHandle, TARGETDIR ^ "games", "wolf.game")< 0) then
        // Report the error.
        MessageBox ("CreateFile " + TARGETDIR ^ "games" + "\\wolf.game failed.", SEVERE);
        abort;
      endif;
      WriteLine(nvFileHandle, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>");
      WriteLine(nvFileHandle, "<!-- generated by Radiant setup, modify at your own risks -->");
      WriteLine(nvFileHandle, "<game");
      WriteLine(nvFileHandle, "  name=\"Return To Castle Wolfenstein\"");
      WriteLine(nvFileHandle, "  enginepath =\"" + szDIR_GAME_WOLF + "/\"");
      WriteLine(nvFileHandle, "  gametools=\"" + szDIR_GAMETOOLS_WOLF + "/\"");
      WriteLine(nvFileHandle, "  basegame=\"main\"");
      WriteLine(nvFileHandle, "  engine=\"WolfSP.exe\"");
      WriteLine(nvFileHandle, "  gamename=\"wolf\"");
      WriteLine(nvFileHandle, "/>");
      CloseFile(nvFileHandle);
    endif;
    if (DO_GAME_JKII_BOOL == 1) then
      if (CreateDir(TARGETDIR ^ "games")< 0) then
         // Report the error; then abort.
         MessageBox ("Unable to create directory " + TARGETDIR ^ "games", SEVERE);
         abort;
      endif;
      if (CreateFile(nvFileHandle, TARGETDIR ^ "games", "jk2.game")< 0) then
        // Report the error.
        MessageBox ("CreateFile " + TARGETDIR ^ "games" + "\\jk2.game failed.", SEVERE);
        abort;
      endif;
      WriteLine(nvFileHandle, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>");
      WriteLine(nvFileHandle, "<!-- generated by Radiant setup, modify at your own risks -->");
      WriteLine(nvFileHandle, "<game");
      WriteLine(nvFileHandle, "  name=\"Jedi Knight II: Jedi Outcast\"");
      WriteLine(nvFileHandle, "  enginepath =\"" + szDIR_GAME_JKII + "/\"");
      WriteLine(nvFileHandle, "  gametools=\"" + szDIR_GAMETOOLS_JKII + "/\"");
      WriteLine(nvFileHandle, "  basegame=\"base\"");
      WriteLine(nvFileHandle, "  engine=\"jk2sp.exe\"");
      WriteLine(nvFileHandle, "  shaderpath=\"shaders/\"");
      WriteLine(nvFileHandle, "  default_scale=\"0.25\"");
      WriteLine(nvFileHandle, "  gamename=\"jk2\"");
      WriteLine(nvFileHandle, "/>");
      CloseFile(nvFileHandle);
    endif;
    if (DO_GAME_STVEF_BOOL == 1) then
      if (CreateDir(TARGETDIR ^ "games")< 0) then
         // Report the error; then abort.
         MessageBox ("Unable to create directory " + TARGETDIR ^ "games", SEVERE);
         abort;
      endif;
      if (CreateFile(nvFileHandle, TARGETDIR ^ "games", "stvef.game")< 0) then
        // Report the error.
        MessageBox ("CreateFile " + TARGETDIR ^ "games" + "\\stvef.game failed.", SEVERE);
        abort;
      endif;
      WriteLine(nvFileHandle, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>");
      WriteLine(nvFileHandle, "<!-- generated by Radiant setup, modify at your own risks -->");
      WriteLine(nvFileHandle, "<game");
      WriteLine(nvFileHandle, "  name=\"Star Trek Voyager : Elite Force\"");
      WriteLine(nvFileHandle, "  gametools=\"" + szDIR_GAMETOOLS_STVEF + "/\"");
      WriteLine(nvFileHandle, "  enginepath =\"" + szDIR_GAME_STVEF + "/\"");
      WriteLine(nvFileHandle, "  basegame=\"baseEF\"");
      WriteLine(nvFileHandle, "  engine=\"stvoy.exe\"");
      WriteLine(nvFileHandle, "  gamename=\"stvef\"");
      WriteLine(nvFileHandle, "/>");
      CloseFile(nvFileHandle);
    endif;
    if (DO_GAME_SOF2_BOOL == 1) then
      if (CreateDir(TARGETDIR ^ "games")< 0) then
         // Report the error; then abort.
         MessageBox ("Unable to create directory " + TARGETDIR ^ "games", SEVERE);
         abort;
      endif;
      if (CreateFile(nvFileHandle, TARGETDIR ^ "games", "sof2.game")< 0) then
        // Report the error.
        MessageBox ("CreateFile " + TARGETDIR ^ "games" + "\\sof2.game failed.", SEVERE);
        abort;
      endif;
      WriteLine(nvFileHandle, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>");
      WriteLine(nvFileHandle, "<!-- generated by Radiant setup, modify at your own risks -->");
      WriteLine(nvFileHandle, "<game");
      WriteLine(nvFileHandle, "  name=\"Soldier of Fortune II - Double Helix\"");
      WriteLine(nvFileHandle, "  gametools=\"" + szDIR_GAMETOOLS_SOF2 + "/\"");
      WriteLine(nvFileHandle, "  basegame=\"base\"");
      WriteLine(nvFileHandle, "  engine=\"sof2.exe\"");
      WriteLine(nvFileHandle, "  enginepath =\"" + szDIR_GAME_SOF2 + "/\"");
      WriteLine(nvFileHandle, "  shaderpath=\"shaders/\"");
      WriteLine(nvFileHandle, "  default_scale=\"0.125\"");
      WriteLine(nvFileHandle, "  caulk_shader=\"textures/tools/caulk\"");
      WriteLine(nvFileHandle, "/>");
      CloseFile(nvFileHandle);
    endif;
    if (DO_GAME_HALFLIFE_BOOL == 1) then
      if (CreateDir(TARGETDIR ^ "games")< 0) then
         // Report the error; then abort.
         MessageBox ("Unable to create directory " + TARGETDIR ^ "games", SEVERE);
         abort;
      endif;
      if (CreateFile(nvFileHandle, TARGETDIR ^ "games", "hl.game")< 0) then
        // Report the error.
        MessageBox ("CreateFile " + TARGETDIR ^ "games" + "\\hl.game failed.", SEVERE);
        abort;
      endif;
      WriteLine(nvFileHandle, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>");
      WriteLine(nvFileHandle, "<!-- generated by Radiant setup, modify at your own risks -->");
      WriteLine(nvFileHandle, "<game");
      if (DO_GAME_CSTRIKE_BOOL == 1) then
        WriteLine(nvFileHandle, "  name=\"Counter-Strike Retail\"");
      	WriteLine(nvFileHandle, "  engine=\"cstrike.exe\"");
      else
        WriteLine(nvFileHandle, "  name=\"Halflife and Modifications\"");
      	WriteLine(nvFileHandle, "  engine=\"hl.exe\"");
      endif;
      WriteLine(nvFileHandle, "  enginepath =\"" + szDIR_GAME_HALFLIFE + "/\"");
      WriteLine(nvFileHandle, "  gametools=\"" + szDIR_GAMETOOLS_HALFLIFE + "/\"");
      WriteLine(nvFileHandle, "  basegame=\"valve\"");
      WriteLine(nvFileHandle, "  gamename=\"halflife\"");
      WriteLine(nvFileHandle, "  eclass_singleload=\"1\"");
      WriteLine(nvFileHandle, "  no_patch=\"1\"");
      WriteLine(nvFileHandle, "  default_scale=\"1.0\"");
      WriteLine(nvFileHandle, "/>");
      CloseFile(nvFileHandle);
    endif;
    if (DO_GAME_ET_BOOL == 1) then
      if (CreateDir(TARGETDIR ^ "games")< 0) then
         // Report the error; then abort.
         MessageBox ("Unable to create directory " + TARGETDIR ^ "games", SEVERE);
         abort;
      endif;
      if (CreateFile(nvFileHandle, TARGETDIR ^ "games", "et.game")< 0) then
        // Report the error.
        MessageBox ("CreateFile " + TARGETDIR ^ "games" + "\\et.game failed.", SEVERE);
        abort;
      endif;
      WriteLine(nvFileHandle, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>");
      WriteLine(nvFileHandle, "<!-- generated by Radiant setup, modify at your own risks -->");
      WriteLine(nvFileHandle, "<game");
      WriteLine(nvFileHandle, "  name=\"Wolfenstein: Enemy Territory\"");
      WriteLine(nvFileHandle, "  enginepath =\"" + szDIR_GAME_ET + "/\"");
      WriteLine(nvFileHandle, "  gametools=\"" + szDIR_GAMETOOLS_ET + "/\"");
      WriteLine(nvFileHandle, "  basegame=\"etmain\"");
      WriteLine(nvFileHandle, "  engine=\"ET.exe\"");
      WriteLine(nvFileHandle, "  gamename=\"et\"");
      WriteLine(nvFileHandle, "/>");
      CloseFile(nvFileHandle);
    endif;
    if (DO_GAME_Q1_BOOL == 1) then
      if (CreateDir(TARGETDIR ^ "games")< 0) then
         // Report the error; then abort.
         MessageBox ("Unable to create directory " + TARGETDIR ^ "games", SEVERE);
         abort;
      endif;
      if (CreateFile(nvFileHandle, TARGETDIR ^ "games", "q1.game")< 0) then
        // Report the error.
        MessageBox ("CreateFile " + TARGETDIR ^ "games" + "\\q1.game failed.", SEVERE);
        abort;
      endif;
      WriteLine(nvFileHandle, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>");
      WriteLine(nvFileHandle, "<!-- generated by Radiant setup, modify at your own risks -->");
      WriteLine(nvFileHandle, "<game");
      WriteLine(nvFileHandle, "  name=\"Quake\"");
      WriteLine(nvFileHandle, "  enginepath =\"" + szDIR_GAME_Q1 + "/\"");
      WriteLine(nvFileHandle, "  gametools=\"" + szDIR_GAMETOOLS_Q1 + "/\"");
      WriteLine(nvFileHandle, "  basegame=\"id1\"");
      WriteLine(nvFileHandle, "  engine=\"quake.exe\"");
      WriteLine(nvFileHandle, "  gamename=\"q1\"");
      WriteLine(nvFileHandle, "  default_scale=\"1.0\"");
      WriteLine(nvFileHandle, "/>");
      CloseFile(nvFileHandle);
    endif;
    if (DO_GAME_JA_BOOL == 1) then
      if (CreateDir(TARGETDIR ^ "games")< 0) then
         // Report the error; then abort.
         MessageBox ("Unable to create directory " + TARGETDIR ^ "games", SEVERE);
         abort;
      endif;
      if (CreateFile(nvFileHandle, TARGETDIR ^ "games", "ja.game")< 0) then
        // Report the error.
        MessageBox ("CreateFile " + TARGETDIR ^ "games" + "\\ja.game failed.", SEVERE);
        abort;
      endif;
      WriteLine(nvFileHandle, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>");
      WriteLine(nvFileHandle, "<!-- generated by Radiant setup, modify at your own risks -->");
      WriteLine(nvFileHandle, "<game");
      WriteLine(nvFileHandle, "  name=\"Jedi Knight Jedi Academy\"");
      WriteLine(nvFileHandle, "  enginepath =\"" + szDIR_GAME_JA + "/\"");
      WriteLine(nvFileHandle, "  gametools=\"" + szDIR_GAMETOOLS_JA + "/\"");
      WriteLine(nvFileHandle, "  basegame=\"base\"");
      WriteLine(nvFileHandle, "  engine=\"jasp.exe\"");
      WriteLine(nvFileHandle, "  shaderpath=\"shaders/\"");
      WriteLine(nvFileHandle, "  default_scale=\"0.25\"");
      WriteLine(nvFileHandle, "  gamename=\"ja\"");
      WriteLine(nvFileHandle, "/>");
      CloseFile(nvFileHandle);
    endif;
    if (DO_GAME_Q2_BOOL == 1) then
      if (CreateDir(TARGETDIR ^ "games")< 0) then
         // Report the error; then abort.
         MessageBox ("Unable to create directory " + TARGETDIR ^ "games", SEVERE);
         abort;
      endif;
      if (CreateFile(nvFileHandle, TARGETDIR ^ "games", "q2.game")< 0) then
        // Report the error.
        MessageBox ("CreateFile " + TARGETDIR ^ "games" + "\\q2.game failed.", SEVERE);
        abort;
      endif;
      WriteLine(nvFileHandle, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>");
      WriteLine(nvFileHandle, "<!-- generated by Radiant setup, modify at your own risks -->");
      WriteLine(nvFileHandle, "<game");
      WriteLine(nvFileHandle, "  name=\"Quake II\"");
      WriteLine(nvFileHandle, "  enginepath =\"" + szDIR_GAME_Q2 + "/\"");
      WriteLine(nvFileHandle, "  gametools=\"" + szDIR_GAMETOOLS_Q2 + "/\"");
      WriteLine(nvFileHandle, "  basegame=\"baseq2\"");
      WriteLine(nvFileHandle, "  engine=\"quake2.exe\"");
      WriteLine(nvFileHandle, "  gamename=\"q2\"");
      WriteLine(nvFileHandle, "  no_patch=\"1\"");
      WriteLine(nvFileHandle, "/>");
      CloseFile(nvFileHandle);
    endif;
    if (DO_GAME_HER2_BOOL == 1) then
      if (CreateDir(TARGETDIR ^ "games")< 0) then
         // Report the error; then abort.
         MessageBox ("Unable to create directory " + TARGETDIR ^ "games", SEVERE);
         abort;
      endif;
      if (CreateFile(nvFileHandle, TARGETDIR ^ "games", "heretic2.game")< 0) then
        // Report the error.
        MessageBox ("CreateFile " + TARGETDIR ^ "games" + "\\heretic2.game failed.", SEVERE);
        abort;
      endif;
      WriteLine(nvFileHandle, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>");
      WriteLine(nvFileHandle, "<!-- generated by Radiant setup, modify at your own risks -->");
      WriteLine(nvFileHandle, "<game");
      WriteLine(nvFileHandle, "  name=\"Heretic II\"");
      WriteLine(nvFileHandle, "  enginepath =\"" + szDIR_GAME_HER2 + "/\"");
      WriteLine(nvFileHandle, "  gametools=\"" + szDIR_GAMETOOLS_HER2 + "/\"");
      WriteLine(nvFileHandle, "  basegame=\"base\"");
      WriteLine(nvFileHandle, "  engine=\"heretic2.exe\"");
      WriteLine(nvFileHandle, "  gamename=\"heretic2\"");
      WriteLine(nvFileHandle, "  no_patch=\"1\"");
      WriteLine(nvFileHandle, "/>");
      CloseFile(nvFileHandle);
    endif;

  endif;
end;

// --- include script file section ---
