;NSIS Modern User Interface version 1.70
;Basic Example Script
;Written by Joost Verburg

!define PRODUCT "qfusion"
!define VERSION "r7"
!define BASE_FOLDER "baseqf"
!define APPLICATION_FOLDER "Quake3 III Arena"

;--------------------------------
;Include Modern UI

  !include "MUI.nsh"

;--------------------------------
;General

  ;LZMA compression
  SetCompressor lzma

  ;Name and file
  Name "${PRODUCT} ${VERSION}"
  OutFile "${PRODUCT}${VERSION}.exe"

  ;Default installation folder
  InstallDir "$PROGRAMFILES\${APPLICATION_FOLDER}"
  
  ;Get installation folder from registry if available
  InstallDirRegKey HKCU "Software\${PRODUCT}" ""

;--------------------------------
;Interface Settings

  !define MUI_ABORTWARNING

;--------------------------------
;Pages

  !insertmacro MUI_PAGE_LICENSE ".\gnu.txt"
  !insertmacro MUI_PAGE_DIRECTORY
  !insertmacro MUI_PAGE_INSTFILES
  
  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES
  
;--------------------------------
;Languages
 
  !insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections

Section "${PRODUCT}" SecCopyUI

  SetOutPath "$INSTDIR"
  
  File ".\source\release\qfusion.exe"
  File ".\source\release\qfds.exe"

  SetOutPath "$INSTDIR\${BASE_FOLDER}"
  File ".\base.pk3"
  File ".\rotmirror5.pk3"
  File ".\source\release\cgame_x86.dll"
  File ".\source\release\game_x86.dll"
  File ".\source\release\ui_x86.dll"

  SetOutPath "$INSTDIR\${BASE_FOLDER}\doc"
  File ".\doc\readme.txt"
  File ".\doc\moving mirrors and portals.txt"
  File ".\doc\Shader Manual.rtf"

  ;Store install folder
  WriteRegStr HKCU "Software\${PRODUCT}" "" $INSTDIR
  
  ;Create uninstaller
  WriteUninstaller "$INSTDIR\${PRODUCT} uninstall.exe"

SectionEnd

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

Section "Uninstall"

  ;ADD YOUR OWN FILES HERE...
  Delete "$INSTDIR\qfusion.exe"
  Delete "$INSTDIR\qfds.exe"

  Delete "$INSTDIR\${BASE_FOLDER}\base.pk3"
  Delete "$INSTDIR\${BASE_FOLDER}\rotmirror5.pk3"
  Delete "$INSTDIR\${BASE_FOLDER}\cgame_x86.dll"
  Delete "$INSTDIR\${BASE_FOLDER}\game_x86.dll"
  Delete "$INSTDIR\${BASE_FOLDER}\ui_x86.dll"
 
  Delete "$INSTDIR\doc\readme.txt"
  Delete "$INSTDIR\${BASE_FOLDER}\doc\moving mirrors and portals.txt"
  Delete "$INSTDIR\${BASE_FOLDER}\doc\Shader Manual.rtf"

  Delete "$INSTDIR\${PRODUCT} uninstall.exe"

  RMDir "$INSTDIR\${BASE_FOLDER}\doc"
  RMDir "$INSTDIR\${BASE_FOLDER}"

  DeleteRegKey /ifempty HKCU "Software\${PRODUCT}"

SectionEnd