param(
    [string] $Temp,
    [string] $Shared,
    [string] $Max2017Path,
    [string] $Max2018Path,
    [string] $Max2019Path,
    [string] $Max2020Path,
    [string] $Max2021Path,
    [switch] $User,
    [switch] $Quiet
)

$simplygonMajorVersion = 9
$defaultTempValue = "%LOCALAPPDATA%\Temp\Simplygon"
$defaultSharedValue = "%USERPROFILE%\Documents\Simplygon\$simplygonMajorVersion"
$simplygonPathVar = "SIMPLYGON_$($simplygonMajorVersion)_PATH"
$simplygonTempVar = "SIMPLYGON_$($simplygonMajorVersion)_TEMP"
$simplygonSharedVar = "SIMPLYGON_$($simplygonMajorVersion)_SHARED"

function Set-EnvVar() {
    param(
        [Parameter(Mandatory=$true)]
        [string] $VariableName,
        [Parameter(Mandatory=$true)]
        [string] $VariableValue,
        [switch] $User,
        [switch] $Quiet
    )
    $environmentTarget = "[EnvironmentVariableTarget]::Machine"
    if ($User) {
        $environmentTarget = "[EnvironmentVariableTarget]::User"
    }
    $command = "[System.Environment]::SetEnvironmentVariable('$VariableName', '$VariableValue', $environmentTarget)"
    if (!$User -and !([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
        if ($Quiet) {
            "!! Error: failed to set machine-wide environment variable, user is not Administrator"
            ""
            exit -100
        }
        Start-Process powershell.exe "-Command `"$command`"" -Verb RunAs -Wait
    } else {
        Invoke-Expression $command
    }
    Set-Item -Path Env:$VariableName -Value $VariableValue
}

function Find-BlenderInstalls() {
    $sitePackages = @()

    try {
        (Get-Item HKLM:\Software\Microsoft\Windows\CurrentVersion\Installer\Folders).GetValueNames() | ForEach-Object {
            if ($_.EndsWith("site-packages\") -and $_.Contains("Blender")) {
                $sitePackages += $_
            }
        }
        $toRemove = @();
        $sitePackages | ForEach-Object {
            $_ -match ".*\\(\d)\.(\d+)\\.*" | Out-Null
            if ($Matches.Length -eq 0) {
                $toRemove += $_
            } else {
                $major = 0
                $minor = 0
                [int]::TryParse($Matches[1], [ref] $major) | Out-Null
                [int]::TryParse($Matches[2], [ref] $minor) | Out-Null
                if ($major -lt 2) {
                    $toRemove += $_
                } elseif ($major -gt 2) {
                    $toRemove += $_
                } else {
                    if ($minor -lt 80) {
                        $toRemove += $_
                    }
                }
            }
        }
        $toRemove | ForEach-Object {
            $sitePackages.Remove($_)
        }
    } catch {}

    $sitePackages
}

function InstallPythonModule() {
    param(
        [Parameter(Mandatory=$true)]
        [string] $LoaderSourceDirectory,
        [Parameter(Mandatory=$true)]
        [string] $SitePackagePath,
        [Parameter(Mandatory=$true)]
        [string] $DirectoryName,
        [switch] $Quiet
    )

    "   - $SitePackagePath"
    $loaderFileSource = "$LoaderSourceDirectory\simplygon_loader.py"
    if ($DirectoryName -eq "Python27" -or $DirectoryName -eq "Python36") {
        $loaderFileSource = "$LoaderSourceDirectory\simplygon_loader_no_type_hints.py"
    }
    $apiFileSources = (Get-ChildItem -Path "$pythonSourceDir" "Simplygon.py" -Recurse)
    $apiFileSources | ForEach-Object {
        $majorMinor = $_.Directory.Name.Substring(0, 10).Replace("-", "").Replace(".", "")
        $builtWithVS2015 = $_.Directory.Name.Contains("vs2015")
        if ($majorMinor -eq $DirectoryName -and ($majorMinor -eq "Python27" -or !$builtWithVS2015)) {
            mkdir "$SitePackagePath" -Force | Out-Null
            Copy-Item -Path "$loaderFileSource" -Destination "$SitePackagePath\simplygon_loader.py" -Force
            New-Item -Path "$SitePackagePath\__init__.py" -Force | Out-Null
            Copy-Item -Path $_.FullName -Destination "$SitePackagePath" -Force
            return
        } elseif ($majorMinor -eq "Python37" -and $builtWithVS2015 -eq $true -and $DirectoryName -eq "blender") {
            $commands = @(
                "mkdir '$SitePackagePath' -Force | Out-Null",
                "Copy-Item -Path '$loaderFileSource' -Destination '$SitePackagePath\simplygon_loader.py' -Force",
                "New-Item -Path '$SitePackagePath\__init__.py' -Force | Out-Null",
                "Copy-Item -Path '$($_.FullName)' -Destination '$SitePackagePath' -Force",
                "`$acl = Get-Acl '$SitePackagePath'",
                "`$ar = New-Object System.Security.AccessControl.FileSystemAccessRule('Users', 'Write', 'ContainerInherit,ObjectInherit', 'None', 'Allow')",
                "`$acl.SetAccessRule(`$ar)",
                "Set-Acl '$SitePackagePath' `$acl"
            )
            if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
                if ($Quiet) {
                    "!! Error: failed to install Simplygon Python module to Blender, user is not Administrator"
                    ""
                    exit -200
                }
                Start-Process powershell.exe "-Command `"$($commands -join "`n")`"" -Verb RunAs -Wait
            } else {
                Invoke-Expression ($commands -join "`n")
            }
            return
        }
    }
}

