; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Zeniapp"
!define PRODUCT_VERSION "DO NOT DISTRIBUTE"
!define PRODUCT_PUBLISHER "Wolverine Soft"
!define ZENIPEX_LIBRARY "Zenipex Library"
!define PRODUCT_WEB_SITE "http://www.wolverinesoft.org/project.php?id=-1"
!define PUBLISHER_WEB_SITE "http://www.wolverinesoft.org/"
!define ZENIPEX_LIBRARY_WEB_SITE "http://zenilib.sourceforge.net/"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\Wolverine Soft\${PRODUCT_NAME}\zeniapp.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

SetCompressor lzma

; MUI 1.67 compatible ------
!include "MUI.nsh"
!include "FontReg.nsh"
!include "FontName.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "icon.ico"
!define MUI_UNICON "icon.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "license.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Run ${PRODUCT_NAME}"
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchZeniapp"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

Function LaunchZeniapp
  ExecShell "" "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk"
FunctionEnd

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "${PRODUCT_NAME} Setup ${PRODUCT_VERSION}.exe"
InstallDir "$PROGRAMFILES\Wolverine Soft\${PRODUCT_NAME}"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show

Section "MainSection" SEC01

  SetOutPath "$INSTDIR\config"
;Configuration Files
  File "zenilib\config\sounds.txt"
  File "zenilib\config\colors.txt"
  File "zenilib\config\fonts.txt"
  File "zenilib\config\textures.txt"

  SetOutPath "$INSTDIR\fonts"
;TTF Fonts for OpenGL
  File "zenilib\fonts\Arial.ttf"

  SetOutPath "$INSTDIR\icons"
;Icons
  File "zenilib\icons\icon.gif"

  SetOutPath "$INSTDIR\redist"
;Redists
  SetOutPath "$INSTDIR\redist\directx_9"
  File "zenilib\redist\directx_9\dsetup32.dll"
  File "zenilib\redist\directx_9\DSETUP.dll"
  File "zenilib\redist\directx_9\dxdllreg_x86.cab"
  File "zenilib\redist\directx_9\dxnt.cab"
  File "zenilib\redist\directx_9\DXSETUP.exe"
  File "zenilib\redist\directx_9\dxupdate.cab"
  File "zenilib\redist\directx_9\JUN2007_d3dx9_34_x86.cab"
  SetOutPath "$INSTDIR\redist\openal_11"
  File "zenilib\redist\openal_11\oalinst.exe"
  SetOutPath "$INSTDIR\redist\visualc_sp1"
  File "zenilib\redist\visualc_sp1\VCREDIST_X86.EXE"

  SetOutPath "$INSTDIR"
;DLLs
  File "zenilib\alut.dll"
  File "zenilib\jpeg.dll"
  File "zenilib\lib3ds_dll.dll"
  File "zenilib\libpng12.dll"
  File "zenilib\libtiff.dll"
  File "zenilib\ogg.dll"
  File "zenilib\SDL.dll"
  File "zenilib\SDL_gfx.dll"
  File "zenilib\SDL_image.dll"
  File "zenilib\SDL_net.dll"
  File "zenilib\SDL_ttf.dll"
  File "zenilib\vorbis.dll"
  File "zenilib\vorbisfile.dll"
  File "zenilib\wrap_oal.dll"
  File "zenilib\zlib1.dll"
;Executable
  File "zenilib\zeniapp.exe"
;INI
  File "zenilib\zeniapp.ini"

SectionEnd

Section -Redist
  ExecWait '"$INSTDIR\redist\visualc_sp1\vcredist_x86.exe" /q:a /c:"msiexec /i vcredist.msi /qn"'
  ExecWait '"$INSTDIR\redist\directx_9\DXSETUP.exe" /silent'
  ExecWait '"$INSTDIR\redist\openal_11\oalinst.exe" /silent'
SectionEnd

Section -Icons

;Link to Start Menu

  CreateDirectory "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}"
  CreateShortCut "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\zeniapp.exe"

;Link to Desktop

  CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\zeniapp.exe"

;Link to Website

  SetOutPath $INSTDIR
  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
  CreateShortCut "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}\${PRODUCT_NAME} Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"

  SetOutPath $INSTDIR
  WriteIniStr "$INSTDIR\${PRODUCT_PUBLISHER}.url" "InternetShortcut" "URL" "${PUBLISHER_WEB_SITE}"
  CreateShortCut "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}\${PRODUCT_PUBLISHER}.lnk" "$INSTDIR\${PRODUCT_PUBLISHER}.url"

  SetOutPath $INSTDIR
  WriteIniStr "$INSTDIR\${ZENIPEX_LIBRARY}.url" "InternetShortcut" "URL" "${ZENIPEX_LIBRARY_WEB_SITE}"
  CreateShortCut "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}\${ZENIPEX_LIBRARY}.lnk" "$INSTDIR\${ZENIPEX_LIBRARY}.url"

