!define MUI_PRODUCT ""
!define MUI_VERSION ""

!include "MUI.nsh"
!include WinMessages.nsh

;--------------------------------
;Configuration

  ;General
  OutFile "test.exe"

  ;Folder selection page
  InstallDir "$PROGRAMFILES\test\"
  
;--------------------------------
;Modern UI Configuration

  !insertmacro MUI_PAGE_WELCOME
  
  !define MUI_LICENSEPAGE_CHECKBOX
  Page license "" "showLicense" "leaveLicense"
  Page license "" "showLicense" "leaveLicense"
    
  !insertmacro MUI_PAGE_COMPONENTS
    !define MUI_COMPONENTSPAGE_SMALLDESC

  !insertmacro MUI_PAGE_INSTFILES

  !insertmacro MUI_PAGE_FINISH
    !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED "$INSTDIR\readme.txt"
  
  !define MUI_ABORTWARNING

  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------
;Languages

  !insertmacro MUI_LANGUAGE "German"
  
;--------------------------------
;Data
  LicenseText "." ;!!!!!!!!!!!!!!!!!!!!!!!!!
  LicenseData "license.txt"
  
;--------------------------------
;Reserve Files

  ;Things that need to be extracted on first (keep these lines before any File command!)
  ;Only useful for BZIP2 compression
  ;!insertmacro MUI_RESERVEFILE_WELCOMEFINISHPAGE
  ReserveFile "readme.txt"

;--------------------------------
;Language Strings

  ;Description

;--------------------------------
;Installer Sections

Section -post
  StrCpy $INSTDIR $INSTDIR\Plugins
  StrCpy $R0 "0"
SectionEnd

SubSection "Gewünschte Plug-Ins auswählen" SecInfo0

SubSectionEnd

;--------------------------------
;Descriptions

!insertmacro MUI_FUNCTIONS_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SecInfo0} "Wählen Sie die gewünschten Plug-Ins aus. Der Maus- zeiger über eine Komponente zeigt die Beschreibung."
!insertmacro MUI_FUNCTIONS_DESCRIPTION_END

;--------------------------------
;Installer Functions

Function .onInit 
  InitPluginsDir 
  File /oname=$PLUGINSDIR\readme.txt "readme.txt" 
FunctionEnd 

Function showLicense
  !insertmacro MUI_INNERDIALOG_TEXT 1006 "Press PAGE DOWN to see the rest of the agreement."
  !insertmacro MUI_INNERDIALOG_TEXT 1040 "If you accept the terms of the agreement click I Agree to continue. You must accept the agreement to install ${MUI_PRODUCT}."
  !insertmacro MUI_HEADER_TEXT "License Agreement" "Please review the license terms before installing."
  StrCmp $R9 1 0 skip
    FindWindow $0 "#32770" "" $HWNDPARENT
    GetDlgItem $0 $0 1000

    SendMessage $0 ${WM_SETTEXT} 0 "STR:"
    FileOpen $1 "$PLUGINSDIR\readme.txt" "r"
    loop:
      FileRead $1 $2
      SendMessage $0 0x00C2 0 "STR:$2"
      IfErrors 0 loop
    FileClose $1
    SendMessage $0 0x00B1 0 0
    SendMessage $0 0x00B7 0 0

  skip:
    StrCpy $R9 0
FunctionEnd

Function leaveLicense
  StrCpy $R9 1
FunctionEnd

Section ""
  DetailPrint "."
SectionEnd

;--------------------------------
;Uninstaller Section

Section "Uninstall"

  ;Display the Finish header
  !insertmacro MUI_UNFINISHHEADER

SectionEnd

;--------------------------------
