!include "MUI2.nsh"
!include "nsDialogs.nsh"

Name "Boiii Application"
OutFile "BoiiiInstaller.exe"
InstallDir $DESKTOP\BoiiiApp
ShowInstDetails show
ShowUnInstDetails show

Var CreateShortcutCheckbox
Var CreateShortcut

Page directory
Page custom nsDialogsPage
Page instfiles

Function nsDialogsPage
    nsDialogs::Create 1018
    Pop $0

    ${If} $0 == error
        Abort
    ${EndIf}

    ${NSD_CreateCheckbox} 0 0 100% 10u "Create a desktop shortcut"
    Pop $CreateShortcutCheckbox
    nsDialogs::Show
FunctionEnd

Function .onInit
    StrCpy $CreateShortcut 0 ; Initialize as unchecked
FunctionEnd

Function nsDialogsLeave
    ${NSD_GetState} $CreateShortcutCheckbox $0
    StrCpy $CreateShortcut $0 ; Store the state of the checkbox
FunctionEnd

Section "Main Application" SecMain
    SetOutPath $INSTDIR
    File "boiii.exe"
SectionEnd

Section "LocalAppData Files" SecData
    SetOutPath $LOCALAPPDATA\boiii
    File /r "boiii\*.*"
SectionEnd

Section "Create Desktop Shortcut" SecShort
    ${If} $CreateShortcut == ${BST_CHECKED}
        SetOutPath $DESKTOP
        CreateShortcut "Boiii.lnk" "$INSTDIR\boiii.exe"
    ${EndIf}
SectionEnd

Section "Uninstall"
    Delete $INSTDIR\boiii.exe
    IfFileExists $DESKTOP\Boiii.lnk 0 +2
        Delete $DESKTOP\Boiii.lnk
    RMDir /r $LOCALAPPDATA\boiii
    RMDir $INSTDIR
SectionEnd

!insertmacro MUI_LANGUAGE "English"
