
!include "MUI.nsh"

	; Name and file
	Name		"Great Little War Game"
	OutFile		"GLWG_Setup.exe"
	InstallDir	"$PROGRAMFILES\Great Little War Game"
  
	InstallDirRegKey HKCU "Software\Rubicon\GLWG" ""

	!define MUI_ABORTWARNING
	!insertmacro MUI_PAGE_LICENSE "eula_pc.txt"
	!insertmacro MUI_PAGE_DIRECTORY
	!insertmacro MUI_PAGE_INSTFILES
	!insertmacro MUI_UNPAGE_CONFIRM
	!insertmacro MUI_UNPAGE_INSTFILES
	!insertmacro MUI_LANGUAGE "English"


Section "Main Section" SecMain

	SetOutPath 	"$INSTDIR"
	
	; Game Files
	File		"..\GLWG.exe"
	File		"..\DataPC.zip"

	CreateDirectory	"$INSTDIR\Redist"
	SetOutPath 	"$INSTDIR\Redist"

	; DX Redist
	File		"Redist\APR2007_xinput_x86.cab"
	File		"Redist\DSETUP.dll"
	File		"Redist\dsetup32.dll"
	File		"Redist\dxdllreg_x86.cab"
	File		"Redist\DXSETUP.exe"
	File		"Redist\dxupdate.cab"
	File		"Redist\Jun2010_d3dx9_43_x86.cab"
	File		"Redist\Jun2010_XAudio_x86.cab"
	File		"Redist\Jun2010_D3DCompiler_43_x86.cab"

  
	WriteRegStr HKCU "Software\Rubicon\GLWG" "" $INSTDIR
  
	WriteUninstaller "$INSTDIR\Uninstall.exe"


	; Run the DX installer
	ExecWait "dxsetup.exe /silent"

	; Create shortcuts
	SetOutPath 	"$INSTDIR"
	CreateDirectory	"$SMPROGRAMS\GLWG"
	CreateShortCut	"$SMPROGRAMS\GLWG\Uninstall.lnk" "$INSTDIR\uninstall.exe"
	CreateShortCut	"$SMPROGRAMS\GLWG\Play GLWG.lnk" "$INSTDIR\GLWG.exe"
	CreateShortCut	"$DESKTOP\GLWG.lnk" "$INSTDIR\GLWG.exe"


SectionEnd

;--------------------------------
;Descriptions
;--------------------------------

	; Language strings
	LangString DESC_SecMain ${LANG_ENGLISH} "Main Section"

	; Assign language strings to sections
	!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
	!insertmacro MUI_FUNCTION_DESCRIPTION_END


;--------------------------------
;Uninstaller Section
;--------------------------------

Section "Uninstall"

	; Remove installed files/folders
	Delete		"$INSTDIR\Uninstall.exe"
	Delete		"$INSTDIR\GLWG.exe"
	Delete		"$INSTDIR\DataPC.zip"
	Delete		"$INSTDIR\ShaderCache\*.*"
	Delete		"$INSTDIR\Redist\*.*"
	Delete		"$INSTDIR\UnlockedItems.secret"

	RMDir		"$INSTDIR\ShaderCache"
	RMDir		"$INSTDIR\Redist"
	RMDir		"$INSTDIR"
	
	; Remove shortcuts
	Delete		"$DESKTOP\GLWG.lnk"
	Delete		"$SMPROGRAMS\GLWG\*.*"
	RMDir		"$SMPROGRAMS\GLWG"


	DeleteRegKey HKCU "Software\Rubicon\GLWG"

SectionEnd

