home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC/CD Gamer UK 41
/
PCGAMER41.bin
/
eng
/
gpm2
/
egpn.mst
< prev
next >
Wrap
Text File
|
1997-01-21
|
14KB
|
464 lines
'' ****************************************************************
''* GPM.MST - F1 GPM Normal Install Setup Script
''**************************************************************************
'' Global variables
GLOBAL ExeType$
GLOBAL Lang$
GLOBAL SrcMainDir$
GLOBAL SrcDrive$
GLOBAL TitleShortName$
GLOBAL TitleLongName$
GLOBAL PromptForPath%
GLOBAL DefaultPath$
GLOBAL ProgManGroup$
GLOBAL ProgManItem$
GLOBAL szTitleDir$
'' WinG globals
GLOBAL DEST$ ''Default destination directory.
GLOBAL bInstallDVA%
'' '$DEFINE DEBUG
'' ****************************************************************
'' ** Setup Variables
'' ****************************************************************
TitleShortName$ = "Grand Prix Manager 2"
TitleLongName$ = "Grand Prix Manager 2"
PromptForPath% = 1 '' we prompt for the install path
DefaultPath$ = "C:\MPS\GPM2" '' default install path when prompt is displayed
ProgManGroup$ = "MicroProse" '' program manager group
ProgManItem$ = "Grand Prix Manager 2" '' program manager item title
'***********************************************************************
'** Mainline
'***********************************************************************
GLOBAL CUIDLL$
'' Include files
'$INCLUDE 'setupapi.inc'
CUIDLL$ = "mscuistf.dll" '' Custom UI dll
'$INCLUDE 'msdetect.inc'
'' Dialog ID's
CONST DESTPATH = 1000
CONST APPHELP = 2000
CONST TOOBIG = 3000
CONST BADPATH = 4000
CONST SUCCESS = 5000
CONST CONT_PH_SETUP = 101
CONST EXIT_PH_SETUP = 102
'' WinG DLG ID's
CONST CHECK = 2500
CONST EXITSUCCESS = 700
CONST EXITFAILURE = 400
CONST EXITQUIT = 600
CONST LOGO = 100 '' bitmap resource id
'' Functions and subroutines
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE FUNCTION GetTitleDir (szDefault$) AS STRING
DECLARE FUNCTION CopyFiles(szTitleDir$) AS INTEGER
DECLARE SUB ModifyProgramManager
DECLARE SUB ShowSuccess
'' functions from WinG install
DECLARE FUNCTION GetRealWindowsSysDir AS STRING
DECLARE SUB UpdateWinG32 (szOrig$)
DECLARE FUNCTION OnWin3x LIB "setuphlp.DLL" AS INTEGER
DECLARE FUNCTION VflatdPresent LIB "setuphlp.DLL" AS INTEGER
DECLARE FUNCTION GetRealSystemDir LIB "setuphlp.DLL" (szDir$,cbBuf%) AS INTEGER
DECLARE FUNCTION IsWin32FileNewer LIB "setuphlp.DLL" (szOrig$,szNew$) AS INTEGER
DECLARE SUB RenameFilePlease LIB "setuphlp.DLL" (szOrig$,szNew$)
'' return value displayer for debug purposes
''i% = DoMsgBox(STR$(i%), "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
INIT:
bInstallDVA% = 0
CUIDLL$ = "mscuistf.dll" ''Custom user interface dll
HELPPROC$ = "FHelpDlgProc" ''Help dialog procedure
'' Set the title and banner bitmap. You must rebuild MSCUISTF.DLL to
'' alter the banner bitmap.
SetTitle "Grand Prix Manager 2"
SetBitmap CUIDLL$, LOGO
szInf$ = GetSymbolValue("STF_SRCINFPATH")
IF szInf$ = "" THEN
szInf$ = GetSymbolValue("STF_CWDDIR") + "wing.inf"
END IF
ReadInfFile szInf$
CHECK:
SrcDir$ = GetSymbolValue("STF_SRCDIR")
SrcDrive$ = MID$(SrcDir$,1,1)
' NON_DEMO SrcMainDir$ = SrcDrive$+":\GPM2\"
' FOR DEMO
SrcMainDir$ = GetSymbolValue("STF_SRCDIR")
' NON_DEMO old SrcDir$ = SrcDrive$+":\GPM2\SYSTEM\"
' FOR DEMO
SrcDir$ = GetSymbolValue("STF_SRCDIR")+"SYSTEM\"
DEST$ = GetWindowsSysDir
AddSectionFilesToCopyList "runtime", SrcDir$, DEST$
'
' only use DVA on Windows 3.x
'
IF OnWin3x() = 1 THEN
AddSectionFilesToCopyList "dva", SrcDir$, DEST$
IF VflatdPresent() = 0 THEN
CreateSysIniKeyValue GetWindowsDir + "system.ini", "386Enh", "device", GetWindowsSysDir+"dva.386", cmoOverwrite
bInstallDVA% = 1
END IF
END IF
DEST$ = GetRealWindowsSysDir
AddSectionFilesToCopyList "wing32", SrcDir$, DEST$
Dest1$ = MakePath(DEST$,"wing32.dll")
Dest2$ = MakePath(DEST$,"wing32.xxx")
RenameFilePlease Dest1$,Dest2$
CopyFilesInCopyList
UpdateWinG32 GetRealWindowsSysDir()
GPM:
'' now install GPM files
'' The following statement turns size checking off. Set it to scmOnFatal
'' to enable size checking, where Setup will compare the disk file size
'' with the INF file size and report an error if they are not the same.
i% = SetSizeCheckMode(scmOff)
'' Read in the INF file.
ReadInfFile SrcMainDir$ + "EGPN.INF"
'' Decide where to put title files
IF PromptForPath% = 1 THEN
szTitleDir$ = GetTitleDir(DefaultPath$)
IF szTitleDir$ = "" THEN
ERROR STFQUIT
GOTO QUIT
ENDIF
ELSE
''szTitleDir$ = GetWindowsDir()
szTitleDir$ = "C:\MPS\GPM2"
ENDIF
''szTitleDir$=MID$(szTitleDir$,1,3)+"MPS\"+MID$(szTitleDir$,4)
'' add game path direction entry to the gpm ini file
CreateIniKeyValue GetWindowsDir+"GPM2MICP.INI","GPM_PATHS","GAME",szTitleDir$,cmoOverwrite
Lang$ = GetIniKeyString(GetWindowsDir+"GPM2MICP.INI","GPM_LANGUAGE","TONGUE")
'' Copy files
IF CopyFiles(szTitleDir$) = 0 THEN
GOTO QUIT
ENDIF
ModifyProgramManager
ShowSuccess
END
QUIT:
ON ERROR GOTO ERRQUIT
IF ERR = 0 THEN
dlg% = EXITSUCCESS
ELSEIF ERR = STFQUIT THEN
dlg% = EXITQUIT
ELSEIF ERR = EXIT_PH_SETUP THEN
dlg% = EXIT_PH_SETUP
ELSE
dlg% = EXITFAILURE
END IF
''i% = DoMsgBox(STR$(ERR)+" "+STR$(dlg%), "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
UIPop 1
sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfoDlgProc", 0, "")
END
ERRQUIT:
i% = DoMsgBox("Setup sources were corrupted, call Microprose", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
END
'*************************************************************************
'** Purpose:
'** Prompts the user for a path for the title files
'** Arguments:
'** szDefault$ - default path
'** Returns:
'** New valid path name, or "" if the user quit.
'*************************************************************************
FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
SetSymbolValue "String", TitleShortName$
SetSymbolValue "EditTextIn", szDefault$
SetSymbolValue "EditFocus", "ALL"
GETPATH:
sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
IF sz$ = "CONTINUE" THEN
szTitleDir$ = GetSymbolValue("EditTextOut")
IF IsDirWritable(szTitleDir$) = 0 THEN
BADPATH:
sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO BADPATH
END IF
UIPop 1
GOTO GETPATH
END IF
UIPop 1
CreateDir szTitleDir$, cmoNone
ELSEIF sz$ = "REACTIVATE" THEN
GOTO GETPATH
ELSE
szTitleDir$ = ""
END IF
GetTitleDir = szTitleDir$
END FUNCTION
'*************************************************************************
'** Purpose:
'** Copies the files in the INF file
'** Arguments:
'** szTitleDir$ - destination directory for the title files
'** Returns
'** 1 if files were copied, 0 otherwise
'*************************************************************************
FUNCTION CopyFiles(szTitleDir$) STATIC AS INTEGER
''i% = DoMsgBox("Copy Files", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
'' Add all of the title files to the copy list
AddSectionFilesToCopyList "GPM_DIR", SrcMainDir$, szTitleDir$
AddSectionFilesToCopyList "EDYS_FROM_GPM_DIR", SrcMainDir$, szTitleDir$
AddSectionFilesToCopyList "PCXS_FROM_GPM_DIR", SrcMainDir$, szTitleDir$
IF Lang$ = "FRENCH" THEN
AddSectionFilesToCopyList "LANG_SPEC_FILES", SrcMainDir$+"FRENCH", szTitleDir$
ELSEIF Lang$ = "GERMAN" THEN
AddSectionFilesToCopyList "LANG_SPEC_FILES", SrcMainDir$+"GERMAN", szTitleDir$
ELSE
AddSectionFilesToCopyList "LANG_SPEC_FILES", SrcMainDir$, szTitleDir$
ENDIF
CreateDir MakePath(szTitleDir$,"TRACKS"), cmoNone
AddSectionFilesToCopyList "TRACKS", SrcMainDir$+"TRACKS", MakePath(szTitleDir$,"TRACKS")
CreateDir MakePath(szTitleDir$,"CARS"), cmoNone
AddSectionFilesToCopyList "CARS", SrcMainDir$+"CARS", MakePath(szTitleDir$,"CARS")
CreateDir MakePath(szTitleDir$,"SPONS"), cmoNone
AddSectionFilesToCopyList "SPONS", SrcMainDir$+"SPONS", MakePath(szTitleDir$,"SPONS")
CreateDir MakePath(szTitleDir$,"PART"), cmoNone
AddSectionFilesToCopyList "PART", SrcMainDir$+"PART", MakePath(szTitleDir$,"PART")
CreateDir MakePath(szTitleDir$,"NEWS"), cmoNone
AddSectionFilesToCopyList "NEWS", SrcMainDir$+"NEWS", MakePath(szTitleDir$,"NEWS")
CreateDir MakePath(szTitleDir$,"TVS"), cmoNone
AddSectionFilesToCopyList "TVS", SrcMainDir$+"TVS", MakePath(szTitleDir$,"TVS")
CreateDir MakePath(szTitleDir$,"SPCHEXC"), cmoNone
AddSectionFilesToCopyList "SPCHEXC", SrcMainDir$+"SPCHEXC", MakePath(szTitleDir$,"SPCHEXC")
AddSectionFilesToCopyList "WAL", SrcMainDir$+"WAL", szTitleDir$
'' CreateDir MakePath(szTitleDir$,"SPCHNOR"), cmoNone
'' AddSectionFilesToCopyList "SPCHNOR", SrcMainDir$+"SPCHNOR", MakePath(szTitleDir$,"SPCHNOR")
CreateDir MakePath(szTitleDir$,"SAVEGAME"), cmoNone
'' Check size
szExtras$ = "Extra"
szCosts$ = "Costs"
szNeededs$ = "Neededs"
FOR i% = 1 TO 26 STEP 1
AddListItem szExtras$, "0"
NEXT i%
'' We assume that VIEWER.INI will take another 4K
ReplaceListItem szExtras$, ASC(MID$(UCASE$(GetWindowsDir()), 1, 1)) - ASC("A") + 1, STR$(4096)
'' Get amount of space required
StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
'' Put up a message if there is not enough space
FOR i% = 1 TO 26 STEP 1
IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
TOOBIG:
sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO TOOBIG
END IF
UIPop 1
CopyFiles = 0
GOTO DONTCOPY
END IF
NEXT i%
'' Copy the files
CopyFilesInCopyList
CopyFiles = 1
GOTO END_GOOD
DONTCOPY:
RemoveFile GetWindowsDir+"GPM2MICP.INI",cmoForce
ERROR 100 '' this will force the default error message
GOTO FINAL
END_GOOD:
ExeType$ = GetIniKeyString(GetWindowsDir+"GPM2MICP.INI","EXE","TYPE")
IF ExeType$ = "0" THEN
RemoveFile szTitleDir$+"\GPM2LNK.EXE",cmoForce
ELSE
RemoveFile szTitleDir$+"\GPM2.EXE",cmoForce
RenameFile szTitleDir$+"\GPM2LNK.EXE","GPM2.EXE"
ENDIF
FINAL:
END FUNCTION
'*************************************************************************
'** Purpose:
'** Puts up a success dialog
'*************************************************************************
SUB ShowSuccess STATIC
SUCCESS:
SetSymbolValue "String1", TitleShortName$
sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO SUCCESS
END IF
UIPop 1
END SUB
'*************************************************************************
'** Purpose:
'** Creates program manager entries for the title
'*************************************************************************
SUB ModifyProgramManager STATIC
'' Create the program manager group
CreateProgmanGroup ProgmanGroup$, "", cmoNone
ShowProgmanGroup ProgmanGroup$, 1, cmoNone
CreateProgmanItem ProgmanGroup$, ProgmanItem$, szTitleDir$+"\GPM2.EXE",szTitleDir$+"\GPM.ICO",cmoOverwrite
'' CreateProgmanItem ProgmanGroup$, "Grand Prix Manager 2 Network Edition", szTitleDir$+"\GPM2LNK.EXE",szTitleDir$+"\GPM2LNK.ICO",cmoOverwrite
CreateProgmanItem ProgmanGroup$, "ReadMe", szTitleDir$+"\README.WRI",szTitleDir$+"\README.ICO",cmoOverwrite
'' CreateProgmanItem ProgmanGroup$, "GPM2 Un-Install", SrcMainDir$+"UNINSTAL.EXE",szTitleDir$+"\UNINSTAL.ICO",cmoOverwrite
''CreateProgmanItem ProgmanGroup$, "ReadMe", SrcMainDir$+"README.WRI",szTitleDir$+"\README.ICO",cmoOverwrite
END SUB
'**
'** Purpose:
'** Appends a file name to the end of a directory path,
'** inserting a backslash character as needed.
'** Arguments:
'** szDir$ - full directory path (with optional ending "\")
'** szFile$ - filename to append to directory
'** Returns:
'** Resulting fully qualified path name.
'*************************************************************************
FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
IF szDir$ = "" THEN
MakePath = szFile$
ELSEIF szFile$ = "" THEN
MakePath = szDir$
ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
MakePath = szDir$ + szFile$
ELSE
MakePath = szDir$ + "\" + szFile$
END IF
END FUNCTION
FUNCTION GetRealWindowsSysDir STATIC AS STRING
szBuf$ = string$(260, 32)
cbBuf% = GetRealSystemDir(szBuf$, 260)
IF cbBuf% = 0 THEN
ERROR STFERR
ELSE
IF cbBuf% > 259 THEN
res% = DoMsgBox("Buffer Overflow", "MS-Setup Error", MB_ICONHAND+MB_OK)
ERROR STFERR
END IF
szBuf$ = RTRIM$(szBuf$)
IF MID$(szBuf$, 1, 1) = "\" THEN
szBuf$ = MID$(CURDIR$, 1, 2) + szBuf$
ELSEIF MID$(szBuf$, 2, 1) <> ":" THEN
szBuf$ = MID$(CURDIR$, 1, 3) + szBuf$
END IF
IF MID$(szBuf$, LEN(szBuf$), 1) <> "\" THEN
szBuf$ = szBuf$ + "\"
END IF
GetRealWindowsSysDir = szBuf$
END IF
szBuf$ = ""
END FUNCTION
SUB UpdateWinG32 (szOrig$) STATIC
'
' Here we check the version ourselves of wing32.dll, since
' we can't get version checking for Win32 apps from Win16
'
FileNew$ = MakePath(szOrig$, "wing32.dll")
FileOrig$ = MakePath(szOrig$, "wing32.xxx")
IF IsWin32FileNewer( FileOrig$, FileNew$ ) THEN
RemoveFile FileOrig$, cmoForce
ELSE
RemoveFile FileNew$, cmoForce ' get rid of new file
RenameFilePlease FileOrig$,FileNew$ ' put back old file
END IF
END SUB