!include "MUI.nsh"
!include "LogicLib.nsh"

Name "Audiobook Maker"
OutFile "Audiobook Maker Installation.exe"

!define INSTALLATIONNAME "Audiobook Maker"
!define thisPath "C:\Documents and Settings\Kim\Desktop\Java\Audiobook Maker\exec"

InstallDir "$PROGRAMFILES\Audiobook Maker"

!define MUI_PAGE_HEADER_TEXT "Changelog"
!define MUI_PAGE_HEADER_SUBTEXT "Audiobook Maker 2.8 Beta Changelog"
!define MUI_LICENSEPAGE_TEXT_TOP "Audiobook Maker 2.8 Beta Changelog"
!define MUI_LICENSEPAGE_TEXT_BOTTOM "Klicken Sie auf Weiter um mit der Installation fortzufahren"
!define MUI_LICENSEPAGE_BUTTON "Weiter"
!insertmacro MUI_PAGE_LICENSE "changelog.rtf"

!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!define MUI_FINISHPAGE_RUN "$INSTDIR\Audiobook Maker.exe"
!define MUI_FINISHPAGE_RUN_TEXT "Audiobook Maker starten"
!define MUI_FINISHPAGE_SHOWREADME "${thisPath}\Readme\Readme+Guide.html"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Readme zeigen"
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "German"

Section ""
        SetOutPath $INSTDIR
        File "${thisPath}\Audiobook Maker.exe"
        File "${thisPath}\Audiobook Maker.jar"
        SetOutPath "$INSTDIR\lib"
        File "${thisPath}\lib\"
        WriteUninstaller $INSTDIR\Uninstall.exe
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "DisplayName" "Forth Installer"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "UninstallString" '"$INSTDIR\uninstall.exe"'
        WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "NoModify" 1
        WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "NoRepair" 1
        SetOutPath $INSTDIR
SectionEnd

Section "Profile" Profile
        SetOutPath "$INSTDIR\Profile\"
        File "${thisPath}\Profile\"
        SetOutPath $INSTDIR
SectionEnd

Section "Start Menu Eintrag" Start
        CreateDirectory "$SMPROGRAMS\${INSTALLATIONNAME}"
        CreateShortCut "$SMPROGRAMS\${INSTALLATIONNAME}\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
        CreateShortCut "$SMPROGRAMS\${INSTALLATIONNAME}\Audiobook Maker.lnk" "$INSTDIR\Audiobook Maker.exe"
        SetOutPath $INSTDIR
SectionEnd

Section "Desktopverknüpfung" Desktop
        SetOutPath "$INSTDIR"
        CreateShortcut "$DESKTOP\Audiobook Maker.lnk" "$INSTDIR\Audiobook Maker.exe"
        SetOutPath $INSTDIR
SectionEnd

Section "Zusätzliche Dateien" addFiles
        SetOutPath $INSTDIR
        File "${thisPath}\changelog.txt"
        SetOutPath "$INSTDIR\Readme\"
        File "${thisPath}\Readme\"
        SetOutPath $INSTDIR
SectionEnd

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
             !insertmacro MUI_DESCRIPTION_TEXT ${Profile} "Installiert die Standard Profile"
             !insertmacro MUI_DESCRIPTION_TEXT ${Start} "Erstellt einen Ordner im Startmenu"
             !insertmacro MUI_DESCRIPTION_TEXT ${Desktop} "Verknüpfung auf Desktop erstellen"
             !insertmacro MUI_DESCRIPTION_TEXT ${addFiles} "Zusätzliche Dateien Extrahieren: Readme und changelog"
!insertmacro MUI_FUNCTION_DESCRIPTION_END

Section "Uninstall"
        DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}"
        RMDir /r "$INSTDIR\lib\"
        RMDir /r "$INSTDIR\Profile\"
        RMDir /r "$INSTDIR\Readme\"
        RMDir /r "$INSTDIR\"
        RMDir /r "$SMPROGRAMS\${INSTALLATIONNAME}\"
        Delete "$DESKTOP\Audiobook Maker.lnk"
SectionEnd