home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer 3.6 / 1997-09_Disc_3.6.iso / demos / dc / setup.rul < prev    next >
Text File  |  1997-06-02  |  12KB  |  316 lines

  1. declare
  2. #include "sddialog.h"
  3.  
  4. //  This is the latest and greatest  5/13/97
  5.  
  6. //  NOTE: IN THIS NEW SETUP.RUL NOTICE THAT YOU MAY CHANGE WANT_README &
  7. //  NEED_DIRECTX.  YOU WILL NEED A README.TXT IN ALL OF YOUR ARCHIVES FOR
  8. //  IT TO WORK.  YOU WILL NEED A REDIST FOLDER FOR DIRECTX.  THERE IS A
  9. //  REDIST FOLDER IN \SHARED\REDIST.
  10.  
  11. //  This is a template that many installs can be made from
  12. //  Change any of the following lines to read how you would like to see them
  13. //  Make sure the "NUMBER_OF_INSTALL_OPTIONS is correctly set, for example
  14. //  Necrodome has a Standard Install and a Full Install, for a total of 2
  15. //  install options.
  16. #define YES_I_DO                1   // DO NOT CHANGE
  17. #define NO_I_DONT               0   // DO NOT CHANGE
  18. #define WANT_README             YES_I_DO  //add readme to all archives first,second,etc.
  19. #define NEED_DIRECTX            YES_I_DO  //have a redist folder on root of CD
  20. #define WANT_AUTORUN            NO_I_DONT
  21. #define WANT_A_SHORTCUT         YES_I_DO
  22. #define WANT_A_SLIDESHOW        NO_I_DONT
  23. #define SPACE_FOR_FIRST         4700000 // size in bytes
  24. #define SPACE_FOR_SECOND           0
  25. #define SPACE_FOR_THIRD         0
  26. #define SPACE_FOR_FOURTH        0
  27. #define SPACE_FOR_FIFTH         0
  28. #define COMPANY_NAME            "Strategic Simulations Inc."
  29. #define PRODUCT_NAME            "Dark Colony"
  30. #define PRODUCT_VERSION         "Demo"
  31. #define GAME_EXE_NAME           "DC.exe"
  32. #define DEFAULT_DIRECTORY       "C:\\Program Files\\Dark Colony Demo" // make sure to use "\\" for "\"
  33. #define DEINSTALL_KEY           "DCDemoDeinstallKey"  // A unique string is needed for each game
  34. #define SELECT_INSTALL_OPTIONS  "" // title of install option window
  35. #define TOP_SELECT_MESSAGE      ""
  36. #define BOTTOM_SELECT_MESSAGE   "You will need 46 MB free on your hard drive."
  37. #define FIRST_INSTALL_OPTION    ""
  38. #define SECOND_INSTALL_OPTION   ""
  39. #define THIRD_INSTALL_OPTION    ""
  40. #define FOURTH_INSTALL_OPTION   ""
  41. #define FIFTH_INSTALL_OPTION    ""
  42. #define NUMBER_OF_INSTALL_OPTIONS 1  // important: games without options = 1
  43. #define FIRST_ARCHIVE           "first.z"  // names of the archives that
  44. #define SECOND_ARCHIVE          ""
  45. #define THIRD_ARCHIVE           ""
  46. #define FOURTH_ARCHIVE          ""            //   them match your ICOMP
  47. #define FIFTH_ARCHIVE           ""            //   archives.
  48.  
  49. //  Start Main Program, modifications should be done with programmer supervision
  50.  
  51. STRING szKey, szShortCut, szMsg, szTitle, szTemp, szDir, svDir, svUninstLogFile, szId, szComponents, svResult,
  52.        szParam,szProgram,szFileSet,szProgCall,szConfigLine,szConfigLine2, szMsg1, szMsg2,
  53.        szFileSet2, szCommandLine, szDir1, szFolderName, szDefFolder, szBitmap;
  54. NUMBER nReturn, nResult, nvFileHandle, nExclusiveFlag, nSpaceRequired, nInstall;
  55. BOOL bSpaceOk;
  56.  
  57.   prototype SetupScreen();
  58.   prototype _Perform( STRING );
  59.  
  60. program
  61.   StartHere:
  62.   Disable( BACKGROUND );
  63.   nSpaceRequired = SPACE_FOR_FIRST;
  64.   GetSystemInfo( OS, nResult, svResult );
  65.   if ((nResult = IS_WINDOWSNT) && (NEED_DIRECTX = YES_I_DO)) then
  66.     MessageBox("Windows NT has been detected.\n\n" +
  67.              "This is a Windows 95 game that will\n" +
  68.              "not run on Windows NT.", SEVERE);
  69.     goto theEnd;
  70.   endif;
  71.   // Set installation info., which is required for registry entries.
  72.   InstallationInfo( COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, GAME_EXE_NAME );
  73.   SetupScreen();
  74.   Enable( DIALOGCACHE );
  75.  
  76. beginInstall:
  77.   SdProductName( PRODUCT_NAME );
  78.   szTitle = PRODUCT_NAME;
  79.   szMsg = "";
  80.   Disable (BACKBUTTON);
  81.   SdWelcome ( szTitle, szMsg );
  82.   Enable (BACKBUTTON);
  83.   if (NUMBER_OF_INSTALL_OPTIONS = 1) then
  84.     nInstall = 1;
  85.     goto getdir;
  86.   endif;
  87.  
  88. getOption:
  89.   szTitle = SELECT_INSTALL_OPTIONS;
  90.   szMsg1 = TOP_SELECT_MESSAGE;
  91.   szMsg2 = BOTTOM_SELECT_MESSAGE;
  92.   szId = "";
  93.   szComponents = FIRST_INSTALL_OPTION;
  94.  
  95.   ComponentAddItem(szComponents, FIRST_INSTALL_OPTION, SPACE_FOR_FIRST, TRUE);
  96.   ComponentAddItem(szComponents, SECOND_INSTALL_OPTION, SPACE_FOR_SECOND, FALSE);
  97.   if (NUMBER_OF_INSTALL_OPTIONS > 2) then
  98.     ComponentAddItem(szComponents, THIRD_INSTALL_OPTION, SPACE_FOR_THIRD, FALSE);
  99.   endif;
  100.   if (NUMBER_OF_INSTALL_OPTIONS > 3) then
  101.     ComponentAddItem(szComponents, FOURTH_INSTALL_OPTION, SPACE_FOR_FOURTH, FALSE);
  102.   endif;
  103.   if (NUMBER_OF_INSTALL_OPTIONS = 5) then
  104.     ComponentAddItem(szComponents, FIFTH_INSTALL_OPTION, SPACE_FOR_FIFTH, FALSE);
  105.   endif;
  106.  
  107.   nExclusiveFlag = EXCLUSIVE;
  108.   nReturn = SdAskOptions ( szTitle, szMsg1, szMsg2, szId, szComponents, nExclusiveFlag);
  109.  
  110.   if (nReturn = BACK) then
  111.     goto beginInstall;
  112.   endif;
  113.   if ComponentIsItemSelected(szComponents,FIRST_INSTALL_OPTION) then
  114.     nInstall = 1;
  115.     nSpaceRequired = SPACE_FOR_FIRST;
  116.   elseif ComponentIsItemSelected(szComponents,SECOND_INSTALL_OPTION) then
  117.     nInstall = 2;
  118.     nSpaceRequired = SPACE_FOR_SECOND;
  119.   elseif (NUMBER_OF_INSTALL_OPTIONS > 2) then
  120.     if ComponentIsItemSelected(szComponents, THIRD_INSTALL_OPTION) then
  121.       nInstall = 3;
  122.       nSpaceRequired = SPACE_FOR_THIRD;
  123.     endif;
  124.   elseif (NUMBER_OF_INSTALL_OPTIONS > 3) then
  125.     if ComponentIsItemSelected(szComponents, FOURTH_INSTALL_OPTION) then
  126.       nInstall = 4;
  127.       nSpaceRequired = SPACE_FOR_FOURTH;
  128.     endif;
  129.   elseif (NUMBER_OF_INSTALL_OPTIONS = 5) then
  130.     if ComponentIsItemSelected(szComponents, FIFTH_INSTALL_OPTION) then
  131.       nInstall = 5;
  132.       nSpaceRequired = SPACE_FOR_FIFTH;
  133.     endif;
  134.   endif;
  135.  
  136. getdir:
  137.   szTitle = "";
  138.   svDir = DEFAULT_DIRECTORY;
  139.   szMsg = "";
  140.  
  141.   nReturn = SdAskDestPath (szTitle, szMsg, svDir, STYLE_NORMAL);
  142.  
  143.   if ( nReturn = NEXT ) then
  144.     if ( ExistsDir ( svDir ) = NOTEXISTS ) then
  145.       szTitle = "Confirm Newly Selected Directory";
  146.       szDir = svDir;
  147.       nResult = SdConfirmNewDir (szTitle, szDir, STYLE_NORMAL);
  148.       if (nResult < 0) then
  149.         SprintfBox( SEVERE, "ERROR",
  150.                     "Error creating the directory '%s'\n" +
  151.                     "Installation is incomplete!",szDir );
  152.         exit;
  153.       elseif (nResult = NO) then
  154.         MessageBox( "Directory not created.\n" +
  155.                     "Installation is incomplete! ", SEVERE);
  156.         exit;
  157.       endif;
  158.       bSpaceOk = TRUE;
  159.       if (GetDiskSpace( svDir ) < nSpaceRequired) then
  160.          szMsg = "There is not enough space available on the disk\n" +
  161.                  "'" + svDir + "' \n" +
  162.                  "Please free up some space or change the target location\n" +
  163.                  "to a different disk";
  164.          MessageBox( szMsg, WARNING );
  165.          bSpaceOk = FALSE;
  166.       endif;
  167.       if (bSpaceOk = FALSE) goto getdir;
  168.     endif;
  169.   else
  170.     if (NUMBER_OF_INSTALL_OPTIONS > 1) then         // back button
  171.       goto getOption;
  172.     else
  173.       goto beginInstall;
  174.     endif;
  175.   endif;
  176.   RegDBSetItem( REGDB_APPPATH, svDir );
  177.   szProgram = svDir ^ GAME_EXE_NAME;
  178.   RegDBSetItem( REGDB_APPPATH_DEFAULT, szProgram );
  179.  
  180.   szFolderName = PRODUCT_NAME;
  181.   szDir1 = svDir;
  182.   LongPathToQuote ( szDir1, TRUE );
  183.  
  184.  
  185. TransferFiles:
  186.     if (WANT_AUTORUN = YES_I_DO) then
  187.       RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
  188.       szKey = "\\SOFTWARE" ^ COMPANY_NAME ^ PRODUCT_NAME ^ PRODUCT_VERSION;
  189.       if (RegDBCreateKeyEx(szKey,"") < 0) then
  190.         MessageBox("Register error!",SEVERE);
  191.       endif;
  192.       RegDBSetKeyValueEx(szKey,"DIRECTORY",REGDB_STRING,svDir,-1);
  193.     endif;
  194.     // Prepare InstallShield to record deinstallation information.
  195.     DeinstallStart( svDir, svUninstLogFile, DEINSTALL_KEY, 0 );
  196.     RegDBSetItem( REGDB_UNINSTALL_NAME, PRODUCT_NAME );
  197.  
  198.     switch (nInstall)
  199.  
  200.     case 1:
  201.       _Perform ("one");
  202.     case 2:
  203.       _Perform ("two");
  204.     case 3:
  205.       _Perform ("three");
  206.     case 4:
  207.       _Perform ("four");
  208.     case 5:
  209.       _Perform ("five");
  210.     endswitch;
  211.  
  212.     switch (nResult)
  213.  
  214.     case FS_DONE: // Successful completion.
  215.  
  216.     case FS_CREATEDIR: // Create directory error.
  217.       MessageBox( "Unable to create a directory under " + TARGETDIR + "."+
  218.                   "Please check write access to this directory.", SEVERE );
  219.       exit;
  220.  
  221.     default: // Group all other errors under default label.
  222.       NumToStr( szTemp, nResult );
  223.       MessageBox( "General file transfer error.\n" +
  224.                   "Please check your target location and try again."+
  225.                   "\n\n Error Number:"+szTemp +
  226.                   "\n Related File: "+ERRORFILENAME,
  227.                   SEVERE );
  228.       exit;
  229.     endswitch;
  230.     if (WANT_A_SHORTCUT = YES_I_DO) then
  231.       szShortCut = svDir ^ GAME_EXE_NAME;
  232.       LongPathToQuote(szShortCut,TRUE);
  233.       AddFolderIcon ( "", PRODUCT_NAME, szShortCut, svDir, "", 0, "", REPLACE );
  234.     endif;
  235.     if (NEED_DIRECTX = YES_I_DO) then
  236.       SetDialogTitle(DLG_ASK_YESNO,"Install complete");
  237.       nResult = AskYesNo("IMPORTANT: " + PRODUCT_NAME +" requires DirectX 3 drivers.\n" +
  238.                "Would you like to run the DirectX 3 install now?", YES);
  239.       if (nResult = YES) then
  240.         szProgCall = SRCDISK ^ "redist\\dinstall.exe";
  241.         LaunchApp(szProgCall,"");   // direct X
  242.       endif;
  243.     endif;
  244.     if (WANT_README = YES_I_DO) then
  245.       SetDialogTitle(DLG_ASK_YESNO,"Readme");
  246.       nResult = AskYesNo("Would you like to read the README file now?",YES);
  247.       if (nResult = YES) then
  248.         szProgram = "NOTEPAD.EXE";
  249.         szParam   = svDir ^ "README.TXT";
  250.         LongPathToShortPath( szParam );
  251.         LaunchAppAndWait( szProgram + " " + szParam, "", NOWAIT );
  252.         Delay(2);
  253.       endif;
  254.     endif;
  255. theEnd:
  256. exit;
  257. function SetupScreen()
  258.         number nDx, nDy;
  259. begin
  260.         GetExtents( nDx, nDy );
  261.  
  262.         Enable( FULLWINDOWMODE );
  263.         Enable( INDVFILESTATUS );
  264.         Enable( BITMAP256COLORS );
  265.  
  266.         SetTitle( "Installing " + PRODUCT_NAME, 28, WHITE );
  267.         if (WANT_A_SLIDESHOW = YES_I_DO) then
  268.           SetColor( BACKGROUND, BK_SOLIDBLACK);
  269.         else
  270.           SetColor( BACKGROUND, BK_BLUE ); // Dark blue dittered.
  271.           SetColor( STATUSBAR, BLUE );     // Bright blue.
  272.         endif;
  273.      //   SizeWindow( BACKGROUND, 640, 480 );
  274.      //   PlaceWindow ( BACKGROUND, CENTERED, CENTERED, CENTERED );
  275.         SetTitle( PRODUCT_NAME, 0, BACKGROUNDCAPTION ); // Caption bar text.
  276.         Enable ( BACKGROUND );
  277.         Delay( 1 );
  278.  
  279. end;
  280. function _Perform ( szFileSet )
  281.         STRING sztemp;
  282. begin
  283.         FileSetBeginDefine ( szFileSet );
  284.  
  285.         TARGETDIR = svDir;
  286.  
  287.         if (StrCompare(szFileSet, "one") = 0) then
  288.           sztemp = FIRST_ARCHIVE;
  289.         endif;
  290.         if (StrCompare(szFileSet, "two") = 0) then
  291.           sztemp = SECOND_ARCHIVE;
  292.         endif;
  293.         if (StrCompare(szFileSet, "three") = 0) then
  294.           sztemp = THIRD_ARCHIVE;
  295.         endif;
  296.         if (StrCompare(szFileSet, "four") = 0) then
  297.           sztemp = FOURTH_ARCHIVE;
  298.         endif;
  299.         if (StrCompare(szFileSet, "five") = 0) then
  300.           sztemp = FIFTH_ARCHIVE;
  301.         endif;
  302.         if (WANT_A_SLIDESHOW = YES_I_DO) then
  303.           Disable (STATUS);
  304.         else
  305.           Enable ( STATUS );
  306.           SetStatusWindow ( 0, "Decompressing files." );
  307.         endif;
  308.         CompressGet( sztemp, "*.*", INCLUDE_SUBDIR );
  309.  
  310.         FileSetEndDefine ( szFileSet );
  311.  
  312.         SetStatusWindow ( 0, "Copying files." );
  313.         StatusUpdate ( ON, 100 );
  314.         nResult = FileSetPerformEz ( szFileSet, 0 );
  315. end;
  316. #include "sddialog.rul"