
################################################################

# Stellarium バージョン

$stellarium_version = "24.4"
$stellarium_qt_version = "24.4-qt5"

################################################################

Write-Host "//"
Write-Host "// INTERSTELLAR CONSOLE セットアップ (ps1)"
Write-Host "// Copyright (C) 2025- Misato Observatory, Wakayama, Japan"
Write-Host "//"
Write-Host ""

################################################################

# Check Windows Version

$winVersion = 0
$winVersion = [System.Environment]::OSVersion.Version.Major

if ( $winVersion -eq 0 ) {
  Write-Host "/////////////////////////////"
  Write-Host "// ERROR: Unexpected error //"
  Write-Host "/////////////////////////////"
  Start-Sleep -Seconds 5
  exit 1
}

Write-Host "Major Version of this Windows is $winVersion"
Write-Host ""

if ( $winVersion -lt 10 ) {
  Write-Host "////////////////////////////////////////////"
  Write-Host "// ERROR: Too OLD Windows!! NOT supported //"
  Write-Host "////////////////////////////////////////////"
  Start-Sleep -Seconds 5
  exit 1
}

################################################################

# Start...

Set-StrictMode -version Latest

Add-Type -AssemblyName System.Windows.Forms

$text = "Interstellar Consoleでは、Stellariumについて`r`n 1. バージョンは 【 $stellarium_qt_version 】`r`n 2. セットアップで 【 For all users 】 を選択`r`n 3. インストール先はデフォルト`r`nを前提としています。`r`nこれらの条件を満たさない場合は動作しませんのでご注意ください。Interstellar Console のセットアップを開始しますか？"
$caption = "Setup: Interstellar Console"
$buttonsType = "YesNo"
$iconType = "Information"

$result = [System.Windows.Forms.MessageBox]::Show($text, $caption, $buttonsType, $iconType)

if ( $result -eq "No" ) {
  exit
}

$currentDirectory = Get-Location

#Write-Host "$PSCommandPath"
#Write-Host "$currentDirectory"

# Using "-Verb runAs" to launch processes with elevated privileges via UAC (User Access Control)
Start-Process -FilePath ".\setup-$stellarium_version.exe" -ArgumentList "-" -Verb runAs

