Repository navigation
Expand file tree
/
Copy pathdev.ps1
More file actions
77 lines (60 loc) · 2.4 KB
/
Copy pathdev.ps1
File metadata and controls
77 lines (60 loc) · 2.4 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
function Stop-SteamProcess {
Write-Host "Stopping Steam process..."
Get-Process -Name "steam" -ErrorAction SilentlyContinue | Stop-Process -Force
}
function Start-SteamProcess {
param ([string]$SteamPath)
Write-Host "Starting Steam process in dev mode..."
Start-Process -FilePath "$SteamPath/steam.exe" -ArgumentList "-dev"
}
function Get-PluginName {
param ([string]$Path)
$json = Get-Content $Path | ConvertFrom-Json
return @($json.name, $json.common_name)
}
function Set-PluginName {
param ([string]$Path, [string]$Name, [string]$CommonName)
$json = Get-Content $Path | ConvertFrom-Json
$json.name = $Name
$json.common_name = $CommonName
$json | ConvertTo-Json -Depth 100 | Set-Content $Path
pnpm oxfmt plugin.json
}
function Build-Plugin {
Write-Host "Building plugin..."
pnpm millennium-ttc --build dev
}
function Copy-PluginFiles {
param ([string]$Destination)
Write-Host "Copying plugin files to $Destination..."
New-Item -Path $Destination -ItemType Directory -Force | Out-Null
Copy-Item -Path "plugin.json" -Destination $Destination -Force
Copy-Item -Path ".millennium" -Destination $Destination -Recurse -Force
Copy-Item -Path "backend" -Destination $Destination -Recurse -Force
}
function Toggle-Plugin {
param ([string]$Path, [string]$Name, [bool]$Enable)
Write-Host "$(if ($Enable) { "Enabling" } else { "Disabling" }) plugin $Name..."
$json = Get-Content -Path $Path -Raw | ConvertFrom-Json
$plugins = @($json.plugins.enabledPlugins)
if ($Enable) {
if (-not ($plugins -contains $Name)) { $plugins = @($plugins + $Name) }
$plugins = @($plugins | Sort-Object -Unique)
} else {
$plugins = @($plugins | Where-Object { $_ -ne $Name })
}
$json.plugins.enabledPlugins = $plugins
$json | ConvertTo-Json -Depth 100 | Set-Content $Path
}
#####
$SteamPath = "C:\Program Files (x86)\Steam"
$ConfigPath = "$SteamPath\millennium\config\config.json"
$PluginName, $PluginCommonName = Get-PluginName -Path "./plugin.json"
Stop-SteamProcess
Set-PluginName -Path "plugin.json" -Name $PluginName-dev -CommonName "$PluginCommonName (dev)"
Build-Plugin
Copy-PluginFiles -Destination "$SteamPath\millennium\plugins\$PluginName-dev"
Set-PluginName -Path "plugin.json" -Name $PluginName -CommonName $PluginCommonName
Toggle-Plugin -Path $ConfigPath -Name $PluginName -Enable $false
Toggle-Plugin -Path $ConfigPath -Name $PluginName-dev -Enable $true
Start-SteamProcess $SteamPath