-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_dev.ps1
More file actions
137 lines (116 loc) · 4.06 KB
/
setup_dev.ps1
File metadata and controls
137 lines (116 loc) · 4.06 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<#
.SYNOPSIS
Setup development environment for SmartHaul RimWorld mod.
#>
param(
[string]$RimWorldPath
)
$ErrorActionPreference = "Stop"
Write-Host ""
Write-Host "=== SmartHaul Development Environment Setup ===" -ForegroundColor Cyan
Write-Host ""
# Check existing
$existingPath = [Environment]::GetEnvironmentVariable("RIMWORLD_PATH", "User")
if ($existingPath -and (Test-Path "$existingPath\RimWorldWin64.exe")) {
Write-Host "RIMWORLD_PATH already set to:" -ForegroundColor Green
Write-Host " $existingPath" -ForegroundColor White
Write-Host ""
$confirm = Read-Host "Keep this path? (Y/n)"
if ($confirm -ne "n" -and $confirm -ne "N") {
Write-Host ""
Write-Host "Setup complete! Restart VS Code if needed." -ForegroundColor Green
Write-Host ""
Read-Host "Press Enter to close"
exit 0
}
}
# Common paths
$commonPaths = @(
"C:\Program Files (x86)\Steam\steamapps\common\RimWorld",
"D:\Steam\steamapps\common\RimWorld",
"D:\SteamLibrary\steamapps\common\RimWorld",
"E:\Steam\steamapps\common\RimWorld",
"D:\Games\RimWorld",
"C:\Games\RimWorld"
)
# Auto-detect
$detectedPath = $null
foreach ($path in $commonPaths) {
if (Test-Path "$path\RimWorldWin64.exe") {
$detectedPath = $path
break
}
}
if ($detectedPath -and -not $RimWorldPath) {
Write-Host "Found RimWorld at:" -ForegroundColor Green
Write-Host " $detectedPath" -ForegroundColor Cyan
Write-Host ""
$useDetected = Read-Host "Use this path? (Y/n)"
if ($useDetected -ne "n" -and $useDetected -ne "N") {
$RimWorldPath = $detectedPath
}
}
# Manual input if needed
if (-not $RimWorldPath) {
Write-Host "Enter RimWorld installation path:" -ForegroundColor Yellow
Write-Host "(folder containing RimWorldWin64.exe)" -ForegroundColor Gray
Write-Host ""
$RimWorldPath = Read-Host "Path"
}
# Validate
$RimWorldPath = $RimWorldPath.Trim('"', "'", " ")
if (-not (Test-Path $RimWorldPath)) {
Write-Host "ERROR: Path does not exist: $RimWorldPath" -ForegroundColor Red
Read-Host "Press Enter to close"
exit 1
}
$exePath = Join-Path $RimWorldPath "RimWorldWin64.exe"
if (-not (Test-Path $exePath)) {
Write-Host "ERROR: RimWorldWin64.exe not found in: $RimWorldPath" -ForegroundColor Red
Read-Host "Press Enter to close"
exit 1
}
# Set environment variable
[Environment]::SetEnvironmentVariable("RIMWORLD_PATH", $RimWorldPath, "User")
# Also set for current session
$env:RIMWORLD_PATH = $RimWorldPath
Write-Host ""
Write-Host "SUCCESS!" -ForegroundColor Green
Write-Host ""
Write-Host "RIMWORLD_PATH = $RimWorldPath" -ForegroundColor Cyan
Write-Host ""
# Create junction
$modsPath = Join-Path $RimWorldPath "Mods"
$projectRoot = $PSScriptRoot
$modName = "SmartHaul"
$targetLink = Join-Path $modsPath $modName
Write-Host "---" -ForegroundColor Gray
$createLink = Read-Host "Create symlink in Mods folder? (Y/n)"
if ($createLink -ne "n" -and $createLink -ne "N") {
try {
if (Test-Path $targetLink) {
$item = Get-Item $targetLink -Force
if ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) {
cmd /c rmdir "$targetLink" 2>$null
} else {
Remove-Item $targetLink -Recurse -Force
}
}
New-Item -ItemType Junction -Path $targetLink -Target $projectRoot -Force | Out-Null
Write-Host "Created: $targetLink" -ForegroundColor Green
}
catch {
Write-Host "Could not create symlink: $_" -ForegroundColor Yellow
}
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " IMPORTANT: Restart VS Code now!" -ForegroundColor Yellow
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "After restart:" -ForegroundColor White
Write-Host " F5 = Build & Run RimWorld" -ForegroundColor Gray
Write-Host " Ctrl+F5 = Build only" -ForegroundColor Gray
Write-Host " Shift+F5 = Build & Run 2 clients" -ForegroundColor Gray
Write-Host ""
Read-Host "Press Enter to close"