; Script generated by the HM NIS Edit Script Wizard.

; Installationsverzeichnis
;INSTDIR
; aktuelles Ausgabeverzeichnis
;OUTDIR
; Sprache
;LANGUAGE

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "FreeDoko"
!define PRODUCT_VERSION "0.6.9"
!define PRODUCT_AUTHORS "Borg Enders und Diether Knof"
!define PRODUCT_PUBLISHER "${PRODUCT_AUTHORS}"
!define PRODUCT_WEB_SITE "http://free-doko.sourceforge.net/"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\FreeDoko.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"

!define INSTALL_DIR "$PROGRAMFILES\FreeDoko"

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "${PRODUCT_NAME}_${PRODUCT_VERSION}.Setup.exe"
InstallDir ${INSTALL_DIR}
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show


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

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

; Welcome page
!define MUI_WELCOMEPAGE_TITLE "Willkommen bei der Installation von ${PRODUCT_NAME}, Version ${PRODUCT_VERSION}"
!define MUI_WELCOMEPAGE_TEXT \
  "FreeDoko ist eine freie Implementierung des Kartenspiels 'Doppelkopf', programmiert von ${PRODUCT_AUTHORS}.\r\n\
  \r\n\
  Das Programm wird unter '${INSTALL_DIR}' installiert, dort befindet sich auch die Dokumentation.\r\n\
  \r\n\
  Die Internetseite von ${PRODUCT_NAME} lautet ${PRODUCT_WEB_SITE}\r\n\
  \r\n\
  Besonderen Dank gilt noch der Firma Altenburg, die uns bis Ende 2006 erlaubt hat, ihre Kartensätze in FreeDoko zu nutzen."

!insertmacro MUI_PAGE_WELCOME

; License page
;!insertmacro MUI_PAGE_LICENSE "FreeDoko_0.6.8\COPYING"
; Directory page
;!insertmacro MUI_PAGE_DIRECTORY
; Start menu page
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "FreeDoko"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
;!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\FreeDoko.bat"
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\LIESMICH"
;!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "German"

; MUI end ------

Function .onInit
  ;!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

var ICONS_GROUP
Section "Hauptgruppe" SEC01
  SetOutPath "$INSTDIR"
  SetOverwrite try
  File /r "${PRODUCT_NAME}_${PRODUCT_VERSION}\*"


  ; Shortcuts
  StrCpy $ICONS_GROUP ${PRODUCT_NAME}
  CreateShortCut "$DESKTOP\FreeDoko.lnk" "$INSTDIR\FreeDoko.bat" "" "$INSTDIR\FreeDoko.ico"

  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\FreeDoko.lnk" "$INSTDIR\FreeDoko.bat" "" "$INSTDIR\FreeDoko.ico"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\uninstall.lnk" "$INSTDIR\uninst.exe"
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\doc"
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\doc\de"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\doc\de\Handbuch.lnk" "$INSTDIR\doc\manual\de\overview.html"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\doc\de\Regeln.lnk" "$INSTDIR\doc\manual\de\rules.html"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\doc\de\Einführung.lnk" "$INSTDIR\doc\de\Einfuehrung.txt"
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\doc\en"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\doc\en\manual.lnk" "$INSTDIR\doc\manual\en\overview.html"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\doc\en\rules.lnk" "$INSTDIR\doc\manual\en\rules.html"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\doc\en\introduction.lnk" "$INSTDIR\doc\en\introduction.txt"
SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\uninst.exe"
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\FreeDoko.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\FreeDoko.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}"

  WriteRegStr HKLM "Software\${PRODUCT_NAME}" "Version" "${PRODUCT_VERSION}"
  WriteRegStr HKLM "Software\${PRODUCT_NAME}" "Directory" "$INSTDIR"
  WriteRegStr HKLM "Software\${PRODUCT_NAME}" "Help Directory" "$INSTDIR\doc\manual"
SectionEnd


Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) wurde erfolgreich deinstalliert."
FunctionEnd

Function un.onInit
  !insertmacro MUI_UNGETLANGUAGE
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Möchten Sie $(^Name) und alle seinen Komponenten deinstallieren?" IDYES +2
  Abort
FunctionEnd

Section Uninstall
;!insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP

  RMDir /r "$INSTDIR"
  RMDir /r "$SMPROGRAMS\$ICONS_GROUP"
  Delete "$DESKTOP\FreeDoko.lnk"


  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  DeleteRegKey HKLM "Software\${PRODUCT_NAME}"
  SetAutoClose true
SectionEnd
