home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / CT / CT9501 / PEBBLES2 / PEBBLES.MST < prev    next >
Text File  |  1994-10-17  |  12KB  |  457 lines

  1. '**************************************************************************
  2. '*                       MSSetup Pebbles voor Windows
  3. '**************************************************************************
  4. '$DEFINE DEBUG
  5.  
  6. '$INCLUDE 'setupapi.inc'
  7. '$INCLUDE 'msdetect.inc'
  8. '$INCLUDE 'msshared.inc'
  9.  
  10. ''Dialog ID's
  11. CONST WELCOME      = 100
  12. CONST ASKQUIT      = 200
  13. CONST DESTPATH     = 300
  14. CONST EXITFAILURE  = 400
  15. CONST EXITQUIT     = 600
  16. CONST EXITSUCCESS  = 700
  17. CONST APPHELP      = 900
  18. CONST CUSTINST     = 6200
  19. CONST TOOBIG       = 6300
  20. CONST BADPATH      = 6400
  21.  
  22. ''Bitmap ID
  23. CONST LOGO         = 1
  24.  
  25. ''File Types
  26. CONST APPFILES     = 1
  27. CONST OPTFILES1    = 2
  28. CONST OPTFILES2    = 3
  29.  
  30.  
  31. GLOBAL DEST$        ''Default destination directory.
  32. GLOBAL WINDRIVE$    ''Windows drive letter.
  33. GLOBAL TEMP$        ''Tempory directory
  34.  
  35. ''CustInst list symbol names
  36. GLOBAL APPNEEDS$    ''Option list costs per drive
  37. GLOBAL OPT1NEEDS$
  38. GLOBAL OPT2NEEDS$
  39. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  40. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  41.  
  42. ''Dialog list symbol names
  43. GLOBAL CHECKSTATES$
  44. GLOBAL STATUSTEXT$
  45. GLOBAL DRIVETEXT$
  46.  
  47.  
  48. DECLARE SUB AddOptFilesToCopyList (ftype%)
  49. DECLARE SUB RecalcOptFiles (ftype%)
  50. DECLARE SUB RecalcPath
  51. DECLARE SUB SetDriveStatus
  52. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  53.  
  54.  
  55.  
  56. INIT:
  57.      CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  58.      HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  59.  
  60.      SetBitmap CUIDLL$, LOGO
  61.      SetTitle "Installatie Pebbles 2.0"
  62.  
  63.      szInf$ = GetSymbolValue("STF_SRCINFPATH")
  64.      IF szInf$ = "" THEN
  65.          szInf$ = GetSymbolValue("STF_CWDDIR") + "PEBBLES.INF"
  66.      END IF
  67.      ReadInfFile szInf$
  68.  
  69.      WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  70.      DEST$ = WINDRIVE$ + ":\PEBBLES"
  71.      TEMP$ = WINDRIVE$ + ":\~PEBBLES.TMP"
  72.  
  73.      ''CustInst list symbols
  74.      CHECKSTATES$ = "CheckItemsState"
  75.      STATUSTEXT$  = "StatusItemsText"
  76.      DRIVETEXT$   = "DriveStatusText"
  77.      FOR i% = 1 TO 3 STEP 1
  78.          AddListItem CHECKSTATES$, "ON"
  79.      NEXT i%
  80.      FOR i% = 1 TO 3 STEP 1
  81.          AddListItem STATUSTEXT$, ""
  82.      NEXT i%
  83.      FOR i% = 1 TO 7 STEP 1
  84.          AddListItem DRIVETEXT$, ""
  85.      NEXT i%
  86.      ReplaceListItem DRIVETEXT$, 7, DEST$
  87.  
  88.      ''Disk cost list symbols
  89.      APPNEEDS$   = "AppNeeds"
  90.      OPT1NEEDS$  = "Opt1Needs"
  91.      OPT2NEEDS$  = "Opt2Needs"
  92.      EXTRACOSTS$ = "ExtraCosts"
  93.      BIGLIST$    = "BigList"
  94.      FOR i% = 1 TO 3 STEP 1
  95.          AddListItem BIGLIST$, ""
  96.      NEXT i%
  97.      FOR i% = 1 TO 26 STEP 1
  98.          AddListItem EXTRACOSTS$, "0"
  99.      NEXT i%
  100.  
  101.      RecalcPath
  102.      SetDriveStatus
  103.  
  104.  
  105.  
  106. WELCOME:
  107.      sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
  108.      IF sz$ = "CONTINUE" THEN
  109.          UIPop 1
  110.      ELSE
  111.          GOSUB ASKQUIT
  112.          GOTO WELCOME
  113.      END IF
  114.  
  115.  
  116.  
  117. CUSTINST:
  118.      sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  119.  
  120.      IF sz$ = "CONTINUE" THEN
  121.          ''Install only if it will fit.
  122.          FOR i% = 1 TO 3 STEP 1
  123.              IF GetListItem(BIGLIST$, i%) <> "" THEN
  124.                  GOSUB TOOBIG
  125.                  GOTO CUSTINST
  126.              END IF
  127.          NEXT i%
  128.          UIPop 1
  129.          GOTO INSTALL
  130.      ELSEIF sz$ = "PATH" THEN
  131.          GOTO GETPATH
  132.      ELSEIF sz$ = "CHK1" THEN
  133.          RecalcOptFiles APPFILES
  134.          SetDriveStatus
  135.          GOTO CUSTINST
  136.      ELSEIF sz$ = "CHK2" THEN
  137.          RecalcOptFiles OPTFILES1
  138.          SetDriveStatus
  139.          GOTO CUSTINST
  140.      ELSEIF sz$ = "CHK3" THEN
  141.          RecalcOptFiles OPTFILES2
  142.          SetDriveStatus
  143.          GOTO CUSTINST
  144.      ELSEIF sz$ = "REACTIVATE" THEN
  145.          RecalcPath
  146.          SetDriveStatus
  147.          GOTO CUSTINST
  148.      ELSE
  149.          GOSUB ASKQUIT
  150.          GOTO CUSTINST
  151.      END IF
  152.  
  153.  
  154.  
  155. INSTALL:
  156.      ClearCopyList
  157.      AddOptFilesToCopyList APPFILES
  158.      AddOptFilesToCopyList OPTFILES1
  159.      AddOptFilesToCopyList OPTFILES2
  160.      CreateDir DEST$, cmoNone
  161.      SetRestartDir TEMP$
  162.      CopyFilesInCopyList
  163.  
  164.     IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  165.         CreateProgmanGroup "Pebbles voor Windows 2.0", "", cmoNone
  166.         ShowProgmanGroup  "Pebbles voor Windows 2.0", 1, cmoNone
  167.         CreateProgmanItem "Pebbles voor Windows 2.0", "Pebbles", MakePath(DEST$,"pebbles.exe"), "", cmoOverwrite
  168.         CreateProgmanItem "Pebbles voor Windows 2.0", "Pebbles Help", "winhelp.exe "+MakePath(DEST$,"pebbles.hlp"), "", cmoOverwrite
  169.         CreateIniKeyValue "WIN.INI", "PEBBLES", "SPEL", "", cmoNone
  170.     END IF
  171.  
  172.     IF GetListItem(CHECKSTATES$, OPTFILES1) = "ON" THEN
  173.         CreateProgmanItem "Pebbles voor Windows 2.0", "LeesMij", "write.exe "+MakePath(DEST$,"leesmij.wri"), "", cmoOverwrite
  174.     END IF
  175. ''Check for system files
  176.     IF RestartListEmpty() = 0 THEN
  177.         i% = DoMsgBox("Setup start Windows opnieuw om Systeem-bestanden te installeren!", "Installatie Pebbles voor Windows", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  178.         IF ExitExecRestart() = 1 THEN
  179.             i% = DoMsgBox("Pebbles kan alleen ge∩nstaleerd worden op Windows versie 3.1 of hoger!", "Installatie Pebbles voor Windows", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  180.         END IF
  181.     END IF
  182.  
  183. QUIT:
  184.      ON ERROR GOTO ERRQUIT
  185.  
  186.      IF ERR = 0 THEN
  187.          dlg% = EXITSUCCESS
  188.      ELSEIF ERR = STFQUIT THEN
  189.          dlg% = EXITQUIT
  190.      ELSE
  191.          dlg% = EXITFAILURE
  192.      END IF
  193. QUITL1:
  194.      sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  195.      IF sz$ = "REACTIVATE" THEN
  196.          GOTO QUITL1
  197.      END IF
  198.      UIPop 1
  199.  
  200.      END
  201.  
  202.  
  203.  
  204. ERRQUIT:
  205.      i% = DoMsgBox("Setup bestanden zijn niet goed, neem contact op met de auteur!", "Setup Boodschap", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  206.      END
  207.  
  208.  
  209.  
  210. GETPATH:
  211.      SetSymbolValue "EditTextIn", DEST$
  212.      SetSymbolValue "EditFocus", "END"
  213. GETPATHL1:
  214.      sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  215.  
  216.      IF sz$ = "CONTINUE" THEN
  217.          olddest$ = DEST$
  218.          DEST$ = GetSymbolValue("EditTextOut")
  219.  
  220.          ''Validate new path.
  221.          IF IsDirWritable(DEST$) = 0 THEN
  222.              GOSUB BADPATH
  223.              GOTO GETPATHL1
  224.          END IF
  225.          UIPop 1
  226.  
  227.          ''Truncate display if too long.
  228.          IF LEN(DEST$) > 23 THEN
  229.              ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  230.          ELSE
  231.              ReplaceListItem DRIVETEXT$, 7, DEST$
  232.          END IF
  233.  
  234.          ''Recalc if path changed.
  235.          IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  236.              RecalcPath
  237.              SetDriveStatus
  238.          END IF
  239.  
  240.          olddest$ = ""
  241.          GOTO CUSTINST
  242.      ELSEIF sz$ = "REACTIVATE" THEN
  243.          RecalcPath
  244.          SetDriveStatus
  245.          GOTO GETPATHL1
  246.      ELSEIF sz$ = "EXIT" THEN
  247.          GOSUB ASKQUIT
  248.          GOTO GETPATHL1
  249.      ELSE
  250.          UIPop 1
  251.          GOTO CUSTINST
  252.      END IF
  253.  
  254.  
  255.  
  256. TOOBIG:
  257.      sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  258.      IF sz$ = "REACTIVATE" THEN
  259.          RecalcPath
  260.          SetDriveStatus
  261.          GOTO TOOBIG
  262.      END IF
  263.      UIPop 1
  264.      RETURN
  265.  
  266.  
  267.  
  268. BADPATH:
  269.      sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  270.      IF sz$ = "REACTIVATE" THEN
  271.          RecalcPath
  272.          SetDriveStatus
  273.          GOTO BADPATH
  274.      END IF
  275.      UIPop 1
  276.      RETURN
  277.  
  278.  
  279.  
  280. ASKQUIT:
  281.      sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  282.  
  283.      IF sz$ = "EXIT" THEN
  284.          UIPopAll
  285.          ERROR STFQUIT
  286.      ELSEIF sz$ = "REACTIVATE" THEN
  287.          GOTO ASKQUIT
  288.      ELSE
  289.          UIPop 1
  290.      END IF
  291.      RETURN
  292.  
  293.  
  294.  
  295. '**
  296. '** Purpose:
  297. '**     Adds the specified option files to the copy list.
  298. '** Arguments:
  299. '**     ftype%  - type of files to add, one of the following:
  300. '**             APPFILES, OPTFILES1, OPTFILES2
  301. '** Returns:
  302. '**     none.
  303. '*************************************************************************
  304. SUB AddOptFilesToCopyList (ftype%) STATIC
  305.  
  306.      IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  307.          SrcDir$ = GetSymbolValue("STF_SRCDIR")
  308.          IF ftype% = APPFILES THEN
  309.              AddSectionFilesToCopyList "programma", SrcDir$, DEST$
  310.              IF DoesFileExist (GetWindowsSysDir + "ctl3dv2.dll", femExists) = 0 THEN
  311.                  AddSpecialFileToCopyList "systeem", "SysteemCtl3dv2", SrcDir$, GetWindowsSysDir + "ctl3dv2.dll"
  312.              END IF
  313.          ELSEIF ftype% = OPTFILES1 THEN
  314.              AddSectionFilesToCopyList "leesmij", SrcDir$, DEST$
  315.          ELSEIF ftype% = OPTFILES2 THEN
  316.              AddSectionFilesToCopyList "voorbeeld", SrcDir$, DEST$
  317.          END IF
  318.          SrcDir$ = ""
  319.      END IF
  320. END SUB
  321.  
  322.  
  323. '**
  324. '** Purpose:
  325. '**     Recalculates disk space for the given option files and sets
  326. '**     the status info symbol "StatusItemsText".
  327. '** Arguments:
  328. '**     ftype% - type of files to add, one of the following:
  329. '**             APPFILES, OPTFILES1, OPTFILES2
  330. '** Returns:
  331. '**     none.
  332. '*************************************************************************
  333. SUB RecalcOptFiles (ftype%) STATIC
  334.      CursorSave% = ShowWaitCursor()
  335.      ClearCopyList
  336.      AddOptFilesToCopyList ftype%
  337.  
  338.      fExtra% = 0
  339.      IF ftype% = APPFILES THEN
  340.          ListSym$ = APPNEEDS$
  341.          IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  342.              ''Add extra cost to Windows drive for ini/progman, etc.
  343.              ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  344.             ReplaceListItem EXTRACOSTS$, ndrive%, "1024"
  345.              fExtra% = 1
  346.          END IF
  347.      ELSEIF ftype% = OPTFILES1 THEN
  348.          ListSym$ = OPT1NEEDS$
  349.      ELSEIF ftype% = OPTFILES2 THEN
  350.          ListSym$ = OPT2NEEDS$
  351.      END IF
  352.  
  353.      StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  354.  
  355.      cost& = 0
  356.      FOR i% = 1 TO 26 STEP 1
  357.          cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  358.      NEXT i%
  359.      ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " kByte"
  360.  
  361.      IF StillNeed& > 0 THEN
  362.          ReplaceListItem BIGLIST$, ftype%, "YES"
  363.      ELSE
  364.          ReplaceListItem BIGLIST$, ftype%, ""
  365.      END IF
  366.  
  367.      IF fExtra% THEN
  368.          ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  369.      END IF
  370.      RestoreCursor CursorSave%
  371.      ListSym$ = ""
  372. END SUB
  373.  
  374.  
  375. '**
  376. '** Purpose:
  377. '**     Recalculates disk space and sets option status info according
  378. '**     to the current destination path.
  379. '** Arguments:
  380. '**     none.
  381. '** Returns:
  382. '**     none.
  383. '*************************************************************************
  384. SUB RecalcPath STATIC
  385.  
  386.      CursorSave% = ShowWaitCursor()
  387.  
  388.      RecalcOptFiles APPFILES
  389.      RecalcOptFiles OPTFILES1
  390.      RecalcOptFiles OPTFILES2
  391.  
  392.      RestoreCursor CursorSave%
  393. END SUB
  394.  
  395.  
  396. '**
  397. '** Purpose:
  398. '**     Sets drive status info according to latest disk space calcs.
  399. '** Arguments:
  400. '**     none.
  401. '** Returns:
  402. '**     none.
  403. '*************************************************************************
  404. SUB SetDriveStatus STATIC
  405.  
  406.      drive$ = MID$(DEST$, 1, 1)
  407.      ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  408.      cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
  409.      free& = GetFreeSpaceForDrive(drive$)
  410.      ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  411.      ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " kByte"
  412.      ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " kByte"
  413.  
  414.      IF drive$ = WINDRIVE$ THEN
  415.          ReplaceListItem DRIVETEXT$, 4, ""
  416.          ReplaceListItem DRIVETEXT$, 5, ""
  417.          ReplaceListItem DRIVETEXT$, 6, ""
  418.      ELSE
  419.          ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  420.          cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
  421.          IF cost& = 0 THEN
  422.              ReplaceListItem DRIVETEXT$, 4, ""
  423.              ReplaceListItem DRIVETEXT$, 5, ""
  424.              ReplaceListItem DRIVETEXT$, 6, ""
  425.          ELSE
  426.              free& = GetFreeSpaceForDrive(WINDRIVE$)
  427.              ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  428.              ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " kByte"
  429.              ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " kByte"
  430.          END IF
  431.      END IF
  432. END SUB
  433.  
  434.  
  435. '**
  436. '** Purpose:
  437. '**     Appends a file name to the end of a directory path,
  438. '**     inserting a backslash character as needed.
  439. '** Arguments:
  440. '**     szDir$  - full directory path (with optional ending "\")
  441. '**     szFile$ - filename to append to directory
  442. '** Returns:
  443. '**     Resulting fully qualified path name.
  444. '*************************************************************************
  445. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  446.      IF szDir$ = "" THEN
  447.          MakePath = szFile$
  448.      ELSEIF szFile$ = "" THEN
  449.          MakePath = szDir$
  450.      ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  451.          MakePath = szDir$ + szFile$
  452.      ELSE
  453.          MakePath = szDir$ + "\" + szFile$
  454.      END IF
  455. END FUNCTION
  456.  
  457.