function Install-MaxPlugin {
    param(
        [Parameter(Mandatory=$true)]
        [string] $Version,
        [Parameter(Mandatory=$true)]
        [string] $Path
    )
    "* Installing Autodesk 3ds Max $Version Simplygon plugin"
    if (!(Test-Path "$Path")) {
        "!! Error: Max$VersionPath could not be found"
        exit -300
    }
    if (!(Test-Path "$Path\bin\assemblies")) {
        "!! Error: No bin\assemblies path found under Max$VersionPath"
        exit -301
    }
    if (!(Test-Path "$Path\Plugins")) {
        "!! Error: No Plugins path found under Max$VersionPath"
        exit -302
    }
    $maxPluginSrc = "$PSScriptRoot\Max\SimplygonMax$Version\SimplygonMax$($Version).dlu"
    $maxPluginUISrc = "$PSScriptRoot\Max\SimplygonMax$Version\SimplygonMax$($Version)UI.dll"
    $pluginTargetPath = (Resolve-Path "$Path\Plugins").Path
    $pluginUITargetPath = (Resolve-Path "$Path\bin\assemblies").Path
    if (!$User -and !([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
        if ($Quiet) {
            "!! Error: failed to copy 3ds Max $Version plugin files, user is not Administrator"
            ""
            exit -303
        }
        Start-Process powershell.exe "-Command `"Copy-Item '$maxPluginSrc' '$pluginTargetPath' -Force; Copy-Item '$maxPluginUISrc' '$pluginUITargetPath' -Force`"" -Verb RunAs -Wait
    }
}

""
$extraLines = $false
if ([string]::IsNullOrEmpty($Temp)) {
    $Temp = $defaultTempValue
} else {
    "* Using $simplygonTempVar override value: $Temp"
    $extraLines = $true
}
if ([string]::IsNullOrEmpty($Shared)) {
    $Shared = $defaultSharedValue
} else {
    "* Using $simplygonSharedVar override value: $Shared"
    $extraLines = $true
}
if ($extraLines) {
    ""
}

# Description text
if (-not $Quiet) {
    "This script sets up Simplygon on your computer by setting $simplygonPathVar,"
    "$simplygonTempVar and $simplygonSharedVar environment variables and copies the"
    "'simplygon$simplygonMajorVersion' Python package to the site-packages folder of each supported"
    "Python version."
    ""
    "Script parameters:"
    "  -Shared       Set $simplygonSharedVar path to given path."
    "                Defaults to %USERPROFILE%\Documents\Simplygon\$simplygonMajorVersion."
    "  -Temp         Set $simplygonTempVar path to given path."
    "                Defaults to %LOCALAPPDATA%\Temp\Simplygon."
    "  -Max2017Path  Path to Autodesk 3ds Max install dir. Specify this value"
    "                to install the 3ds Max Simplygon plugin (with UI)."
    "  -Max2018Path"
    "  -Max2019Path"
    "  -Max2020Path"
    "  -Max2021Path"
    "  -Max2022Path"
    "  -User         Installs the environment variables in user space rather"
    "                than machine-wide space."
    "  -Quiet        Run script without showing this help text and without user"
    "                interaction."
    ""
    "Press ENTER to continue or CTRL+C to abort the script."
    $dummy = Read-Host
}

# Install $simplygonPathVar
"* Setting $simplygonPathVar to $PSScriptRoot..."
Set-EnvVar -VariableName "$simplygonPathVar" -VariableValue "$PSScriptRoot" -User:$User -Quiet:$Quiet

# Install $simplygonTempVar
if ([string]::IsNullOrEmpty([System.Environment]::GetEnvironmentVariable($simplygonTempVar))) {
    "* Setting $simplygonTempVar to $Temp..."
    Set-EnvVar -VariableName "$simplygonTempVar" -VariableValue "$Temp" -User:$User -Quiet:$Quiet
    $tempPathExpanded = [System.Environment]::ExpandEnvironmentVariables($Temp)
    if ($false -eq (Test-Path "$tempPathExpanded")) {
        New-Item -Path "$tempPathExpanded" -ItemType Directory -Force | Out-Null
    }
} else {
    "* $simplygonTempVar is previously set to $([System.Environment]::GetEnvironmentVariable($simplygonTempVar))"
}

# Install $simplygonSharedVar
if ([string]::IsNullOrEmpty([System.Environment]::GetEnvironmentVariable($simplygonSharedVar))) {
    "* Setting $simplygonSharedVar to $Shared..."
    Set-EnvVar -VariableName "$simplygonSharedVar" -VariableValue "$Shared" -User:$User -Quiet:$Quiet
    $sharedPathExpanded = [System.Environment]::ExpandEnvironmentVariables($Shared)
    if ($false -eq (Test-Path "$sharedPathExpanded")) {
        New-Item -Path "$sharedPathExpanded" -ItemType Directory -Force | Out-Null
    }
} else {
    "* $simplygonSharedVar is previously set to $([System.Environment]::GetEnvironmentVariable($simplygonSharedVar))"
}

# Install simplygon_loader modules
$pythonSourceDir = "$PSScriptRoot\Python"
if (Test-Path "$pythonSourceDir") {
    "* Installing simplygon_loader Python modules"
    $dirNames = @(
        "Python27",
        "Python36",
        "Python37",
        "Python38"
    )
    $loaderSourceDir = "$pythonSourceDir\simplygon_loader"
    $pythonModulesBaseDir = "$($env:APPDATA)\Python"
    $dirNames | ForEach-Object {
        $dirName = $_
        $targetDirs = @(
            "$pythonModulesBaseDir\$dirName\site-packages\simplygon"
            "$pythonModulesBaseDir\$dirName\site-packages\simplygon$simplygonMajorVersion"
        )
        $targetDirs | ForEach-Object {
            $targetDir = $_
            InstallPythonModule -LoaderSourceDirectory "$loaderSourceDir" -SitePackagePath "$targetDir" -DirectoryName $dirName -Quiet:$Quiet
        }
    }

    # Find and install the python module into any Blender installs
    $blenderSitePackages = Find-BlenderInstalls
    $blenderSitePackages | ForEach-Object {
        if ($_[-1] -eq "\") {
            $_ = $_.Substring(0, $_.Length - 1)
        }
        $targetDirs = @(
            "$_\simplygon"
            "$_\simplygon$simplygonMajorVersion"
        )
        $targetDirs | ForEach-Object {
            $targetDir = $_
            InstallPythonModule -LoaderSourceDirectory "$loaderSourceDir" -SitePackagePath "$targetDir" -DirectoryName "blender" -Quiet:$Quiet
        }
    }
}

# Max plugins
$maxSourceDir = "$PSScriptRoot\Max"
if (Test-Path "$maxSourceDir") {
    if (-not [string]::IsNullOrEmpty($Max2017Path)) {
        Install-MaxPlugin -Version 2017 -Path "$Max2017Path"
    }
    if (-not [string]::IsNullOrEmpty($Max2018Path)) {
        Install-MaxPlugin -Version 2018 -Path "$Max2018Path"
    }
    if (-not [string]::IsNullOrEmpty($Max2019Path)) {
        Install-MaxPlugin -Version 2019 -Path "$Max2019Path"
    }
    if (-not [string]::IsNullOrEmpty($Max2020Path)) {
        Install-MaxPlugin -Version 2020 -Path "$Max2020Path"
    }
    if (-not [string]::IsNullOrEmpty($Max2021Path)) {
        Install-MaxPlugin -Version 2021 -Path "$Max2021Path"
    }
    if (-not [string]::IsNullOrEmpty($Max2022Path)) {
        Install-MaxPlugin -Version 2022 -Path "$Max2022Path"
    }
} elseif ($Max2017Path -or $Max2018Path -or $Max2019Path -or $Max2020Path -or $Max2021Path -or $Max2022Path) {
    "[WARNING] Max plugin not bundled with this zip!"
}

""
"All done!"
""
"Please note that VC++ Redist (x64) is required to run Simplygon."
"Install the latest version from here:"
"https://aka.ms/vs/16/release/VC_redist.x64.exe"
""

# SIG # Begin signature block
# MIIntwYJKoZIhvcNAQcCoIInqDCCJ6QCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCAoZ1SPwMDpTGwU
# RswWF0p6XCb3ikuUNewWsmVKrjssxqCCDYEwggX/MIID56ADAgECAhMzAAACUosz
# qviV8znbAAAAAAJSMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD
# VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy
# b3NvZnQgQ29ycG9yYXRpb24xKDAm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