home *** CD-ROM | disk | FTP | other *** search
/ gdead.berkeley.edu / gdead.berkeley.edu.tar / gdead.berkeley.edu / pub / gdead / ibm / howdo220.exe / TITLE.MST < prev    next >
Text File  |  1997-05-19  |  18KB  |  498 lines

  1. '**************************************************************************
  2. '*
  3. '* TITLE.MST - Viewer Runtime Setup Script
  4. '*
  5. '* CUSTOMIZING TITLE.MST
  6. '*
  7. '* For a simple Setup routine, you just need to assign values to the
  8. '* series of variables following the heading "Setup Variables". This
  9. '* script also provides for the following more-advanced options, which
  10. '* are supported by subroutines located later in this script:
  11. '*
  12. '* Option                                         See Subroutine
  13. '* ------------------------------------------     ---------------------
  14. '* Install more than one .MVB file                ModifyViewerIni
  15. '* Install Help title                             ModifyViewerIni
  16. '* Install custom DLLs                            ModifyViewerIni
  17. '* Install multiple Program Manager items         ModifyProgramManager
  18. '* Display a custom icon with the ProgMan item    ModifyProgramManager
  19. '* Install custom fonts                           RegisterCustomFonts
  20. '* Install Video for Windows runtime files        RegisterDrivers
  21. '*
  22. '* Each customization note starts with the heading CUSTOMIZATION.
  23. '*
  24. '**************************************************************************
  25.  
  26.         '' Global variables
  27.  
  28.         GLOBAL TitleShortName$
  29.         GLOBAL TitleLongName$
  30.         GLOBAL MVBFileName$
  31.         GLOBAL PromptForPath%
  32.         GLOBAL DefaultPath$
  33.         GLOBAL ProgManGroup$
  34.         GLOBAL ProgManItem$
  35.         GLOBAL szTitleDir$
  36.  
  37.         '' ****************************************************************
  38.         '' ** Setup Variables
  39.         '' ****************************************************************
  40.  
  41.         '' Set the following string to a short form of the title name
  42.         '' (for example, "Gallery")
  43.  
  44.         TitleShortName$ = "How Does The Song Go"
  45.  
  46.         '' Set the following string to a long form of the title name
  47.         '' (for example, "Viewer 2.0 Gallery")
  48.  
  49.         TitleLongName$ = "How Does The Song Go v2.01"
  50.  
  51.         '' Set the following variable to the name of the MVB file, without
  52.         '' the filename extension (for example, "GALLERY")
  53.  
  54.         MVBFileName$ = "Howdoes"
  55.  
  56.         '' The following variable determines whether Setup prompts the user
  57.         '' to specify a directory in which to install title files. (Files
  58.         '' to be installed on the hard disk must be listed in the TITLE.INF
  59.         '' file under the [Installed Title Files] section.) Specify one of
  60.         '' the following values:
  61.         ''
  62.         '' 0    Install title files in the Windows directory (default setting).
  63.         ''      This is an appropriate setting if you have a limited number
  64.         ''      of files to copy (for example, a single custom icon or DLL).
  65.         ''
  66.         '' 1    Display a dialog box to prompt the user for a directory in
  67.         ''      which to install files
  68.  
  69.         PromptForPath% = 1
  70.  
  71.         '' If you have specified 1 in PromptForPath%, set the following
  72.         '' variable to the default path that will be displayed in the dialog
  73.         '' box (for example, "C:\GALLERY").
  74.  
  75.         DefaultPath$ = "c:\rtsoft"
  76.  
  77.         '' Set the following variable to the name of the program manager
  78.         '' group you would like to create (for example, "Viewer 2.0 Gallery")
  79.  
  80.         ProgManGroup$ = "Rising Tide Software"
  81.  
  82.         '' Set the following variable to the caption of the program manager
  83.         '' item for your title (for example, "Gallery")
  84.  
  85.         ProgManItem$ = "How Does The Song Go"
  86.  
  87.         '***********************************************************************
  88.         '** Mainline
  89.         '***********************************************************************
  90.  
  91.         GLOBAL CUIDLL$
  92.  
  93.         '' Include files
  94.         '$INCLUDE 'setupapi.inc'
  95.  
  96.         '' Custom UI dll
  97.         CUIDLL$ = "mscuistf.dll"
  98.  
  99.         '' Dialog ID's
  100.         CONST DESTPATH      = 1000
  101.         CONST APPHELP       = 2000
  102.         CONST TOOBIG        = 3000
  103.         CONST BADPATH       = 4000
  104.         CONST SUCCESS       = 5000
  105.  
  106.         '' Bitmap ID
  107.         CONST LOGO = 1
  108.  
  109.         '' Functions and subroutines
  110.         DECLARE FUNCTION AddFont LIB "mscuistf.dll" (szFont$, szName$) AS INTEGER
  111.         DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  112.         DECLARE FUNCTION GetTitleDir (szDefault$) AS STRING
  113.         DECLARE FUNCTION CopyFiles(szTitleDir$) AS INTEGER
  114.         DECLARE SUB RegisterFont(fontfile$, fontname$)
  115.         DECLARE SUB ModifyViewerIni
  116.         DECLARE SUB RegisterCustomFonts
  117.         DECLARE SUB ModifyProgramManager
  118.         DECLARE SUB ShowSuccess
  119.         DECLARE SUB RegisterDrivers
  120.  
  121.         '' The following statement turns size checking off. Set it to scmOnFatal
  122.         '' to enable size checking, where Setup will compare the disk file size
  123.         '' with the INF file size and report an error if they are not the same.
  124.  
  125.         i% = SetSizeCheckMode(scmOff)
  126.  
  127.         '' Set the title and banner bitmap. You must rebuild MSCUISTF.DLL to
  128.         '' alter the banner bitmap.
  129.  
  130.         SetTitle "How Does The Song Go ?  V2.20 - Setup"
  131.         SetBitmap CUIDLL$, LOGO
  132.  
  133.         '' Read in the INF file.
  134.  
  135.         ReadInfFile GetSymbolValue("STF_CWDDIR") + "TITLE.INF"
  136.  
  137.         '' Decide where to put title files
  138.         IF PromptForPath% = 1 THEN
  139.                 szTitleDir$ = GetTitleDir(DefaultPath$)
  140.                 IF szTitleDir$ = "" THEN
  141.                         GOTO QUIT
  142.                 ENDIF
  143.         ELSE
  144.                 szTitleDir$ = GetWindowsDir()
  145.         ENDIF
  146.  
  147.         '' Copy files
  148.         IF CopyFiles(szTitleDir$) = 0 THEN
  149.                 GOTO QUIT
  150.         ENDIF
  151.  
  152.         '' Create the MVIEWER2.EXE MVB association
  153.         CreateIniKeyValue "WIN.INI", "Extensions", "MVB", "mviewer2.exe", cmoNone
  154.  
  155.         '' Register in VIEWER.INI
  156.         ModifyViewerIni
  157.  
  158.         '' Register custom fonts
  159.         RegisterCustomFonts
  160.  
  161.         '' Register drivers
  162.         RegisterDrivers
  163.  
  164.         '' Modify Program Manager
  165.         ModifyProgramManager
  166.  
  167.         '' Success dialog
  168.         ShowSuccess
  169.  
  170.         '' Now start the title
  171.  
  172.         RUN "mviewer2.exe " + MVBFileName$ + ".MVB", NOWAIT
  173.  
  174. QUIT:
  175.  
  176.         END
  177.  
  178.  
  179. '*************************************************************************
  180. '** Purpose:
  181. '**     Prompts the user for a path for the title files
  182. '** Arguments:
  183. '**     szDefault$ - default path
  184. '** Returns:
  185. '**     New valid path name, or "" if the user quit.
  186. '*************************************************************************
  187.  
  188. FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
  189.  
  190.         SetSymbolValue "String", TitleShortName$
  191.         SetSymbolValue "EditTextIn", szDefault$
  192.         SetSymbolValue "EditFocus", "ALL"
  193.  
  194.         GETPATH:
  195.  
  196.         sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
  197.  
  198.         IF sz$ = "CONTINUE" THEN
  199.                 szTitleDir$ = GetSymbolValue("EditTextOut")
  200.                 IF IsDirWritable(szTitleDir$) = 0 THEN
  201.  
  202.                         BADPATH:
  203.  
  204.                         sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
  205.                         IF sz$ = "REACTIVATE" THEN
  206.                                 GOTO BADPATH
  207.                         END IF
  208.                         UIPop 1
  209.                         GOTO GETPATH
  210.                 END IF
  211.                 UIPop 1
  212.                 CreateDir szTitleDir$, cmoNone
  213.                 CreateDir szTitleDir$ + "\midi", cmoNone
  214.  
  215.         ELSEIF sz$ = "REACTIVATE" THEN
  216.                 GOTO GETPATH
  217.  
  218.         ELSE
  219.                 szTitleDir$ = ""
  220.  
  221.         END IF
  222.  
  223.         GetTitleDir = szTitleDir$
  224.  
  225. END FUNCTION
  226.  
  227.  
  228. '*************************************************************************
  229. '** Purpose:
  230. '**     Copies the files in the INF file
  231. '** Arguments:
  232. '**     szTitleDir$ - destination directory for the title files
  233. '** Returns
  234. '**     1 if files were copied, 0 otherwise
  235. '*************************************************************************
  236.  
  237. FUNCTION CopyFiles(szTitleDir$) STATIC AS INTEGER
  238.  
  239.         '' Add all system files to the copy list
  240.         AddSectionFilesToCopyList "System Files", GetSymbolValue("STF_SRCDIR"), GetWindowsSysDir()
  241.  
  242.         '' Add all of the title files to the copy list
  243.         AddSectionFilesToCopyList "Installed Title Files", GetSymbolValue("STF_SRCDIR"), szTitleDir$
  244.  
  245.         '' Add all of the title's midi files to the copy list
  246.         AddSectionFilesToCopyList "Title Midi Files", GetSymbolValue("STF_SRCDIR"), szTitleDir$ + "\midi"
  247.  
  248.  
  249.         '' Check size
  250.         szExtras$ = "Extra"
  251.         szCosts$ = "Costs"
  252.         szNeededs$ = "Neededs"
  253.         FOR i% = 1 TO 26 STEP 1
  254.                 AddListItem szExtras$, "0"
  255.         NEXT i%
  256.  
  257.         '' We assume that VIEWER.INI will take another 4K
  258.         ReplaceListItem szExtras$, ASC(MID$(GetWindowsDir(), 1, 1)) - ASC("A") + 1, STR$(4096)
  259.  
  260.         '' Get amount of space required
  261.         StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
  262.  
  263.         '' Put up a message if there is not enough space
  264.         FOR i% = 1 TO 26 STEP 1
  265.                 IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
  266.  
  267.                         SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
  268.                         SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
  269.  
  270.                         TOOBIG:
  271.  
  272.                         sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
  273.                         IF sz$ = "REACTIVATE" THEN
  274.                                 GOTO TOOBIG
  275.                         END IF
  276.                         UIPop 1
  277.                         CopyFiles = 0
  278.                         GOTO DONTCOPY
  279.                 END IF
  280.         NEXT i%
  281.  
  282.         '' Copy the files
  283.         CopyFilesInCopyList
  284.  
  285.         CopyFiles = 1
  286.  
  287. DONTCOPY:
  288.  
  289. END FUNCTION
  290.  
  291.  
  292. '*************************************************************************
  293. '** Purpose:
  294. '**     Puts up a success dialog
  295. '*************************************************************************
  296.  
  297. SUB ShowSuccess STATIC
  298.  
  299.         SUCCESS:
  300.  
  301.         SetSymbolValue "String1", TitleShortName$
  302.         sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
  303.         IF sz$ = "REACTIVATE" THEN
  304.                 GOTO SUCCESS
  305.         END IF
  306.         UIPop 1
  307.  
  308. END SUB
  309.  
  310.  
  311. '*************************************************************************
  312. '** Purpose:
  313. '**     Appends a file name to the end of a directory path,
  314. '**     inserting a backslash character as needed.
  315. '** Arguments:
  316. '**     szDir$  - full directory path (with optional ending "\")
  317. '**     szFile$ - filename to append to directory
  318. '** Returns:
  319. '**     Resulting fully qualified path name.
  320. '*************************************************************************
  321.  
  322. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  323.     IF szDir$ = "" THEN
  324.                 MakePath = szFile$
  325.     ELSEIF szFile$ = "" THEN
  326.                 MakePath = szDir$
  327.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  328.                 MakePath = szDir$ + szFile$
  329.     ELSE
  330.                 MakePath = szDir$ + "\" + szFile$
  331.     END IF
  332. END FUNCTION
  333.  
  334.  
  335. '*************************************************************************
  336. '** Purpose:
  337. '**     Registers a font.
  338. '** Arguments:
  339. '**     fontfile$ - font filename
  340. '**     fontname$ - font name.
  341. '*************************************************************************
  342.  
  343. SUB RegisterFont(fontfile$, fontname$) STATIC
  344.  
  345.         '' A simple error catching wrapper around AddFont, which is a 'C' routine in MSCUISTF.DLL
  346.  
  347.     IF AddFont(fontfile$, fontname$) = -1 THEN
  348.                 j% = DoMsgBox("Could not install " + fontfile$ + " font.", "Viewer Font Installation", 0)
  349.     ENDIF
  350.  
  351. END SUB
  352.  
  353.  
  354. '*************************************************************************
  355. '** Purpose:
  356. '**     Registers title in VIEWER.INI
  357. '*************************************************************************
  358.  
  359. SUB ModifyViewerIni STATIC
  360.  
  361.         '' Get the VIEWER.INI file
  362.  
  363.         szIni$ = MakePath(GetWindowsDir(), "VIEWER.INI")
  364.  
  365.         '' First register the title file, setting the Name and Path entries.
  366.         '' We assume that the MVB file is the same directory as SETUP.EXE.
  367.         ''
  368.         '' CUSTOMIZATION: If you're installing multiple MVB files, copy the
  369.         '' following two statements for each additional file, substituting
  370.         '' the appropriate long name and MVB filename for the TitleLongName$
  371.         '' and MVBFileName$ variables.
  372.  
  373.         CreateIniKeyValue szIni$, MVBFileName$, "Name", TitleLongName$, cmoOverwrite
  374.         CreateIniKeyValue szIni$, MVBFileName$, "Path", szTitleDir$, cmoOverwrite
  375.  
  376.         CreateIniKeyValue szIni$, "VWRHELP", "Name", "Using Viewer", cmoOverwrite
  377.         CreateIniKeyValue szIni$, "VWRHELP", "Path", szTitleDir$, cmoOverwrite
  378.  
  379.         CreateIniKeyValue szIni$, "DISCO", "Name", "Disc'O Dead", cmoOverwrite
  380.         CreateIniKeyValue szIni$, "DISCO", "Path", szTitleDir$, cmoOverwrite
  381.  
  382.         '' Now we have to register the MVB file in the [FILES] section, so
  383.         '' Viewer can find files that are not on the path and display a
  384.         '' special message when a file is not found.
  385.  
  386.         CreateIniKeyValue szIni$, "FILES", MVBFileName$ + ".MVB", szTitleDir$ + "," + "Please insert the " + TitleLongName$ + " disk.", cmoOverwrite
  387.  
  388.         CreateIniKeyValue szIni$, "FILES", "VWRHELP.MVB", szTitleDir$ + "," + "Please insert the " + TitleLongName$ + " disk.", cmoOverwrite
  389.  
  390.         CreateIniKeyValue szIni$, "FILES", "DISCO.MVB", szTitleDir$ + "," + "Please insert the " + TitleLongName$ + " disk.", cmoOverwrite
  391.  
  392.         '' CUSTOMIZATION: If you're installing a Help title or any custom DLLs,
  393.         '' you should copy the preceding statement for each extra title or DLL.
  394.         ''
  395.         '' Example for installing an extra title:
  396.         ''
  397.         ''    CreateIniKeyValue szIni$, "FILES", "GALHELP.MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the Viewer 2.0 Gallery disk.", cmoOverwrite
  398.         ''
  399.         '' Example for installing a custom DLL:
  400.         ''
  401.         ''    CreateIniKeyValue szIni$, "FILES", "GALLERY.DLL", GetSymbolValue("STF_SRCDIR") + "," + "A required file is missing. Please reinstall the Viewer Gallery.", cmoOverwrite
  402.  
  403. END SUB
  404.  
  405.  
  406. '*************************************************************************
  407. '** Purpose:
  408. '**     Creates program manager entries for the title
  409. '*************************************************************************
  410.  
  411. SUB ModifyProgramManager STATIC
  412.  
  413.         '' Create the program manager group
  414.  
  415.         CreateProgmanGroup ProgmanGroup$, "", cmoNone
  416.         ShowProgmanGroup ProgmanGroup$, 1, cmoNone
  417.  
  418.         '' Create an entry for the title
  419.  
  420.         '' CreateProgmanItem ProgmanGroup$, ProgmanItem$, "mviewer2.exe " + MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".MVB"), "", cmoOverwrite
  421.  
  422.         '' CUSTOMIZATION:
  423.         ''
  424.         '' To create additional Program Manager items, copy the preceding
  425.         '' statement for each additional item, substituting the appropriate
  426.         '' name for the MVBFileName$ variable.
  427.         ''
  428.         '' To display a custom icon with the Program Manager item, specify
  429.         '' the icon filename with the fourth parameter (this parameter is
  430.         '' currently an empty string, ""). The following example specifies
  431.     '' an icon with the same filename as the .MVB file:
  432.         ''
  433.         CreateProgmanItem ProgmanGroup$, ProgmanItem$, "mviewer2.exe " + MakePath(szTitleDir$, MVBFileName$ + ".MVB"), MakePath(szTitleDir$, MVBFileName$ + ".ICO"), cmoOverwrite
  434.  
  435.  
  436. END SUB
  437.  
  438.  
  439. '*************************************************************************
  440. '** Purpose:
  441. '**     Registers custom fonts with Windows.
  442. '*************************************************************************
  443.  
  444. SUB RegisterCustomFonts STATIC
  445.  
  446.         '' CUSTOMIZATION: If you install custom fonts, then add statements
  447.         '' in this routine to register the fonts with the current Windows
  448.         '' session and to add them to the WIN.INI [Fonts] section.
  449.         ''
  450.         '' Note that TrueType fonts can only be installed in Windows 3.1.
  451.         '' RegisterFont automatically creates the required .FOT file for
  452.         '' TrueType fonts.
  453.         ''
  454.         '' The following example registers a font residing in MISTRAL.TTF
  455.         '' and installs the font with the name Mistral (True Type):
  456.         ''
  457.         ''     RegisterFont "mistral.ttf", "Mistral (TrueType)"
  458.         ''
  459.  
  460. END SUB
  461.  
  462.  
  463. '*************************************************************************
  464. '** Purpose:
  465. '**     Registers Windows drivers
  466. '*************************************************************************
  467.  
  468. SUB RegisterDrivers STATIC
  469.  
  470. '' CUSTOMIZATION: Video for Windows is not a standard component of
  471. '' Windows 3.1. If your title uses video, proceed as follows.
  472. ''
  473. '' 1) Add the following files to the [System Files] section of the INF file:
  474. ''
  475. ''    dispdib.dll
  476. ''    msvideo.dll
  477. ''    indeo.drv
  478. ''    mciavi.drv
  479. ''    msvidc.drv
  480. ''
  481. '' 2) Add the above files to your release directory. US versions can be
  482. ''    found in the \SYSTEM subdirectory of your Viewer disc. French and
  483. ''    German versions were not available at ship time. Please contact
  484. ''    Microsoft or check the Multimedia Viewer section on the Microsoft
  485. ''    Compuserve Forum for further details.
  486. ''
  487. '' 3) Uncomment the following lines:
  488. ''
  489. '' CreateIniKeyValue "WIN.INI", "mci extensions", "AVI", "AVIVIDEO", cmoNone
  490. '' CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "mci", "AVIVIDEO", "MCIAVI.DRV", cmoNone
  491. '' CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "drivers", "vidc.msvc", "msvidc.drv", cmoNone
  492. '' CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "drivers", "vidc.rt21", "indeo.drv", cmoNone
  493.  
  494. END SUB
  495.  
  496.  
  497.  
  498.