home *** CD-ROM | disk | FTP | other *** search
/ Trivial Pursuit (CD-ROM Edition) / TrivialP.iso / tpeurope.mst < prev    next >
Text File  |  1995-10-15  |  13KB  |  473 lines

  1. '**************************************************************************
  2. '*                       TRIVIAL PURSUIT SETUP
  3. '**************************************************************************
  4.  
  5. '$DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''The following are for installation of the TrueType Font
  11. CONST WM_FONTCHANGE = 29
  12. CONST HWND_BROADCAST = -1
  13.  
  14. ''following were taken from windows.h. &H means they're hex
  15. CONST WS_VISIBLE=&H10000000
  16. CONST WS_BORDER =&H00800000
  17. CONST WS_CLIPCHILDREN =&H02000000
  18. CONST GWL_STYLE =-16
  19. CONST SW_SHOWMAXIMIZED=3
  20.  
  21. CONST DO_CUSTOM = 1
  22.  
  23. CONST VERSION_WIN95    = 95
  24.  
  25. CONST MYIDOK        = 1
  26. CONST MYIDCANCEL    = 0
  27. CONST MB_OKCANCEL    =&H0001
  28.  
  29. ''Dialog ID's
  30. CONST ASKQUIT      = 200
  31. CONST DESTPATH     = 300
  32. CONST EXITFAILURE  = 400
  33. CONST EXITQUIT     = 600
  34. CONST EXITSUCCESS  = 700
  35. CONST OPTIONS      = 800
  36. CONST APPHELP      = 900
  37. CONST CUSTINST     = 6200
  38. CONST TOOBIG       = 6300
  39. CONST BADPATH      = 6400
  40.  
  41. ''Bitmap ID
  42. CONST LOGO         = 1
  43.  
  44. ''File Types
  45. CONST APPFILES     = 1
  46. CONST OPTFILES1    = 2
  47. CONST OPTFILES2    = 3
  48.  
  49. GLOBAL DEST$        ''Default destination directory.
  50. GLOBAL WINDRIVE$    ''Windows drive letter.
  51. GLOBAL OPT1OPT$     ''Option selection from OptFiles1 option dialog.
  52. GLOBAL OPT2OPT$     ''Option selection from OptFiles2 option dialog.
  53.  
  54. ''CustInst list symbol names
  55. GLOBAL APPNEEDS$    ''Option list costs per drive
  56. GLOBAL OPT1NEEDS$
  57. GLOBAL OPT2NEEDS$
  58. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  59. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  60.  
  61. ''Dialog list symbol names
  62. GLOBAL CHECKSTATES$
  63. GLOBAL STATUSTEXT$
  64. GLOBAL DRIVETEXT$
  65.  
  66. '' The next three declarations are for font installation.
  67.  
  68. DECLARE FUNCTION CreateScalableFontResource  LIB "GDI.EXE" (fHidden%, FOTFile$, TTFFile$, SysDir$) AS INTEGER
  69. DECLARE FUNCTION AddFontResource  LIB "GDI.EXE" (FOTFile$) AS INTEGER
  70. DECLARE FUNCTION SendMessage  LIB "USER.EXE" (hWnd%, Message%, wParam%, lParam&) AS LONG
  71.  
  72. DECLARE FUNCTION ShowWindow  LIB "user.exe" (hWnd%,iShow%) AS INTEGER
  73. DECLARE FUNCTION SetWindowLong LIB "user.exe" (hWnd%, offset%, style&) AS LONG
  74. DECLARE SUB PlaySound LIB "mscuistf.dll" (arg$)
  75. DECLARE SUB CreateBackground LIB "mscuistf.dll" (arg%)
  76. DECLARE SUB DisplayBitmap LIB "mscuistf.dll" (arg%)
  77. DECLARE SUB CleanUp LIB "mscuistf.dll" 
  78.  
  79. DECLARE SUB AddOptFilesToCopyList (ftype%)
  80. DECLARE SUB RecalcOptFiles (ftype%)
  81. DECLARE SUB RecalcPath
  82. DECLARE SUB SetDriveStatus
  83. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  84.  
  85. INIT:
  86.  
  87.     hWnd%=HwndFrame()
  88.     CreateBackground (hWnd%)
  89.     SWLxx&=SetWindowLong(hWnd%,GWL_STYLE,WS_VISIBLE+WS_BORDER+WS_CLIPCHILDREN)
  90.     SWyy%=ShowWindow(hWnd%,SW_SHOWMAXIMIZED)
  91.     DisplayBitmap (hWnd%)
  92.     
  93.     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  94.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  95.  
  96. ''    SetBitmap CUIDLL$, LOGO
  97.     SetTitle "Trivial Pursuit"
  98.  
  99.     ''Find out if everything else has been installed properly before putting our stuff down on the disk 
  100.      DoInstall% = AskInstall(1)
  101.     IF DoInstall% <> MYIDOK THEN
  102.         GOTO ABORTINSTALL
  103.     ENDIF
  104.  
  105.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  106.     IF szInf$ = "" THEN
  107.         szInf$ = GetSymbolValue("STF_CWDDIR") + "TPEUROPE.INF"
  108.     END IF
  109.     ReadInfFile szInf$
  110.  
  111.     
  112.     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  113.     DEST$ = WINDRIVE$ + ":\PURSUIT"
  114.  
  115.     ''CustInst list symbols
  116.     CHECKSTATES$ = "CheckItemsState"
  117.     STATUSTEXT$  = "StatusItemsText"
  118.     DRIVETEXT$   = "DriveStatusText"
  119.     FOR i% = 1 TO 3 STEP 1
  120.         AddListItem CHECKSTATES$, "ON"
  121.     NEXT i%
  122.     FOR i% = 1 TO 3 STEP 1
  123.         AddListItem STATUSTEXT$, ""
  124.     NEXT i%
  125.     FOR i% = 1 TO 7 STEP 1
  126.         AddListItem DRIVETEXT$, ""
  127.     NEXT i%
  128.     ReplaceListItem DRIVETEXT$, 7, DEST$
  129.  
  130.     ''Disk cost list symbols
  131.     APPNEEDS$   = "AppNeeds"
  132.     OPT1NEEDS$  = "Opt1Needs"
  133.     OPT2NEEDS$  = "Opt2Needs"
  134.     EXTRACOSTS$ = "ExtraCosts"
  135.     BIGLIST$    = "BigList"
  136.     FOR i% = 1 TO 3 STEP 1
  137.         AddListItem BIGLIST$, ""
  138.     NEXT i%
  139.     FOR i% = 1 TO 26 STEP 1
  140.         AddListItem EXTRACOSTS$, "0"
  141.     NEXT i%
  142.  
  143.     WaveFile$ = "PURSUIT.WAV"
  144.     PlaySound(WaveFile$)
  145.  
  146.     ''File Option Variables
  147.     OPT1OPT$ = "1"
  148.     OPT2OPT$ = "1"
  149.  
  150.     RecalcPath
  151.     SetDriveStatus
  152.  
  153. '$IFDEF DEBUG
  154.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  155. '$ENDIF ''DEBUG
  156.  
  157.  
  158.  
  159. CUSTINST:
  160.     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  161.  
  162.     IF sz$ = "CONTINUE" THEN
  163.         ''Install only if it will fit.
  164.         FOR i% = 1 TO 3 STEP 1
  165.             IF GetListItem(BIGLIST$, i%) <> "" THEN
  166.                 GOSUB TOOBIG
  167.                 GOTO CUSTINST
  168.             END IF
  169.         NEXT i%
  170.         UIPop 1
  171.         GOTO INSTALL
  172.     ELSEIF sz$ = "PATH" THEN
  173.         GOTO GETPATH
  174.     ELSEIF sz$ = "REACTIVATE" THEN
  175.         RecalcPath
  176.         SetDriveStatus
  177.         GOTO CUSTINST
  178.     ELSE
  179.         GOSUB ASKQUIT
  180.         GOTO CUSTINST
  181.     END IF
  182.  
  183.  
  184.  
  185. INSTALL:
  186.     ClearCopyList
  187.     AddOptFilesToCopyList APPFILES
  188.                                        
  189.     myVersion% = GetWindowsMinorVersion ()
  190.     MySrcDir$ = GetSymbolValue("STF_SRCDIR")
  191.  
  192.     '' Is Win95 running?
  193.     IF myVersion% <> VERSION_WIN95    THEN
  194.         AddSectionFilesToCopyList "WIN31", MySrcDir$, DEST$
  195.     ELSE
  196.         AddSectionFilesToCopyList "WIN95", MySrcDir$, DEST$
  197.     ENDIF
  198.  
  199.     CreateDir DEST$, cmoNone
  200.     CopyFilesInCopyList                   
  201.     
  202.     CreateProgmanGroup "Trivial Pursuit", "", cmoNone
  203.      ShowProgmanGroup  "Trivial Pursuit", 1, cmoNone
  204.     CreateProgmanItem "Trivial Pursuit", "Trivial Pursuit", MakePath(DEST$,"pursuit.exe"), "", cmoOverwrite
  205.  
  206. ABORTINSTALL:
  207.  
  208.     dlg% = EXITQUIT
  209.     CleanUp
  210.     
  211.     END        
  212.  
  213. QUIT:
  214.     ON ERROR GOTO ERRQUIT
  215.  
  216.     IF ERR = 0 THEN
  217.         dlg% = EXITSUCCESS
  218.         CleanUp
  219.     ELSEIF ERR = STFQUIT THEN
  220.         dlg% = EXITQUIT
  221.         CleanUp
  222.     ELSE
  223.         dlg% = EXITFAILURE
  224.         CleanUp
  225.     END IF
  226. QUITL1:
  227.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  228.     IF sz$ = "REACTIVATE" THEN
  229.         GOTO QUITL1
  230.     END IF
  231.     UIPop 1
  232.  
  233.     END
  234.  
  235. ERRQUIT:
  236.     i% = DoMsgBox("Setup sources were corrupted, call Product Support!", "Fatal Error", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  237.     END
  238.  
  239.  
  240.  
  241. GETPATH:
  242.     SetSymbolValue "EditTextIn", DEST$
  243.     SetSymbolValue "EditFocus", "END"
  244. GETPATHL1:
  245.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  246.  
  247.     IF sz$ = "CONTINUE" THEN
  248.         olddest$ = DEST$
  249.         DEST$ = GetSymbolValue("EditTextOut")
  250.  
  251.         ''Validate new path.
  252.         IF IsDirWritable(DEST$) = 0 THEN
  253.             GOSUB BADPATH
  254.             GOTO GETPATHL1
  255.         END IF
  256.         UIPop 1
  257.  
  258.         ''Truncate display if too long.
  259.         IF LEN(DEST$) > 23 THEN
  260.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  261.         ELSE
  262.             ReplaceListItem DRIVETEXT$, 7, DEST$
  263.         END IF
  264.  
  265.         ''Recalc if path changed.
  266.         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  267.             RecalcPath
  268.             SetDriveStatus
  269.         END IF
  270.  
  271.         olddest$ = ""
  272.         GOTO CUSTINST
  273.     ELSEIF sz$ = "REACTIVATE" THEN
  274.         RecalcPath
  275.         SetDriveStatus
  276.         GOTO GETPATHL1
  277.     ELSEIF sz$ = "EXIT" THEN
  278.         GOSUB ASKQUIT
  279.         GOTO GETPATHL1
  280.     ELSE
  281.         UIPop 1
  282.         GOTO CUSTINST
  283.     END IF
  284.  
  285. TOOBIG:
  286.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  287.     IF sz$ = "REACTIVATE" THEN
  288.         RecalcPath
  289.         SetDriveStatus
  290.         GOTO TOOBIG
  291.     END IF
  292.     UIPop 1
  293.     RETURN
  294.  
  295.  
  296.  
  297. BADPATH:
  298.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  299.     IF sz$ = "REACTIVATE" THEN
  300.         RecalcPath
  301.         SetDriveStatus
  302.         GOTO BADPATH
  303.     END IF
  304.     UIPop 1
  305.     RETURN
  306.  
  307.  
  308.  
  309. ASKQUIT:
  310.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  311.  
  312.     IF sz$ = "EXIT" THEN
  313.         UIPopAll
  314.         ERROR STFQUIT
  315.         CleanUp
  316.     ELSEIF sz$ = "REACTIVATE" THEN
  317.         GOTO ASKQUIT
  318.     ELSE
  319.         UIPop 1
  320.     END IF
  321.     RETURN
  322.  
  323.  
  324.  
  325. '**
  326. '** Purpose:
  327. '**     Adds the specified option files to the copy list.
  328. '** Arguments:
  329. '**     ftype%  - type of files to add, one of the following:
  330. '**             APPFILES, OPTFILES1, OPTFILES2
  331. '** Returns:
  332. '**     none.
  333. '*************************************************************************
  334. SUB AddOptFilesToCopyList (ftype%) STATIC
  335.  
  336.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  337.     IF ftype% = APPFILES THEN
  338.         AddSectionFilesToCopyList "AppFiles", SrcDir$, DEST$
  339.     END IF
  340.     SrcDir$ = ""
  341. END SUB
  342.  
  343.  
  344. '**
  345. '** Purpose:
  346. '**     Recalculates disk space for the given option files and sets
  347. '**     the status info symbol "StatusItemsText".
  348. '** Arguments:
  349. '**     ftype% - type of files to add, one of the following:
  350. '**             APPFILES, OPTFILES1, OPTFILES2
  351. '** Returns:
  352. '**     none.
  353. '*************************************************************************
  354. SUB RecalcOptFiles (ftype%) STATIC
  355.     CursorSave% = ShowWaitCursor()
  356.     ClearCopyList
  357.     AddOptFilesToCopyList ftype%
  358.  
  359.     fExtra% = 0
  360.     IF ftype% = APPFILES THEN
  361.         ListSym$ = APPNEEDS$
  362.         ''Add extra cost to Windows drive for ini/progman, etc.
  363.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  364.         ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  365.         fExtra% = 1
  366.     ELSEIF ftype% = OPTFILES1 THEN
  367.         ListSym$ = OPT1NEEDS$
  368.     ELSEIF ftype% = OPTFILES2 THEN
  369.         ListSym$ = OPT2NEEDS$
  370.     END IF
  371.  
  372.     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  373.  
  374.     cost& = 0
  375.     FOR i% = 1 TO 26 STEP 1
  376.         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  377.     NEXT i%
  378.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  379.  
  380.     IF StillNeed& > 0 THEN
  381.         ReplaceListItem BIGLIST$, ftype%, "YES"
  382.     ELSE
  383.         ReplaceListItem BIGLIST$, ftype%, ""
  384.     END IF
  385.  
  386.     IF fExtra% THEN
  387.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  388.     END IF
  389.     RestoreCursor CursorSave%
  390.     ListSym$ = ""
  391. END SUB
  392.  
  393.  
  394. '**
  395. '** Purpose:
  396. '**     Recalculates disk space and sets option status info according
  397. '**     to the current destination path.
  398. '** Arguments:
  399. '**     none.
  400. '** Returns:
  401. '**     none.
  402. '*************************************************************************
  403. SUB RecalcPath STATIC
  404.  
  405.     CursorSave% = ShowWaitCursor()
  406.     RecalcOptFiles APPFILES
  407.     RestoreCursor CursorSave%
  408.  
  409. END SUB
  410.  
  411.  
  412. '**
  413. '** Purpose:
  414. '**     Sets drive status info according to latest disk space calcs.
  415. '** Arguments:
  416. '**     none.
  417. '** Returns:
  418. '**     none.
  419. '*************************************************************************
  420. SUB SetDriveStatus STATIC
  421.  
  422.     drive$ = MID$(DEST$, 1, 1)
  423.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  424.     cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) ''+ VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
  425.     free& = GetFreeSpaceForDrive(drive$)
  426.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  427.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  428.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  429.  
  430.     IF drive$ = WINDRIVE$ THEN
  431.         ReplaceListItem DRIVETEXT$, 4, ""
  432.         ReplaceListItem DRIVETEXT$, 5, ""
  433.         ReplaceListItem DRIVETEXT$, 6, ""
  434.     ELSE
  435.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  436.         cost& = VAL(GetListItem(APPNEEDS$, ndrive%))'' + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
  437.         IF cost& = 0 THEN
  438.             ReplaceListItem DRIVETEXT$, 4, ""
  439.             ReplaceListItem DRIVETEXT$, 5, ""
  440.             ReplaceListItem DRIVETEXT$, 6, ""
  441.         ELSE
  442.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  443.             ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  444.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  445.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  446.         END IF
  447.     END IF
  448. END SUB
  449.  
  450.  
  451. '**
  452. '** Purpose:
  453. '**     Appends a file name to the end of a directory path,
  454. '**     inserting a backslash character as needed.
  455. '** Arguments:
  456. '**     szDir$  - full directory path (with optional ending "\")
  457. '**     szFile$ - filename to append to directory
  458. '** Returns:
  459. '**     Resulting fully qualified path name.
  460. '*************************************************************************
  461. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  462.     IF szDir$ = "" THEN
  463.         MakePath = szFile$
  464.     ELSEIF szFile$ = "" THEN
  465.         MakePath = szDir$
  466.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  467.         MakePath = szDir$ + szFile$
  468.     ELSE
  469.         MakePath = szDir$ + "\" + szFile$
  470.     END IF
  471. END FUNCTION
  472.  
  473.