home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 9 / CDE9_B.mdf / gpm / edgpm.mst < prev    next >
Text File  |  1996-01-31  |  12KB  |  403 lines

  1. '' ****************************************************************
  2. '* GPM.MST - F1 GPM Minimal Install Setup Script
  3. '**************************************************************************
  4.     
  5.     '' Global variables
  6.  
  7.     GLOBAL Lang$
  8.     GLOBAL SrcMainDir$
  9.     GLOBAL SrcDrive$
  10.     GLOBAL TitleShortName$
  11.     GLOBAL TitleLongName$
  12.     GLOBAL PromptForPath%
  13.     GLOBAL DefaultPath$
  14.     GLOBAL ProgManGroup$
  15.     GLOBAL ProgManItem$
  16.     GLOBAL szTitleDir$
  17.  
  18.     '' WinG globals
  19.     
  20.     GLOBAL DEST$        ''Default destination directory.
  21.     GLOBAL bInstallDVA%
  22.  
  23. '' ****************************************************************
  24. '' ** Setup Variables
  25. '' ****************************************************************
  26.  
  27.  TitleShortName$ = "Grand Prix Manager - Demonstration"
  28.  TitleLongName$  = "Grand Prix Manager - Demonstration"
  29.     PromptForPath%  = 1                                             '' we prompt for the install path
  30.     DefaultPath$    = "C:\MPS\GPM"                          '' default install path when prompt is displayed   
  31.     ProgManGroup$  = "MicroProse" '' program manager group 
  32.  ProgManItem$  = "Grand Prix Manager - Demonstration"     '' program manager item title
  33.     
  34. '***********************************************************************
  35. '** Mainline
  36. '***********************************************************************
  37.  
  38.     GLOBAL CUIDLL$
  39.  
  40.     '' Include files
  41.     '$INCLUDE 'setupapi.inc'
  42.     CUIDLL$ = "mscuistf.dll"  '' Custom UI dll
  43.     '$INCLUDE 'msdetect.inc'   
  44.     
  45.     '' Dialog ID's
  46.     CONST DESTPATH      = 1000
  47.     CONST APPHELP       = 2000
  48.     CONST TOOBIG        = 3000
  49.     CONST BADPATH       = 4000
  50.     CONST SUCCESS       = 5000
  51.     CONST CONT_PH_SETUP = 101
  52.     CONST EXIT_PH_SETUP = 102
  53.  
  54.     '' WinG DLG ID's
  55.     CONST CHECK         = 2500
  56.     CONST EXITSUCCESS   = 700
  57.     CONST EXITFAILURE   = 400
  58.     CONST EXITQUIT      = 600
  59.     
  60.     CONST LOGO = 100   '' bitmap resource id
  61.     
  62.     '' Functions and subroutines
  63.     DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  64.     DECLARE FUNCTION GetTitleDir (szDefault$) AS STRING
  65.     DECLARE FUNCTION CopyFiles(szTitleDir$) AS INTEGER
  66.     DECLARE SUB ModifyProgramManager
  67.     DECLARE SUB ShowSuccess
  68.     
  69.     '' functions from WinG install
  70.     DECLARE FUNCTION GetRealWindowsSysDir AS STRING
  71.     DECLARE SUB UpdateWinG32 (szOrig$) 
  72.     DECLARE FUNCTION OnWin3x LIB "setuphlp.DLL" AS INTEGER
  73.     DECLARE FUNCTION VflatdPresent LIB "setuphlp.DLL" AS INTEGER
  74.     DECLARE FUNCTION GetRealSystemDir LIB "setuphlp.DLL" (szDir$,cbBuf%) AS INTEGER
  75.     DECLARE FUNCTION IsWin32FileNewer LIB "setuphlp.DLL" (szOrig$,szNew$) AS INTEGER
  76.     DECLARE SUB RenameFilePlease LIB "setuphlp.DLL" (szOrig$,szNew$) 
  77.  
  78.     '' return value displayer for debug purposes
  79.     ''i% = DoMsgBox(STR$(i%), "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  80.  
  81. INIT:
  82.     bInstallDVA% = 0
  83.     
  84.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  85.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  86.  
  87.     '' Set the title and banner bitmap. You must rebuild MSCUISTF.DLL to 
  88.     '' alter the banner bitmap.
  89.     
  90.  SetTitle "Grand Prix Manager - Demonstration"
  91.     SetBitmap CUIDLL$, LOGO 
  92.     
  93.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  94.     IF szInf$ = "" THEN
  95.         szInf$ = GetSymbolValue("STF_CWDDIR") + "wing.inf"
  96.     END IF
  97.     ReadInfFile szInf$
  98.  
  99. CHECK:
  100.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  101.     SrcDrive$ = MID$(SrcDir$,1,1)
  102.     SrcMainDir$ = SrcDrive$+":\GPM\"
  103.     SrcDir$ = SrcDrive$+":\GPM\SYSTEM\"
  104.     DEST$ = GetWindowsSysDir
  105.     AddSectionFilesToCopyList "runtime", SrcDir$, DEST$
  106.     '
  107.     ' only use DVA on Windows 3.x
  108.     '
  109.     IF OnWin3x() = 1 THEN
  110.         AddSectionFilesToCopyList "dva", SrcDir$, DEST$
  111.         IF VflatdPresent() = 0 THEN
  112.         CreateSysIniKeyValue GetWindowsDir + "system.ini", "386Enh", "device", GetWindowsSysDir+"dva.386", cmoOverwrite
  113.         bInstallDVA% = 1
  114.         END IF
  115.     END IF
  116.     
  117.     DEST$ = GetRealWindowsSysDir
  118.     AddSectionFilesToCopyList "wing32", SrcDir$, DEST$
  119.     Dest1$ = MakePath(DEST$,"wing32.dll")
  120.     Dest2$ = MakePath(DEST$,"wing32.xxx")
  121.     RenameFilePlease Dest1$,Dest2$
  122.     CopyFilesInCopyList
  123.     UpdateWinG32 GetRealWindowsSysDir()
  124.  
  125. GPM:
  126.     '' now install GPM files
  127.     
  128.     '' The following statement turns size checking off. Set it to scmOnFatal 
  129.     '' to enable size checking, where Setup will compare the disk file size 
  130.     '' with the INF file size and report an error if they are not the same.
  131.     
  132.     i% = SetSizeCheckMode(scmOff)
  133.     
  134.     
  135.     '' Read in the INF file.
  136.     
  137.  ReadInfFile SrcMainDir$ + "EDGPM.INF"
  138.     
  139.     '' Decide where to put title files
  140.     IF PromptForPath% = 1 THEN
  141.         szTitleDir$ = GetTitleDir(DefaultPath$)
  142.         IF szTitleDir$ = "" THEN
  143.             ERROR STFQUIT
  144.             GOTO QUIT
  145.         ENDIF
  146.     ELSE
  147.         ''szTitleDir$ = GetWindowsDir()
  148.     szTitleDir$ = "C:MPS\GPM"
  149.     ENDIF   
  150.  
  151. '' szTitleDir$=MID$(szTitleDir$,1,3)+"MPS\"+MID$(szTitleDir$,4)
  152.     
  153.     '' add game path direction entry to the gpm ini file
  154.     CreateIniKeyValue GetWindowsDir+"GPMMICP.INI","GPM_PATHS","GAME",szTitleDir$,cmoOverwrite
  155.  
  156.     Lang$ = GetIniKeyString(GetWindowsDir+"GPMMICP.INI","GPM_LANGUAGE","TONGUE") 
  157.     
  158.     '' Copy files
  159.     IF CopyFiles(szTitleDir$) = 0 THEN
  160.         GOTO QUIT
  161.     ENDIF
  162.     
  163.     ModifyProgramManager    
  164.     ShowSuccess
  165.     END
  166.  
  167. QUIT:
  168.     ON ERROR GOTO ERRQUIT
  169.  
  170.     IF ERR = 0 THEN
  171.         dlg% = EXITSUCCESS
  172.     ELSEIF ERR = STFQUIT THEN
  173.         dlg% = EXITQUIT
  174.     ELSEIF ERR = EXIT_PH_SETUP THEN
  175.         dlg% = EXIT_PH_SETUP
  176.     ELSE
  177.         dlg% = EXITFAILURE
  178.     END IF
  179.         
  180.     ''i% = DoMsgBox(STR$(ERR)+" "+STR$(dlg%), "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  181.     
  182.     UIPop 1
  183.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfoDlgProc", 0, "")
  184.     END
  185.  
  186. ERRQUIT:
  187.     i% = DoMsgBox("Setup sources were corrupted, call Microprose Technical Support (see package documentation).", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  188.     END
  189.     
  190.  
  191. '*************************************************************************
  192. '** Purpose:
  193. '**     Prompts the user for a path for the title files
  194. '** Arguments:
  195. '**     szDefault$ - default path
  196. '** Returns:
  197. '**     New valid path name, or "" if the user quit.
  198. '*************************************************************************
  199.  
  200. FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
  201.  
  202.     SetSymbolValue "String", TitleShortName$
  203.     SetSymbolValue "EditTextIn", szDefault$
  204.     SetSymbolValue "EditFocus", "ALL"
  205.  
  206.     GETPATH:
  207.  
  208.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
  209.  
  210.     IF sz$ = "CONTINUE" THEN
  211.         szTitleDir$ = GetSymbolValue("EditTextOut")
  212.         IF IsDirWritable(szTitleDir$) = 0 THEN
  213.  
  214.             BADPATH:
  215.  
  216.             sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
  217.             IF sz$ = "REACTIVATE" THEN
  218.                 GOTO BADPATH
  219.             END IF
  220.             UIPop 1
  221.             GOTO GETPATH
  222.         END IF
  223.         UIPop 1
  224.         CreateDir szTitleDir$, cmoNone
  225.  
  226.     ELSEIF sz$ = "REACTIVATE" THEN
  227.         GOTO GETPATH
  228.     ELSE
  229.         szTitleDir$ = ""
  230.  
  231.     END IF
  232.  
  233.     GetTitleDir = szTitleDir$
  234.  
  235. END FUNCTION
  236.  
  237.  
  238. '*************************************************************************
  239. '** Purpose:
  240. '**     Copies the files in the INF file
  241. '** Arguments:
  242. '**     szTitleDir$ - destination directory for the title files
  243. '** Returns
  244. '**     1 if files were copied, 0 otherwise
  245. '*************************************************************************
  246.  
  247. FUNCTION CopyFiles(szTitleDir$) STATIC AS INTEGER
  248.  
  249.     '' Add all of the title files to the copy list
  250.     AddSectionFilesToCopyList "GPM_DIR", SrcMainDir$, szTitleDir$
  251.     
  252.     IF Lang$ = "FRENCH" THEN
  253.       AddSectionFilesToCopyList "LANG_SPEC_FILES", SrcMainDir$+"FRENCH", szTitleDir$
  254.     ELSEIF Lang$ = "GERMAN" THEN        
  255.       AddSectionFilesToCopyList "LANG_SPEC_FILES", SrcMainDir$+"GERMAN", szTitleDir$
  256.     ELSE
  257.       AddSectionFilesToCopyList "LANG_SPEC_FILES", SrcMainDir$, szTitleDir$
  258.     ENDIF
  259.     
  260.     CreateDir MakePath(szTitleDir$,"SAVEGAME"), cmoNone
  261.  
  262.     '' Check size
  263.     szExtras$ = "Extra"
  264.     szCosts$ = "Costs"
  265.     szNeededs$ = "Neededs"
  266.     FOR i% = 1 TO 26 STEP 1
  267.         AddListItem szExtras$, "0"
  268.     NEXT i%
  269.     
  270.     '' We assume that VIEWER.INI will take another 4K
  271.     ReplaceListItem szExtras$, ASC(MID$(UCASE$(GetWindowsDir()), 1, 1)) - ASC("A") + 1, STR$(4096)
  272.     
  273.     '' Get amount of space required
  274.     StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
  275.     
  276.     '' Put up a message if there is not enough space
  277.     FOR i% = 1 TO 26 STEP 1
  278.         IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
  279.     
  280.             SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
  281.             SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
  282.     
  283.             TOOBIG:
  284.     
  285.             sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
  286.             IF sz$ = "REACTIVATE" THEN
  287.                 GOTO TOOBIG
  288.             END IF
  289.             UIPop 1
  290.             CopyFiles = 0
  291.             GOTO DONTCOPY
  292.         END IF
  293.     NEXT i%
  294.  
  295.     '' Copy the files
  296.     CopyFilesInCopyList
  297.     
  298.     CopyFiles = 1
  299.  
  300. DONTCOPY:
  301.  
  302. END FUNCTION
  303.  
  304. '*************************************************************************
  305. '** Purpose:
  306. '**     Puts up a success dialog
  307. '*************************************************************************
  308.  
  309. SUB ShowSuccess STATIC
  310.  
  311.     SUCCESS:
  312.     
  313.     SetSymbolValue "String1", TitleShortName$
  314.     sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
  315.     IF sz$ = "REACTIVATE" THEN
  316.         GOTO SUCCESS
  317.     END IF
  318.     UIPop 1
  319.     
  320. END SUB
  321.  
  322. '*************************************************************************
  323. '** Purpose:
  324. '**     Creates program manager entries for the title
  325. '*************************************************************************
  326.  
  327. SUB ModifyProgramManager STATIC
  328.  
  329.     '' Create the program manager group
  330.  
  331.     CreateProgmanGroup ProgmanGroup$, "", cmoNone
  332.     ShowProgmanGroup ProgmanGroup$, 1, cmoNone
  333.     CreateProgmanItem ProgmanGroup$, ProgmanItem$, szTitleDir$+"\GPM.EXE",szTitleDir$+"\GPM.ICO",cmoOverwrite
  334.  
  335. ''CreateProgmanItem ProgmanGroup$, "ReadMe", SrcMainDir$+"README.WRI",szTitleDir$+"\README.ICO",cmoOverwrite
  336.  
  337. END SUB
  338.  
  339. '**
  340. '** Purpose:
  341. '**     Appends a file name to the end of a directory path,
  342. '**     inserting a backslash character as needed.
  343. '** Arguments:
  344. '**     szDir$  - full directory path (with optional ending "\")
  345. '**     szFile$ - filename to append to directory
  346. '** Returns:
  347. '**     Resulting fully qualified path name.
  348. '*************************************************************************
  349. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  350.     IF szDir$ = "" THEN
  351.     MakePath = szFile$
  352.     ELSEIF szFile$ = "" THEN
  353.     MakePath = szDir$
  354.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  355.     MakePath = szDir$ + szFile$
  356.     ELSE
  357.     MakePath = szDir$ + "\" + szFile$
  358.     END IF
  359. END FUNCTION
  360.  
  361.  
  362. FUNCTION GetRealWindowsSysDir STATIC AS STRING
  363.     szBuf$ = string$(260, 32)
  364.     cbBuf% = GetRealSystemDir(szBuf$, 260)
  365.     IF cbBuf% = 0 THEN
  366.     ERROR STFERR
  367.     ELSE
  368.     IF cbBuf% > 259 THEN
  369.         res% = DoMsgBox("Buffer Overflow", "MS-Setup Error", MB_ICONHAND+MB_OK)
  370.         ERROR STFERR
  371.     END IF
  372.     szBuf$ = RTRIM$(szBuf$)
  373.     IF MID$(szBuf$, 1, 1) = "\" THEN
  374.         szBuf$ = MID$(CURDIR$, 1, 2) + szBuf$
  375.     ELSEIF MID$(szBuf$, 2, 1) <> ":" THEN
  376.         szBuf$ = MID$(CURDIR$, 1, 3) + szBuf$
  377.     END IF
  378.     IF MID$(szBuf$, LEN(szBuf$), 1) <> "\" THEN
  379.         szBuf$ = szBuf$ + "\"
  380.     END IF
  381.     GetRealWindowsSysDir = szBuf$
  382.     END IF
  383.  
  384.     szBuf$ = ""
  385. END FUNCTION
  386.  
  387. SUB UpdateWinG32 (szOrig$) STATIC 
  388.     '
  389.     ' Here we check the version ourselves of wing32.dll, since 
  390.     ' we can't get version checking for Win32 apps from Win16
  391.     '
  392.     FileNew$ = MakePath(szOrig$, "wing32.dll")
  393.     FileOrig$ = MakePath(szOrig$, "wing32.xxx")
  394.     IF IsWin32FileNewer( FileOrig$, FileNew$ ) THEN
  395.     RemoveFile FileOrig$, cmoForce
  396.     ELSE
  397.     RemoveFile FileNew$, cmoForce           ' get rid of new file
  398.     RenameFilePlease FileOrig$,FileNew$     ' put back old file
  399.     END IF
  400. END SUB
  401.  
  402.  
  403.