!include "MUI2.nsh"
!include "WinVer.nsh"

; Constants
!define PRODUCT_NAME "Boiii Application"
!define PRODUCT_DESCRIPTION "Boiii Application Description"
!define COPYRIGHT "Copyright © 2023 Your Company"
!define PRODUCT_VERSION "1.0.0.0"
!define SETUP_VERSION "1.0.0.0"

; Attributes
Name "${PRODUCT_NAME}"
OutFile "BoiiiInstaller.exe"
InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
RequestExecutionLevel user ; Request user-level execution, not admin

; Version Info
VIProductVersion "${PRODUCT_VERSION}"
VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
VIAddVersionKey "FileDescription" "${PRODUCT_DESCRIPTION}"
VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
VIAddVersionKey "FileVersion" "${SETUP_VERSION}"

; Modern UI Appearance
!define MUI_ICON "Contrib\Graphics\Icons\modern-install.ico"
!define MUI_HEADERIMAGE
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_RUN "$INSTDIR\boiii.exe"
!define MUI_FINISHPAGE_LINK "Create a desktop shortcut"
!define MUI_FINISHPAGE_TEXT "Setup has finished installing ${PRODUCT_NAME} on your computer.$\n$\nClick Finish to close this wizard."

; Modern UI Settings
!define MUI_ABORTWARNING
!define MUI_UNABORTWARNING

; Pages
!insertmacro MUI_PAGE_WELCOME
;!insertmacro MUI_PAGE_LICENSE "Readme.txt"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

; Languages
!insertmacro MUI_LANGUAGE "English"

; Sections
Section "Main Application" SecMain
    SetOutPath $INSTDIR
    File "boiii.exe"
    WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd

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

Section "Create Desktop Shortcut" SEC_SHORTCUT
    CreateShortcut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\boiii.exe"
SectionEnd

; Uninstaller Sections
Section "Uninstall"
    Delete $INSTDIR\boiii.exe
    Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
    RMDir /r $LOCALAPPDATA\boiii
    Delete "$INSTDIR\Uninstall.exe"
    RMDir $INSTDIR
SectionEnd

; Functions
Function .onInit
    ; Set default installation directory
    WriteRegStr HKCU "Software\${PRODUCT_NAME}" "" $INSTDIR
FunctionEnd

Function .onInstSuccess
    ; No custom actions needed here for now
FunctionEnd

; Custom finish page actions (currently empty, can be customized if needed)
Function MyFinishPage
FunctionEnd