; liquidwar.nsi
;
; This script is based on example2.nsi

;--------------------------------

; The name of the installer
Name "Liquid War @VERSION@"

; The file to write
OutFile "lw@VERSION_COMPACT@.exe"

; The default installation directory
InstallDir "$PROGRAMFILES\Liquid War"

; Registry key to check for directory (so if you install again, it will 
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\Liquid_War_5" "Install_Dir"

;--------------------------------

; Pages

Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

; The stuff to install
Section "Liquid War (required)"

  SectionIn RO
  
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR

  ; Put file there
  File "lwwin.exe"
  File "lwwinmap.exe"
  File "lwwinsrv.exe"
  File "alleg42.dll"
  File "changes.txt"
  File "license.txt"
  File "readme.txt"
  File "readmede.txt"
  File "readmedk.txt"
  File "readmefr.txt"
  File /r "custom"
  File /r "data"
  File /r "doc"
  File /r "misc"
  
  ; Write the installation path into the registry
  WriteRegStr HKLM "SOFTWARE\Liquid_War_5" "Install_Dir" "$INSTDIR"
  
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Liquid_War_5" "DisplayName" "Liquid War @VERSION@"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Liquid_War_5" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Liquid_War_5" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Liquid_War_5" "NoRepair" 1
  WriteUninstaller "uninstall.exe"
  
SectionEnd

; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"

  CreateDirectory "$SMPROGRAMS\Liquid War"
  CreateShortCut "$SMPROGRAMS\Liquid War\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\Liquid War\Liquid War.lnk" "$INSTDIR\lwwin.exe" "" "$INSTDIR\lwwin.exe" 0
  CreateShortCut "$SMPROGRAMS\Liquid War\Liquid War server.lnk" "$INSTDIR\lwwinsrv.exe" "" "$INSTDIR\lwwinsrv.exe" 0
  CreateShortCut "$SMPROGRAMS\Liquid War\Documentation.lnk" "$INSTDIR\doc\html\index.html" "" "$INSTDIR\doc\html\index.html" 0
  
SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"
  
  ; Remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Liquid_War_5"
  DeleteRegKey HKLM "SOFTWARE\Liquid_War_5"

  ; Remove files and uninstaller
  Delete "$INSTDIR\*.exe"
  Delete "$INSTDIR\*.dll"
  Delete "$INSTDIR\*.txt"
  Delete "$INSTDIR\custom\map\*.*"
  Delete "$INSTDIR\custom\music\*.*"
  Delete "$INSTDIR\custom\texture\*.*"
  Delete "$INSTDIR\data\*.*"
  Delete "$INSTDIR\doc\html\*.*"
  Delete "$INSTDIR\doc\pdf\*.*"
  Delete "$INSTDIR\doc\txt\*.*"
  Delete "$INSTDIR\misc\*.*"

  ; Remove shortcuts, if any
  Delete "$SMPROGRAMS\Liquid War\*.*"

  ; Remove directories used
  RMDir "$INSTDIR\custom\map"
  RMDir "$INSTDIR\custom\music"
  RMDir "$INSTDIR\custom\texture"
  RMDir "$INSTDIR\custom"
  RMDir "$INSTDIR\data"
  RMDir "$INSTDIR\doc\html"
  RMDir "$INSTDIR\doc\pdf"
  RMDir "$INSTDIR\doc\txt"
  RMDir "$INSTDIR\doc"
  RMDir "$INSTDIR\misc"
  RMDir "$INSTDIR"

  RMDir "$SMPROGRAMS\Liquid War"

SectionEnd
