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

$defaultTempValue = "%LOCALAPPDATA%\Temp\Simplygon"
$defaultSharedValue = "%USERPROFILE%\Documents\Simplygon\9"

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 SIMPLYGON_9_TEMP override value: $Temp"
    $extraLines = $true
}
if ([string]::IsNullOrEmpty($Shared)) {
    $Shared = $defaultSharedValue
} else {
    "* Using SIMPLYGON_9_SHARED override value: $Shared"
    $extraLines = $true
}
if ($extraLines) {
    ""
}

# Description text
if (-not $Quiet) {
    "This script sets up Simplygon on your computer by setting SIMPLYGON_9_PATH,"
    "SIMPLYGON_9_TEMP and SIMPLYGON_9_SHARED environment variables and copies the"
    "'simplygon' Python package to the site-packages folder of each supported"
    "Python version."
    ""
    "Script parameters:"
    "  -Shared       Set SIMPLYGON_9_SHARED path to given path."
    "                Defaults to %USERPROFILE%\Documents\Simplygon\9."
    "  -Temp         Set SIMPLYGON_9_TEMP 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 SIMPLYGON_9_PATH
"* Setting SIMPLYGON_9_PATH to $PSScriptRoot..."
Set-EnvVar -VariableName "SIMPLYGON_9_PATH" -VariableValue "$PSScriptRoot" -User:$User -Quiet:$Quiet

# Install SIMPLYGON_9_TEMP
if ([string]::IsNullOrEmpty($env:SIMPLYGON_9_TEMP)) {
    "* Setting SIMPLYGON_9_TEMP to $Temp..."
    Set-EnvVar -VariableName "SIMPLYGON_9_TEMP" -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 {
    "* SIMPLYGON_9_TEMP is previously set to $($env:SIMPLYGON_9_TEMP)"
}

# Install SIMPLYGON_9_SHARED
if ([string]::IsNullOrEmpty($env:SIMPLYGON_9_SHARED)) {
    "* Setting SIMPLYGON_9_SHARED to $Shared..."
    Set-EnvVar -VariableName "SIMPLYGON_9_SHARED" -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 {
    "* SIMPLYGON_9_SHARED is previously set to $($env:SIMPLYGON_9_SHARED)"
}

# 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 = $_
        $targetDir = "$pythonModulesBaseDir\$dirName\site-packages\simplygon"
        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)
        }
        $targetDir = "$_\simplygon"
        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
# MIIjhgYJKoZIhvcNAQcCoIIjdzCCI3MCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCLLQWc08TY8B2e
# HM8jKUANoc8fMo1d/jAsEbtCVkmm5KCCDYEwggX/MIID56ADAgECAhMzAAACUosz
# qviV8znbAAAAAAJSMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD
# VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy
# b3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBDb2RlIFNpZ25p
# bmcgUENBIDIwMTEwHhcNMjEwOTAyMTgzMjU5WhcNMjIwOTAxMTgzMjU5WjB0MQsw
# CQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9u
# ZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMR4wHAYDVQQDExVNaWNy
# b3NvZnQgQ29ycG9yYXRp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