#define SourcePath
#if SourcePath=ReadReg(HKLM,'SOFTWARE\Capcom\LOSTPLANET 2','InstallDir',False)
#else
#error Lost Planet 2 not installed, game's folder entry not found
#endif
#define AppName "Lost Planet 2"
#define GUID "{737369DC-08E8-4787-A78C-F86943247BDF}"
#define mp3filename "InstallLoop.mp3"
#define Autorunmp3filename "AMusicLoop.mp3"
#define ClickSoundfilename "Click.wav"

//Colorscheme Soapsky | Normalsoapsky.ini
//StylesIniName values| LargeFontssoapsky.ini
//                    | ExtraLargesoapsky.ini

#define StylesName "Soapsky.cjstyles"
#define StylesIniName "Normalsoapsky.ini"

#define VideoMem "256"
#define CpuMHZ "2400"
#define PhysicalRam "2048"


#define InstallMusicLoop
#define AddToFireWallList
#define AddToGameExplorer
#define ISSkin
//#define FreeArc
#define Autorun
#define AMusicLoop

[Setup]
AppName={#AppName}
AppVerName={#AppName}
DefaultDirName={pf}\CAPCOM\LOST PLANET 2
OutputBaseFilename=setup
Compression=lzma2/ultra64
LZMADictionarySize=65536
CompressionThreads=2
LZMANumFastBytes=273
SolidCompression=yes
LZMAUseSeparateProcess=yes
#ifndef FreeArc
DiskSpanning=yes
DiskSliceSize=1550000000
SlicesPerDisk=3
#endif
ShowLanguageDialog=auto
MinVersion=0,5.01
OutputDir=.\Compiled
SetupIconFile=.\Wizard_Res\icon.ico
WizardImageFile=.\Wizard_Res\WizardImage.bmp
WizardSmallImageFile=.\Wizard_Res\WizardSmallImage.bmp
DefaultGroupName=Capcom\LOST PLANET 2

[Files]

Source: .\Wizard_Res\BGI*.bmp; DestDir: {tmp}; Flags: dontcopy
Source: .\Wizard_Res\SplashScreen.bmp; DestDir: {tmp}; Flags: dontcopy
#ifdef Autorun
Source: .\Wizard_Res\AutorunBGI.bmp; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef ISSkin
Source: .\Wizard_Res\{#StylesName}; DestDir: {app}; Flags: ignoreversion
#endif
#ifdef InstallMusicLoop
Source: .\Wizard_Res\{#mp3filename}; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef Autorun
#ifdef AMusicLoop
Source: .\Wizard_Res\{#Autorunmp3filename}; DestDir: {tmp}; Flags: dontcopy
#endif
#endif
#ifdef Autorun
Source: .\Wizard_Res\{#ClickSoundfilename}; DestDir: {tmp}; Flags: dontcopy
#endif
Source: .\Libraries\InnoCallback.dll; DestDir: {tmp}; Flags: dontcopy
Source: .\Libraries\get_hw_caps.dll; DestDir: {tmp}; Flags: dontcopy
#ifdef AddToGameExplorer
Source: .\Libraries\GameuxInstallHelper.dll; DestDir: {app}; Flags: ignoreversion
#endif
#ifdef AddToFireWallList
Source: .\Libraries\FirewallInstallHelper.dll; DestDir: {app}; Flags: ignoreversion
#endif
#ifdef FreeArc
Source: .\Libraries\unarc.dll; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef ISSkin
Source: .\Libraries\ISSkin.dll; DestDir: {app}; Flags: ignoreversion
#endif
Source:{#SourcePath}*; DestDir: {app}; Flags: ignoreversion recursesubdirs

[Tasks]

Name: desktopicon; Description: {cm:CreateDesktopIcon}
Name: MenuShortCuts; Description: {cm:AdditionalIcons}
;Name: DirectX; Description: {cm:run} DirectX
;Name: GFWL; Description: {cm:run} Games for Windows - LIVE

[Registry]
Root: HKLM; Subkey: SOFTWARE\Capcom\LOSTPLANET 2; Flags: uninsdeletekeyifempty
Root: HKLM; Subkey: SOFTWARE\Capcom\LOSTPLANET 2; ValueName: InstallDir; ValueType: String; ValueData: {app}\; Flags: uninsdeletekey
Root: HKLM; Subkey: SOFTWARE\Capcom\LOSTPLANET 2; ValueName: GUID; ValueType: String; ValueData: {{#GUID}; Flags: uninsdeletekey
Root: HKLM; Subkey: SOFTWARE\Capcom\LOSTPLANET 2; ValueName: Language; ValueType: String; ValueData: {code:GetLngID}; Flags: uninsdeletekey
Root: HKLM; Subkey: SOFTWARE\Capcom\LOSTPLANET 2; ValueName: launch; ValueType: DWord; ValueData: 0; Flags: uninsdeletekey
Root: HKLM; Subkey: SOFTWARE\Classes\.Lostplanet2Save-capcom; ValueName: ; ValueType: String; ValueData: CAPCOMLostPlanet2SAVEFILE; Flags: uninsdeletekey
Root: HKLM; Subkey: SOFTWARE\Classes\CAPCOMLostPlanet2SAVEFILE\Shell\Open\Command; ValueName: ; ValueType: String; ValueData: {app}\Launcher.exe; Flags: uninsdeletekey
Root: HKCR; Subkey: .Lostplanet2Save-capcom; ValueName: ; ValueType: String; ValueData: CAPCOMLostPlanet2SAVEFILE; Flags: uninsdeletekey
Root: HKCR; Subkey: CAPCOMLostPlanet2SAVEFILE\Shell\Open\Command; ValueName: ; ValueType: String; ValueData: {app}\Launcher.exe; Flags: uninsdeletekey


#ifdef AddToGameExplorer
;Supporting an Upgrade from Windows XP for current user (Game Explorer)
Root: HKCU; Subkey: Software\Classes\Software\Microsoft\Windows\CurrentVersion\GameUX\GamesToFindOnWindowsUpgrade\{code:GetGUIDStr}; Flags: uninsdeletekey; check: CheckXPOs()
Root: HKCU; Subkey: Software\Classes\Software\Microsoft\Windows\CurrentVersion\GameUX\GamesToFindOnWindowsUpgrade; ValueName: GDFBinaryPath; ValueType: String; ValueData: {app}; Flags: uninsdeletekey; check: CheckXPOs()
Root: HKCU; Subkey: Software\Classes\Software\Microsoft\Windows\CurrentVersion\GameUX\GamesToFindOnWindowsUpgrade; ValueName: GameInstallPath; ValueType: String; ValueData: {app}; Flags: uninsdeletekey; check: CheckXPOs()
;Supporting an Upgrade from Windows XP for current user (Game Explorer)
#endif

[Dirs]

#ifdef AddToGameExplorer
;Supporting an Upgrade from Windows XP for current user (Game Explorer)
Name: {localappdata}\Microsoft\Windows\GameExplorer\{code:GetGUIDStr}\PlayTasks; check: CheckXPOs()
Name: {localappdata}\Microsoft\Windows\GameExplorer\{code:GetGUIDStr}\SupportTasks; check: CheckXPOs()
;Supporting an Upgrade from Windows XP for current user (Game Explorer)
#endif

[Run]

;Filename: {src}\redist\directx_Jun2010\DXSETUP.exe; Parameters: /silent; StatusMsg: {cm:run} Microsoft DirectX...; Tasks: DirectX
;Filename: {src}\redist\gfwlivesetup.exe; Parameters: /q /nu; StatusMsg: {cm:run} Games for Windows - LIVE...; Tasks: GFWL
Filename: {app}\Launcher.exe; Description: {cm:LaunchProgram,Lost Planet 2}; flags: unchecked postinstall

[Icons]

Name: {userdesktop}\{cm:LaunchProgram,Lost Planet 2}; Filename: {app}\Launcher.exe; WorkingDir: {app}; Tasks: desktopicon
Name: {group}\{cm:LaunchProgram,Lost Planet 2}; Filename: {app}\Launcher.exe; WorkingDir: {app}; Tasks: MenuShortCuts
Name: {group}\{cm:UninstallProgram,Lost Planet 2}; Filename: {uninstallexe}; WorkingDir: {app}; Tasks: MenuShortCuts

[CustomMessages]

en.Run=Install
en.Uninstall=%1 Uninstall
en.About=&About...
en.removemsg=Do you wish to remove your saved games and settings?
en.NotDeviceDriver= Hardware component not detected
en.cpu=Processor
en.vga=Video card
en.audio=Audio Card
en.pmem=Physical Memory
en.os=Operating System
en.cpcaption=Hardware Informations
en.glabel=The hardware does meet minimum requirements.
en.rlabel=The hardware does not meet minimum requirements.
en.setup=Setup
en.readme=Readme
en.readmefile=ReadMe_English.txt
en.continue=Do you wish to continue?
en.support=Support


it.Uninstall=%1 Disinstallazione
it.About=&Informazioni su...
it.Run=Installazione
it.removemsg=Vuoi rimuovere i salvataggi e le impostazioni utente?
it.NotDeviceDriver=Componente hardware non rilevato
it.cpu=Processore
it.vga=Scheda Video
it.audio=Scheda Audio
it.pmem=Memoria Fisica
it.os=Sistema Operativo
it.cpcaption=Informazioni Hardware
it.glabel=L'hardware soddisfa i requisiti minimi.
it.rlabel=L'hardware non soddisfa i requisiti minimi.
it.setup=Impostazioni
it.readme=Leggimi
it.readmefile=ReadMe_Italian.txt
it.continue=Vuoi continuare?
it.support=Supporto


es.Uninstall=%1 Desinstalar
es.About=&Acerca de...
es.Run=Instalar
es.removemsg=¿Desea eliminar sus juegos guardados y ajustes?
es.NotDeviceDriver=Componente de hardware no se detecta
es.cpu=Procesador
es.vga=Tarjeta gráfica
es.audio=Tarjeta de sonido
es.pmem=Memoria RAM
es.os=Sistema operativo
es.cpcaption=Información del Hardware
es.glabel=El hardware cumple los requisitos mínimos.
es.rlabel=El hardware no cumple los requisitos mínimos.
es.setup=Ajustes
es.readme=Leeme
es.readmefile=ReadMe_Spanish.txt
es.continue=¿Desea continuar?
es.support=Asistencia


de.Uninstall=%1 Deinstallieren
de.About=&Über...
de.Run=Installieren
de.removemsg=Möchten Sie Ihre gespeicherten Spiele und Einstellungen zu entfernen?
de.NotDeviceDriver=Hardware-Komponente nicht erkannt
de.cpu=Prozessor
de.vga=Grafikkarte
de.audio=Audiokarte
de.pmem=Gerätespeicher
de.os=Betriebssystem
de.cpcaption=Hardware Informationen
de.glabel=Die Hardware funktioniert Mindestanforderungen erfüllen.
de.rlabel=Die Hardware entspricht nicht den Mindestanforderungen.
de.setup=Einstellungen
de.readme=Liesmich
de.readmefile=ReadMe_German.txt
de.continue=Wollen Sie weitermachen?
de.support=Support


fr.Uninstall=%1 Désinstaller
fr.About=&À Propos...
fr.Run=Installer
fr.removemsg=Voulez-vous supprimer vos parties sauvegardées et les paramètres?
fr.NotDeviceDriver=Composant hardware non détecté
fr.cpu=Processeur
fr.vga=Carte vidéo
fr.audio=Carte son
fr.pmem=Mémoire RAM
fr.os=Système d'exploitation
fr.cpcaption=Información del Hardware
fr.glabel=Le hardware ne satisfont aux exigences minimales.
fr.rlabel=Le hardware ne répond pas aux exigences minimales.
fr.setup=Paramètres
fr.readme=Lisezmoi
fr.readmefile=ReadMe_French.txt
fr.continue=Voulez-vous continuer?
fr.support=Assistance


[Languages]
; These files are stubs
; To achieve better results after recompilation, use the real language files

Name: en; MessagesFile: compiler:Default.isl; licensefile: .\Wizard_Res\EULA_G4WL_English_B001.rtf

Name: it; MessagesFile: compiler:languages\italian.isl; licensefile: .\Wizard_Res\EULA_G4WL_Italian_B001.rtf

Name: de; MessagesFile: compiler:languages\german.isl; licensefile: .\Wizard_Res\EULA_G4WL_English_B001.rtf

Name: es; MessagesFile: compiler:languages\spanish.isl; licensefile: .\Wizard_Res\EULA_G4WL_Spanish_B001.rtf

Name: fr; MessagesFile: compiler:languages\french.isl; licensefile: .\Wizard_Res\EULA_G4WL_French_B001.rtf



[Code]
const
  PlayTask = 0;
  SupportTask= 1;
  AllUsers = 2;
  Current = 3;
  GE_resource = '\Launcher.exe';
  bgicount= 8;
  WSplash=500;
  HSplash=246;
  
type
  TGUID = record
  Data1: Longword;
  Data2,
  Data3: Word;
  Data4: array [0..7] of byte;
end;

type
  Timgname = record
  name: string;
end;

type
  TSlideShow=procedure();

var
  GUID: TGUID;
  AppNamelbl: TNewStaticText;
  i,c,VideoRam,vr,CpuFreq,PhyRam: integer;
  bgImage : TBitmapImage;
  timercallback,Tid: LongWord;
  names: array of Timgname;
  AboutButton: TNewButton;
  HWStatusLabel1,HWStatusLabel2: TLabel;
  Frame1,Frame2: TBevel;
  HWCP: TWizardPage;
  CpuField,VideoField,AudioField,CpuDesField,VideoDesField,AudioDesField,MemoryField,MemoryDesField,OSDesField,OSField: TNewEdit;
  PLegenda1,PLegenda2: TPanel;
  Pdm,OSName: string;
  VideoReq,CPUReq,AudioReq,PhyRamReq,OSReq: Boolean;


//Funzioni Windows API
function WrapCallback(callback:TSlideShow; paramcount:integer):longword;
external 'wrapcallback@files:innocallback.dll stdcall';
function SetTimer(hWnd: longword; nIDEvent, uElapse: longword; lpTimerFunc: longword): longword;
external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord;
external 'KillTimer@user32 stdcall delayload';
function GetDC(HWND: DWord): DWord;
external 'GetDC@user32.dll stdcall';
function GetDeviceCaps(DC: DWord; Index: Integer): Integer;
external 'GetDeviceCaps@gdi32.dll stdcall';
function ReleaseDC(HWND: DWord;DC: DWord): Integer;
external 'ReleaseDC@user32.dll stdcall';
function ShowWindow(hWnd: DWord; nCmdShow: Integer): Boolean;
external 'ShowWindow@user32.dll stdcall';
function SetWindowLong(hWnd: DWord; nIndex: Integer; dwNewLong: Longint):Longint;
external 'SetWindowLongA@user32.dll stdcall';
#ifdef AddToGameExplorer
function GenerateGUID(var GUID: TGUID): Cardinal;
external 'GenerateGUID@files:GameuxInstallHelper.dll stdcall setuponly';
function AddToGameExplorer(Binary: String; Path: String; InstallType: Integer; var GUID: TGUID): Cardinal;
external 'AddToGameExplorerA@files:GameuxInstallHelper.dll stdcall setuponly';
function CreateTask(InstallType: Integer; var GUID: TGUID; TaskType: Integer; TaskNumber: Integer; TaskName: String; Binary: String; Parameters: String): Cardinal;
external 'CreateTaskA@files:GameuxInstallHelper.dll stdcall setuponly';
function RetrieveGUIDForApplication(Binary: String; var GUID: TGUID): Cardinal;
external 'RetrieveGUIDForApplicationA@{app}\GameuxInstallHelper.dll stdcall uninstallonly';
function RemoveFromGameExplorer(var GUID: TGUID): Cardinal;
external 'RemoveFromGameExplorer@{app}\GameuxInstallHelper.dll stdcall uninstallonly';
function RemoveTasks(var GUID: TGUID): Cardinal;
external 'RemoveTasks@{app}\GameuxInstallHelper.dll stdcall uninstallonly';
#endif
function SHGetFolderPath(hwndOwner,nFolder,hToken: Integer; dwFlags: DWord; pszPath: PChar): Cardinal;
external 'SHGetFolderPathA@shell32.dll stdcall';
function StringFromGUID2(var GUID: TGUID; lpsz: PChar; cchMax: integer): Integer;
external 'StringFromGUID2@Ole32.dll stdcall';
#ifdef InstallMusicLoop
function mciSendString(lpstrCommand, lpstrReturnString: PChar; uReturnLength: UINT; hWndCallback: DWord): Integer;
external 'mciSendStringA@winmm.dll stdcall';
#endif
function PlaySound(pszSound: String;hmod: Integer; fdwSound: DWord): Integer;
external 'PlaySoundA@Winmm.dll stdcall';
function CreateRoundRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect, nWidthEllipse, nHeightEllipse: Integer): Dword;
external 'CreateRoundRectRgn@Gdi32.dll stdcall';
function SetWindowRgn(hWnd, hRgn: Dword; bRedraw: Boolean): Integer;
external 'SetWindowRgn@User32.dll stdcall';
function DeleteObject(hObject: Dword): Boolean;
external 'DeleteObject@Gdi32.dll stdcall';
function DetectHardware: Integer;
external 'hwc_DetectHardware@files:get_hw_caps.dll stdcall setuponly';
function GetProcessorName: PChar;
external 'hwc_GetProcessorName@files:get_hw_caps.dll stdcall setuponly';
function GetProcessorFreq: Integer;
external 'hwc_GetProcessorFreq@files:get_hw_caps.dll stdcall setuponly';
function GetVideoCardName: PChar;
external 'hwc_GetVideoCardName@files:get_hw_caps.dll stdcall setuponly';
function GetVidMemLocal: Integer;
external 'hwc_GetVidMemLocal@files:get_hw_caps.dll stdcall setuponly';
function GetPdmWidth: Integer;
external 'hwc_GetPdmWidth@files:get_hw_caps.dll stdcall setuponly';
function GetPdmHeight: Integer;
external 'hwc_GetPdmHeight@files:get_hw_caps.dll stdcall setuponly';
function GetSoundCards: Integer;
external 'hwc_GetSoundCards@files:get_hw_caps.dll stdcall setuponly';
function GetSoundCardName: PChar;
external 'hwc_GetSoundCardName@files:get_hw_caps.dll stdcall setuponly';
function GetSystemPhys: Integer;
external 'hwc_GetSystemPhys@files:get_hw_caps.dll stdcall setuponly';
function GetWindowsName: PChar;
external 'hwc_GetWindowsName@files:get_hw_caps.dll stdcall setuponly';
#ifdef AddToFireWallList
function AddApplicationToExceptionList(PathToExe,FName: String): Integer;
external 'AddApplicationToExceptionListA@files:FirewallInstallHelper.dll stdcall setuponly';
function RemoveApplicationFromExceptionList(PathToExe: String): Integer;
external 'RemoveApplicationFromExceptionListA@{app}\FirewallInstallHelper.dll stdcall uninstallonly';
#endif
#ifdef ISSkin
procedure LoadSkin(lpszPath: String; lpszIniFileName: String);
external 'LoadSkin@{tmp}\isskin.dll stdcall delayload';
procedure UnloadSkin();
external 'UnloadSkin@{tmp}\isskin.dll stdcall delayload';
#endif

#ifdef FreeArc
 #include "FreeArc.iss"
#endif

#ifdef Autorun
 #include "Autorun.iss"
#endif

function CheckXPOs(): Boolean;

begin

if GetWindowsVersion shr 24 < 6 then Result:=TRUE

end;

function GetScreenHeight(): integer;
var
    dc: DWord;

begin
 dc:=GetDC(MainForm.Handle);
 Result:=GetDeviceCaps(dc,10);
 ReleaseDC(MainForm.Handle,dc);
end;

function GetScreenWidth(): integer;
 var
    dc: DWord;

begin
 dc:=GetDC(MainForm.Handle);
 Result:=GetDeviceCaps(dc,8);
 ReleaseDC(MainForm.Handle,dc);
end;

function IntToHex(l:longword; digits:integer):string;

var hexchars:string;

begin

 hexchars:='0123456789ABCDEF';
 setlength(result,digits);

 while (digits>0) do begin

   result[digits]:=hexchars[l mod 16+1];
   l:=l div 16;
   digits:=digits-1;

end;

end;

function GetGUIDStr(Param: string): string;

begin

Result:='{'+IntToHex(GUID.Data1,8)+'-'+
        IntToHex(GUID.Data2,4)+'-'+
        IntToHex(GUID.Data3,4)+'-'+
        IntToHex(GUID.Data4[0],2)+IntToHex(GUID.Data4[1],2)+'-'+
        IntToHex(GUID.Data4[2],2)+IntToHex(GUID.Data4[3],2)+
        IntToHex(GUID.Data4[4],2)+IntToHex(GUID.Data4[5],2)+
        IntToHex(GUID.Data4[6],2)+IntToHex(GUID.Data4[7],2)+
        '}';
end;


function InitializeSetup(): Boolean;
#ifndef Autorun
var
  appath: string;
  ResultCode: Integer;
#endif

begin
    #ifdef ISSkin
    ExtractTemporaryFile('{#StylesName}');
    ExtractTemporaryFile('ISSkin.dll');
    LoadSkin(ExpandConstant('{tmp}\{#StylesName}'), '{#StylesIniName}');
    #endif
    #ifdef Autorun
    Result:=LaunchAutorun();
    #endif
    #ifndef Autorun
  if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Capcom\LOSTPLANET 2') then
   begin
    RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Capcom\LOSTPLANET 2',
     'InstallDir', appath)
    Exec((appath +'unins000.exe'), '', '', SW_SHOW,
     ewWaitUntilTerminated, ResultCode)
    end else
    begin
    Result := TRUE
    end;
    #endif
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);

begin
  if CurUninstallStep = usUninstall then
  begin
    #ifdef AddToFireWallList
    RemoveApplicationFromExceptionList(ExpandConstant('{app}\Launcher.exe'));
    UnloadDll(ExpandConstant('{app}\FirewallInstallHelper.dll'));
    #endif
    #ifdef AddToGameExplorer
    if not CheckXPOs then
    begin
    RetrieveGUIDForApplication(ExpandConstant('{app}'+GE_resource), GUID);
    RemoveFromGameExplorer(GUID);
    RemoveTasks(GUID);
    UnloadDll(ExpandConstant('{app}\GameuxInstallHelper.dll'));
    end;
    #endif
    if MsgBox(ExpandConstant('{cm:removemsg}'), mbConfirmation, MB_YESNO)=IDYES then
     begin
      DelTree(ExpandConstant('{userdocs}'+'\capcom\LOST PLANET 2'), True, True, True);
     end;
    end;
  end;


procedure CurStepChanged(CurStep: TSetupStep);

begin
 #ifdef AddToGameExplorer
 if CurStep = ssInstall then
    GenerateGUID(GUID);
 #endif

    if CurStep = ssPostInstall then begin
    #ifdef FreeArc
            WizardForm.FilenameLabel.Top := 0;
            WizardForm.FilenameLabel.Left := 0;
            WizardForm.FilenameLabel.Font.size:= 7;
            WizardForm.FilenameLabel.Font.Name:='Arial';
            WizardForm.FilenameLabel.Font.Style:=[fsBold];
            WizardForm.Caption:=WizardForm.Caption +' - '+ cm('ArcTitle');
            UnPackError:= UnPack(Archives)
            if UnPackError = 0 then begin
            SetTaskBarTitle(SetupMessage(msgSetupAppTitle))
            WizardForm.Caption:=FmtMessage(SetupMessage(msgSetupWindowTitle),['{#AppName}']) ;
        end else
        begin
            // Error occured, uninstall it then
            Exec(ExpandConstant('{uninstallexe}'), '/SILENT','', sw_Hide, ewWaitUntilTerminated, n);
            SetTaskBarTitle(SetupMessage(msgErrorTitle))
            WizardForm.Caption:= SetupMessage(msgErrorTitle) +' - '+ cm('ArcBreak')

        end;
    #endif
    
    #ifdef AddToGameExplorer
     if not CheckXPOs then
    
    begin
  
    AddToGameExplorer(ExpandConstant('{app}'+GE_resource), ExpandConstant('{app}'), Current, GUID);
    CreateTask(3, GUID, PlayTask, 0,'', ExpandConstant('{app}\Launcher.exe'), '');
    //CreateTask(3, GUID, SupportTask, 0,'', ExpandConstant('http://www.capcom.com/'), '');

    end;
    #endif
    
    #ifdef AddToFireWallList
    AddApplicationToExceptionList(ExpandConstant('{app}\Launcher.exe'),'{#AppName}');
    #endif

  end;

end;

procedure SlideShow();

var
bgipercents: integer;

begin

bgipercents:=WizardForm.ProgressGauge.Max div bgicount
if  (WizardForm.ProgressGauge.Position >= bgipercents*c) and (WizardForm.ProgressGauge.Position < WizardForm.ProgressGauge.Max) then begin
bgImage.bitmap.LoadFromFile(expandConstant('{tmp}\'+names[c].name));
c:=c+1

end;
end;

procedure CurPageChanged(CurPageID: Integer);

  #ifdef InstallMusicLoop
  var MCIstr: PChar;
  #endif
      
  begin
  
  #ifdef FreeArc
  if (CurPageID = wpFinished) and (UnPackError <> 0) then
    begin // Extraction was unsuccessful
        // Show error message
        WizardForm.FinishedLabel.Font.Color:= $0000C0;
        WizardForm.FinishedLabel.Height:= WizardForm.FinishedLabel.Height * 2;
        WizardForm.FinishedLabel.Caption:= SetupMessage(msgSetupAborted) + #13#10#13#10 + msgError;
    end;
  #endif
    
  if (CurPageID = wpInstalling) then

   begin

   With WizardForm Do Begin

     ClientWidth:=310
     ClientHeight:=145
     top:=GetScreenHeight-ClientHeight-45
     left:=GetScreenWidth-ClientWidth-20
     PageNameLabel.Visible:=false;
     PageDescriptionLabel.Visible:=false;
     WizardSmallBitmapImage.visible:=true;
     WizardSmallBitmapImage.Width:= ClientWidth;
     WizardSmallBitmapImage.Left:=0;
     ProgressGauge.parent := WizardForm.InstallingPage;
     ProgressGauge.Top := 30;
     ProgressGauge.Left := 0;
     ProgressGauge.Width := 230;
     ProgressGauge.Height := 15;

     CancelButton.Parent := WizardForm.InstallingPage;
     CancelButton.Top := ProgressGauge.Top + ProgressGauge.Height + 3;
     CancelButton.Left := ((ProgressGauge.Width - CancelButton.Width) div 2);
     #ifdef FreeArc
     CancelButton.Hide;
     #endif
     
     #ifdef FreeArc
     btnCancelUnpacking:=TButton.create(WizardForm);
     btnCancelUnpacking.Parent:= WizardForm.InstallingPage;
     btnCancelUnpacking.OnClick:= @btnCancelUnpackingOnClick;
     btnCancelUnpacking.Top := CancelButton.Top;
     btnCancelUnpacking.Left := CancelButton.Left;
     btnCancelUnpacking.Width:=CancelButton.Width;
     btnCancelUnpacking.Height:=CancelButton.Height;
     btnCancelUnpacking.Hide;
     #endif

     FilenameLabel.Width := ProgressGauge.Width
     FilenameLabel.Top := 14
     FilenameLabel.Left := 0

    end;
    #ifdef InstallMusicLoop
    mciSendString('OPEN ' + ExpandConstant('{tmp}') + '\{#mp3filename} TYPE MPEGVIDEO ALIAS InstallMusicLoop', MCIstr, 255, 0);
    mciSendString('PLAY InstallMusicLoop REPEAT', MCIstr, 255, 0);
    #endif
    c:=1;
    bgImage.Show;
    ShowWindow(Mainform.Handle,SW_SHOWMAXIMIZED);
    timercallback:=WrapCallBack(@SlideShow,0);
    Tid:=settimer(0,0,1000,timercallback)

  end;

   if (CurPageID = wpFinished) then
   begin

   With WizardForm Do Begin

    ClientWidth:=497;
    ClientHeight:=360;
    top:=((GetScreenHeight-ClientHeight)div 2);
    left:=((GetScreenWidth-ClientWidth)div 2);

    end;
    
    #ifdef InstallMusicLoop
    mciSendString('STOP InstallMusicLoop', MCIstr, 255, 0);
    #endif
    ShowWindow(Mainform.Handle,SW_HIDE);

   end;
   
   if (CurPageID = wpWelcome) or (CurPageID = wpFinished) then
   begin
   if (CurPageID = wpWelcome) then begin
   AboutButton.Enabled:=True
   AppNamelbl.Visible := False;
   end;
   if  (CurPageID = wpFinished) then begin
   AboutButton.Enabled:=False;
   AppNamelbl.Visible := False;
   end;
   end else begin
   AboutButton.Enabled:=False;
   AppNamelbl.Visible := True;
   end;

  end;

function ShouldSkipPage(PageID: Integer): Boolean;

begin
if (PageID = wpSelectProgramGroup) then
 begin
 if not CheckXPOs then Result:=TRUE
 end;
end;

procedure AboutButtonOnClick(Sender: TObject);

begin
 MsgBox('Lost Planet 2 - Inno Setup script by Peterf1999', mbInformation, mb_Ok);
end;

procedure SplashScreen();

var hRgn1,hRgn2: Dword;

begin
  ExtractTemporaryFile('SplashScreen.BMP');
  bgImage.bitmap.LoadFromFile(expandConstant('{tmp}\SplashScreen.BMP'));
  hRgn1:=CreateRoundRectRgn((GetScreenWidth-WSplash) div 2,(GetScreenHeight-HSplash) div 2,(GetScreenWidth-WSplash) div 2 + WSplash+1 ,(GetScreenHeight-HSplash) div 2 + HSplash+1 ,0,0);
  SetWindowRgn(Mainform.Handle,hRgn1,False);
  ShowWindow(Mainform.Handle,SW_SHOWMAXIMIZED);
  Sleep(3000);
  ShowWindow(Mainform.Handle,SW_HIDE);
  hRgn2:=CreateRoundRectRgn(0,0,GetScreenWidth+1,GetScreenHeight+1,0,0);
  SetWindowRgn(Mainform.Handle,hRgn2,False);
  DeleteObject(hRgn1);
  DeleteObject(hRgn2);
end;

procedure CreateHWCustomPage;

begin
  { Creates Hardware wizard page }
  HWCP := CreateCustomPage(wpLicense, ExpandConstant('{cm:cpcaption}'), '');

  { Frame1 }
  Frame1 := TBevel.Create(WizardForm);
  with Frame1 do
  begin
    Parent := HWCP.Surface;
    Left := ScaleX(0);
    Top := ScaleY(0);
    Width := ScaleX(417);
    Height := ScaleY(184);
    Shape:=Bsframe;
  end;

  { Frame2 }
  Frame2 := TBevel.Create(WizardForm);
  with Frame2 do
  begin
    Parent := HWCP.Surface;
    Left := Frame1.Left;
    Top := Frame1.Height+ScaleY(5);
    Width := ScaleX(417);
    Height := ScaleY(40);
    Shape:=Bsframe;
  end;
  
   PLegenda1 := TPanel.Create(WizardForm);
  with PLegenda1 do
  begin
    Parent := HWCP.Surface;
    Left := Frame1.Left+ScaleX(38);
    Top := Frame1.Height+ScaleY(8);
    Width := ScaleX(15);
    Height := ScaleY(15);
    Color := $3dfb37;
    ParentBackground := False;
  end;

   PLegenda2 := TPanel.Create(WizardForm);
  with PLegenda2 do
  begin
    Parent := HWCP.Surface;
    Left := Frame1.Left+ScaleX(38);
    Top := Frame1.Height+ScaleY(26);
    Width := ScaleX(15);
    Height := ScaleY(15);
    Color := $3d37fb;
    ParentBackground := False;
  end;
  
  { HWStatusLabel1 }
  HWStatusLabel1 := TLabel.Create(WizardForm);
  with HWStatusLabel1 do
  begin
    Parent := HWCP.Surface;
    Caption := ExpandConstant('{cm:glabel}');
    Transparent := True;
    Left := Frame2.Left+ScaleX(72);
    Top := Frame2.Top+ScaleY(4);
    Width := ScaleX(417);
    Height := ScaleY(20);
    Font.Style := [fsBold];
  end;
  
  { HWStatusLabel2 }
  
  HWStatusLabel2 := TLabel.Create(WizardForm);
  with HWStatusLabel2 do
  begin
    Parent := HWCP.Surface;
    Caption := ExpandConstant('{cm:rlabel}');
    Transparent := True;
    Left := Frame2.Left+ScaleX(72);
    Top := Frame2.Top+ScaleY(22);
    Width := ScaleX(417);
    Height := ScaleY(20);
    Font.Style := [fsBold];
  end;
  
  { CpuField }
  CpuField := TNewEdit.Create(WizardForm);
  with CpuField do
  begin
    Parent := HWCP.Surface;
    Left := ScaleX(8);
    Top := ScaleY(16);
    Width := ScaleX(90);
    Height := ScaleY(24);
    Color := clMenu;
    Font.Color := clBlack;
    Font.Size := 7;
    Font.Name := 'Arial';
    Font.Style := [fsBold];
    ParentFont := False;
    ReadOnly := True;
    HideSelection:=True;
    AutoSelect:=False;
    Text := ExpandConstant('{cm:cpu}');
  end;

  { VideoField }
  VideoField := TNewEdit.Create(WizardForm);
  with VideoField do
  begin
    Parent := HWCP.Surface;
    Left := ScaleX(8);
    Top := ScaleY(48);
    Width := ScaleX(90);
    Height := ScaleY(23);
    Color := clMenu;
    Font.Color := clBlack;
    Font.Size := 7;
    Font.Name := 'Arial';
    Font.Style := [fsBold];
    ParentFont := False;
    ReadOnly := True;
    HideSelection:=True;
    AutoSelect:=False;
    Text := ExpandConstant('{cm:vga}');
  end;

  { AudioField }
  AudioField := TNewEdit.Create(WizardForm);
  with AudioField do
  begin
    Parent := HWCP.Surface;
    Left := ScaleX(8);
    Top := ScaleY(80);
    Width := ScaleX(90);
    Height := ScaleY(23);
    Color := clMenu;
    Font.Color := clBlack;
    Font.Size := 7;
    Font.Name := 'Arial';
    Font.Style := [fsBold];
    ParentFont := False;
    ReadOnly := True;
    HideSelection:=True;
    AutoSelect:=False;
    Text := ExpandConstant('{cm:audio}');
  end;
  
  { MemoryField }
  MemoryField := TNewEdit.Create(WizardForm);
  with MemoryField do
  begin
    Parent := HWCP.Surface;
    Left := ScaleX(8);
    Top := ScaleY(112);
    Width := ScaleX(90);
    Height := ScaleY(23);
    Color := clMenu;
    Font.Color := clblack;
    Font.Size := 7;
    Font.Name := 'Arial';
    Font.Style := [fsBold];
    ParentFont := False;
    ReadOnly := True;
    HideSelection:=True;
    AutoSelect:=False;
    Text := ExpandConstant('{cm:pmem}');
  end;
  
  { OSField }
   OSField := TNewEdit.Create(WizardForm);
  with OSField do
  begin
    Parent := HWCP.Surface;
    Left := ScaleX(8);
    Top := ScaleY(144);
    Width := ScaleX(90);
    Height := ScaleY(23);
    Font.Color := clBlack;
    Font.Size := 7;
    Font.Name := 'Arial';
    Font.Style := [fsBold];
    ParentFont := False;
    ReadOnly := True;
    HideSelection:=True;
    AutoSelect:=False;
    Text := ExpandConstant('{cm:os}');
  end;

  { CpuDesField }
  CpuDesField := TNewEdit.Create(WizardForm);
  with CpuDesField do
  begin
    Parent := HWCP.Surface;
    Left := ScaleX(103);
    Top := ScaleY(16);
    Width := ScaleX(306);
    Height := ScaleY(23);
    Color := $3dfb37;
    Font.Color := clBlack;
    Font.Size := 8;
    Font.Name := 'Arial';
    ParentFont := False;
    ReadOnly := True;
    HideSelection:=True;
    AutoSelect:=False;
    Text := GetProcessorName;
  end;
  
  CpuFreq:=GetProcessorFreq
  if CpuFreq < {#CpuMHZ} then begin
   CpuDesField.Text:=CpuDesField.Text +' @'+inttostr(CpuFreq)+' MHZ';
   CpuDesField.Color:=$3d37fb
   end else begin
   CpuDesField.Text:=CpuDesField.Text +' @'+inttostr(CpuFreq)+' MHZ';
   CPUReq:=True;
   end;
   
  { VideoDesField }
  VideoDesField := TNewEdit.Create(WizardForm);
  with VideoDesField do
  begin
    Parent := HWCP.Surface;
    Left := ScaleX(103);
    Top := ScaleY(48);
    Width := ScaleX(306);
    Height := ScaleY(23);
    Color := $3dfb37;
    Font.Color := clBlack;
    Font.Size := 8;
    Font.Name := 'Arial';
    ParentFont := False;
    ReadOnly := True;
    HideSelection:=True;
    AutoSelect:=False;
    Text := GetVideoCardName;
  end;
  
  Pdm:=' ['+IntToStr(GetScreenWidth)+'x'+IntToStr(GetScreenHeight)+']';

  VideoRam:=GetVidMemLocal/1048576;
  if (VideoRam<63) or (VideoRam>1100) then vr:=VideoRam
  else if VideoRam<100 then vr:=64
  else if VideoRam<200 then vr:=128
  else if VideoRam<300 then vr:=256
  else if VideoRam<400 then vr:=384
  else if VideoRam<600 then vr:=512
  else if VideoRam<800 then vr:=792
  else if VideoRam>800 then vr:=1024;

  if VideoRam=0 then begin
    VideoDesField.Text:=ExpandConstant('{cm:NotDeviceDriver}')
    VideoDesField.Color:=$3d37fb;
  end
    else VideoDesField.Text:=VideoDesField.Text+'~'+IntToStr(vr)+' MB'+Pdm;
  if vr<{#VideoMem} then begin
    VideoDesField.Color:=$3d37fb;
  end
  else VideoReq:=True;

  { AudioDesField }
  AudioDesField := TNewEdit.Create(WizardForm);
  with AudioDesField do
  begin
    Parent := HWCP.Surface;
    Left := ScaleX(103);
    Top := ScaleY(80);
    Width := ScaleX(306);
    Height := ScaleY(23);
    Color := $3dfb37;
    Font.Color := clBlack;
    Font.Size := 8;
    Font.Name := 'Arial';
    ParentFont := False;
    ReadOnly := True;
    HideSelection:=True;
    AutoSelect:=False;
    Text := GetSoundCardName;
  end;

  if GetSoundCards = 0 then begin
  AudioDesField.Text:=ExpandConstant('{cm:NotDeviceDriver}')
  AudioDesField.Color:=$3d37fb;
  end else AudioReq:=True;

  {MemoryDesField }
 MemoryDesField := TNewEdit.Create(WizardForm);
  with MemoryDesField do
  begin
    Parent := HWCP.Surface;
    Left := ScaleX(103);
    Top := ScaleY(112);
    Width := ScaleX(306);
    Height := ScaleY(23);
    Color := $3dfb37;
    Font.Color := clBlack;
    Font.Size := 8;
    Font.Name := 'Arial';
    ParentFont := False;
    ReadOnly := True;
    HideSelection:=True;
    AutoSelect:=False;
    Text := '';
  end;
  
  PhyRam:=GetSystemPhys+1;
  if PhyRam < {#PhysicalRam} then begin
   MemoryDesField.Text:=IntToStr(PhyRam)+' MB';
   MemoryDesField.Color:=$3d37fb
   end else begin
   MemoryDesField.Text:=IntToStr(PhyRam)+' MB';
   PhyRamReq:=True;
   end;

  { OSDesField}
  OSDesField := TNewEdit.Create(WizardForm);
  with OSDesField do
  begin
    Parent := HWCP.Surface;
    Left := ScaleX(103);
    Top := ScaleY(144);
    Width := ScaleX(306);
    Height := ScaleY(23);
    Color := $3dfb37;
    Font.Color := clBlack;
    Font.Size := 8;
    Font.Name := 'Arial';
    ParentFont := False;
    ReadOnly := True;
    HideSelection:= True;
    AutoSelect:= False;
    Text := '';
  end;
  
 OSName:=GetWindowsName;
 if (Pos('Windows 7',OSName)<> 0) or (Pos('Windows Vista',OSName)<> 0) or (Pos('Windows XP',OSName)<> 0) then begin
    OSDesField.Text:= OSName;
    OSReq:=True;
    end else begin
    OSDesField.Text:= OSName;
    OSDesField.Color:= $3d37fb
 end;

end;

procedure InitializeWizard();

begin

with wizardform do begin
	
  BorderIcons := [];
  bgImage:=TBitmapImage.Create(MainForm);
  bgImage.Align:=alClient;
  bgImage.Stretch:=False;
  bgImage.Parent:=MainForm;
  bgImage.Center:=True;
  bgImage.BackColor:=$000000;
  AppNamelbl:=TNewStaticText.Create(WizardForm);
  AppNamelbl.Parent := WizardForm;
  AppNamelbl.Caption := '{#AppName}';
  AppNamelbl.Enabled := False;
  AppNamelbl.Left := ScaleX(5);
  AppNamelbl.Top := ScaleY(306);
  AppNamelbl.Width := ScaleX(70);
  AppNamelbl.Height := ScaleY(14);
  Bevel.left:=5;
  Bevel.width:=492;
  AboutButton := TNewButton.Create(Wizardform);
  AboutButton.Left := Wizardform.ClientWidth - CancelButton.Left - CancelButton.Width;
  AboutButton.Top := CancelButton.Top;
  AboutButton.Width := CancelButton.Width+18;
  AboutButton.Height := CancelButton.Height;
  AboutButton.Caption :=ExpandConstant('{cm:About}');
  AboutButton.OnClick := @AboutButtonOnClick;
  AboutButton.Parent :=Wizardform ;
  WizardSmallBitmapImage.visible:=true;
  WizardSmallBitmapImage.Width:=250;
  WizardSmallBitmapImage.Height:=58;
  WizardSmallBitmapImage.Left:=0;
  PageDescriptionLabel.Visible:=false;
  PageNameLabel.Width:=ClientWidth-PageNameLabel.left-250;
  PageNameLabel.Left:=ClientWidth-PageNameLabel.Width;
  
  #ifdef FreeArc
  with WizardForm.ProgressGauge do
  begin
        // Create a label to show current FileName being extracted
  lblExtractFileName:= TLabel.Create(WizardForm);
  lblExtractFileName.parent:=WizardForm.InstallingPage;
  lblExtractFileName.autosize:=false;
  lblExtractFileName.Width:= Width;
  lblExtractFileName.top:=Top + ScaleY(35);
  lblExtractFileName.Caption:= '';
  lblExtractFileName.Hide;

        // Create a label to show percentage
  ExtractFile:= TLabel.Create(WizardForm);
  ExtractFile.parent:=WizardForm.InstallingPage;
  ExtractFile.autosize:=false;
  ExtractFile.Width:= Width;
  ExtractFile.top:=14;
  ExtractFile.caption:= '';
  ExtractFile.Hide;
  end;
  #endif

  end;
  CreateHWCustomPage();
  SetWindowLong(MainForm.Handle,-16,$80000000);
  SplashScreen();

  
  //case GetScreenHeight of
   
  //  4/3 Resolutions
  //  600: Hres:=800;
  //  768: Hres:=1024;
  //  1024: HRes:=1280;
    
  //  else Hres:=1024

  //  end;

   for i:=0 to bgicount -1  do begin
   
     SetArrayLength(names,i+1);
     //names[i].name:='BGI'+IntToStr(i)+'_'+IntToStr(HRes)+'.bmp';
     names[i].name:='BGI'+IntToStr(i)+'.bmp';
     ExtractTemporaryFile(names[i].name);
     
   end;
   #ifdef InstallMusicLoop
   ExtractTemporaryFile('{#mp3filename}');
   #endif
   bgImage.bitmap.LoadFromFile(expandConstant('{tmp}\'+names[0].name));

end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin

if (CurPageID = HWCP.id) then begin
   if Videoreq and CPUReq and AudioReq and PhyRamReq and OSReq then Result:=True
   else begin
      if MsgBox(ExpandConstant('{cm:rlabel}')+#13#10+ExpandConstant('{cm:continue}'), mbConfirmation, MB_YESNO)=IDYES then Result:=True
      end
   end
 else Result:=True;
end;


Procedure DeInitializeSetup;

Begin
    KillTimer(0, Tid)
    #ifdef ISSkin
   	UnloadSkin();
   	#endif
end;

procedure InitializeUninstallProgressForm();

begin

with UninstallProgressForm do begin

  ClientWidth:= 497
  ClientHeight:= 145
  BorderIcons := [];
  PageNameLabel.Visible:=false;
  PageDescriptionLabel.Visible:=true;
  PageDescriptionLabel.Caption:=ExpandConstant('{cm:Uninstall,Lost Planet 2}');
  PageDescriptionLabel.Font.Name:='Arial';
  PageDescriptionLabel.Font.Size:=16;
  PageDescriptionLabel.Font.Style:=[fsBold];
  ProgressBar.Top := 33;
  ProgressBar.Left := (ClientWidth-ProgressBar.Width-5)div 2;
  ProgressBar.Width := 417;
  ProgressBar.Height := 15;

 end;
end;

function InitializeUninstall(): Boolean;
begin
#ifdef ISSkin
FileCopy(ExpandConstant('{app}\{#StylesName}'),ExpandConstant('{tmp}\{#StylesName}'),False);
FileCopy(ExpandConstant('{app}\ISSkin.dll'),ExpandConstant('{tmp}\ISSkin.dll'),False);
LoadSkin(ExpandConstant('{tmp}\{#StylesName}'), '{#StylesIniName}');
#endif
Result:=True;
end;

procedure DeinitializeUninstall();

begin
#ifdef ISSkin
UnloadSkin();
#endif
end;

function GetLngID(Param: String): String;

begin
case GetUILanguage of
    1033: Result:='1033'
    1040: Result:='1040'
    1031: Result:='1031'
    1036: Result:='1036'
    3082: Result:='1034'
    1041: Result:='1041'
    1042: Result:='1042'
    1045: Result:='1045'
    1049: Result:='1049'
    else  Result:='1033'  
    end;
end;