;Uninstaller

  CreateShortCut "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\uninst.exe"

SectionEnd

Section "Fonts"
  StrCpy $FONT_DIR $FONTS

  !insertmacro InstallTTFFont 'ARIAL.TTF'

  SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=5000
SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\uninst.exe"
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\zeniapp.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\zeniapp.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd

Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd

Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
  Abort
FunctionEnd

Section Uninstall
;Temp Files
  Delete "$INSTDIR\stderr.txt"
  Delete "$INSTDIR\stdout.txt"

;Links
  Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
  Delete "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}\Uninstall.lnk"
  Delete "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk"
  Delete "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}\${PRODUCT_NAME} Website.lnk"
  Delete "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}\${PRODUCT_PUBLISHER}.lnk"
  Delete "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}\${ZENIPEX_LIBRARY}.lnk"
  RMDir "$SMPROGRAMS\Wolverine Soft\${PRODUCT_NAME}"
  RMDir "$SMPROGRAMS\Wolverine Soft"

;Additional Items
  Delete "$INSTDIR\${PRODUCT_NAME}.url"
  Delete "$INSTDIR\${PRODUCT_PUBLISHER}.url"
  Delete "$INSTDIR\${ZENIPEX_LIBRARY}.url"
  Delete "$INSTDIR\uninst.exe"

;Configuration Files
  Delete "$INSTDIR\config\textures.txt"
  Delete "$INSTDIR\config\fonts.txt"
  Delete "$INSTDIR\config\colors.txt"
  Delete "$INSTDIR\config\sounds.txt"
  RMDir "$INSTDIR\config"

;Icons
  Delete "$INSTDIR\icons\icon.gif"
  RMDir "$INSTDIR\icons"

;TTF Fonts for OpenGL
  Delete "$INSTDIR\fonts\Arial.ttf"
  RMDir "$INSTDIR\fonts"

;Redists
  Delete "$INSTDIR\redist\directx_9\dsetup32.dll"
  Delete "$INSTDIR\redist\directx_9\DSETUP.dll"
  Delete "$INSTDIR\redist\directx_9\dxdllreg_x86.cab"
  Delete "$INSTDIR\redist\directx_9\dxnt.cab"
  Delete "$INSTDIR\redist\directx_9\DXSETUP.exe"
  Delete "$INSTDIR\redist\directx_9\dxupdate.cab"
  Delete "$INSTDIR\redist\directx_9\JUN2007_d3dx9_34_x86.cab"
  Delete "$INSTDIR\redist\openal_11\oalinst.exe"
  Delete "$INSTDIR\redist\visualc_sp1\VCREDIST_X86.EXE"
  RMDir "$INSTDIR\redist\openal_11"
  RMDir "$INSTDIR\redist\directx_9"
  RMDir "$INSTDIR\redist\visualc_sp1"
  RMDir "$INSTDIR\redist"

;DLLs
  Delete "$INSTDIR\alut.dll"
  Delete "$INSTDIR\jpeg.dll"
  Delete "$INSTDIR\lib3ds_dll.dll"
  Delete "$INSTDIR\libpng12.dll"
  Delete "$INSTDIR\libtiff.dll"
  Delete "$INSTDIR\ogg.dll"
  Delete "$INSTDIR\SDL.dll"
  Delete "$INSTDIR\SDL_gfx.dll"
  Delete "$INSTDIR\SDL_image.dll"
  Delete "$INSTDIR\SDL_net.dll"
  Delete "$INSTDIR\SDL_ttf.dll"
  Delete "$INSTDIR\vorbis.dll"
  Delete "$INSTDIR\vorbisfile.dll"
  Delete "$INSTDIR\wrap_oal.dll"
  Delete "$INSTDIR\zlib1.dll"
;Executable
  Delete "$INSTDIR\zeniapp.exe"
;INI
  Delete "$INSTDIR\zeniapp.ini"
  RMDir "$INSTDIR"
  RMDir "$PROGRAMFILES\Wolverine Soft"

;Registry Keys
  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  SetAutoClose true
SectionEnd
