-
Aug 7th, 2011, 06:23 PM
#1
Thread Starter
Lively Member
Install script for a Game (Inno Setup)
When your game is complete and your want to offer it to the public you will need to write an installer - a setup program - that will install your game and game resources so the novice computer user also has a chance to play your game.
I have been using Jordan Russel's great free setup maker, called InnoSetup. Below is an example of script for a sample game make with Ice2D Game Engine. The script will check for the correct vesion of directX is present and will offer the user to upgrade directX if its missing as it's a requirement for my game. Some lines are commented out ( with a leading ; ), but i have left them because they show how to install VB6 runtime files and a few common ocx's
I have used a script like this for the Ice2D Game Engine Demo suite in this topic http://www.vbforums.com/showthread.php?t=657161
InnoSetup uses just a single file called Ice2DInst.iss
Code:
; -- Ice2DInst.iss --
; Demonstrates how to install a game made with Ice2D Game Engine.
; Website: http://www.ice2d.com
; Copyright ©2011 DracullSoft™
[Setup]
AppName=Ice2D Setup Test
AppVerName=Ice2D Game Engine Setup Test
DefaultDirName={pf}\Ice2DSetupTest
DefaultGroupName=Ice2D Games
;UninstallDisplayIcon={app}\DxIceSampleD.exe
OutputDir=..\DELIVERY
SourceDir=..\SETUP
OutputBaseFilename=Ice2DSetupTest
AppCopyright=Copyright ©2011 DracullSoft™
AppPublisher=DracullSoft.
AppPublisherURL=http://www.Ice2d.com/
AppVersion=1.87
VersionInfoVersion=1.8.7.1
LicenseFile=License.txt
DisableFinishedPage=yes
;SetupIconFile=InstallICO.ico
Compression=lzma
SolidCompression=yes
WizardImageFile=Wiz-IS.bmp
WizardSmallImageFile=WizSmall-IS.bmp
PrivilegesRequired=admin
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
; begin VB system files - not needed unless windows is pre XP
;Source: vbfiles\stdole2.tlb; DestDir: {sys}; Flags: restartreplace uninsneveruninstall sharedfile regtypelib
;Source: vbfiles\msvbvm60.dll; DestDir: {sys}; Flags: restartreplace uninsneveruninstall sharedfile regserver
;Source: vbfiles\oleaut32.dll; DestDir: {sys}; Flags: restartreplace uninsneveruninstall sharedfile regserver
;Source: vbfiles\olepro32.dll; DestDir: {sys}; Flags: restartreplace uninsneveruninstall sharedfile regserver
;Source: vbfiles\asycfilt.dll; DestDir: {sys}; Flags: restartreplace uninsneveruninstall sharedfile
;Source: vbfiles\comcat.dll; DestDir: {sys}; Flags: restartreplace uninsneveruninstall sharedfile regserver
; begin VB Support files
;Source: MSWinSck.ocx; DestDir: {sys}; Flags: sharedfile regserver - win7 support for tool examples
;Source: vbextra\comdlg32.ocx; DestDir: {sys}; Flags: restartreplace sharedfile regserver
;Source: vbextra\comctl32.ocx; DestDir: {sys}; Flags: restartreplace sharedfile regserver
;Ice2D engine
Source: Ice2D\DxIce9H.dll; DestDir: "{app}\Ice2D"
Source: Ice2D\DxIce110.Pak; DestDir: "{app}\Ice2D"
Source: Ice2D\Dx9Ice187.dll; DestDir: "{app}\Ice2D";Flags: restartreplace regserver 32bit
Source: Ice2D\bass.dll; DestDir: "{app}\Ice2D"
Source: Ice2D\ReadMe.txt; DestDir: "{app}\Ice2D"
; Ice2D Game Demo
; install recursive folders and files
Source: "Prog\*"; DestDir: "{app}"; Excludes: "*.m,.svn"; Flags: recursesubdirs createallsubdirs ignoreversion
Source: Ice2D\Ice2D.url; DestDir: "{app}"
; direct X installer
Source: "dxwebsetup.exe"; Flags: dontcopy
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Icons]
Name: "{group}\Ice2DSetupTest"; Filename: "{app}\DxIceSampleD.exe"
Name: "{group}\Visit Ice2D.com"; Filename: {app}\Ice2D.url
Name: "{group}\{cm:UninstallProgram,Ice2D Demo}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\Ice2DSetupTest"; Filename: "{app}\DxIceSampleD.exe"; Tasks: desktopicon
[Run]
Filename: "{app}\DxIceSampleD.exe"; Description: "{cm:LaunchProgram,Ice2D SetupTest App}"; Flags: nowait postinstall skipifsilent hidewizard
[InstallDelete]
Type: filesandordirs; Name: "{app}"
<<code>>
procedure DecodeVersion( verstr: String; var verint: array of Integer );
var
i,p: Integer; s: string;
begin
verint := [0,0,0,0];
i := 0;
while ( (Length(verstr) > 0) and (i < 4) ) do
begin
p := pos('.', verstr);
if p > 0 then
begin
if p = 1 then s:= '0' else s:= Copy( verstr, 1, p - 1 );
verint[i] := StrToInt(s);
i := i + 1;
verstr := Copy( verstr, p+1, Length(verstr) );
end
else
begin
verint[i] := StrToInt( verstr );
verstr := '';
end;
end;
end;
function CompareVersion( ver1, ver2: String ) : Integer;
var
verint1, verint2: array of Integer;
i: integer;
begin
SetArrayLength( verint1, 4 );
DecodeVersion( ver1, verint1 );
SetArrayLength( verint2, 4 );
DecodeVersion( ver2, verint2 );
Result := 0; i := 0;
while ( (Result = 0) and ( i < 4 ) ) do
begin
if verint1[i] > verint2[i] then
Result := 1
else
if verint1[i] < verint2[i] then
Result := -1
else
Result := 0;
i := i + 1;
end;
end;
function GetDirectXVersion(): String;
var
sVersion: String;
begin
sVersion := '';
RegQueryStringValue( HKLM, 'SOFTWARE\Microsoft\DirectX', 'Version', sVersion );
Result := sVersion;
end;
function InitializeSetup(): Boolean;
var
ResultCode: Integer;
begin
if CompareVersion( GetDirectXVersion(), '4.9.0.904') < 0 then
begin
Result := MsgBox('DirectX 9.0.904 or higher is needed but it has not been found. Do you wish to continue with the installation?',
mbConfirmation, MB_YESNO) = idYes;
if Result = False then begin
MsgBox('Please upgrade your DirectX Version to at least least 9.0.904. (DirectX 9,0c aug 2009)', mbInformation, MB_OK);
end
else begin
ExtractTemporaryFile('dxwebsetup.exe');
// Launch Notepad and wait for it to terminate
if Exec(ExpandConstant('{tmp}\dxwebsetup.exe'), '', '', SW_SHOW,
ewWaitUntilTerminated, ResultCode) then
begin
// handle success if necessary; ResultCode contains the exit code
end
else begin
// handle failure if necessary; ResultCode contains the error code
end;
end
end
else
Result := true;
end;
Last edited by DracullSoft; Aug 7th, 2011 at 06:29 PM.
Reason: issue with code tag: rename the <<code>> to [Code] in the iss file
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|