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