Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
47 lines (42 sloc)
1.72 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Show-SimCityLoadingScreen { | |
<# | |
.SYNOPSIS | |
Create a new PowerShell window that scrolls through classic Sim City loading messages | |
.EXAMPLE | |
# Create loading screen | |
$loadingScreen = Show-SimCityLoadingScreen | |
'Doing something...' | |
Start-Sleep -Seconds 10 | |
'Done' | |
# Close loading screen | |
$loadingScreen.Kill() | |
.EXAMPLE | |
Show-SimCityLoadingScreen -WindowTitle 'Custom title' -WelcomeMessage 'Custom welcome message' -WindowHeight 20 -WindowWidth 80 | |
.OUTPUTS | |
System.Diagnostics.Process | |
.LINK | |
https://github.com/weebsnore/PowerShell-SimCity-Loading-Screen | |
.NOTES | |
This function is a wrapper for loading_screen_script.ps1 | |
#> | |
param ( | |
[string]$WindowTitle, | |
[int]$WindowHeight, | |
[int]$WindowWidth, | |
[string]$WelcomeMessage | |
) | |
# Decide whether to spawn pwsh or powershell | |
$powerShellPath = if ($PSEdition -eq 'Core') {'pwsh'} else {'powershell'} | |
# Construct PowerShell arguments | |
$loadingScreenPath = Join-Path $PSScriptRoot 'loading_screen_script.ps1' | |
$psArguments = @() | |
$psArguments += '-ExecutionPolicy Bypass' | |
$psArguments += "-File `"$loadingScreenPath`"" | |
if ($WindowTitle) {$psArguments += "-WindowTitle `"$WindowTitle`""} | |
if ($WindowHeight) {$psArguments += "-WindowHeight $WindowHeight"} | |
if ($WindowWidth) {$psArguments += "-WindowWidth $WindowWidth"} | |
if ($WelcomeMessage) {$psArguments += "-WelcomeMessage `"$WelcomeMessage`""} | |
# Launch loading screen script and return process object | |
# The process object can later be killed to close the window | |
return Start-Process -FilePath $powerShellPath -PassThru -ArgumentList $psArguments | |
} |