-
Notifications
You must be signed in to change notification settings - Fork 0
/
startOnline.ps1
45 lines (36 loc) · 1.32 KB
/
startOnline.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
& dotnet build
if (-not $?) {
throw 'Build failed'
}
[xml]$config = Get-Content "$PSScriptRoot\Config.props"
$roundsDir = $config.Project.PropertyGroup.RoundsDir
$bepinexDir = $config.Project.PropertyGroup.BepInExDir
Import-Module .\tools\WindowUtils.psm1
function Start-Game([System.Int32]$Monitor, [System.String]$Arguments) {
$process = Start-Process "$roundsDir\Rounds.exe" -PassThru -ArgumentList "$Arguments -- --doorstop-enable true --doorstop-target-assembly ""$bepinexDir\core\BepInEx.Preloader.dll"""
Start-Sleep -Seconds 1
$consoleWindow = $process.MainWindowHandle
Move-Window -WindowHandle $consoleWindow -Monitor $Monitor -X 30 -Y 30
Show-Window -WindowHandle $consoleWindow
Start-Sleep -Seconds 1
$appWindow = Get-ChildWindow -Process $process
Move-Window -WindowHandle $appWindow -Monitor $Monitor -X 30 -Y 60 -FromRight -FromBottom
Show-Window -WindowHandle $appWindow
return $process
}
try {
$process1 = Start-Game -Monitor 1 -Arguments "-autoHost eu:1234"
Start-Sleep -Seconds 2
$process2 = Start-Game -Monitor 0 -Arguments "-autoConnect eu:1234"
while ($process1.HasExited -eq $false -and $process2.HasExited -eq $false) {
Start-Sleep -Milliseconds 100
}
}
finally {
$process1, $process2 | ForEach-Object {
if (-not ($_ -eq $null) -and -not $_.HasExited) {
Stop-Process -Id $_.Id
}
}
Pop-Location
}