home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 31 / XENIATGM31.iso / terademo / setup.bak < prev    next >
Text File  |  1997-01-09  |  13KB  |  461 lines

  1. /*----------------------------------------------------------------------------*\
  2.  
  3.     (c)1996 Eidos Interactive Ltd.
  4.  
  5.     Simis Terracide InstallShield Script.
  6.  
  7.     Adrian Hawkins.
  8.  
  9.  
  10. \*----------------------------------------------------------------------------*/
  11.  
  12. declare
  13.  
  14. // Constant declarations.
  15. #define TERRA_SPACE_REQUIRED    29000000          // Disk space in bytes.
  16. #define PART_SPACE_REQUIRED     1000          // Disk space in bytes.
  17. #define TERRA_APP_NAME          "Terracide"
  18.  
  19. #define PROGRAM_FOLDER_NAME     "Eidos Interactive"
  20. #define INSTALL_BASE_PATH       "Terracide"
  21.  
  22. #define COMPANY_NAME            "Eidos Interactive"
  23. #define PRODUCT_NAME            "Terracide"
  24. #define PRODUCT_VERSION         "1.0"
  25. #define PRODUCT_KEY             "Terracide"
  26.  
  27. #define TERRA_DEINSTALL_KEY     "3-Level Terracide Internal Demo"
  28. #define TERRA_UNINSTALL_NAME    "3-Level Terracide Internal Demo"
  29.  
  30.  
  31.  
  32.         // Global variable declarations.
  33.         STRING  svFolder, svDir, szMsg, szFileSet, szTitle, svUninstLogFile;
  34.         STRING  svTarget, szProgram, szParam, szTemp, szAppPath, szSplash, szSourceDir;
  35.         BOOL    bSpaceOk, bFullInstall, bWin, bWinNT, bWin32s, bIsShellExplorer;
  36.         BOOL    bInstallTerracide, bInstallTombRaider;
  37.         NUMBER  nResult, nInstallType, nPrograms, nSpaceRequired, nSpaceAvail;
  38.         LIST    listData;
  39.         LONG    lResult;
  40.  
  41.         // Function declarations.
  42.         prototype SetupScreen();
  43.         prototype CheckRequirements();
  44.         prototype ShowOptions();
  45.         prototype ShowPrograms();
  46.  
  47. #include "sddialog.h"
  48.  
  49. program
  50.  
  51. StartHere:
  52.         Disable (BACKGROUND);
  53.  
  54.         // Set installation info., which is required for registry entries.
  55.         InstallationInfo (COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY);
  56.  
  57.         // Set up thr installation screen.
  58.         SetupScreen ();
  59.         Enable (DIALOGCACHE);
  60.  
  61.         Disable (BACKBUTTON);
  62.  
  63.    // Create a Welcome dialog.
  64.  
  65. WelcomeDlg:
  66.         Welcome ("", 0);
  67.         Enable (BACKBUTTON);
  68.  
  69.         // Test target system for proper configuration.
  70.         CheckRequirements();
  71.  
  72.         bInstallTerracide  = TRUE;
  73.  
  74. GetConfig: // CD-ROM or hard disk install.
  75.  
  76.     nInstallType = ShowOptions ();
  77.  
  78.     bFullInstall = TRUE;
  79.  
  80.     switch (nInstallType)
  81.     case BACK :
  82.         goto WelcomeDlg;
  83.  
  84.     case 101 :
  85.         bFullInstall = TRUE;
  86.     case 102 :
  87.         bFullInstall = FALSE;
  88.  
  89.     endswitch;
  90.  
  91.  
  92.     // Ask user for a destination location for the installation.
  93. GetTargetDirectory:
  94.  
  95.     if (bFullInstall) then
  96.  
  97.         nSpaceRequired = 0;
  98.  
  99.         svTarget = TARGETDISK ^ INSTALL_BASE_PATH;
  100.  
  101.         if (AskDestPath( "", "", svTarget, 0 ) = BACK)
  102.             goto GetConfig;
  103.  
  104.         nSpaceRequired = nSpaceRequired + TERRA_SPACE_REQUIRED;
  105.  
  106.     endif;
  107.  
  108.     // Perform space check of target drive.
  109.     bSpaceOk = TRUE;
  110.  
  111.     nSpaceAvail = GetDiskSpace (svTarget ^ INSTALL_BASE_PATH);
  112.  
  113.     if (nSpaceAvail < nSpaceRequired) then
  114.         szMsg = "There is not enough space available on the disk\n" +
  115.                 "Please free up some space or change the target location\n" +
  116.                 "to a different disk";
  117.         MessageBox( szMsg, WARNING );
  118.         bSpaceOk = FALSE;
  119.     endif;
  120.  
  121.          // If not enough space, ask user to try again.
  122.         if (bSpaceOk = FALSE)
  123.             goto GetTargetDirectory;
  124.  
  125.  
  126. Confirm:
  127.  
  128.     // Store retrieved information in list.
  129.     listData = ListCreate (STRINGLIST);
  130.     ListAddString (listData, "Setup Type:" , AFTER);
  131.  
  132.     ListAddString (listData, "Install Terracide" , AFTER);
  133.  
  134.     if (bFullInstall = TRUE) then
  135.         ListAddString (listData, "  Full Installation - Run from hard disk." , AFTER);
  136.     else
  137.         ListAddString (listData, "  Minimal Installation - Run from CD-ROM." , AFTER);
  138.     endif;
  139.  
  140.     ListAddString (listData, "" , AFTER);
  141.  
  142.     ListAddString (listData, "Destination Directory:" , AFTER);
  143.     ListAddString (listData, "  " + svTarget, AFTER);
  144.  
  145.     ListAddString (listData, "" , AFTER);
  146.  
  147.         // Set title and static text for SdStartCopy.
  148.     szTitle = "Check Setup Information";
  149.  
  150.     szMsg = "Setup has enough information to begin the file-transfer\n" +
  151.             "operation.  If you want to review or change any of the\n" +
  152.             "settings, click Back.  If you are satisfied with the\n" +
  153.             "settings, click Next to begin copying files.";
  154.  
  155.     // Call SdStartCopy to display user selections.
  156.     lResult = SdStartCopy (szTitle, szMsg, listData);
  157.  
  158.     if (lResult = BACK) then
  159.         goto GetConfig;
  160.     endif;
  161.  
  162. SetupFilesToTransfer:
  163.      // Get rid of the old teracide.ini settings ...
  164.      TARGETDIR=WINDIR;
  165.      DeleteFile("Teracide.ini");
  166.  
  167.     if (bFullInstall = TRUE) then
  168.  
  169.         Enable (BITMAPFADE);
  170.  
  171.         // Set the App Paths key in the registry for the main program.
  172.         szAppPath = svTarget ^ "Terawin.exe";
  173.         RegDBSetItem( REGDB_APPPATH, szAppPath );
  174.         szProgram = svTarget ^ "Terawin.exe";
  175.         RegDBSetItem( REGDB_APPPATH_DEFAULT, szProgram );
  176.  
  177.         szFileSet = "MyFileSet";
  178.  
  179.         szSplash = SRCDIR ^ "Setup.bmp";
  180.         PlaceBitmap (szSplash, 12, 10, 10, UPPER_RIGHT);
  181.  
  182.         // Move windows to fit splash bitmap.
  183.         PlaceWindow (FEEDBACK,  10, 10, LOWER_LEFT);
  184.         PlaceWindow (STATUSDLG, CENTERED, 10, LOWER_LEFT);
  185.  
  186.         SetStatusWindow( -1, "Copying program files..." );
  187.  
  188.         // TransferFiles
  189.  
  190.         // Prepare InstallShield to record deinstallation information.
  191.         DeinstallStart( svTarget, svUninstLogFile, TERRA_DEINSTALL_KEY, 0 );
  192.         RegDBSetItem( REGDB_UNINSTALL_NAME, TERRA_UNINSTALL_NAME );
  193.  
  194.         // Set up progress indicator and information gauge.
  195.         Disable( DIALOGCACHE );
  196.         Enable( STATUSDLG );
  197.  
  198.         StatusUpdate( ON, 100 );
  199.  
  200.         TARGETDIR = svTarget;
  201.         SRCDIR = SRCDIR ^ "Teracide";
  202.         nResult=XCopyFile("*.*","*.*",INCLUDE_SUBDIR);
  203.         // Perform the file set.
  204.  
  205.         switch (nResult)
  206.  
  207.             case 0: // Successful completion.
  208.  
  209.             default: // Group all other errors under default label.
  210.                 NumToStr( szTemp, nResult );
  211.                 MessageBox( "General file transfer error."+
  212.                             "Please check your target location and try again." +
  213.                             "\n\n Error Number:" + szTemp +
  214.                             "\n Related File: " + ERRORFILENAME,
  215.                             SEVERE );
  216.                 exit;
  217.         endswitch;
  218.  
  219.     endif;
  220.  
  221.     Delay( 1 );
  222.     Disable( STATUSDLG );
  223.  
  224.  
  225. InstallProgramItems:
  226.  
  227.     // Create a folder
  228.     CreateProgramFolder (PROGRAM_FOLDER_NAME);
  229.  
  230.     // Show it
  231.     ShowProgramFolder (PROGRAM_FOLDER_NAME, SW_SHOW);
  232.  
  233.     SetStatusWindow( 100, "Creating Folder...." );
  234.  
  235.  
  236.     // Add a shortcut to the target executable, or the  CD-ROM
  237.     if (bFullInstall = TRUE) then
  238.         szProgram = svTarget ^ "Terawin.exe";
  239.  
  240.         LongPathToQuote( szProgram, TRUE );
  241.  
  242.         AddFolderIcon(PROGRAM_FOLDER_NAME, "Terracide", szProgram + " -h",
  243.                         svTarget ,
  244.                         "", 0, "", REPLACE );
  245.  
  246.         AddFolderIcon(PROGRAM_FOLDER_NAME, "Terracide ReadMe", svTarget ^ "Readme.Txt",
  247.                       svTarget ,
  248.                       "", 0, "", REPLACE );
  249.     else
  250.         szProgram = SRCDIR ^ "Teracide" ^ "Terawin.exe";
  251.  
  252.         LongPathToQuote( szProgram, TRUE );
  253.  
  254.         AddFolderIcon(  PROGRAM_FOLDER_NAME, "Terracide", SRCDIR ^ "Teracide" ^ "Terawin.exe" + " -h",
  255.                         SRCDIR ^ "Teracide",
  256.                         "", 0, "", REPLACE );
  257.  
  258.         AddFolderIcon(PROGRAM_FOLDER_NAME, "Terracide ReadMe", SRCDIR ^ "Teracide" ^ "Readme.Txt",
  259.                       SRCDIR ^ "Teracide",
  260.                       "", 0, "", REPLACE );
  261.     endif;
  262.  
  263.     // Refresh the folder
  264.     ShowProgramFolder (PROGRAM_FOLDER_NAME, SW_SHOW);
  265.  
  266.     if (bFullInstall = TRUE) then
  267.         // Add an unInstall icon
  268.         AddFolderIcon (    PROGRAM_FOLDER_NAME,
  269.                         "unInstallShield for Terracide Demo", "UnInst -f" + svUninstLogFile,
  270.                         WINDIR,
  271.                         "",
  272.                         0,
  273.                         "",
  274.                         REPLACE);
  275.  
  276.         ShowProgramFolder (PROGRAM_FOLDER_NAME, SW_SHOW);
  277.     endif;
  278.  
  279.     ShowProgramFolder (PROGRAM_FOLDER_NAME, SW_SHOW);
  280.  
  281.  
  282.    // Announce setup complete and offer to run setup for Tomb Raider.
  283.    SetStatusWindow( 100, "Installation complete." );
  284.  
  285.  
  286.         szMsg = "Setup is complete.\n"+
  287.                 "You may run Terracide by double-clicking the icon in the Terracide folder.\n\n" +
  288.                 "Terracide can be removed by clicking the unInstall icon, or by choosing\n" +
  289.                 "'Add/Remove Programs' from Control Panel.\n\n" +
  290.                 "To activate the in-game menu, press the <ALT> key.";
  291.  
  292.         MessageBox (szMsg, INFORMATION);
  293.  
  294.         Delay( 2 );
  295.  
  296.  
  297.         if(AskYesNo("Would you also like to install DirectX 3 ?",YES)=YES) then
  298.             ChangeDirectory (SRCDIR);
  299.             ChangeDirectory ("..");
  300.             ChangeDirectory ("..");
  301.             LaunchApp( SRCDISK ^ "DIRECTX" ^ "DIRECTX" ^ "DXSETUP.EXE", "" );
  302.         else
  303.             // Show the Terracide readme.
  304.             if (bFullInstall = TRUE ) then
  305.                 LaunchApp( "Notepad.exe", svTarget ^ "Readme.Txt" );
  306.             else
  307.                 LaunchApp( "Notepad.exe", SRCDIR ^ "Teracide" ^ "Readme.Txt" );
  308.             endif;
  309.         endif;
  310.  
  311. exit;
  312.  
  313. /*---------------------------------------------------------------------------*\
  314. \*---------------------------------------------------------------------------*/
  315. function ShowOptions ();
  316.     STRING        szTitle;
  317.     STRING        szMsg;
  318.     NUMBER        nReturn;
  319.     LIST        listButtons, listDescrip;
  320.  
  321. begin
  322.  
  323.     // Setup the necessary variables.
  324.     szTitle  = "Terracide Setup Options";
  325.     szMsg    = "Click the kind of Terracide Setup your prefer.";
  326.  
  327.     // Grey out the Next button, since we do not want
  328.     // users to use it.
  329.     Disable( NEXTBUTTON );
  330.  
  331.     // create the list of buttons and their descriptions.
  332.  
  333.     listButtons = ListCreate (STRINGLIST);
  334.     listDescrip = ListCreate (STRINGLIST);
  335.  
  336.     // set button list
  337.     // Add the bitmap buttons to the listButtons list.  The second parameter
  338.     // is a specially formatted string designating a bitmap resource found
  339.     // in _ISRES.DLL.
  340.     ListAddString (listButtons, "@12001;1;255,0,255", AFTER);
  341.     ListAddString (listButtons, "@12002;1;255,0,255", AFTER);
  342.  
  343.     // set description list
  344.     ListAddString( listDescrip, "Run Terracide From Hard Disk.\n" +
  345.                     "All files will be installed onto your hard\n" +
  346.                     "disk.\n", AFTER );
  347.  
  348.     ListAddString( listDescrip, "Run Terracide From CD-ROM.\n" +
  349.                     "Selecting this option may result in slow\n" +
  350.                     "gameplay.\n", AFTER);
  351.  
  352.     // Display the set of buttons.
  353.     nReturn = SdOptionsButtons( szTitle, szMsg,listButtons, listDescrip );
  354.  
  355.     // Destroy the lists.
  356.     ListDestroy( listButtons );
  357.     ListDestroy( listDescrip );
  358.  
  359.     Enable (NEXTBUTTON);
  360.  
  361.  
  362.     return nReturn;
  363.  
  364. end;
  365.  
  366. /*---------------------------------------------------------------------------*\
  367.  *
  368.  * Function:  SetupScreen
  369.  *
  370.  *  Purpose:  This function will set up the screen look.  This includes
  371.  *            colors, fonts, text to be displayed, etc.
  372.  *
  373.  *
  374.  *    Input:
  375.  *
  376.  *  Returns:
  377.  *
  378.  * Comments:
  379. \*---------------------------------------------------------------------------*/
  380. function SetupScreen()
  381.         number nDx, nDy;
  382. begin
  383.         GetExtents( nDx, nDy );
  384.  
  385.         Enable( FULLWINDOWMODE );
  386.         Enable( INDVFILESTATUS );
  387.         Enable( BITMAP256COLORS );
  388.  
  389.         SetTitle( "Terracide Internal Demonstration" + "\n(c)1996 Eidos Interactive.", 24, WHITE );
  390.  
  391.         SetColor( BACKGROUND, BK_BLUE ); // Dark blue.
  392.         SetColor( STATUSBAR, BLUE );     // Bright blue.
  393.         SetTitle( "Terracide Demonstration Setup", 0, BACKGROUNDCAPTION ); // Caption bar text.
  394.  
  395.         Enable( BACKGROUND );
  396.  
  397.         // Show the bitmap.
  398. /*        Enable( BITMAPFADE );
  399.         PlaceBitmap( SUPPORTDIR ^ "Splash.BMP", 1, 10, 10, UPPER_LEFT | BITMAPICON );
  400.         Disable( BITMAPFADE ); */
  401.  
  402.  
  403.  
  404.         Delay( 1 );
  405.  
  406. end;
  407.  
  408.  
  409. /*---------------------------------------------------------------------------*\
  410.  *
  411.  * Function:  CheckRequirements
  412.  *
  413.  *  Purpose:  This function will check all minimum requirements for the
  414.  *            application being installed.  If any fail, then the user
  415.  *            is informed and the installation is terminated.
  416.  *
  417.  *
  418.  *    Input:
  419.  *
  420.  *  Returns:
  421.  *
  422.  * Comments:
  423. \*---------------------------------------------------------------------------*/
  424. function CheckRequirements()
  425. number nvDx, nvDy;
  426. number nvResult;
  427. STRING svResult;
  428.  
  429. begin
  430.  
  431.         // Check screen resolution.
  432.         GetExtents( nvDx, nvDy );
  433.         if (nvDy < 480) then
  434.            MessageBox( "This program requires VGA or better resolution.", WARNING );
  435.            exit;
  436.         endif;
  437.  
  438.         // Determine the target system's operating system.
  439.         GetSystemInfo( OS, nvResult, svResult );
  440.         bWinNT  = FALSE;
  441.         bWin32s = FALSE;
  442.         bIsShellExplorer = FALSE;
  443.  
  444.         if (nvResult =  IS_WINDOWSNT) then
  445.            bWinNT = TRUE; // Running Windows NT.
  446.  
  447.            // Check to see if NT is using EXPLORER Shell
  448.            if( QueryShellMgr( svResult ) = 0 ) then
  449.                if( StrCompare( svResult, "EXPLORER.EXE" ) = 0 ) then
  450.                    bIsShellExplorer = TRUE;
  451.                endif;
  452.            endif;
  453.  
  454.         elseif (nvResult =  IS_WIN32S) then
  455.            bWin32s = TRUE; // Running Win32s.
  456.         endif;
  457.  
  458. end;
  459.  
  460.  
  461. #include "sddialog.rul"