home *** CD-ROM | disk | FTP | other *** search
/ Imaginator / 1_IMAGINATOR.iso / pc / setup / setup.mst < prev    next >
Encoding:
Text File  |  1995-07-16  |  14.3 KB  |  514 lines

  1. '**************************************************************************
  2. '*
  3. '*                      Imaginator! 1.4 setup script
  4. '*                      based on MSSetup Toolkit Sample 2
  5. '*
  6. '**************************************************************************
  7.  
  8. ''$DEFINE DEBUG  ''Define for script development/debugging
  9.  
  10. '$INCLUDE 'setupapi.inc'
  11. '$INCLUDE 'msdetect.inc'
  12.  
  13. ''Dialog ID's
  14. CONST ASKQUIT      = 200
  15. CONST DESTPATH     = 300
  16. CONST EXITFAILURE  = 400
  17. CONST EXITQUIT     = 600
  18. CONST EXITSUCCESS  = 700
  19. CONST OPTIONS      = 800
  20. CONST APPHELP      = 900
  21. CONST TCHELP       = 1000
  22. CONST TCOPTIONS    = 1300
  23. CONST CUSTINST     = 6200
  24. CONST TOOBIG       = 6300
  25. CONST BADPATH      = 6400
  26.  
  27. ''Bitmap ID
  28. CONST LOGO         = 1
  29.  
  30. ''File Types
  31. CONST APPFILES     = 1
  32. CONST OPTFILES1    = 2
  33.  
  34.  
  35. GLOBAL DEST$        ''Default destination directory.
  36. GLOBAL WINDRIVE$    ''Windows drive letter.
  37.  
  38. ''CustInst list symbol names
  39. GLOBAL APPNEEDS$    ''Option list costs per drive
  40. GLOBAL OPT1NEEDS$
  41. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  42. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  43.  
  44. ''Dialog list symbol names
  45. GLOBAL CHECKSTATES$
  46. GLOBAL STATUSTEXT$
  47. GLOBAL DRIVETEXT$
  48.  
  49.  
  50. GLOBAL VERSION$
  51.  
  52. DECLARE SUB AddOptFilesToCopyList (ftype%)
  53. DECLARE SUB RecalcOptFiles (ftype%)
  54. DECLARE SUB RecalcPath
  55. DECLARE SUB SetDriveStatus
  56. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  57.  
  58.  
  59.  
  60. INIT:
  61.     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  62.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  63.  
  64.     SetBitmap CUIDLL$, LOGO
  65.     SetTitle "Imaginator! Installer"
  66.     VERSION$ = ""
  67.  
  68.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  69.     IF szInf$ = "" THEN
  70.         szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  71.     END IF
  72.     ReadInfFile szInf$
  73.  
  74.     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  75.     DEST$ = WINDRIVE$ + ":\IMAGINE"
  76.  
  77.     ''CustInst list symbols
  78.     CHECKSTATES$ = "CheckItemsState"
  79.     STATUSTEXT$  = "StatusItemsText"
  80.     DRIVETEXT$   = "DriveStatusText"
  81.  
  82.     MakeListFromSectionKeys "Chests", "Chests"
  83.     FOR i% = 1 TO GetListLength("Chests")
  84.         temp$ = GetListItem("Chests",i%)
  85.         temp$ = GetSectionKeyFilename("Chests", temp$)
  86.         temp$ = MID$(temp$, 1,LEN(temp$)-4)     '' Remove .CLK
  87.         AddListItem "ChestDir", temp$
  88.         AddListItem "ChestState", "C"
  89.     NEXT i%
  90.  
  91.     FOR i% = 1 TO 3 STEP 1
  92.         AddListItem CHECKSTATES$, "ON"
  93.     NEXT i%
  94.     FOR i% = 1 TO 3 STEP 1
  95.         AddListItem STATUSTEXT$, ""
  96.     NEXT i%
  97.     FOR i% = 1 TO 7 STEP 1
  98.         AddListItem DRIVETEXT$, ""
  99.     NEXT i%
  100.     ReplaceListItem DRIVETEXT$, 7, DEST$
  101.  
  102.     ''Disk cost list symbols
  103.     APPNEEDS$   = "AppNeeds"
  104.     OPT1NEEDS$  = "Opt1Needs"
  105.     EXTRACOSTS$ = "ExtraCosts"
  106.     BIGLIST$    = "BigList"
  107.     FOR i% = 1 TO 3 STEP 1
  108.         AddListItem BIGLIST$, ""
  109.     NEXT i%
  110.     FOR i% = 1 TO 26 STEP 1
  111.         AddListItem EXTRACOSTS$, "0"
  112.     NEXT i%
  113.  
  114.     ''File Option Variables
  115.     OPT1OPT$ = ""
  116.  
  117.     RecalcPath
  118.     SetDriveStatus
  119.  
  120. '$IFDEF DEBUG
  121.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  122. '$ENDIF ''DEBUG
  123.  
  124.  
  125.  
  126. CUSTINST:
  127.     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  128.  
  129.     IF sz$ = "CONTINUE" THEN
  130.         ''Install only if it will fit.
  131.         FOR i% = 1 TO 3 STEP 1
  132.             IF GetListItem(BIGLIST$, i%) <> "" THEN
  133.                 GOSUB TOOBIG
  134.                 GOTO CUSTINST
  135.             END IF
  136.         NEXT i%
  137.         UIPop 1
  138.         GOTO INSTALL
  139.     ELSEIF sz$ = "PATH" THEN
  140.         GOTO GETPATH
  141.     ELSEIF sz$ = "CHK1" THEN
  142.         RecalcOptFiles APPFILES
  143.         SetDriveStatus
  144.         GOTO CUSTINST
  145.     ELSEIF sz$ = "CHK2" THEN
  146.         RecalcOptFiles OPTFILES1
  147.         SetDriveStatus
  148.         GOTO CUSTINST
  149.     ELSEIF sz$ = "BTN2" THEN
  150.         GOTO OPTFILES1
  151.     ELSEIF sz$ = "REACTIVATE" THEN
  152.         RecalcPath
  153.         SetDriveStatus
  154.         GOTO CUSTINST
  155.     ELSE
  156.         GOSUB ASKQUIT
  157.         GOTO CUSTINST
  158.     END IF
  159.  
  160.  
  161.  
  162. INSTALL:
  163.     ClearCopyList
  164.     AddOptFilesToCopyList APPFILES
  165.     AddOptFilesToCopyList OPTFILES1
  166.     CreateDir DEST$, cmoNone
  167.  
  168.     CopyFilesInCopyList
  169.  
  170.  
  171.  
  172.     IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  173.         temp$ = makePath(DEST$,"imagine.exe")
  174.         CreateProgmanGroup "Imaginator!", "", cmoNone
  175.         ShowProgmanGroup  "Imaginator!", 1, cmoNone
  176.         CreateProgmanItem "Imaginator!", "Imaginator!", temp$, "", cmoOverwrite
  177.         CreateProgmanItem "Imaginator!", "Imaginator! Help", "winhelp.exe "+MakePath(DEST$,"imagine.hlp"), "", cmoOverwrite
  178.         CreateProgmanItem "Imaginator!", "Imaginator! Read Me", "write.exe "+MakePath(DEST$,"readme.wri"), "", cmoOverwrite
  179.         CreateIniKeyValue "WIN.INI", "Extensions", "KSS", temp$+" ^.KSS", cmoOverwrite
  180.         CreateIniKeyValue "WIN.INI", "Extensions", "KSF", temp$+" ^.KSF", cmoOverwrite
  181.     END IF
  182.  
  183. '' Set up link files to point to the CD-ROM
  184.     IF GetListItem(CHECKSTATES$, OPTFILES1) = "ON" THEN
  185.         FOR i% = 1 TO GetListLength("Chests")
  186.             IF GetListItem("ChestState",i%) = "L" THEN
  187.                 temp$ = GetListItem("ChestDir",i%)
  188.                 open MakePath(DEST$,"chests\"+temp$+".clk") for output as #1
  189.                 print #1, MakePath(GetSymbolValue("STF_SRCDIR"),"imagine\chests\"+temp$+".chs")
  190. '$IFDEF DEBUG
  191.                 print #1, GetListItem("Chests",i%)
  192.                 print #1, GetListItem("ChestDir",i%)
  193.                 print #1, OPT1OPT$
  194. '$ENDIF ''DEBUG
  195.                 close #1
  196.             END IF
  197.         NEXT i%
  198.     END IF
  199.  
  200.  
  201. QUIT:
  202.     ON ERROR GOTO ERRQUIT
  203.  
  204.     IF ERR = 0 THEN
  205.         dlg% = EXITSUCCESS
  206.     ELSEIF ERR = STFQUIT THEN
  207.         dlg% = EXITQUIT
  208.     ELSE
  209.         dlg% = EXITFAILURE
  210. '$ifdef DEBUG
  211.         StfApiErr saeFail, "Setup", STR$(ERR)
  212. '$endif ''DEBUG
  213.     END IF
  214. QUITL1:
  215.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  216.     IF sz$ = "REACTIVATE" THEN
  217.         GOTO QUITL1
  218.     END IF
  219.     UIPop 1
  220.  
  221.     END
  222.  
  223. ERRQUIT:
  224.     i% = DoMsgBox("Setup sources were corrupted, call KidSoft", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  225.     END
  226.  
  227.  
  228.  
  229. GETPATH:
  230.     SetSymbolValue "EditTextIn", DEST$
  231.     SetSymbolValue "EditFocus", "END"
  232. GETPATHL1:
  233.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  234.  
  235.     IF sz$ = "CONTINUE" THEN
  236.         olddest$ = DEST$
  237.         DEST$ = GetSymbolValue("EditTextOut")
  238.  
  239.         ''Validate new path.
  240.         IF IsDirWritable(DEST$) = 0 THEN
  241.             GOSUB BADPATH
  242.             GOTO GETPATHL1
  243.         END IF
  244.         UIPop 1
  245.  
  246.         ''Truncate display if too long.
  247.         IF LEN(DEST$) > 23 THEN
  248.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  249.         ELSE
  250.             ReplaceListItem DRIVETEXT$, 7, DEST$
  251.         END IF
  252.  
  253.         ''Recalc if path changed.
  254.         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  255.             RecalcPath
  256.             SetDriveStatus
  257.         END IF
  258.  
  259.         olddest$ = ""
  260.         GOTO CUSTINST
  261.     ELSEIF sz$ = "REACTIVATE" THEN
  262.         RecalcPath
  263.         SetDriveStatus
  264.         GOTO GETPATHL1
  265.     ELSEIF sz$ = "EXIT" THEN
  266.         GOSUB ASKQUIT
  267.         GOTO GETPATHL1
  268.     ELSE
  269.         UIPop 1
  270.         GOTO CUSTINST
  271.     END IF
  272.  
  273.  
  274.  
  275. OPTFILES1:
  276.     opt$ = GetSymbolValue("ChestState")
  277.     SetSymbolValue "ListItemsIn", GetSymbolValue("Chests")
  278.     SetSymbolValue "ListValuesIn", opt$
  279. OPT1L1:
  280.     sz$ = UIStartDlg(CUIDLL$, TCOPTIONS, "FMultiDlgProc", TCHELP, HELPPROC$)
  281.     newopt$ = GetSymbolValue("ListValuesOut")
  282.  
  283.     IF sz$ = "CONTINUE" THEN
  284.         UIPop 1
  285.         IF newopt$ <> opt$ THEN
  286.             SetSymbolValue "ChestState", newopt$
  287.             RecalcOptFiles OPTFILES1
  288.             SetDriveStatus
  289.         END IF
  290.         newopt$ = ""
  291.         GOTO CUSTINST
  292.     ELSEIF sz$ = "REACTIVATE" THEN
  293.         RecalcPath
  294.         SetDriveStatus
  295.         GOTO OPT1L1
  296.     ELSEIF sz$ = "EXIT" THEN
  297.         GOSUB ASKQUIT
  298.         GOTO OPT1L1
  299.     ELSE
  300.         UIPop 1
  301.         newopt$ = ""
  302.         GOTO CUSTINST
  303.     END IF
  304.  
  305. TOOBIG:
  306.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  307.     IF sz$ = "REACTIVATE" THEN
  308.         RecalcPath
  309.         SetDriveStatus
  310.         GOTO TOOBIG
  311.     END IF
  312.     UIPop 1
  313.     RETURN
  314.  
  315.  
  316.  
  317. BADPATH:
  318.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  319.     IF sz$ = "REACTIVATE" THEN
  320.         RecalcPath
  321.         SetDriveStatus
  322.         GOTO BADPATH
  323.     END IF
  324.     UIPop 1
  325.     RETURN
  326.  
  327.  
  328.  
  329. ASKQUIT:
  330.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  331.  
  332.     IF sz$ = "EXIT" THEN
  333.         UIPopAll
  334.         ERROR STFQUIT
  335.     ELSEIF sz$ = "REACTIVATE" THEN
  336.         GOTO ASKQUIT
  337.     ELSE
  338.         UIPop 1
  339.     END IF
  340.     RETURN
  341.  
  342.  
  343. '**
  344. '** Purpose:
  345. '**     Adds the specified option files to the copy list.
  346. '** Arguments:
  347. '**     ftype%  - type of files to add, one of the following:
  348. '**             APPFILES, OPTFILES1, OPTFILES2
  349. '** Returns:
  350. '**     none.
  351. '*************************************************************************
  352. SUB AddOptFilesToCopyList (ftype%) STATIC
  353.  
  354.     SrcDir$ = MakePath(GetSymbolValue("STF_SRCDIR"), "imagine")
  355.  
  356.     IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  357.  
  358.         IF ftype% = APPFILES THEN
  359.             AddSectionFilesToCopyList "Program", SrcDir$, DEST$
  360.             AddSectionFilesToCopyList "DLLs", SrcDir$, DEST$
  361.             srcSnd$ = MakePath(SrcDir$,"sounds")
  362.             dstSnd$ = MakePath(DEST$,"sounds")
  363.             AddSectionFilesToCopyList "Sounds", srcSnd$, dstSnd$
  364.         ELSEIF ftype% = OPTFILES1 THEN
  365.             srcTC$ = MakePath(SrcDir$,"chests")
  366.             dstTC$ = MakePath(DEST$,"chests")
  367.             FOR i% = 1 TO GetListLength("Chests")
  368.                 IF GetListItem("ChestState",i%) = "L" THEN
  369.                     AddSectionKeyFileToCopyList "Chests",GetListItem("Chests",i%), srcTC$, dstTC$
  370.                 ELSEIF GetListItem("ChestState",i%) = "C" THEN
  371.                     temp$ = GetListItem("ChestDir",i%)
  372.                     AddSectionFilesToCopyList temp$, srcTC$, dstTC$
  373.                     temp$ = temp$ + "_"
  374.                     AddSectionFilesToCopyList temp$, MakePath(srcTC$,temp$), MakePath(dstTC$,temp$)
  375.                 END IF
  376.             NEXT i%
  377.         END IF
  378.  
  379.     END IF
  380.     SrcDir$ = ""
  381. END SUB
  382.  
  383.  
  384. '**
  385. '** Purpose:
  386. '**     Recalculates disk space for the given option files and sets
  387. '**     the status info symbol "StatusItemsText".
  388. '** Arguments:
  389. '**     ftype% - type of files to add, one of the following:
  390. '**             APPFILES, OPTFILES1, OPTFILES2
  391. '** Returns:
  392. '**     none.
  393. '*************************************************************************
  394. SUB RecalcOptFiles (ftype%) STATIC
  395.     CursorSave% = ShowWaitCursor()
  396.     ClearCopyList
  397.     AddOptFilesToCopyList ftype%
  398.  
  399.     fExtra% = 0
  400.     IF ftype% = APPFILES THEN
  401.         ListSym$ = APPNEEDS$
  402.         IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  403.             ''Add extra cost to Windows drive for ini/progman, etc.
  404.             ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  405.             ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  406.             fExtra% = 1
  407.         END IF
  408.     ELSEIF ftype% = OPTFILES1 THEN
  409.         ListSym$ = OPT1NEEDS$
  410.     END IF
  411.  
  412.     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  413.  
  414.     cost& = 0
  415.     FOR i% = 1 TO 26 STEP 1
  416.         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  417.     NEXT i%
  418.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  419.  
  420.     IF StillNeed& > 0 THEN
  421.         ReplaceListItem BIGLIST$, ftype%, "YES"
  422.     ELSE
  423.         ReplaceListItem BIGLIST$, ftype%, ""
  424.     END IF
  425.  
  426.     IF fExtra% THEN
  427.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  428.     END IF
  429.     RestoreCursor CursorSave%
  430.     ListSym$ = ""
  431. END SUB
  432.  
  433.  
  434. '**
  435. '** Purpose:
  436. '**     Recalculates disk space and sets option status info according
  437. '**     to the current destination path.
  438. '** Arguments:
  439. '**     none.
  440. '** Returns:
  441. '**     none.
  442. '*************************************************************************
  443. SUB RecalcPath STATIC
  444.  
  445.     CursorSave% = ShowWaitCursor()
  446.  
  447.     RecalcOptFiles APPFILES
  448.     RecalcOptFiles OPTFILES1
  449.     RestoreCursor CursorSave%
  450. END SUB
  451.  
  452.  
  453. '**
  454. '** Purpose:
  455. '**     Sets drive status info according to latest disk space calcs.
  456. '** Arguments:
  457. '**     none.
  458. '** Returns:
  459. '**     none.
  460. '*************************************************************************
  461. SUB SetDriveStatus STATIC
  462.  
  463.     drive$ = MID$(DEST$, 1, 1)
  464.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  465.     cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%))
  466.     free& = GetFreeSpaceForDrive(drive$)
  467.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  468.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  469.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  470.  
  471.     IF drive$ = WINDRIVE$ THEN
  472.         ReplaceListItem DRIVETEXT$, 4, ""
  473.         ReplaceListItem DRIVETEXT$, 5, ""
  474.         ReplaceListItem DRIVETEXT$, 6, ""
  475.     ELSE
  476.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  477.         cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%))
  478.         IF cost& = 0 THEN
  479.             ReplaceListItem DRIVETEXT$, 4, ""
  480.             ReplaceListItem DRIVETEXT$, 5, ""
  481.             ReplaceListItem DRIVETEXT$, 6, ""
  482.         ELSE
  483.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  484.             ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  485.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  486.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  487.         END IF
  488.     END IF
  489. END SUB
  490.  
  491.  
  492. '**
  493. '** Purpose:
  494. '**     Appends a file name to the end of a directory path,
  495. '**     inserting a backslash character as needed.
  496. '** Arguments:
  497. '**     szDir$  - full directory path (with optional ending "\")
  498. '**     szFile$ - filename to append to directory
  499. '** Returns:
  500. '**     Resulting fully qualified path name.
  501. '*************************************************************************
  502. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  503.     IF szDir$ = "" THEN
  504.         MakePath = szFile$
  505.     ELSEIF szFile$ = "" THEN
  506.         MakePath = szDir$
  507.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  508.         MakePath = szDir$ + szFile$
  509.     ELSE
  510.         MakePath = szDir$ + "\" + szFile$
  511.     END IF
  512. END FUNCTION
  513.  
  514.