home *** CD-ROM | disk | FTP | other *** search
/ Tech-ROM Library / Tech-Rom Library - The Technical Library on CD-ROM 1993.iso / hw / gateway2 / menu / title.bak < prev    next >
Encoding:
Text File  |  1993-06-09  |  15.1 KB  |  485 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.  
  36.     '' ****************************************************************
  37.     '' ** Setup Variables
  38.     '' ****************************************************************
  39.  
  40.     '' Set the following string to a short form of the title name
  41.     '' (for example, "Gallery")
  42.     
  43.     TitleShortName$ = "Gateway"
  44.     
  45.     '' Set the following string to a long form of the title name
  46.     '' (for example, "Viewer 2.0 Gallery")
  47.     
  48.     TitleLongName$ = "the Gateway Mall"
  49.         
  50.     '' Set the following variable to the name of the MVB file, without 
  51.     '' the filename extension (for example, "GALLERY")
  52.         
  53.     MVBFileName$ = "Gatemall"
  54.         
  55.     '' The following variable determines whether Setup prompts the user
  56.     '' to specify a directory in which to install title files. (Files
  57.     '' to be installed on the hard disk must be listed in the TITLE.INF 
  58.     '' file under the [Installed Title Files] section.) Specify one of
  59.     '' the following values:
  60.     ''
  61.     '' 0    Install title files in the Windows directory (default setting).
  62.     ''      This is an appropriate setting if you have a limited number
  63.     ''      of files to copy (for example, a single custom icon or DLL).
  64.     ''
  65.     '' 1    Display a dialog box to prompt the user for a directory in 
  66.     ''      which to install files
  67.         
  68.     PromptForPath% = 0
  69.         
  70.     '' If you have specified 1 in PromptForPath%, set the following 
  71.     '' variable to the default path that will be displayed in the dialog
  72.     '' box (for example, "C:\Mall").
  73.         
  74.     DefaultPath$ = ""
  75.     
  76.     '' Set the following variable to the name of the program manager 
  77.     '' group you would like to create (for example, "Viewer 2.0 Gallery")
  78.         
  79.     ProgManGroup$ = "The Gateway Mall"
  80.     
  81.     '' Set the following variable to the caption of the program manager 
  82.     '' item for your title (for example, "Gallery")
  83.         
  84.     ProgManItem$ = "The Gateway Mall"
  85.     
  86.     '***********************************************************************
  87.     '** Mainline
  88.     '***********************************************************************
  89.  
  90.     GLOBAL CUIDLL$
  91.  
  92.     '' Include files
  93.     '$INCLUDE 'setupapi.inc'
  94.     
  95.     '' Custom UI dll
  96.     CUIDLL$ = "mscuistf.dll"
  97.     
  98.     '' Dialog ID's
  99.     CONST DESTPATH      = 1000
  100.     CONST APPHELP       = 2000
  101.     CONST TOOBIG        = 3000
  102.     CONST BADPATH       = 4000
  103.     CONST SUCCESS       = 5000
  104.     
  105.     '' Bitmap ID
  106.     CONST LOGO = 1
  107.     
  108.     '' Functions and subroutines
  109.     DECLARE FUNCTION AddFont LIB "mscuistf.dll" (szFont$, szName$) AS INTEGER
  110.     DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  111.     DECLARE FUNCTION GetTitleDir (szDefault$) AS STRING
  112.     DECLARE FUNCTION CopyFiles(szTitleDir$) AS INTEGER
  113.     DECLARE SUB RegisterFont(fontfile$, fontname$)
  114.     DECLARE SUB ModifyViewerIni(szTitleDir$)
  115.     DECLARE SUB RegisterCustomFonts
  116.     DECLARE SUB ModifyProgramManager
  117.     DECLARE SUB ShowSuccess
  118.     DECLARE SUB RegisterDrivers
  119.     
  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 "Viewer Title 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 szTitleDir$
  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.     
  171.     Run "dice.exe",nowwait
  172.     '' Now start the title
  173.  
  174.     ''RUN "mviewer2.exe " + MVBFileName$ + ".MVB", NOWAIT
  175.  
  176. QUIT:
  177.     
  178.     END
  179.     
  180.  
  181. '*************************************************************************
  182. '** Purpose:
  183. '**     Prompts the user for a path for the title files
  184. '** Arguments:
  185. '**     szDefault$ - default path
  186. '** Returns:
  187. '**     New valid path name, or "" if the user quit.
  188. '*************************************************************************
  189.  
  190. FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
  191.  
  192.     SetSymbolValue "String", TitleShortName$
  193.     SetSymbolValue "EditTextIn", szDefault$
  194.     SetSymbolValue "EditFocus", "ALL"
  195.  
  196.     GETPATH:
  197.  
  198.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
  199.  
  200.     IF sz$ = "CONTINUE" THEN
  201.         szTitleDir$ = GetSymbolValue("EditTextOut")
  202.         IF IsDirWritable(szTitleDir$) = 0 THEN
  203.  
  204.             BADPATH:
  205.  
  206.             sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
  207.             IF sz$ = "REACTIVATE" THEN
  208.                 GOTO BADPATH
  209.             END IF
  210.             UIPop 1
  211.             GOTO GETPATH
  212.         END IF
  213.         UIPop 1
  214.         CreateDir szTitleDir$, cmoNone
  215.  
  216.     ELSEIF sz$ = "REACTIVATE" THEN
  217.         GOTO GETPATH
  218.  
  219.     ELSE
  220.         szTitleDir$ = ""
  221.  
  222.     END IF
  223.  
  224.     GetTitleDir = szTitleDir$
  225.  
  226. END FUNCTION
  227.  
  228.  
  229. '*************************************************************************
  230. '** Purpose:
  231. '**     Copies the files in the INF file
  232. '** Arguments:
  233. '**     szTitleDir$ - destination directory for the title files
  234. '** Returns
  235. '**     1 if files were copied, 0 otherwise
  236. '*************************************************************************
  237.  
  238. FUNCTION CopyFiles(szTitleDir$) STATIC AS INTEGER
  239.  
  240.     '' Add all system files to the copy list
  241.     AddSectionFilesToCopyList "System Files", GetSymbolValue("STF_SRCDIR"), GetWindowsSysDir()
  242.     
  243.     '' Add all of the title files to the copy list
  244.     AddSectionFilesToCopyList "Installed Title Files", GetSymbolValue("STF_SRCDIR"), szTitleDir$
  245.     
  246.     '' Check size
  247.     szExtras$ = "Extra"
  248.     szCosts$ = "Costs"
  249.     szNeededs$ = "Neededs"
  250.     FOR i% = 1 TO 26 STEP 1
  251.         AddListItem szExtras$, "0"
  252.     NEXT i%
  253.     
  254.     '' We assume that VIEWER.INI will take another 4K
  255.     ReplaceListItem szExtras$, ASC(MID$(GetWindowsDir(), 1, 1)) - ASC("A") + 1, STR$(4096)
  256.     
  257.     '' Get amount of space required
  258.     StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
  259.     
  260.     '' Put up a message if there is not enough space
  261.     FOR i% = 1 TO 26 STEP 1
  262.         IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
  263.     
  264.             SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
  265.             SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
  266.     
  267.             TOOBIG:
  268.     
  269.             sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
  270.             IF sz$ = "REACTIVATE" THEN
  271.                 GOTO TOOBIG
  272.             END IF
  273.             UIPop 1
  274.             CopyFiles = 0
  275.             GOTO DONTCOPY
  276.         END IF
  277.     NEXT i%
  278.     
  279.     '' Copy the files
  280.     CopyFilesInCopyList
  281.     
  282.     CopyFiles = 1
  283.  
  284. DONTCOPY:
  285.  
  286. END FUNCTION
  287.  
  288.  
  289. '*************************************************************************
  290. '** Purpose:
  291. '**     Puts up a success dialog
  292. '*************************************************************************
  293.  
  294. SUB ShowSuccess STATIC
  295.  
  296.     SUCCESS:
  297.     
  298.     SetSymbolValue "String1", TitleShortName$
  299.     sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
  300.     IF sz$ = "REACTIVATE" THEN
  301.         GOTO SUCCESS
  302.     END IF
  303.     UIPop 1
  304.     
  305. END SUB
  306.  
  307.  
  308. '*************************************************************************
  309. '** Purpose:
  310. '**     Appends a file name to the end of a directory path,
  311. '**     inserting a backslash character as needed.
  312. '** Arguments:
  313. '**     szDir$  - full directory path (with optional ending "\")
  314. '**     szFile$ - filename to append to directory
  315. '** Returns:
  316. '**     Resulting fully qualified path name.
  317. '*************************************************************************
  318.  
  319. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  320.     IF szDir$ = "" THEN
  321.         MakePath = szFile$
  322.     ELSEIF szFile$ = "" THEN
  323.         MakePath = szDir$
  324.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  325.         MakePath = szDir$ + szFile$
  326.     ELSE
  327.         MakePath = szDir$ + "\" + szFile$
  328.     END IF
  329. END FUNCTION
  330.  
  331.  
  332. '*************************************************************************
  333. '** Purpose:
  334. '**     Registers a font.
  335. '** Arguments:
  336. '**     fontfile$ - font filename
  337. '**     fontname$ - font name.
  338. '*************************************************************************
  339.  
  340. SUB RegisterFont(fontfile$, fontname$) STATIC
  341.  
  342.     '' A simple error catching wrapper around AddFont, which is a 'C' routine in MSCUISTF.DLL
  343.  
  344.     IF AddFont(fontfile$, fontname$) = -1 THEN
  345.         j% = DoMsgBox("Could not install " + fontfile$ + " font.", "Viewer Font Installation", 0)
  346.     ENDIF
  347.  
  348. END SUB
  349.  
  350.  
  351. '*************************************************************************
  352. '** Purpose:
  353. '**     Registers title in VIEWER.INI
  354. '*************************************************************************
  355.  
  356. SUB ModifyViewerIni (szTitleDir$) STATIC
  357.  
  358.     '' Get the VIEWER.INI file
  359.     
  360.     szIni$ = MakePath(GetWindowsDir(), "VIEWER.INI")
  361.  
  362.     '' First register the title file, setting the Name and Path entries. 
  363.     '' We assume that the MVB file is the same directory as SETUP.EXE.
  364.     ''
  365.     '' CUSTOMIZATION: If you're installing multiple MVB files, copy the
  366.     '' following two statements for each additional file, substituting
  367.     '' the appropriate long name and MVB filename for the TitleLongName$
  368.     '' and MVBFileName$ variables.
  369.     
  370.     CreateIniKeyValue szIni$, MVBFileName$, "Name", TitleLongName$, cmoOverwrite
  371.     CreateIniKeyValue szIni$, MVBFileName$, "Path", GetSymbolValue("STF_SRCDIR"), cmoOverwrite
  372.     
  373.     '' Now we have to register the MVB file in the [FILES] section, so 
  374.     '' Viewer can find files that are not on the path and display a 
  375.     '' special message when a file is not found.
  376.  
  377.     CreateIniKeyValue szIni$, "FILES", MVBFileName$ + ".MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the " + TitleLongName$ + " disk.", cmoOverwrite
  378.  
  379.     '' CUSTOMIZATION: If you're installing a Help title or any custom DLLs,
  380.     '' you should copy the preceding statement for each extra title or DLL.
  381.     ''
  382.     '' Example for installing an extra title:
  383.     ''
  384.     ''    CreateIniKeyValue szIni$, "FILES", "GALHELP.MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the Viewer 2.0 Gallery disk.", cmoOverwrite
  385.     ''
  386.     '' Example for installing a custom DLL:
  387.     ''
  388.     ''    CreateIniKeyValue szIni$, "FILES", "GALLERY.DLL", szTitleDir$ + "\," + "A required file is missing. Please reinstall Gallery.", cmoOverwrite
  389.  
  390. END SUB
  391.  
  392.  
  393. '*************************************************************************
  394. '** Purpose:
  395. '**     Creates program manager entries for the title
  396. '*************************************************************************
  397.  
  398. SUB ModifyProgramManager STATIC
  399.  
  400.     '' Create the program manager group
  401.  
  402.     CreateProgmanGroup ProgmanGroup$, "", cmoNone
  403.     ShowProgmanGroup ProgmanGroup$, 1, cmoNone
  404.     
  405.     '' Create an entry for the title
  406.      
  407.     CreateProgmanItem ProgmanGroup$, ProgmanItem$, "mviewer2.exe " + MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".MVB"), MakePath(GetSymbolValue("STF_SRCDIR"), "olg.ICO"), cmoOverwrite
  408.     
  409.     '' CUSTOMIZATION: 
  410.     ''
  411.     '' To create additional Program Manager items, copy the preceding 
  412.     '' statement for each additional item, substituting the appropriate
  413.     '' Program Manager item name for ProgmanItem$ and filename for 
  414.     '' MVBFileName$.
  415.     ''
  416.     '' To display a custom icon with the Program Manager item, specify
  417.     '' the icon filename with the fourth parameter (this parameter is 
  418.     '' currently an empty string, ""). The following example specifies 
  419.     '' an icon with the same filename as the .MVB file:
  420.     ''
  421.     ''       CreateProgmanItem ProgmanGroup$, ProgmanItem$, "mviewer2.exe " + MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".MVB"), MakePath(GetSymbolValue("STF_SRCDIR"), "olg.ICO"), cmoOverwrite
  422.  
  423. END SUB
  424.  
  425.  
  426. '*************************************************************************
  427. '** Purpose:
  428. '**     Registers custom fonts with Windows.
  429. '*************************************************************************
  430.  
  431. SUB RegisterCustomFonts STATIC
  432.  
  433.     '' CUSTOMIZATION: If you install custom fonts, then add statements
  434.     '' in this routine to register the fonts with the current Windows 
  435.     '' session and to add them to the WIN.INI [Fonts] section. 
  436.     ''
  437.     '' Note that TrueType fonts can only be installed in Windows 3.1.
  438.     '' RegisterFont automatically creates the required .FOT file for 
  439.     '' TrueType fonts.
  440.     ''    
  441.     '' The following example registers a font residing in MISTRAL.TTF
  442.     '' and installs the font with the name Mistral (True Type):
  443.     '' 
  444.     ''     RegisterFont "mistral.ttf", "Mistral (TrueType)"
  445.     ''
  446.  
  447. END SUB
  448.  
  449.  
  450. '*************************************************************************
  451. '** Purpose:
  452. '**     Registers Windows drivers
  453. '*************************************************************************
  454.  
  455. SUB RegisterDrivers STATIC
  456.  
  457. '' CUSTOMIZATION: Video for Windows is not a standard component of
  458. '' Windows 3.1. If your title uses video, proceed as follows.
  459. ''
  460. '' 1) Add the following files to the [System Files] section of the INF file:
  461. ''
  462. ''    dispdib.dll
  463. ''    msvideo.dll
  464. ''    indeo.drv
  465. ''    mciavi.drv
  466. ''    msvidc.drv
  467. ''
  468. '' 2) Add the above files to your release directory. US versions can be 
  469. ''    found in the \SYSTEM subdirectory of your Viewer disc. French and
  470. ''    German versions were not available at ship time. Please contact 
  471. ''    Microsoft or check the Multimedia Viewer section on the Microsoft
  472. ''    Compuserve Forum for further details.
  473. ''
  474. '' 3) Uncomment the following lines:
  475. ''
  476.  CreateIniKeyValue "WIN.INI", "mci extensions", "AVI", "AVIVIDEO", cmoNone
  477.  CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "mci", "AVIVIDEO", "MCIAVI.DRV", cmoNone
  478.  CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "drivers", "vidc.msvc", "msvidc.drv", cmoNone
  479.  CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "drivers", "vidc.rt21", "indeo.drv", cmoNone
  480.  
  481. END SUB
  482.  
  483.  
  484.  
  485.